Don't record spans for predicates in coherence
This commit is contained in:
parent
ac02e40380
commit
4647aea7aa
7 changed files with 19 additions and 37 deletions
|
@ -238,7 +238,7 @@ pub struct ImplHeader<'tcx> {
|
||||||
pub impl_def_id: DefId,
|
pub impl_def_id: DefId,
|
||||||
pub self_ty: Ty<'tcx>,
|
pub self_ty: Ty<'tcx>,
|
||||||
pub trait_ref: Option<TraitRef<'tcx>>,
|
pub trait_ref: Option<TraitRef<'tcx>>,
|
||||||
pub predicates: Vec<(Predicate<'tcx>, Span)>,
|
pub predicates: Vec<Predicate<'tcx>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, TypeFoldable, TypeVisitable)]
|
#[derive(Copy, Clone, PartialEq, Eq, Debug, TypeFoldable, TypeVisitable)]
|
||||||
|
|
|
@ -152,16 +152,14 @@ fn with_fresh_ty_vars<'cx, 'tcx>(
|
||||||
.predicates_of(impl_def_id)
|
.predicates_of(impl_def_id)
|
||||||
.instantiate(tcx, impl_args)
|
.instantiate(tcx, impl_args)
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(c, s)| (c.as_predicate(), s))
|
.map(|(c, _)| c.as_predicate())
|
||||||
.collect(),
|
.collect(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let InferOk { value: mut header, obligations } = selcx
|
let InferOk { value: mut header, obligations } =
|
||||||
.infcx
|
selcx.infcx.at(&ObligationCause::dummy(), param_env).normalize(header);
|
||||||
.at(&ObligationCause::dummy_with_span(tcx.def_span(impl_def_id)), param_env)
|
|
||||||
.normalize(header);
|
|
||||||
|
|
||||||
header.predicates.extend(obligations.into_iter().map(|o| (o.predicate, o.cause.span)));
|
header.predicates.extend(obligations.into_iter().map(|o| o.predicate));
|
||||||
header
|
header
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,17 +259,11 @@ fn overlap<'tcx>(
|
||||||
infcx.tcx.def_span(impl2_header.impl_def_id),
|
infcx.tcx.def_span(impl2_header.impl_def_id),
|
||||||
"the second impl is here",
|
"the second impl is here",
|
||||||
);
|
);
|
||||||
if !failing_obligation.cause.span.is_dummy() {
|
lint.note(format!(
|
||||||
lint.span_label(
|
"`{}` may be considered to hold in future releases, \
|
||||||
failing_obligation.cause.span,
|
causing the impls to overlap",
|
||||||
format!(
|
infcx.resolve_vars_if_possible(failing_obligation.predicate)
|
||||||
"`{}` may be considered to hold in future releases, \
|
));
|
||||||
causing the impls to overlap",
|
|
||||||
infcx
|
|
||||||
.resolve_vars_if_possible(failing_obligation.predicate)
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
lint
|
lint
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -355,8 +347,8 @@ fn impl_intersection_has_impossible_obligation<'cx, 'tcx>(
|
||||||
[&impl1_header.predicates, &impl2_header.predicates]
|
[&impl1_header.predicates, &impl2_header.predicates]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.flatten()
|
.flatten()
|
||||||
.map(|&(predicate, span)| {
|
.map(|&predicate| {
|
||||||
Obligation::new(infcx.tcx, ObligationCause::dummy_with_span(span), param_env, predicate)
|
Obligation::new(infcx.tcx, ObligationCause::dummy(), param_env, predicate)
|
||||||
})
|
})
|
||||||
.chain(obligations.into_iter().cloned())
|
.chain(obligations.into_iter().cloned())
|
||||||
.find(|obligation: &PredicateObligation<'tcx>| {
|
.find(|obligation: &PredicateObligation<'tcx>| {
|
||||||
|
|
|
@ -6,13 +6,11 @@ LL | #[derive(PartialEq, Default)]
|
||||||
...
|
...
|
||||||
LL | impl<T, Q> PartialEq<Q> for Interval<T>
|
LL | impl<T, Q> PartialEq<Q> for Interval<T>
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the first impl is here
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the first impl is here
|
||||||
...
|
|
||||||
LL | Q: ?Sized + PartialOrd,
|
|
||||||
| ---------- `Interval<_>: PartialOrd` may be considered to hold in future releases, causing the impls to overlap
|
|
||||||
|
|
|
|
||||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
= note: for more information, see issue #114040 <https://github.com/rust-lang/rust/issues/114040>
|
= note: for more information, see issue #114040 <https://github.com/rust-lang/rust/issues/114040>
|
||||||
= note: impls that are not considered to overlap may be considered to overlap in the future
|
= note: impls that are not considered to overlap may be considered to overlap in the future
|
||||||
|
= note: `Interval<_>: PartialOrd` may be considered to hold in future releases, causing the impls to overlap
|
||||||
note: the lint level is defined here
|
note: the lint level is defined here
|
||||||
--> $DIR/warn-when-cycle-is-error-in-coherence.rs:1:9
|
--> $DIR/warn-when-cycle-is-error-in-coherence.rs:1:9
|
||||||
|
|
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
//~ ERROR overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send`
|
||||||
struct A<T>(B<T>);
|
struct A<T>(B<T>);
|
||||||
//~^ ERROR recursive types `A` and `B` have infinite size
|
//~^ ERROR recursive types `A` and `B` have infinite size
|
||||||
struct B<T>(A<A<T>>);
|
struct B<T>(A<A<T>>);
|
||||||
trait Foo {}
|
trait Foo {}
|
||||||
impl<T> Foo for T where T: Send {}
|
impl<T> Foo for T where T: Send {}
|
||||||
//~^ ERROR overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send`
|
|
||||||
impl Foo for B<u8> {}
|
impl Foo for B<u8> {}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0072]: recursive types `A` and `B` have infinite size
|
error[E0072]: recursive types `A` and `B` have infinite size
|
||||||
--> $DIR/issue-105231.rs:1:1
|
--> $DIR/issue-105231.rs:2:1
|
||||||
|
|
|
|
||||||
LL | struct A<T>(B<T>);
|
LL | struct A<T>(B<T>);
|
||||||
| ^^^^^^^^^^^ ---- recursive without indirection
|
| ^^^^^^^^^^^ ---- recursive without indirection
|
||||||
|
@ -15,14 +15,10 @@ LL ~ struct B<T>(Box<A<A<T>>>);
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0275]: overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send`
|
error[E0275]: overflow evaluating the requirement `A<A<A<A<A<A<A<...>>>>>>>: Send`
|
||||||
--> $DIR/issue-105231.rs:5:28
|
|
||||||
|
|
|
||||||
LL | impl<T> Foo for T where T: Send {}
|
|
||||||
| ^^^^
|
|
||||||
|
|
|
|
||||||
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_105231`)
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_105231`)
|
||||||
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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
|
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>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>`
|
||||||
--> $DIR/issue-105231.rs:3:8
|
--> $DIR/issue-105231.rs:4:8
|
||||||
|
|
|
|
||||||
LL | struct B<T>(A<A<T>>);
|
LL | struct B<T>(A<A<T>>);
|
||||||
| ^
|
| ^
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
//~ ERROR overflow
|
||||||
// A regression test for #111729 checking that we correctly
|
// A regression test for #111729 checking that we correctly
|
||||||
// track recursion depth for obligations returned by confirmation.
|
// track recursion depth for obligations returned by confirmation.
|
||||||
use std::panic::RefUnwindSafe;
|
use std::panic::RefUnwindSafe;
|
||||||
|
@ -14,7 +15,6 @@ struct RootDatabase {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: RefUnwindSafe> Database for T {
|
impl<T: RefUnwindSafe> Database for T {
|
||||||
//~^ ERROR overflow
|
|
||||||
type Storage = SalsaStorage;
|
type Storage = SalsaStorage;
|
||||||
}
|
}
|
||||||
impl Database for RootDatabase {
|
impl Database for RootDatabase {
|
||||||
|
|
|
@ -1,17 +1,13 @@
|
||||||
error[E0275]: overflow evaluating the requirement `Runtime<RootDatabase>: RefUnwindSafe`
|
error[E0275]: overflow evaluating the requirement `Runtime<RootDatabase>: RefUnwindSafe`
|
||||||
--> $DIR/cycle-via-builtin-auto-trait-impl.rs:16:9
|
|
||||||
|
|
|
||||||
LL | impl<T: RefUnwindSafe> Database for T {
|
|
||||||
| ^^^^^^^^^^^^^
|
|
||||||
|
|
|
|
||||||
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`cycle_via_builtin_auto_trait_impl`)
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`cycle_via_builtin_auto_trait_impl`)
|
||||||
note: required because it appears within the type `RootDatabase`
|
note: required because it appears within the type `RootDatabase`
|
||||||
--> $DIR/cycle-via-builtin-auto-trait-impl.rs:12:8
|
--> $DIR/cycle-via-builtin-auto-trait-impl.rs:13:8
|
||||||
|
|
|
|
||||||
LL | struct RootDatabase {
|
LL | struct RootDatabase {
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
note: required for `RootDatabase` to implement `Database`
|
note: required for `RootDatabase` to implement `Database`
|
||||||
--> $DIR/cycle-via-builtin-auto-trait-impl.rs:16:24
|
--> $DIR/cycle-via-builtin-auto-trait-impl.rs:17:24
|
||||||
|
|
|
|
||||||
LL | impl<T: RefUnwindSafe> Database for T {
|
LL | impl<T: RefUnwindSafe> Database for T {
|
||||||
| ------------- ^^^^^^^^ ^
|
| ------------- ^^^^^^^^ ^
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue