diff --git a/src/librustc_infer/infer/region_constraints/leak_check.rs b/src/librustc_infer/infer/region_constraints/leak_check.rs index 111a7b997a486..91c39a0e78ffb 100644 --- a/src/librustc_infer/infer/region_constraints/leak_check.rs +++ b/src/librustc_infer/infer/region_constraints/leak_check.rs @@ -42,23 +42,10 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> { _ => bug!("leak_check: expected placeholder found {:?}", placeholder_region,), }; - // Find all regions that this placeholder `!p` must outlive -- i.e., - // any region `r` where `!p: r` must hold. It is an error if any - // such region `r` is another placeholder or in a universe that - // can't see the placeholder. (This is actually incorrect, because - // we don't take into account the possibility of bounds in - // environment that tell us that the placeholder may be related to - // other regions). - // - // Note that we *don't* look for cases like `r: !p`. This is - // because: - // - // * If `r` is some other placeholder `!p1`, then we'll find the - // error when we search the regions that `!p1` must outlive. - // * If `r` is a variable in some outer universe, then it can - // potentially be assigned to `'static`, so this relation could - // hold. - let mut taint_set = TaintSet::new(TaintDirections::outgoing(), placeholder_region); + // Find all regions that are related to this placeholder + // in some way. This means any region that either outlives + // or is outlived by a placeholder. + let mut taint_set = TaintSet::new(TaintDirections::both(), placeholder_region); taint_set.fixed_point( tcx, self.undo_log.region_constraints(), diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.rs b/src/test/ui/closure-expected-type/expect-fn-supply-fn.rs index 6977fd47a2e85..a4e43da91baf8 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.rs +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.rs @@ -28,14 +28,14 @@ fn expect_free_supply_bound() { // Here, we are given a function whose region is bound at closure level, // but we expect one bound in the argument. Error results. with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); - //~^ ERROR mismatched types + //~^ ERROR type mismatch } fn expect_bound_supply_free_from_fn<'x>(x: &'x u32) { // Here, we are given a `fn(&u32)` but we expect a `fn(&'x // u32)`. In principle, this could be ok, but we demand equality. with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); - //~^ ERROR mismatched types + //~^ ERROR type mismatch } fn expect_bound_supply_free_from_closure() { @@ -44,7 +44,7 @@ fn expect_bound_supply_free_from_closure() { // the argument level. type Foo<'a> = fn(&'a u32); with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| { - //~^ ERROR mismatched types + //~^ ERROR type mismatch }); } diff --git a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr index 8a183bb704b4d..fae41c4114abc 100644 --- a/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr +++ b/src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr @@ -36,33 +36,46 @@ note: ...does not necessarily outlive the anonymous lifetime #2 defined on the b LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {}); | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:30:52 +error[E0631]: type mismatch in closure arguments + --> $DIR/expect-fn-supply-fn.rs:30:5 | +LL | fn with_closure_expecting_fn_with_free_region(_: F) + | ------------------------------------------ required by a bound in this +LL | where F: for<'a> FnOnce(fn(&'a u32), &i32) + | ------------------------- required by this bound in `with_closure_expecting_fn_with_free_region` +... LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {}); - | ^^^^^^^^ one type is more general than the other - | - = note: expected fn pointer `fn(&u32)` - found fn pointer `for<'r> fn(&'r u32)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `fn(for<'r> fn(&'r u32), _) -> _` + | | + | expected signature of `fn(fn(&'a u32), &i32) -> _` -error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:37:53 +error[E0631]: type mismatch in closure arguments + --> $DIR/expect-fn-supply-fn.rs:37:5 | +LL | fn with_closure_expecting_fn_with_bound_region(_: F) + | ------------------------------------------- required by a bound in this +LL | where F: FnOnce(fn(&u32), &i32) + | ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region` +... LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {}); - | ^^^^^^^^^^^ one type is more general than the other - | - = note: expected fn pointer `for<'r> fn(&'r u32)` - found fn pointer `fn(&'x u32)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- found signature of `fn(fn(&'x u32), _) -> _` + | | + | expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _` -error[E0308]: mismatched types - --> $DIR/expect-fn-supply-fn.rs:46:53 +error[E0631]: type mismatch in closure arguments + --> $DIR/expect-fn-supply-fn.rs:46:5 | +LL | fn with_closure_expecting_fn_with_bound_region(_: F) + | ------------------------------------------- required by a bound in this +LL | where F: FnOnce(fn(&u32), &i32) + | ---------------------- required by this bound in `with_closure_expecting_fn_with_bound_region` +... LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| { - | ^^^^^^^ one type is more general than the other - | - = note: expected fn pointer `for<'r> fn(&'r u32)` - found fn pointer `fn(&u32)` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _` + | | + | expected signature of `fn(for<'r> fn(&'r u32), &i32) -> _` error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0308, E0631. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr index c4e838e6887b5..45f53d4fe99db 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_a_b_vs_bound_a.stderr @@ -1,14 +1,17 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:96:1 +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:39:26 | -LL | / fn main() { -LL | | -LL | | -LL | | -... | -LL | | -LL | | } - | |_^ +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a +... +LL | / check! { bound_a_b_vs_bound_a: (for<'a,'b> fn(&'a u32, &'b u32), +LL | | for<'a> fn(&'a u32, &'a u32)) } + | |__________________________________________________________________- in this macro invocation + | + = note: expected enum `std::option::Option fn(&'a u32, &'b u32)>` + found enum `std::option::Option fn(&'a u32, &'a u32)>` + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr index c4e838e6887b5..6aba6466fada5 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_a.stderr @@ -1,11 +1,11 @@ error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:96:1 + --> $DIR/hr-subtype.rs:100:1 | LL | / fn main() { LL | | LL | | LL | | -... | +LL | | LL | | LL | | } | |_^ diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr index c4e838e6887b5..6aba6466fada5 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_bound_b.stderr @@ -1,11 +1,11 @@ error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:96:1 + --> $DIR/hr-subtype.rs:100:1 | LL | / fn main() { LL | | LL | | LL | | -... | +LL | | LL | | LL | | } | |_^ diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr index b3e3f5dc401cf..c3e4f6d2ed0c1 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/hr-subtype.rs:39:26 | LL | gimme::<$t1>(None::<$t2>); - | ^^^^^^^^^^^ one type is more general than the other + | ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a ... LL | / check! { bound_a_vs_free_x: (for<'a> fn(&'a u32), LL | | fn(&'x u32)) } diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr index c4e838e6887b5..4d7b86027f564 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_b_vs_bound_co_a.stderr @@ -1,14 +1,17 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:96:1 +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:39:26 | -LL | / fn main() { -LL | | -LL | | -LL | | -... | -LL | | -LL | | } - | |_^ +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a +... +LL | / check! { bound_co_a_b_vs_bound_co_a: (for<'a,'b> fn(Co<'a>, Co<'b>), +LL | | for<'a> fn(Co<'a>, Co<'a>)) } + | |______________________________________________________________________- in this macro invocation + | + = note: expected enum `std::option::Option fn(Co<'a>, Co<'b>)>` + found enum `std::option::Option fn(Co<'a>, Co<'a>)>` + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr index c4e838e6887b5..7f0a4197dd7fe 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_co_b_ret_contra_a.stderr @@ -1,14 +1,17 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:96:1 +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:39:26 | -LL | / fn main() { -LL | | -LL | | -LL | | -... | -LL | | -LL | | } - | |_^ +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a +... +LL | / check! { bound_co_a_co_b_ret_contra_a: (for<'a,'b> fn(Co<'a>, Co<'b>) -> Contra<'a>, +LL | | for<'a> fn(Co<'a>, Co<'a>) -> Contra<'a>) } + | |______________________________________________________________________________________- in this macro invocation + | + = note: expected enum `std::option::Option fn(Co<'a>, Co<'b>) -> Contra<'a>>` + found enum `std::option::Option fn(Co<'a>, Co<'a>) -> Contra<'a>>` + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr index c4e838e6887b5..6aba6466fada5 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_co_a_vs_bound_co_b.stderr @@ -1,11 +1,11 @@ error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:96:1 + --> $DIR/hr-subtype.rs:100:1 | LL | / fn main() { LL | | LL | | LL | | -... | +LL | | LL | | LL | | } | |_^ diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr index c4e838e6887b5..c12e543a44e79 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_contra_a_contra_b_ret_co_a.stderr @@ -1,14 +1,17 @@ -error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:96:1 +error[E0308]: mismatched types + --> $DIR/hr-subtype.rs:39:26 | -LL | / fn main() { -LL | | -LL | | -LL | | -... | -LL | | -LL | | } - | |_^ +LL | gimme::<$t1>(None::<$t2>); + | ^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter 'a +... +LL | / check! { bound_contra_a_contra_b_ret_co_a: (for<'a,'b> fn(Contra<'a>, Contra<'b>) -> Co<'a>, +LL | | for<'a> fn(Contra<'a>, Contra<'a>) -> Co<'a>) } + | |______________________________________________________________________________________________- in this macro invocation + | + = note: expected enum `std::option::Option fn(Contra<'a>, Contra<'b>) -> Co<'a>>` + found enum `std::option::Option fn(Contra<'a>, Contra<'a>) -> Co<'a>>` + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr b/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr index c4e838e6887b5..6aba6466fada5 100644 --- a/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.bound_inv_a_vs_bound_inv_b.stderr @@ -1,11 +1,11 @@ error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:96:1 + --> $DIR/hr-subtype.rs:100:1 | LL | / fn main() { LL | | LL | | LL | | -... | +LL | | LL | | LL | | } | |_^ diff --git a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr index c4e838e6887b5..6aba6466fada5 100644 --- a/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr +++ b/src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_x.stderr @@ -1,11 +1,11 @@ error: fatal error triggered by #[rustc_error] - --> $DIR/hr-subtype.rs:96:1 + --> $DIR/hr-subtype.rs:100:1 | LL | / fn main() { LL | | LL | | LL | | -... | +LL | | LL | | LL | | } | |_^ diff --git a/src/test/ui/hr-subtype/hr-subtype.rs b/src/test/ui/hr-subtype/hr-subtype.rs index 995ec64d53b83..b31f198bd97bf 100644 --- a/src/test/ui/hr-subtype/hr-subtype.rs +++ b/src/test/ui/hr-subtype/hr-subtype.rs @@ -42,6 +42,10 @@ macro_rules! check { //[bound_inv_a_b_vs_bound_inv_a]~^^^ ERROR //[bound_a_b_ret_a_vs_bound_a_ret_a]~^^^^ ERROR //[free_inv_x_vs_free_inv_y]~^^^^^ ERROR + //[bound_a_b_vs_bound_a]~^^^^^^ ERROR mismatched types + //[bound_co_a_co_b_ret_contra_a]~^^^^^^^ ERROR + //[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^ ERROR + //[bound_co_a_b_vs_bound_co_a]~^^^^^^^^^ ERROR } } } @@ -99,8 +103,4 @@ fn main() { //[bound_inv_a_vs_bound_inv_b]~^^^ ERROR fatal error triggered by #[rustc_error] //[bound_co_a_vs_bound_co_b]~^^^^ ERROR fatal error triggered by #[rustc_error] //[free_x_vs_free_x]~^^^^^ ERROR fatal error triggered by #[rustc_error] -//[bound_a_b_vs_bound_a]~^^^^^^ ERROR fatal error triggered by #[rustc_error] -//[bound_co_a_b_vs_bound_co_a]~^^^^^^^ ERROR fatal error triggered by #[rustc_error] -//[bound_co_a_co_b_ret_contra_a]~^^^^^^^^ ERROR fatal error triggered by #[rustc_error] -//[bound_contra_a_contra_b_ret_co_a]~^^^^^^^^^ ERROR fatal error triggered by #[rustc_error] } diff --git a/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr b/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr index 9914783d9767d..328e98657effb 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-fn.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/hrtb-exists-forall-fn.rs:17:34 | LL | let _: for<'b> fn(&'b u32) = foo(); - | ^^^^^ one type is more general than the other + | ------------------- ^^^^^ expected concrete lifetime, found bound lifetime parameter 'b + | | + | expected due to this | = note: expected fn pointer `for<'b> fn(&'b u32)` found fn pointer `fn(&u32)` diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs index 921061916fc95..4c1d4d28a09b0 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.rs @@ -32,5 +32,5 @@ fn main() { // NB. *However*, the reinstated leak-check gives an error here. foo::<()>(); - //~^ ERROR implementation of `Trait` is not general enough + //~^ ERROR not satisfied } diff --git a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr index fe8209d054c8a..7a7285d3d76e0 100644 --- a/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr +++ b/src/test/ui/hrtb/hrtb-exists-forall-trait-contravariant.stderr @@ -1,14 +1,18 @@ -error: implementation of `Trait` is not general enough - --> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:5 +error[E0277]: the trait bound `(): Trait fn(&'b u32)>` is not satisfied + --> $DIR/hrtb-exists-forall-trait-contravariant.rs:34:11 | -LL | trait Trait {} - | ----------------- trait `Trait` defined here +LL | fn foo() + | --- required by a bound in this +LL | where +LL | T: Trait fn(&'b u32)>, + | -------------------------- required by this bound in `foo` ... LL | foo::<()>(); - | ^^^^^^^^^ implementation of `Trait` is not general enough + | ^^ the trait `Trait fn(&'b u32)>` is not implemented for `()` | - = note: `()` must implement `Trait fn(&'b u32)>` - = note: ...but `()` actually implements `Trait`, for some specific lifetime `'0` + = help: the following implementations were found: + <() as Trait> error: aborting due to previous error +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr index ebb3abf184856..87a13889298df 100644 --- a/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr +++ b/src/test/ui/hrtb/hrtb-higher-ranker-supertraits-transitive.stderr @@ -1,12 +1,19 @@ -error[E0308]: mismatched types - --> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:47:5 +error[E0277]: the trait bound `for<'ccx> B: Bar<'ccx>` is not satisfied + --> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:47:26 | +LL | fn want_bar_for_any_ccx(b: &B) + | -------------------- required by a bound in this +LL | where B : for<'ccx> Bar<'ccx> + | ------------------- required by this bound in `want_bar_for_any_ccx` +... LL | want_bar_for_any_ccx(b); - | ^^^^^^^^^^^^^^^^^^^^ one type is more general than the other + | ^ the trait `for<'ccx> Bar<'ccx>` is not implemented for `B` | - = note: expected type `for<'ccx> Bar<'ccx>` - found type `Bar<'static>` +help: consider further restricting this bound + | +LL | where B : Qux + for<'ccx> Bar<'ccx> + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/hrtb/hrtb-just-for-static.stderr b/src/test/ui/hrtb/hrtb-just-for-static.stderr index bf7373059a074..4fa404624775b 100644 --- a/src/test/ui/hrtb/hrtb-just-for-static.stderr +++ b/src/test/ui/hrtb/hrtb-just-for-static.stderr @@ -1,16 +1,16 @@ -error: implementation of `Foo` is not general enough - --> $DIR/hrtb-just-for-static.rs:24:5 +error[E0277]: the trait bound `for<'a> StaticInt: Foo<&'a isize>` is not satisfied + --> $DIR/hrtb-just-for-static.rs:24:17 | -LL | / trait Foo { -LL | | fn foo(&self, x: X) { } -LL | | } - | |_- trait `Foo` defined here +LL | fn want_hrtb() + | --------- required by a bound in this +LL | where T : for<'a> Foo<&'a isize> + | ---------------------- required by this bound in `want_hrtb` ... -LL | want_hrtb::() - | ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough +LL | want_hrtb::() + | ^^^^^^^^^ the trait `for<'a> Foo<&'a isize>` is not implemented for `StaticInt` | - = note: `StaticInt` must implement `Foo<&'0 isize>`, for any lifetime `'0`... - = note: ...but `StaticInt` actually implements `Foo<&'1 isize>`, for some specific lifetime `'1` + = help: the following implementations were found: + > error[E0277]: the trait bound `for<'a> &'a u32: Foo<&'a isize>` is not satisfied --> $DIR/hrtb-just-for-static.rs:30:17 diff --git a/src/test/ui/hrtb/issue-46989.rs b/src/test/ui/hrtb/issue-46989.rs index eb6549099fe6a..2c85905545807 100644 --- a/src/test/ui/hrtb/issue-46989.rs +++ b/src/test/ui/hrtb/issue-46989.rs @@ -38,5 +38,5 @@ fn assert_foo() {} fn main() { assert_foo::(); - //~^ ERROR implementation of `Foo` is not general enough + //~^ ERROR the trait bound `for<'r> fn(&'r i32): Foo` is not satisfied } diff --git a/src/test/ui/hrtb/issue-46989.stderr b/src/test/ui/hrtb/issue-46989.stderr index 0865aa4224b97..0a7382c4dd818 100644 --- a/src/test/ui/hrtb/issue-46989.stderr +++ b/src/test/ui/hrtb/issue-46989.stderr @@ -1,16 +1,15 @@ -error: implementation of `Foo` is not general enough - --> $DIR/issue-46989.rs:40:5 +error[E0277]: the trait bound `for<'r> fn(&'r i32): Foo` is not satisfied + --> $DIR/issue-46989.rs:40:18 | -LL | / trait Foo { -LL | | -LL | | } - | |_- trait `Foo` defined here +LL | fn assert_foo() {} + | --- required by this bound in `assert_foo` ... -LL | assert_foo::(); - | ^^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough +LL | assert_foo::(); + | ^^^^^^^^ the trait `Foo` is not implemented for `for<'r> fn(&'r i32)` | - = note: `Foo` would have to be implemented for the type `for<'r> fn(&'r i32)` - = note: ...but `Foo` is actually implemented for the type `fn(&'0 i32)`, for some specific lifetime `'0` + = help: the following implementations were found: + error: aborting due to previous error +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/issues/issue-57362-1.rs b/src/test/ui/issues/issue-57362-1.rs index 3ba82300fabea..1fa417fe98ab7 100644 --- a/src/test/ui/issues/issue-57362-1.rs +++ b/src/test/ui/issues/issue-57362-1.rs @@ -17,7 +17,7 @@ impl Trait for fn(&T) { fn f() { let a: fn(_) = |_: &u8| {}; - a.f(); //~ ERROR implementation of `Trait` is not general enough + a.f(); //~ ERROR no method named `f` } fn main() {} diff --git a/src/test/ui/issues/issue-57362-1.stderr b/src/test/ui/issues/issue-57362-1.stderr index 24408420b1373..5c611cd43d3cc 100644 --- a/src/test/ui/issues/issue-57362-1.stderr +++ b/src/test/ui/issues/issue-57362-1.stderr @@ -1,16 +1,17 @@ -error: implementation of `Trait` is not general enough +error[E0599]: no method named `f` found for fn pointer `fn(&u8)` in the current scope --> $DIR/issue-57362-1.rs:20:7 | -LL | / trait Trait { -LL | | fn f(self); -LL | | } - | |_- trait `Trait` defined here -... -LL | a.f(); - | ^ implementation of `Trait` is not general enough +LL | a.f(); + | ^ method not found in `fn(&u8)` | - = note: `Trait` would have to be implemented for the type `fn(&'0 u8)`, for some specific lifetime `'0`... - = note: ...but `Trait` is actually implemented for the type `for<'r> fn(&'r u8)` + = note: `a` is a function, perhaps you wish to call it + = help: items from traits can only be used if the trait is implemented and in scope +note: `Trait` defines an item `f`, perhaps you need to implement it + --> $DIR/issue-57362-1.rs:8:1 + | +LL | trait Trait { + | ^^^^^^^^^^^ error: aborting due to previous error +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/issues/issue-57362-2.rs b/src/test/ui/issues/issue-57362-2.rs index 7b6594abc9647..870d7f28ba953 100644 --- a/src/test/ui/issues/issue-57362-2.rs +++ b/src/test/ui/issues/issue-57362-2.rs @@ -19,9 +19,7 @@ impl<'a> X for fn(&'a ()) { } fn g() { - let x = ::make_g(); - //~^ ERROR implementation of `X` is not general enough - //~| ERROR implementation of `X` is not general enough + let x = ::make_g(); //~ ERROR no function or associated item } fn main() {} diff --git a/src/test/ui/issues/issue-57362-2.stderr b/src/test/ui/issues/issue-57362-2.stderr index dfd48ec22275b..2edc009746455 100644 --- a/src/test/ui/issues/issue-57362-2.stderr +++ b/src/test/ui/issues/issue-57362-2.stderr @@ -1,33 +1,16 @@ -error: implementation of `X` is not general enough - --> $DIR/issue-57362-2.rs:22:13 +error[E0599]: no function or associated item named `make_g` found for fn pointer `for<'r> fn(&'r ())` in the current scope + --> $DIR/issue-57362-2.rs:22:25 | -LL | / trait X { -LL | | type G; -LL | | fn make_g() -> Self::G; -LL | | } - | |_- trait `X` defined here -... -LL | let x = ::make_g(); - | ^^^^^^^^^^^^^^^^^^ implementation of `X` is not general enough +LL | let x = ::make_g(); + | ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())` | - = note: `X` would have to be implemented for the type `for<'r> fn(&'r ())` - = note: ...but `X` is actually implemented for the type `fn(&'0 ())`, for some specific lifetime `'0` - -error: implementation of `X` is not general enough - --> $DIR/issue-57362-2.rs:22:13 - | -LL | / trait X { -LL | | type G; -LL | | fn make_g() -> Self::G; - | | ----------------------- due to a where-clause on `X::make_g`... -LL | | } - | |_- trait `X` defined here -... -LL | let x = ::make_g(); - | ^^^^^^^^^^^^^^^^^^ doesn't satisfy where-clause + = help: items from traits can only be used if the trait is implemented and in scope +note: `X` defines an item `make_g`, perhaps you need to implement it + --> $DIR/issue-57362-2.rs:8:1 | - = note: ...`X` would have to be implemented for the type `for<'r> fn(&'r ())` - = note: ...but `X` is actually implemented for the type `fn(&'0 ())`, for some specific lifetime `'0` +LL | trait X { + | ^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error +For more information about this error, try `rustc --explain E0599`. diff --git a/src/test/ui/lub-glb/old-lub-glb-hr.rs b/src/test/ui/lub-glb/old-lub-glb-hr.rs index 5e24a99bcc331..bc7b787cd65ac 100644 --- a/src/test/ui/lub-glb/old-lub-glb-hr.rs +++ b/src/test/ui/lub-glb/old-lub-glb-hr.rs @@ -3,21 +3,21 @@ // error. However, now that we handle subtyping correctly, we no // longer get an error, because we recognize these two types as // equivalent! +// +// Whoops -- now that we reinstituted the leak-check, we get an error +// again. fn foo( x: fn(&u8, &u8), y: for<'a> fn(&'a u8, &'a u8), ) { - // The two types above are actually equivalent. With the older - // leak check, though, we didn't consider them as equivalent, and - // hence we gave errors. But now we've fixed that. let z = match 22 { 0 => x, - _ => y, + _ => y, //~ ERROR `match` arms have incompatible types }; } -fn foo_cast( +fn bar( x: fn(&u8, &u8), y: for<'a> fn(&'a u8, &'a u8), ) { @@ -28,30 +28,5 @@ fn foo_cast( }; } -fn bar( - x: for<'a, 'b> fn(&'a u8, &'b u8)-> &'a u8, - y: for<'a> fn(&'a u8, &'a u8) -> &'a u8, -) { - // The two types above are not equivalent. With the older LUB/GLB - // algorithm, this may have worked (I don't remember), but now it - // doesn't because we require equality. - let z = match 22 { - 0 => x, - _ => y, //~ ERROR `match` arms have incompatible types - }; -} - -fn bar_cast( - x: for<'a, 'b> fn(&'a u8, &'b u8)-> &'a u8, - y: for<'a> fn(&'a u8, &'a u8) -> &'a u8, -) { - // But we can *upcast* explicitly the type of `x` and figure - // things out: - let z = match 22 { - 0 => x as for<'a> fn(&'a u8, &'a u8) -> &'a u8, - _ => y, - }; -} - fn main() { } diff --git a/src/test/ui/lub-glb/old-lub-glb-hr.stderr b/src/test/ui/lub-glb/old-lub-glb-hr.stderr index d242fb7789aa1..6d5d51174699f 100644 --- a/src/test/ui/lub-glb/old-lub-glb-hr.stderr +++ b/src/test/ui/lub-glb/old-lub-glb-hr.stderr @@ -1,17 +1,17 @@ error[E0308]: `match` arms have incompatible types - --> $DIR/old-lub-glb-hr.rs:40:14 + --> $DIR/old-lub-glb-hr.rs:16:14 | LL | let z = match 22 { | _____________- LL | | 0 => x, - | | - this is found to be of type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` + | | - this is found to be of type `for<'r, 's> fn(&'r u8, &'s u8)` LL | | _ => y, - | | ^ expected bound lifetime parameter 'a, found concrete lifetime + | | ^ expected bound lifetime parameter, found concrete lifetime LL | | }; | |_____- `match` arms have incompatible types | - = note: expected type `for<'a, 'b> fn(&'a u8, &'b u8) -> &'a u8` - found fn pointer `for<'a> fn(&'a u8, &'a u8) -> &'a u8` + = note: expected type `for<'r, 's> fn(&'r u8, &'s u8)` + found fn pointer `for<'a> fn(&'a u8, &'a u8)` error: aborting due to previous error diff --git a/src/test/ui/regions-fn-subtyping-return-static-fail.stderr b/src/test/ui/regions-fn-subtyping-return-static-fail.stderr index 7848f770a70cf..27704b3e0a8c7 100644 --- a/src/test/ui/regions-fn-subtyping-return-static-fail.stderr +++ b/src/test/ui/regions-fn-subtyping-return-static-fail.stderr @@ -11,10 +11,10 @@ error[E0308]: mismatched types --> $DIR/regions-fn-subtyping-return-static-fail.rs:48:12 | LL | want_G(baz); - | ^^^ one type is more general than the other + | ^^^ expected concrete lifetime, found bound lifetime parameter 'cx | = note: expected fn pointer `for<'cx> fn(&'cx S) -> &'static S` - found fn pointer `for<'r> fn(&'r S) -> &'r S` + found fn item `for<'r> fn(&'r S) -> &'r S {baz}` error: aborting due to 2 previous errors diff --git a/src/test/ui/where-clauses/where-for-self-2.rs b/src/test/ui/where-clauses/where-for-self-2.rs index 0ce38e69f6b0f..31174fd4cf163 100644 --- a/src/test/ui/where-clauses/where-for-self-2.rs +++ b/src/test/ui/where-clauses/where-for-self-2.rs @@ -18,5 +18,5 @@ fn foo(x: &T) {} fn main() { - foo(&X); //~ ERROR implementation of `Bar` is not general enough + foo(&X); //~ ERROR trait bound } diff --git a/src/test/ui/where-clauses/where-for-self-2.stderr b/src/test/ui/where-clauses/where-for-self-2.stderr index b3cadf5b1b078..9976243b200dc 100644 --- a/src/test/ui/where-clauses/where-for-self-2.stderr +++ b/src/test/ui/where-clauses/where-for-self-2.stderr @@ -1,16 +1,17 @@ -error: implementation of `Bar` is not general enough +error[E0277]: the trait bound `for<'a> &'a _: Bar` is not satisfied --> $DIR/where-for-self-2.rs:21:5 | -LL | / trait Bar { -LL | | fn bar(&self); -LL | | } - | |_- trait `Bar` defined here +LL | fn foo(x: &T) + | --- required by a bound in this +LL | where for<'a> &'a T: Bar + | --- required by this bound in `foo` ... -LL | foo(&X); - | ^^^ implementation of `Bar` is not general enough +LL | foo(&X); + | ^^^ the trait `for<'a> Bar` is not implemented for `&'a _` | - = note: `Bar` would have to be implemented for the type `&'0 u32`, for any lifetime `'0`... - = note: ...but `Bar` is actually implemented for the type `&'1 u32`, for some specific lifetime `'1` + = help: the following implementations were found: + <&'static u32 as Bar> error: aborting due to previous error +For more information about this error, try `rustc --explain E0277`.