diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 95f327112253a..d2dcd07a24009 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -10,7 +10,7 @@ use rustc_hir::ItemKind; use rustc_infer::infer::outlives::env::{OutlivesEnvironment, RegionBoundPairs}; use rustc_infer::infer::outlives::obligations::TypeOutlives; use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt}; -use rustc_infer::traits::Normalized; +use rustc_infer::traits::{Normalized, TraitEngine, TraitEngineExt as _}; use rustc_middle::ty::query::Providers; use rustc_middle::ty::subst::{GenericArgKind, InternalSubsts, Subst}; use rustc_middle::ty::trait_def::TraitSpecializationKind; @@ -27,7 +27,8 @@ use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _ use rustc_trait_selection::traits::query::normalize::AtExt; use rustc_trait_selection::traits::query::NoSolution; use rustc_trait_selection::traits::{ - self, ObligationCause, ObligationCauseCode, ObligationCtxt, WellFormedLoc, + self, FulfillmentContext, ObligationCause, ObligationCauseCode, ObligationCtxt, + SelectionContext, WellFormedLoc, }; use std::cell::LazyCell; @@ -1817,7 +1818,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { /// Feature gates RFC 2056 -- trivial bounds, checking for global bounds that /// aren't true. fn check_false_global_bounds(&mut self) { - let tcx = self.ocx.infcx.tcx; + let tcx = self.infcx.tcx; let mut span = self.span; let empty_env = ty::ParamEnv::empty(); @@ -1833,33 +1834,76 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { if let ty::PredicateKind::WellFormed(..) = obligation.predicate.kind().skip_binder() { continue; } - let pred = obligation.predicate; - // Match the existing behavior. - if pred.is_global() && !pred.has_late_bound_regions() { - let pred = self.normalize(span, None, pred); - let hir_node = tcx.hir().find(self.body_id); - // only use the span of the predicate clause (#90869) + let pred = obligation.predicate; - if let Some(hir::Generics { predicates, .. }) = - hir_node.and_then(|node| node.generics()) - { - let obligation_span = obligation.cause.span(); - - span = predicates - .iter() - // There seems to be no better way to find out which predicate we are in - .find(|pred| pred.span().contains(obligation_span)) - .map(|pred| pred.span()) - .unwrap_or(obligation_span); - } + // only use the span of the predicate clause (#90869) + let hir_node = tcx.hir().find(self.body_id); + if let Some(hir::Generics { predicates, .. }) = + hir_node.and_then(|node| node.generics()) + { + let obligation_span = obligation.cause.span(); + span = predicates + .iter() + // There seems to be no better way to find out which predicate we are in + .find(|pred| pred.span().contains(obligation_span)) + .map(|pred| pred.span()) + .unwrap_or(obligation_span); + } + // Match the existing behavior. + if pred.is_global() && !pred.has_late_bound_regions() { + let normalized_pred = self.normalize(span, None, pred); let obligation = traits::Obligation::new( traits::ObligationCause::new(span, self.body_id, traits::TrivialBound), empty_env, - pred, + normalized_pred, ); - self.ocx.register_obligation(obligation); + self.register_obligation(obligation); + } else { + self.infcx.probe(|_| { + // Manually normalize because `wfcx.normalize` may report errors + let Normalized { value: normalized_pred, obligations } = traits::normalize( + &mut SelectionContext::new(self.infcx), + self.param_env, + ObligationCause::dummy(), + pred, + ); + if normalized_pred.is_global() { + let mut fulfill_cx = FulfillmentContext::new_in_snapshot(); + fulfill_cx.register_predicate_obligations(self.infcx, obligations); + fulfill_cx.register_predicate_obligation( + self.infcx, + traits::Obligation::new( + traits::ObligationCause::new( + span, + self.body_id, + traits::TrivialBound, + ), + empty_env, + normalized_pred, + ), + ); + if !fulfill_cx.select_all_or_error(self.infcx).is_empty() { + let mut diag = self.tcx() + .sess + .struct_span_warn( + span, + format!("the where-clause bound `{pred}` is impossible to satisfy"), + ); + diag.span_label( + self.span, + "this item cannot be referenced without causing an error", + ); + if self.infcx.tcx.sess.opts.unstable_features.is_nightly_build() { + diag.help( + "add `#![feature(trivial_bounds)]` to the crate attributes to allow it", + ); + } + diag.emit(); + } + } + }); } } } diff --git a/src/test/ui/associated-types/bound-lifetime-in-binding-only.ok.stderr b/src/test/ui/associated-types/bound-lifetime-in-binding-only.ok.stderr index b709fae5a8e56..06036ee3ac25d 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-binding-only.ok.stderr +++ b/src/test/ui/associated-types/bound-lifetime-in-binding-only.ok.stderr @@ -1,8 +1,32 @@ +warning: the where-clause bound `for<'a> as Foo>::Item == &'a i32` is impossible to satisfy + --> $DIR/bound-lifetime-in-binding-only.rs:67:19 + | +LL | fn ok3() where for<'a> Parameterized<'a>: Foo { + | _- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | | +LL | | +LL | | } + | |_- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + +warning: the where-clause bound `for<'a> Parameterized<'a>: Foo` is impossible to satisfy + --> $DIR/bound-lifetime-in-binding-only.rs:67:19 + | +LL | fn ok3() where for<'a> Parameterized<'a>: Foo { + | _- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | | +LL | | +LL | | } + | |_- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + error: fatal error triggered by #[rustc_error] - --> $DIR/bound-lifetime-in-binding-only.rs:71:1 + --> $DIR/bound-lifetime-in-binding-only.rs:73:1 | LL | fn main() { } | ^^^^^^^^^ -error: aborting due to previous error +error: aborting due to previous error; 2 warnings emitted diff --git a/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs b/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs index e714457ef7b38..e3e2daf29e073 100644 --- a/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs +++ b/src/test/ui/associated-types/bound-lifetime-in-binding-only.rs @@ -65,6 +65,8 @@ fn ok2 Fn<(&'b Parameterized<'a>,), Output=&'a i32>>() { #[cfg(ok)] fn ok3() where for<'a> Parameterized<'a>: Foo { + //[ok]~^ WARNING the where-clause bound + //[ok]~| WARNING the where-clause bound } #[rustc_error] diff --git a/src/test/ui/associated-types/issue-59324.rs b/src/test/ui/associated-types/issue-59324.rs index 162f9e00edd81..87345e54d4536 100644 --- a/src/test/ui/associated-types/issue-59324.rs +++ b/src/test/ui/associated-types/issue-59324.rs @@ -12,7 +12,7 @@ pub trait ThriftService: //~^ ERROR the trait bound `Bug: Foo` is not satisfied //~| ERROR the trait bound `Bug: Foo` is not satisfied Service::OnlyFoo> -{ + { fn get_service( //~^ ERROR the trait bound `Bug: Foo` is not satisfied &self, diff --git a/src/test/ui/associated-types/issue-69398.rs b/src/test/ui/associated-types/issue-69398.rs index ca3d66b1c8eb7..01654461afea2 100644 --- a/src/test/ui/associated-types/issue-69398.rs +++ b/src/test/ui/associated-types/issue-69398.rs @@ -12,6 +12,7 @@ pub trait Broken { impl Broken for T { type Assoc = (); fn broken(&self) where Self::Assoc: Foo { + //~^ WARNING the where-clause bound let _x: ::Bar; } } diff --git a/src/test/ui/associated-types/issue-69398.stderr b/src/test/ui/associated-types/issue-69398.stderr new file mode 100644 index 0000000000000..8bc51ea5eec12 --- /dev/null +++ b/src/test/ui/associated-types/issue-69398.stderr @@ -0,0 +1,14 @@ +warning: the where-clause bound `::Assoc: Foo` is impossible to satisfy + --> $DIR/issue-69398.rs:14:28 + | +LL | fn broken(&self) where Self::Assoc: Foo { + | _____- ^^^^^^^^^^^^^^^^ +LL | | +LL | | let _x: ::Bar; +LL | | } + | |_____- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + +warning: 1 warning emitted + diff --git a/src/test/ui/consts/issue-67696-const-prop-ice.rs b/src/test/ui/consts/issue-67696-const-prop-ice.rs index ad52608b3f46d..c04a9fd7a54ae 100644 --- a/src/test/ui/consts/issue-67696-const-prop-ice.rs +++ b/src/test/ui/consts/issue-67696-const-prop-ice.rs @@ -11,6 +11,9 @@ trait A { impl A for [fn(&())] { fn foo(&self) -> Self where Self: Copy { *(&[] as &[_]) } + //~^ WARNING the where-clause bound + //~| WARNING the where-clause bound + //~| WARNING the where-clause bound } impl A for i32 { diff --git a/src/test/ui/consts/issue-67696-const-prop-ice.stderr b/src/test/ui/consts/issue-67696-const-prop-ice.stderr new file mode 100644 index 0000000000000..2cbd1bcde740a --- /dev/null +++ b/src/test/ui/consts/issue-67696-const-prop-ice.stderr @@ -0,0 +1,26 @@ +warning: the where-clause bound `[for<'r> fn(&'r ())]: Copy` is impossible to satisfy + --> $DIR/issue-67696-const-prop-ice.rs:13:33 + | +LL | fn foo(&self) -> Self where Self: Copy { *(&[] as &[_]) } + | ----------------------------^^^^^^^^^^------------------- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + +warning: the where-clause bound `[for<'r> fn(&'r ())]: Clone` is impossible to satisfy + --> $DIR/issue-67696-const-prop-ice.rs:13:33 + | +LL | fn foo(&self) -> Self where Self: Copy { *(&[] as &[_]) } + | ----------------------------^^^^^^^^^^------------------- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + +warning: the where-clause bound `[for<'r> fn(&'r ())]: Sized` is impossible to satisfy + --> $DIR/issue-67696-const-prop-ice.rs:13:33 + | +LL | fn foo(&self) -> Self where Self: Copy { *(&[] as &[_]) } + | ----------------------------^^^^^^^^^^------------------- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + +warning: 3 warnings emitted + diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs b/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs index 3dbaf5dea250e..2045c87a30249 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.rs @@ -63,6 +63,7 @@ fn return_str() -> str where str: Sized { //~ ERROR // This is currently accepted because the function pointer isn't // considered global. fn global_hr(x: fn(&())) where fn(&()): Foo { // OK + //~^ WARNING the where-clause bound x.test(); } diff --git a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr index 1b87ebd9f20ce..4914b05260ef1 100644 --- a/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr +++ b/src/test/ui/feature-gates/feature-gate-trivial_bounds.stderr @@ -113,6 +113,18 @@ LL | fn return_str() -> str where str: Sized { = help: see issue #48214 = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable -error: aborting due to 11 previous errors +warning: the where-clause bound `for<'r> fn(&'r ()): Foo` is impossible to satisfy + --> $DIR/feature-gate-trivial_bounds.rs:65:32 + | +LL | fn global_hr(x: fn(&())) where fn(&()): Foo { // OK + | _- ^^^^^^^^^^^^ +LL | | +LL | | x.test(); +LL | | } + | |_- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + +error: aborting due to 11 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.rs b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.rs index fffb54f86ca03..6b3a02215d95d 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.rs +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.rs @@ -7,6 +7,7 @@ impl BufferUdpStateContext for C {} trait StackContext where Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, + //~^ WARNING the where-clause bound { type Dispatcher; } @@ -26,6 +27,7 @@ where struct EthernetWorker(C) where Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>; + //~^ WARNING the where-clause bound impl EthernetWorker {} //~^ ERROR: is not satisfied [E0277] diff --git a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr index a6858154dfb29..c609a20fcb37a 100644 --- a/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr +++ b/src/test/ui/higher-rank-trait-bounds/normalize-under-binder/issue-89118.stderr @@ -1,5 +1,20 @@ +warning: the where-clause bound `for<'a> Ctx<()>: BufferUdpStateContext<&'a ()>` is impossible to satisfy + --> $DIR/issue-89118.rs:9:5 + | +LL | / trait StackContext +LL | | where +LL | | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, + | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | | +LL | | { +LL | | type Dispatcher; +LL | | } + | |_- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied - --> $DIR/issue-89118.rs:19:8 + --> $DIR/issue-89118.rs:20:8 | LL | C: StackContext, | ^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` @@ -18,8 +33,18 @@ LL | where LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StackContext` +warning: the where-clause bound `for<'a> Ctx<()>: BufferUdpStateContext<&'a ()>` is impossible to satisfy + --> $DIR/issue-89118.rs:29:5 + | +LL | / struct EthernetWorker(C) +LL | | where +LL | | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>; + | |_____^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied - --> $DIR/issue-89118.rs:29:9 + --> $DIR/issue-89118.rs:31:9 | LL | impl EthernetWorker {} | ^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` @@ -30,7 +55,7 @@ note: required because of the requirements on the impl of `for<'a> BufferUdpStat LL | impl BufferUdpStateContext for C {} | ^^^^^^^^^^^^^^^^^^^^^^^^ ^ note: required by a bound in `EthernetWorker` - --> $DIR/issue-89118.rs:28:14 + --> $DIR/issue-89118.rs:29:14 | LL | struct EthernetWorker(C) | -------------- required by a bound in this @@ -39,7 +64,7 @@ LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EthernetWorker` error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied - --> $DIR/issue-89118.rs:22:20 + --> $DIR/issue-89118.rs:23:20 | LL | type Handler = Ctx; | ^^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` @@ -58,6 +83,6 @@ LL | where LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StackContext` -error: aborting due to 3 previous errors +error: aborting due to 3 previous errors; 2 warnings emitted For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/issues/issue-36839.rs b/src/test/ui/issues/issue-36839.rs index ca3d66b1c8eb7..01654461afea2 100644 --- a/src/test/ui/issues/issue-36839.rs +++ b/src/test/ui/issues/issue-36839.rs @@ -12,6 +12,7 @@ pub trait Broken { impl Broken for T { type Assoc = (); fn broken(&self) where Self::Assoc: Foo { + //~^ WARNING the where-clause bound let _x: ::Bar; } } diff --git a/src/test/ui/issues/issue-36839.stderr b/src/test/ui/issues/issue-36839.stderr new file mode 100644 index 0000000000000..8dd876a690e90 --- /dev/null +++ b/src/test/ui/issues/issue-36839.stderr @@ -0,0 +1,14 @@ +warning: the where-clause bound `::Assoc: Foo` is impossible to satisfy + --> $DIR/issue-36839.rs:14:28 + | +LL | fn broken(&self) where Self::Assoc: Foo { + | _____- ^^^^^^^^^^^^^^^^ +LL | | +LL | | let _x: ::Bar; +LL | | } + | |_____- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + +warning: 1 warning emitted + diff --git a/src/test/ui/issues/issue-39970.rs b/src/test/ui/issues/issue-39970.rs index f51e3b522e1c5..b3205eeac78c9 100644 --- a/src/test/ui/issues/issue-39970.rs +++ b/src/test/ui/issues/issue-39970.rs @@ -13,6 +13,7 @@ impl<'a> Array<'a> for () { impl Visit for () where //(): for<'a> Array<'a, Element=&'a ()>, // No ICE (): for<'a> Array<'a, Element=()>, // ICE + //~^ WARNING the where-clause bound {} fn main() { diff --git a/src/test/ui/issues/issue-39970.stderr b/src/test/ui/issues/issue-39970.stderr index 1f64a90bc1cf9..514a1b1df86aa 100644 --- a/src/test/ui/issues/issue-39970.stderr +++ b/src/test/ui/issues/issue-39970.stderr @@ -1,5 +1,18 @@ +warning: the where-clause bound `for<'a> <() as Array<'a>>::Element == ()` is impossible to satisfy + --> $DIR/issue-39970.rs:15:5 + | +LL | / impl Visit for () where +LL | | //(): for<'a> Array<'a, Element=&'a ()>, // No ICE +LL | | (): for<'a> Array<'a, Element=()>, // ICE + | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | | +LL | | {} + | |__- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + error[E0271]: type mismatch resolving `for<'a> <() as Array<'a>>::Element == ()` - --> $DIR/issue-39970.rs:19:5 + --> $DIR/issue-39970.rs:20:5 | LL | <() as Visit>::visit(); | ^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `for<'a> <() as Array<'a>>::Element == ()` @@ -15,6 +28,6 @@ note: required because of the requirements on the impl of `Visit` for `()` LL | impl Visit for () where | ^^^^^ ^^ -error: aborting due to previous error +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/issues/issue-42796.rs b/src/test/ui/issues/issue-42796.rs index 5e83a1cd67785..d9b723876e5ef 100644 --- a/src/test/ui/issues/issue-42796.rs +++ b/src/test/ui/issues/issue-42796.rs @@ -7,6 +7,7 @@ impl Mirror for T { } pub fn poison(victim: String) where >::Image: Copy { + //~^ WARNING the where-clause bound loop { drop(victim); } } diff --git a/src/test/ui/issues/issue-42796.stderr b/src/test/ui/issues/issue-42796.stderr index f3e0e7b20a178..2e3ea6bf929ad 100644 --- a/src/test/ui/issues/issue-42796.stderr +++ b/src/test/ui/issues/issue-42796.stderr @@ -1,5 +1,17 @@ +warning: the where-clause bound `>::Image: Copy` is impossible to satisfy + --> $DIR/issue-42796.rs:9:40 + | +LL | pub fn poison(victim: String) where >::Image: Copy { + | _- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | | +LL | | loop { drop(victim); } +LL | | } + | |_- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + error[E0382]: borrow of moved value: `s` - --> $DIR/issue-42796.rs:18:20 + --> $DIR/issue-42796.rs:19:20 | LL | let s = "Hello!".to_owned(); | - move occurs because `s` has type `String`, which does not implement the `Copy` trait @@ -11,6 +23,6 @@ LL | println!("{}", s); | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error: aborting due to previous error; 1 warning emitted For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/issues/issue-50714-1.rs b/src/test/ui/issues/issue-50714-1.rs index a25940ce1cbef..0b1c9f46f248b 100644 --- a/src/test/ui/issues/issue-50714-1.rs +++ b/src/test/ui/issues/issue-50714-1.rs @@ -6,6 +6,7 @@ extern crate std; #[start] -fn start(_: isize, _: *const *const u8) -> isize where fn(&()): Eq { //~ ERROR [E0647] +fn start(_: isize, _: *const *const u8) -> isize where fn(&()): Eq { + //~^ ERROR start function is not allowed to have a `where` clause 0 } diff --git a/src/test/ui/issues/issue-50714.rs b/src/test/ui/issues/issue-50714.rs index c571a470cee1c..32da3748fed9c 100644 --- a/src/test/ui/issues/issue-50714.rs +++ b/src/test/ui/issues/issue-50714.rs @@ -1,3 +1,8 @@ // Regression test for issue 50714, make sure that this isn't a linker error. -fn main() where fn(&()): Eq {} //~ ERROR [E0646] +fn main() +where +//~^ ERROR `main` function is not allowed to have a `where` clause + fn(&()): Eq, +{ +} diff --git a/src/test/ui/issues/issue-50714.stderr b/src/test/ui/issues/issue-50714.stderr index a11aceb6211c5..d02cb51523a8f 100644 --- a/src/test/ui/issues/issue-50714.stderr +++ b/src/test/ui/issues/issue-50714.stderr @@ -1,8 +1,10 @@ error[E0646]: `main` function is not allowed to have a `where` clause - --> $DIR/issue-50714.rs:3:11 + --> $DIR/issue-50714.rs:4:1 | -LL | fn main() where fn(&()): Eq {} - | ^^^^^^^^^^^^^^^^^ `main` cannot have a `where` clause +LL | / where +LL | | +LL | | fn(&()): Eq, + | |________________^ `main` cannot have a `where` clause error: aborting due to previous error diff --git a/src/test/ui/mir/issue-91745.rs b/src/test/ui/mir/issue-91745.rs index ca3d66b1c8eb7..01654461afea2 100644 --- a/src/test/ui/mir/issue-91745.rs +++ b/src/test/ui/mir/issue-91745.rs @@ -12,6 +12,7 @@ pub trait Broken { impl Broken for T { type Assoc = (); fn broken(&self) where Self::Assoc: Foo { + //~^ WARNING the where-clause bound let _x: ::Bar; } } diff --git a/src/test/ui/mir/issue-91745.stderr b/src/test/ui/mir/issue-91745.stderr new file mode 100644 index 0000000000000..ae38f01dc3c80 --- /dev/null +++ b/src/test/ui/mir/issue-91745.stderr @@ -0,0 +1,14 @@ +warning: the where-clause bound `::Assoc: Foo` is impossible to satisfy + --> $DIR/issue-91745.rs:14:28 + | +LL | fn broken(&self) where Self::Assoc: Foo { + | _____- ^^^^^^^^^^^^^^^^ +LL | | +LL | | let _x: ::Bar; +LL | | } + | |_____- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + +warning: 1 warning emitted + diff --git a/src/test/ui/trait-bounds/issue-94680.rs b/src/test/ui/trait-bounds/issue-94680.rs index 58e892079e65f..fc8463bcf9214 100644 --- a/src/test/ui/trait-bounds/issue-94680.rs +++ b/src/test/ui/trait-bounds/issue-94680.rs @@ -7,6 +7,7 @@ fn main() { pub fn cloneit(it: &'_ mut T) -> (&'_ mut T, &'_ mut T) where for<'any> &'any mut T: Clone, + //~^ WARNING the where-clause bound { (it.clone(), it) } diff --git a/src/test/ui/trait-bounds/issue-94680.stderr b/src/test/ui/trait-bounds/issue-94680.stderr new file mode 100644 index 0000000000000..73e14dd9dce7a --- /dev/null +++ b/src/test/ui/trait-bounds/issue-94680.stderr @@ -0,0 +1,17 @@ +warning: the where-clause bound `for<'any> &'any mut (): Clone` is impossible to satisfy + --> $DIR/issue-94680.rs:9:13 + | +LL | / pub fn cloneit(it: &'_ mut T) -> (&'_ mut T, &'_ mut T) +LL | | where +LL | | for<'any> &'any mut T: Clone, + | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | | +LL | | { +LL | | (it.clone(), it) +LL | | } + | |_________- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + +warning: 1 warning emitted + diff --git a/src/test/ui/trait-bounds/issue-94999.rs b/src/test/ui/trait-bounds/issue-94999.rs index e131902346f1b..b2116874072b4 100644 --- a/src/test/ui/trait-bounds/issue-94999.rs +++ b/src/test/ui/trait-bounds/issue-94999.rs @@ -24,6 +24,7 @@ impl Holds for X { impl Clone for X where >::T: Clone, + //~^ WARNING the where-clause bound X: Holds, { fn clone(&self) -> Self { diff --git a/src/test/ui/trait-bounds/issue-94999.stderr b/src/test/ui/trait-bounds/issue-94999.stderr new file mode 100644 index 0000000000000..91863e754b44a --- /dev/null +++ b/src/test/ui/trait-bounds/issue-94999.stderr @@ -0,0 +1,17 @@ +warning: the where-clause bound `>::T: Clone` is impossible to satisfy + --> $DIR/issue-94999.rs:26:5 + | +LL | / impl Clone for X +LL | | where +LL | | >::T: Clone, + | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | | +... | +LL | | } +LL | | } + | |_- this item cannot be referenced without causing an error + | + = help: add `#![feature(trivial_bounds)]` to the crate attributes to allow it + +warning: 1 warning emitted +