Walk into alias-eq nested goals even if normalization fails
This commit is contained in:
parent
8337ba9189
commit
52b2c88bdf
14 changed files with 83 additions and 22 deletions
|
@ -48,6 +48,12 @@ impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
|
||||||
rhs
|
rhs
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add a `make_canonical_response` probe step so that we treat this as
|
||||||
|
// a candidate, even if `try_evaluate_added_goals` bails due to an error.
|
||||||
|
// It's `Certainty::AMBIGUOUS` because this candidate is not "finished",
|
||||||
|
// since equating the normalized terms will lead to additional constraints.
|
||||||
|
self.inspect.make_canonical_response(Certainty::AMBIGUOUS);
|
||||||
|
|
||||||
// Apply the constraints.
|
// Apply the constraints.
|
||||||
self.try_evaluate_added_goals()?;
|
self.try_evaluate_added_goals()?;
|
||||||
let lhs = self.resolve_vars_if_possible(lhs);
|
let lhs = self.resolve_vars_if_possible(lhs);
|
||||||
|
|
|
@ -460,9 +460,8 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
|
||||||
polarity: ty::PredicatePolarity::Positive,
|
polarity: ty::PredicatePolarity::Positive,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_)) => {
|
ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(_))
|
||||||
ChildMode::WellFormedObligation
|
| ty::PredicateKind::AliasRelate(..) => ChildMode::PassThrough,
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
return ControlFlow::Break(self.obligation.clone());
|
return ControlFlow::Break(self.obligation.clone());
|
||||||
}
|
}
|
||||||
|
@ -496,7 +495,7 @@ impl<'tcx> ProofTreeVisitor<'tcx> for BestObligation<'tcx> {
|
||||||
(_, GoalSource::InstantiateHigherRanked) => {
|
(_, GoalSource::InstantiateHigherRanked) => {
|
||||||
obligation = self.obligation.clone();
|
obligation = self.obligation.clone();
|
||||||
}
|
}
|
||||||
(ChildMode::WellFormedObligation, _) => {
|
(ChildMode::PassThrough, _) => {
|
||||||
obligation = make_obligation(self.obligation.cause.clone());
|
obligation = make_obligation(self.obligation.cause.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,7 +526,7 @@ enum ChildMode<'tcx> {
|
||||||
// Skip trying to derive an `ObligationCause` from this obligation, and
|
// Skip trying to derive an `ObligationCause` from this obligation, and
|
||||||
// report *all* sub-obligations as if they came directly from the parent
|
// report *all* sub-obligations as if they came directly from the parent
|
||||||
// obligation.
|
// obligation.
|
||||||
WellFormedObligation,
|
PassThrough,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn derive_cause<'tcx>(
|
fn derive_cause<'tcx>(
|
||||||
|
|
|
@ -15,7 +15,7 @@ use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, InferOk};
|
||||||
use rustc_macros::extension;
|
use rustc_macros::extension;
|
||||||
use rustc_middle::traits::query::NoSolution;
|
use rustc_middle::traits::query::NoSolution;
|
||||||
use rustc_middle::traits::solve::{inspect, QueryResult};
|
use rustc_middle::traits::solve::{inspect, QueryResult};
|
||||||
use rustc_middle::traits::solve::{Certainty, Goal};
|
use rustc_middle::traits::solve::{Certainty, Goal, MaybeCause};
|
||||||
use rustc_middle::traits::ObligationCause;
|
use rustc_middle::traits::ObligationCause;
|
||||||
use rustc_middle::ty::{TyCtxt, TypeFoldable};
|
use rustc_middle::ty::{TyCtxt, TypeFoldable};
|
||||||
use rustc_middle::{bug, ty};
|
use rustc_middle::{bug, ty};
|
||||||
|
@ -291,7 +291,10 @@ impl<'a, 'tcx> InspectGoal<'a, 'tcx> {
|
||||||
steps.push(step)
|
steps.push(step)
|
||||||
}
|
}
|
||||||
inspect::ProbeStep::MakeCanonicalResponse { shallow_certainty: c } => {
|
inspect::ProbeStep::MakeCanonicalResponse { shallow_certainty: c } => {
|
||||||
assert_eq!(shallow_certainty.replace(c), None);
|
assert!(matches!(
|
||||||
|
shallow_certainty.replace(c),
|
||||||
|
None | Some(Certainty::Maybe(MaybeCause::Ambiguity))
|
||||||
|
));
|
||||||
}
|
}
|
||||||
inspect::ProbeStep::NestedProbe(ref probe) => {
|
inspect::ProbeStep::NestedProbe(ref probe) => {
|
||||||
match probe.kind {
|
match probe.kind {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error[E0284]: type annotations needed: cannot satisfy `<dyn Object<U, Output = T> as Object<U>>::Output == T`
|
error[E0284]: type annotations needed: cannot satisfy `<dyn Object<U, Output = T> as Object<U>>::Output normalizes-to _`
|
||||||
--> $DIR/indirect-impl-for-trait-obj-coherence.rs:25:41
|
--> $DIR/indirect-impl-for-trait-obj-coherence.rs:25:41
|
||||||
|
|
|
|
||||||
LL | foo::<dyn Object<U, Output = T>, U>(x)
|
LL | foo::<dyn Object<U, Output = T>, U>(x)
|
||||||
| ^ cannot satisfy `<dyn Object<U, Output = T> as Object<U>>::Output == T`
|
| ^ cannot satisfy `<dyn Object<U, Output = T> as Object<U>>::Output normalizes-to _`
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ fn foo<T: ?Sized, U>(x: <T as Object<U>>::Output) -> U {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn transmute<T, U>(x: T) -> U {
|
fn transmute<T, U>(x: T) -> U {
|
||||||
foo::<dyn Object<U, Output = T>, U>(x)
|
foo::<dyn Object<U, Output = T>, U>(x)
|
||||||
//[next]~^ ERROR type annotations needed: cannot satisfy `<dyn Object<U, Output = T> as Object<U>>::Output == T`
|
//[next]~^ ERROR type annotations needed: cannot satisfy `<dyn Object<U, Output = T> as Object<U>>::Output normalizes-to _`
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -16,11 +16,11 @@ LL | | for<'a> *const T: ToUnit<'a>,
|
||||||
|
|
|
|
||||||
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
|
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
|
||||||
|
|
||||||
error[E0284]: type annotations needed: cannot satisfy `<for<'a> fn(&'a (), ()) as Overlap<for<'a> fn(&'a (), ())>>::Assoc == usize`
|
error[E0284]: type annotations needed: cannot satisfy `<for<'a> fn(&'a (), ()) as Overlap<for<'a> fn(&'a (), ())>>::Assoc normalizes-to _`
|
||||||
--> $DIR/associated-type.rs:44:59
|
--> $DIR/associated-type.rs:44:59
|
||||||
|
|
|
|
||||||
LL | foo::<for<'a> fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize);
|
LL | foo::<for<'a> fn(&'a (), ()), for<'a> fn(&'a (), ())>(3usize);
|
||||||
| ^^^^^^ cannot satisfy `<for<'a> fn(&'a (), ()) as Overlap<for<'a> fn(&'a (), ())>>::Assoc == usize`
|
| ^^^^^^ cannot satisfy `<for<'a> fn(&'a (), ()) as Overlap<for<'a> fn(&'a (), ())>>::Assoc normalizes-to _`
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ LL | SelectInt.check("bar");
|
||||||
= help: the trait `AsExpression<Text>` is implemented for `&str`
|
= help: the trait `AsExpression<Text>` is implemented for `&str`
|
||||||
= help: for that trait implementation, expected `Text`, found `Integer`
|
= help: for that trait implementation, expected `Text`, found `Integer`
|
||||||
|
|
||||||
error[E0271]: type mismatch resolving `<&str as AsExpression<<SelectInt as Expression>::SqlType>>::Expression == _`
|
error[E0271]: type mismatch resolving `<SelectInt as Expression>::SqlType == Text`
|
||||||
--> $DIR/as_expression.rs:57:5
|
--> $DIR/as_expression.rs:57:5
|
||||||
|
|
|
|
||||||
LL | SelectInt.check("bar");
|
LL | SelectInt.check("bar");
|
||||||
|
|
|
@ -18,3 +18,4 @@ fn weird1() -> impl !Sized + Sized {}
|
||||||
//~^ ERROR type mismatch resolving `impl !Sized + Sized == ()`
|
//~^ ERROR type mismatch resolving `impl !Sized + Sized == ()`
|
||||||
fn weird2() -> impl !Sized {}
|
fn weird2() -> impl !Sized {}
|
||||||
//~^ ERROR type mismatch resolving `impl !Sized == ()`
|
//~^ ERROR type mismatch resolving `impl !Sized == ()`
|
||||||
|
//~| ERROR the size for values of type `impl !Sized` cannot be known at compilation time
|
||||||
|
|
|
@ -16,6 +16,15 @@ error[E0271]: type mismatch resolving `impl !Sized == ()`
|
||||||
LL | fn weird2() -> impl !Sized {}
|
LL | fn weird2() -> impl !Sized {}
|
||||||
| ^^^^^^^^^^^ types differ
|
| ^^^^^^^^^^^ types differ
|
||||||
|
|
||||||
|
error[E0277]: the size for values of type `impl !Sized` cannot be known at compilation time
|
||||||
|
--> $DIR/opaque-type-unsatisfied-bound.rs:19:16
|
||||||
|
|
|
||||||
|
LL | fn weird2() -> impl !Sized {}
|
||||||
|
| ^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
||||||
|
= help: the trait `Sized` is not implemented for `impl !Sized`
|
||||||
|
= note: the return type of a function must have a statically known size
|
||||||
|
|
||||||
error[E0277]: the trait bound `impl !Trait: Trait` is not satisfied
|
error[E0277]: the trait bound `impl !Trait: Trait` is not satisfied
|
||||||
--> $DIR/opaque-type-unsatisfied-bound.rs:12:13
|
--> $DIR/opaque-type-unsatisfied-bound.rs:12:13
|
||||||
|
|
|
|
||||||
|
@ -30,7 +39,7 @@ note: required by a bound in `consume`
|
||||||
LL | fn consume(_: impl Trait) {}
|
LL | fn consume(_: impl Trait) {}
|
||||||
| ^^^^^ required by this bound in `consume`
|
| ^^^^^ required by this bound in `consume`
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 5 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0271, E0277.
|
Some errors have detailed explanations: E0271, E0277.
|
||||||
For more information about an error, try `rustc --explain E0271`.
|
For more information about an error, try `rustc --explain E0271`.
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
error[E0284]: type annotations needed: cannot satisfy `{ || {} } == _`
|
error[E0284]: type annotations needed: cannot satisfy `X::{constant#0} normalizes-to _`
|
||||||
--> $DIR/const-region-infer-to-static-in-binder.rs:4:10
|
--> $DIR/const-region-infer-to-static-in-binder.rs:4:10
|
||||||
|
|
|
|
||||||
LL | struct X<const FN: fn() = { || {} }>;
|
LL | struct X<const FN: fn() = { || {} }>;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `{ || {} } == _`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `X::{constant#0} normalizes-to _`
|
||||||
|
|
||||||
error: using function pointers as const generic parameters is forbidden
|
error: using function pointers as const generic parameters is forbidden
|
||||||
--> $DIR/const-region-infer-to-static-in-binder.rs:4:20
|
--> $DIR/const-region-infer-to-static-in-binder.rs:4:20
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
//@ compile-flags: -Znext-solver
|
||||||
|
|
||||||
|
trait Trait {
|
||||||
|
type Assoc;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_poly<T>() {
|
||||||
|
let x: <T as Trait>::Assoc = ();
|
||||||
|
//~^ ERROR the trait bound `T: Trait` is not satisfied
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test() {
|
||||||
|
let x: <i32 as Trait>::Assoc = ();
|
||||||
|
//~^ ERROR the trait bound `i32: Trait` is not satisfied
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,26 @@
|
||||||
|
error[E0277]: the trait bound `T: Trait` is not satisfied
|
||||||
|
--> $DIR/projection-trait-ref.rs:8:12
|
||||||
|
|
|
||||||
|
LL | let x: <T as Trait>::Assoc = ();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
|
||||||
|
|
|
||||||
|
help: consider restricting type parameter `T`
|
||||||
|
|
|
||||||
|
LL | fn test_poly<T: Trait>() {
|
||||||
|
| +++++++
|
||||||
|
|
||||||
|
error[E0277]: the trait bound `i32: Trait` is not satisfied
|
||||||
|
--> $DIR/projection-trait-ref.rs:13:12
|
||||||
|
|
|
||||||
|
LL | let x: <i32 as Trait>::Assoc = ();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `i32`
|
||||||
|
|
|
||||||
|
help: this trait has no implementations, consider adding one
|
||||||
|
--> $DIR/projection-trait-ref.rs:3:1
|
||||||
|
|
|
||||||
|
LL | trait Trait {
|
||||||
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0277`.
|
|
@ -10,17 +10,17 @@ LL | #![feature(specialization)]
|
||||||
|
|
||||||
error: cannot normalize `<T as Default>::Id: '_`
|
error: cannot normalize `<T as Default>::Id: '_`
|
||||||
|
|
||||||
error[E0284]: type annotations needed: cannot satisfy `<T as Default>::Id == _`
|
error[E0284]: type annotations needed: cannot satisfy `<T as Default>::Id normalizes-to _`
|
||||||
--> $DIR/specialization-transmute.rs:15:23
|
--> $DIR/specialization-transmute.rs:15:23
|
||||||
|
|
|
|
||||||
LL | fn intu(&self) -> &Self::Id {
|
LL | fn intu(&self) -> &Self::Id {
|
||||||
| ^^^^^^^^^ cannot satisfy `<T as Default>::Id == _`
|
| ^^^^^^^^^ cannot satisfy `<T as Default>::Id normalizes-to _`
|
||||||
|
|
||||||
error[E0284]: type annotations needed: cannot satisfy `T <: <T as Default>::Id`
|
error[E0284]: type annotations needed: cannot satisfy `<T as Default>::Id normalizes-to T`
|
||||||
--> $DIR/specialization-transmute.rs:17:9
|
--> $DIR/specialization-transmute.rs:17:9
|
||||||
|
|
|
|
||||||
LL | self
|
LL | self
|
||||||
| ^^^^ cannot satisfy `T <: <T as Default>::Id`
|
| ^^^^ cannot satisfy `<T as Default>::Id normalizes-to T`
|
||||||
|
|
||||||
error[E0284]: type annotations needed: cannot satisfy `<u8 as Default>::Id == Option<NonZero<u8>>`
|
error[E0284]: type annotations needed: cannot satisfy `<u8 as Default>::Id == Option<NonZero<u8>>`
|
||||||
--> $DIR/specialization-transmute.rs:28:13
|
--> $DIR/specialization-transmute.rs:28:13
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0284]: type annotations needed: cannot satisfy `<Out as Trait<Bar, In>>::Out == ()`
|
error[E0284]: type annotations needed: cannot satisfy `Bar == _`
|
||||||
--> $DIR/issue-84660-unsoundness.rs:22:37
|
--> $DIR/issue-84660-unsoundness.rs:22:37
|
||||||
|
|
|
|
||||||
LL | fn convert(_i: In) -> Self::Out {
|
LL | fn convert(_i: In) -> Self::Out {
|
||||||
|
@ -7,7 +7,7 @@ LL | |
|
||||||
LL | |
|
LL | |
|
||||||
LL | | unreachable!();
|
LL | | unreachable!();
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_____^ cannot satisfy `<Out as Trait<Bar, In>>::Out == ()`
|
| |_____^ cannot satisfy `Bar == _`
|
||||||
|
|
||||||
error[E0119]: conflicting implementations of trait `Trait<Bar, _>`
|
error[E0119]: conflicting implementations of trait `Trait<Bar, _>`
|
||||||
--> $DIR/issue-84660-unsoundness.rs:29:1
|
--> $DIR/issue-84660-unsoundness.rs:29:1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue