do not constrain infer vars in find_best_leaf_obligation
This commit is contained in:
parent
f2abf827c1
commit
d25ecfd5d6
10 changed files with 25 additions and 123 deletions
|
@ -346,12 +346,21 @@ fn find_best_leaf_obligation<'tcx>(
|
|||
consider_ambiguities: bool,
|
||||
) -> PredicateObligation<'tcx> {
|
||||
let obligation = infcx.resolve_vars_if_possible(obligation.clone());
|
||||
// FIXME: we use a probe here as the `BestObligation` visitor does not
|
||||
// check whether it uses candidates which get shadowed by where-bounds.
|
||||
//
|
||||
// We should probably fix the visitor to not do so instead, as this also
|
||||
// means the leaf obligation may be incorrect.
|
||||
infcx
|
||||
.visit_proof_tree(obligation.clone().into(), &mut BestObligation {
|
||||
obligation: obligation.clone(),
|
||||
consider_ambiguities,
|
||||
.fudge_inference_if_ok(|| {
|
||||
infcx
|
||||
.visit_proof_tree(obligation.clone().into(), &mut BestObligation {
|
||||
obligation: obligation.clone(),
|
||||
consider_ambiguities,
|
||||
})
|
||||
.break_value()
|
||||
.ok_or(())
|
||||
})
|
||||
.break_value()
|
||||
.unwrap_or(obligation)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,35 +1,11 @@
|
|||
error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
|
||||
--> $DIR/unsized_coercion.rs:15:17
|
||||
--> $DIR/unsized_coercion.rs:14:17
|
||||
|
|
||||
LL | let x = hello();
|
||||
| ^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `dyn Trait`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/unsized_coercion.rs:19:5
|
||||
|
|
||||
LL | fn hello() -> Box<impl Trait> {
|
||||
| ---------------
|
||||
| | |
|
||||
| | the expected opaque type
|
||||
| expected `Box<impl Trait>` because of return type
|
||||
...
|
||||
LL | Box::new(1u32)
|
||||
| ^^^^^^^^^^^^^^ types differ
|
||||
|
|
||||
= note: expected struct `Box<impl Trait>`
|
||||
found struct `Box<u32>`
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time
|
||||
--> $DIR/unsized_coercion.rs:12:1
|
||||
|
|
||||
LL | fn hello() -> Box<impl Trait> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||
|
|
||||
= help: the trait `Sized` is not implemented for `dyn Trait`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0308.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
@ -10,13 +10,12 @@ trait Trait {}
|
|||
impl Trait for u32 {}
|
||||
|
||||
fn hello() -> Box<impl Trait> {
|
||||
//[next]~^ ERROR the size for values of type `dyn Trait` cannot be known at compilation time
|
||||
if true {
|
||||
let x = hello();
|
||||
//[next]~^ ERROR: the size for values of type `dyn Trait` cannot be known at compilation time
|
||||
let y: Box<dyn Trait> = x;
|
||||
}
|
||||
Box::new(1u32) //[next]~ ERROR: mismatched types
|
||||
Box::new(1u32)
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,35 +1,11 @@
|
|||
error[E0277]: the trait bound `dyn Send: Trait` is not satisfied
|
||||
--> $DIR/unsized_coercion3.rs:14:17
|
||||
--> $DIR/unsized_coercion3.rs:13:17
|
||||
|
|
||||
LL | let x = hello();
|
||||
| ^^^^^^^ the trait `Trait` is not implemented for `dyn Send`
|
||||
|
|
||||
= help: the trait `Trait` is implemented for `u32`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/unsized_coercion3.rs:19:5
|
||||
|
|
||||
LL | fn hello() -> Box<impl Trait + ?Sized> {
|
||||
| ------------------------
|
||||
| | |
|
||||
| | the expected opaque type
|
||||
| expected `Box<impl Trait + ?Sized>` because of return type
|
||||
...
|
||||
LL | Box::new(1u32)
|
||||
| ^^^^^^^^^^^^^^ types differ
|
||||
|
|
||||
= note: expected struct `Box<impl Trait + ?Sized>`
|
||||
found struct `Box<u32>`
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
error[E0277]: the trait bound `dyn Send: Trait` is not satisfied
|
||||
--> $DIR/unsized_coercion3.rs:11:1
|
||||
|
|
||||
LL | fn hello() -> Box<impl Trait + ?Sized> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `dyn Send`
|
||||
|
|
||||
= help: the trait `Trait` is implemented for `u32`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0308.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time
|
||||
--> $DIR/unsized_coercion3.rs:16:32
|
||||
--> $DIR/unsized_coercion3.rs:15:32
|
||||
|
|
||||
LL | let y: Box<dyn Send> = x;
|
||||
| ^ doesn't have a size known at compile-time
|
||||
|
|
|
@ -9,7 +9,6 @@ trait Trait {}
|
|||
impl Trait for u32 {}
|
||||
|
||||
fn hello() -> Box<impl Trait + ?Sized> {
|
||||
//[next]~^ ERROR: the trait bound `dyn Send: Trait` is not satisfied
|
||||
if true {
|
||||
let x = hello();
|
||||
//[next]~^ ERROR: the trait bound `dyn Send: Trait` is not satisfied
|
||||
|
@ -17,7 +16,6 @@ fn hello() -> Box<impl Trait + ?Sized> {
|
|||
//[old]~^ ERROR: the size for values of type `impl Trait + ?Sized` cannot be know
|
||||
}
|
||||
Box::new(1u32)
|
||||
//[next]~^ ERROR: mismatched types
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -14,13 +14,7 @@ fn main() {
|
|||
|
||||
fn weird0() -> impl Sized + !Sized {}
|
||||
//~^ ERROR the trait bound `(): !Sized` is not satisfied
|
||||
//~| ERROR the trait bound `(): !Sized` is not satisfied
|
||||
//~| ERROR the trait bound `(): !Sized` is not satisfied
|
||||
fn weird1() -> impl !Sized + Sized {}
|
||||
//~^ ERROR the trait bound `(): !Sized` is not satisfied
|
||||
//~| ERROR the trait bound `(): !Sized` is not satisfied
|
||||
//~| ERROR the trait bound `(): !Sized` is not satisfied
|
||||
fn weird2() -> impl !Sized {}
|
||||
//~^ ERROR the trait bound `(): !Sized` is not satisfied
|
||||
//~| ERROR the trait bound `(): !Sized` is not satisfied
|
||||
//~| ERROR the trait bound `(): !Sized` is not satisfied
|
||||
|
|
|
@ -5,53 +5,17 @@ LL | fn weird0() -> impl Sized + !Sized {}
|
|||
| ^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
|
||||
|
||||
error[E0277]: the trait bound `(): !Sized` is not satisfied
|
||||
--> $DIR/opaque-type-unsatisfied-bound.rs:15:36
|
||||
|
|
||||
LL | fn weird0() -> impl Sized + !Sized {}
|
||||
| ^^ the trait bound `(): !Sized` is not satisfied
|
||||
|
||||
error[E0277]: the trait bound `(): !Sized` is not satisfied
|
||||
--> $DIR/opaque-type-unsatisfied-bound.rs:15:1
|
||||
|
|
||||
LL | fn weird0() -> impl Sized + !Sized {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
|
||||
|
||||
error[E0277]: the trait bound `(): !Sized` is not satisfied
|
||||
--> $DIR/opaque-type-unsatisfied-bound.rs:19:16
|
||||
--> $DIR/opaque-type-unsatisfied-bound.rs:17:16
|
||||
|
|
||||
LL | fn weird1() -> impl !Sized + Sized {}
|
||||
| ^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
|
||||
|
||||
error[E0277]: the trait bound `(): !Sized` is not satisfied
|
||||
--> $DIR/opaque-type-unsatisfied-bound.rs:19:36
|
||||
|
|
||||
LL | fn weird1() -> impl !Sized + Sized {}
|
||||
| ^^ the trait bound `(): !Sized` is not satisfied
|
||||
|
||||
error[E0277]: the trait bound `(): !Sized` is not satisfied
|
||||
--> $DIR/opaque-type-unsatisfied-bound.rs:19:1
|
||||
|
|
||||
LL | fn weird1() -> impl !Sized + Sized {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
|
||||
|
||||
error[E0277]: the trait bound `(): !Sized` is not satisfied
|
||||
--> $DIR/opaque-type-unsatisfied-bound.rs:23:16
|
||||
--> $DIR/opaque-type-unsatisfied-bound.rs:19:16
|
||||
|
|
||||
LL | fn weird2() -> impl !Sized {}
|
||||
| ^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
|
||||
|
||||
error[E0277]: the trait bound `(): !Sized` is not satisfied
|
||||
--> $DIR/opaque-type-unsatisfied-bound.rs:23:28
|
||||
|
|
||||
LL | fn weird2() -> impl !Sized {}
|
||||
| ^^ the trait bound `(): !Sized` is not satisfied
|
||||
|
||||
error[E0277]: the trait bound `(): !Sized` is not satisfied
|
||||
--> $DIR/opaque-type-unsatisfied-bound.rs:23:1
|
||||
|
|
||||
LL | fn weird2() -> impl !Sized {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied
|
||||
|
||||
error[E0277]: the trait bound `impl !Trait: Trait` is not satisfied
|
||||
--> $DIR/opaque-type-unsatisfied-bound.rs:12:13
|
||||
|
|
||||
|
@ -66,6 +30,6 @@ note: required by a bound in `consume`
|
|||
LL | fn consume(_: impl Trait) {}
|
||||
| ^^^^^ required by this bound in `consume`
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
|
@ -4,7 +4,5 @@
|
|||
|
||||
fn produce() -> impl !Fn<(u32,)> {}
|
||||
//~^ ERROR the trait bound `(): !Fn(u32)` is not satisfied
|
||||
//~| ERROR the trait bound `(): !Fn(u32)` is not satisfied
|
||||
//~| ERROR the trait bound `(): !Fn(u32)` is not satisfied
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -4,18 +4,6 @@ error[E0277]: the trait bound `(): !Fn(u32)` is not satisfied
|
|||
LL | fn produce() -> impl !Fn<(u32,)> {}
|
||||
| ^^^^^^^^^^^^^^^^ the trait bound `(): !Fn(u32)` is not satisfied
|
||||
|
||||
error[E0277]: the trait bound `(): !Fn(u32)` is not satisfied
|
||||
--> $DIR/opaque-type-unsatisfied-fn-bound.rs:5:34
|
||||
|
|
||||
LL | fn produce() -> impl !Fn<(u32,)> {}
|
||||
| ^^ the trait bound `(): !Fn(u32)` is not satisfied
|
||||
|
||||
error[E0277]: the trait bound `(): !Fn(u32)` is not satisfied
|
||||
--> $DIR/opaque-type-unsatisfied-fn-bound.rs:5:1
|
||||
|
|
||||
LL | fn produce() -> impl !Fn<(u32,)> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Fn(u32)` is not satisfied
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0277`.
|
||||
|
|
Loading…
Add table
Reference in a new issue