Skip to content

Commit 2ae4bed

Browse files
more span info
1 parent ffaa32b commit 2ae4bed

File tree

6 files changed

+24
-14
lines changed

6 files changed

+24
-14
lines changed

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ pub struct ImplHeader<'tcx> {
238238
pub impl_def_id: DefId,
239239
pub self_ty: Ty<'tcx>,
240240
pub trait_ref: Option<TraitRef<'tcx>>,
241-
pub predicates: Vec<Predicate<'tcx>>,
241+
pub predicates: Vec<(Predicate<'tcx>, Span)>,
242242
}
243243

244244
#[derive(Copy, Clone, PartialEq, Eq, Debug, TypeFoldable, TypeVisitable)]

compiler/rustc_trait_selection/src/traits/coherence.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,16 @@ fn with_fresh_ty_vars<'cx, 'tcx>(
151151
.predicates_of(impl_def_id)
152152
.instantiate(tcx, impl_args)
153153
.iter()
154-
.map(|(c, _)| c.as_predicate())
154+
.map(|(c, s)| (c.as_predicate(), s))
155155
.collect(),
156156
};
157157

158-
let InferOk { value: mut header, obligations } =
159-
selcx.infcx.at(&ObligationCause::dummy(), param_env).normalize(header);
158+
let InferOk { value: mut header, obligations } = selcx
159+
.infcx
160+
.at(&ObligationCause::dummy_with_span(tcx.def_span(impl_def_id)), param_env)
161+
.normalize(header);
160162

161-
header.predicates.extend(obligations.into_iter().map(|o| o.predicate));
163+
header.predicates.extend(obligations.into_iter().map(|o| (o.predicate, o.cause.span)));
162164
header
163165
}
164166

@@ -289,7 +291,7 @@ fn impl_intersection_has_impossible_obligation<'cx, 'tcx>(
289291
) -> bool {
290292
let infcx = selcx.infcx;
291293

292-
let obligation_guaranteed_to_fail = move |obligation: &PredicateObligation<'tcx>| {
294+
let obligation_guaranteed_to_fail = |obligation: &PredicateObligation<'tcx>| {
293295
if infcx.next_trait_solver() {
294296
infcx.evaluate_obligation(obligation).map_or(false, |result| !result.may_apply())
295297
} else {
@@ -306,8 +308,8 @@ fn impl_intersection_has_impossible_obligation<'cx, 'tcx>(
306308
let opt_failing_obligation = [&impl1_header.predicates, &impl2_header.predicates]
307309
.into_iter()
308310
.flatten()
309-
.map(|&predicate| {
310-
Obligation::new(infcx.tcx, ObligationCause::dummy(), param_env, predicate)
311+
.map(|&(predicate, span)| {
312+
Obligation::new(infcx.tcx, ObligationCause::dummy_with_span(span), param_env, predicate)
311313
})
312314
.chain(obligations)
313315
.find(obligation_guaranteed_to_fail);

tests/ui/traits/issue-105231.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
//~ ERROR overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send`
21
struct A<T>(B<T>);
32
//~^ ERROR recursive types `A` and `B` have infinite size
43
struct B<T>(A<A<T>>);
54
trait Foo {}
65
impl<T> Foo for T where T: Send {}
6+
//~^ ERROR overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send`
77
impl Foo for B<u8> {}
88

99
fn main() {}

tests/ui/traits/issue-105231.stderr

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0072]: recursive types `A` and `B` have infinite size
2-
--> $DIR/issue-105231.rs:2:1
2+
--> $DIR/issue-105231.rs:1:1
33
|
44
LL | struct A<T>(B<T>);
55
| ^^^^^^^^^^^ ---- recursive without indirection
@@ -15,10 +15,14 @@ LL ~ struct B<T>(Box<A<A<T>>>);
1515
|
1616

1717
error[E0275]: overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send`
18+
--> $DIR/issue-105231.rs:5:28
19+
|
20+
LL | impl<T> Foo for T where T: Send {}
21+
| ^^^^
1822
|
1923
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_105231`)
2024
note: required because it appears within the type `B<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<u8>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
21-
--> $DIR/issue-105231.rs:4:8
25+
--> $DIR/issue-105231.rs:3:8
2226
|
2327
LL | struct B<T>(A<A<T>>);
2428
| ^

tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//~ ERROR overflow
21
// A regression test for #111729 checking that we correctly
32
// track recursion depth for obligations returned by confirmation.
43
use std::panic::RefUnwindSafe;
@@ -15,6 +14,7 @@ struct RootDatabase {
1514
}
1615

1716
impl<T: RefUnwindSafe> Database for T {
17+
//~^ ERROR overflow
1818
type Storage = SalsaStorage;
1919
}
2020
impl Database for RootDatabase {

tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.stderr

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
error[E0275]: overflow evaluating the requirement `Runtime<RootDatabase>: RefUnwindSafe`
2+
--> $DIR/cycle-via-builtin-auto-trait-impl.rs:16:9
3+
|
4+
LL | impl<T: RefUnwindSafe> Database for T {
5+
| ^^^^^^^^^^^^^
26
|
37
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`cycle_via_builtin_auto_trait_impl`)
48
note: required because it appears within the type `RootDatabase`
5-
--> $DIR/cycle-via-builtin-auto-trait-impl.rs:13:8
9+
--> $DIR/cycle-via-builtin-auto-trait-impl.rs:12:8
610
|
711
LL | struct RootDatabase {
812
| ^^^^^^^^^^^^
913
note: required for `RootDatabase` to implement `Database`
10-
--> $DIR/cycle-via-builtin-auto-trait-impl.rs:17:24
14+
--> $DIR/cycle-via-builtin-auto-trait-impl.rs:16:24
1115
|
1216
LL | impl<T: RefUnwindSafe> Database for T {
1317
| ------------- ^^^^^^^^ ^

0 commit comments

Comments
 (0)