diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 5553490542b75..ee67b62155384 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -463,7 +463,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { let obligations = self.nominal_obligations(data.def_id, data.args); self.out.extend(obligations); - self.compute_projection_args(data.args); + data.args.visit_with(self); } /// Pushes the obligations required for an inherent alias to be WF @@ -493,33 +493,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> { self.out.extend(obligations); } - self.compute_projection_args(data.args); - } - - fn compute_projection_args(&mut self, args: GenericArgsRef<'tcx>) { - let tcx = self.tcx(); - let cause = self.cause(traits::WellFormed(None)); - let param_env = self.param_env; - let depth = self.recursion_depth; - - self.out.extend( - args.iter() - .filter(|arg| { - matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..)) - }) - .filter(|arg| !arg.has_escaping_bound_vars()) - .map(|arg| { - traits::Obligation::with_depth( - tcx, - cause.clone(), - depth, - param_env, - ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed( - arg, - ))), - ) - }), - ); + data.args.visit_with(self); } fn require_sized(&mut self, subty: Ty<'tcx>, cause: traits::ObligationCauseCode<'tcx>) { diff --git a/tests/ui/inference/issue-80409.compat.stderr b/tests/ui/inference/issue-80409.compat.stderr new file mode 100644 index 0000000000000..fbc41f951d2fb --- /dev/null +++ b/tests/ui/inference/issue-80409.compat.stderr @@ -0,0 +1,19 @@ +error[E0277]: the trait bound `TFsm: Fsm` is not satisfied + --> $DIR/issue-80409.rs:25:26 + | +LL | fn on_entry)>(&self, _action: TAction) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Fsm` is not implemented for `TFsm` + | +note: required by a bound in `StateContext` + --> $DIR/issue-80409.rs:33:31 + | +LL | struct StateContext<'a, TFsm: Fsm> { + | ^^^ required by this bound in `StateContext` +help: consider restricting type parameter `TFsm` + | +LL | impl FsmStateBuilder { + | +++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/inference/issue-80409.no-compat.stderr b/tests/ui/inference/issue-80409.no-compat.stderr index c772225be7549..fbc41f951d2fb 100644 --- a/tests/ui/inference/issue-80409.no-compat.stderr +++ b/tests/ui/inference/issue-80409.no-compat.stderr @@ -1,14 +1,19 @@ -error: internal compiler error: error performing operation: fully_perform - --> $DIR/issue-80409.rs:49:30 +error[E0277]: the trait bound `TFsm: Fsm` is not satisfied + --> $DIR/issue-80409.rs:25:26 | -LL | builder.state().on_entry(|_| {}); - | ^^^ +LL | fn on_entry)>(&self, _action: TAction) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Fsm` is not implemented for `TFsm` | -note: - --> $DIR/issue-80409.rs:49:30 +note: required by a bound in `StateContext` + --> $DIR/issue-80409.rs:33:31 | -LL | builder.state().on_entry(|_| {}); - | ^^^ +LL | struct StateContext<'a, TFsm: Fsm> { + | ^^^ required by this bound in `StateContext` +help: consider restricting type parameter `TFsm` + | +LL | impl FsmStateBuilder { + | +++++ + +error: aborting due to 1 previous error -query stack during panic: -end of query stack +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/inference/issue-80409.rs b/tests/ui/inference/issue-80409.rs index dfb84563e6d80..dbada82ca7763 100644 --- a/tests/ui/inference/issue-80409.rs +++ b/tests/ui/inference/issue-80409.rs @@ -1,18 +1,7 @@ // This should not pass, because `usize: Fsm` does not hold. However, it currently ICEs. -// ignore-tidy-linelength - //@ revisions: compat no-compat -//@[compat] check-pass //@[no-compat] compile-flags: -Zno-implied-bounds-compat -//@[no-compat] check-fail -//@[no-compat] known-bug: #80409 -//@[no-compat] failure-status: 101 -//@[no-compat] normalize-stderr-test "delayed at.*" -> "" -//@[no-compat] normalize-stderr-test "note: .*\n\n" -> "" -//@[no-compat] normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" -//@[no-compat] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " -//@[no-compat] rustc-env:RUST_BACKTRACE=0 #![allow(unreachable_code, unused)] @@ -34,6 +23,7 @@ struct FsmStateBuilder { impl FsmStateBuilder { fn on_entry)>(&self, _action: TAction) {} + //~^ ERROR the trait bound `TFsm: Fsm` is not satisfied } trait Fsm {