Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5946bac

Browse files
committedApr 10, 2024
Auto merge of #123737 - compiler-errors:alias-wf, r=<try>
Check alias args for WF even if they have escaping bound vars r? `@ghost`
2 parents c2239bc + 6143a2c commit 5946bac

File tree

4 files changed

+37
-49
lines changed

4 files changed

+37
-49
lines changed
 

‎compiler/rustc_trait_selection/src/traits/wf.rs

+2-28
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
463463
let obligations = self.nominal_obligations(data.def_id, data.args);
464464
self.out.extend(obligations);
465465

466-
self.compute_projection_args(data.args);
466+
data.args.visit_with(self);
467467
}
468468

469469
/// Pushes the obligations required for an inherent alias to be WF
@@ -493,33 +493,7 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
493493
self.out.extend(obligations);
494494
}
495495

496-
self.compute_projection_args(data.args);
497-
}
498-
499-
fn compute_projection_args(&mut self, args: GenericArgsRef<'tcx>) {
500-
let tcx = self.tcx();
501-
let cause = self.cause(traits::WellFormed(None));
502-
let param_env = self.param_env;
503-
let depth = self.recursion_depth;
504-
505-
self.out.extend(
506-
args.iter()
507-
.filter(|arg| {
508-
matches!(arg.unpack(), GenericArgKind::Type(..) | GenericArgKind::Const(..))
509-
})
510-
.filter(|arg| !arg.has_escaping_bound_vars())
511-
.map(|arg| {
512-
traits::Obligation::with_depth(
513-
tcx,
514-
cause.clone(),
515-
depth,
516-
param_env,
517-
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::WellFormed(
518-
arg,
519-
))),
520-
)
521-
}),
522-
);
496+
data.args.visit_with(self);
523497
}
524498

525499
fn require_sized(&mut self, subty: Ty<'tcx>, cause: traits::ObligationCauseCode<'tcx>) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0277]: the trait bound `TFsm: Fsm` is not satisfied
2+
--> $DIR/issue-80409.rs:25:26
3+
|
4+
LL | fn on_entry<TAction: Fn(&mut StateContext<'_, TFsm>)>(&self, _action: TAction) {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Fsm` is not implemented for `TFsm`
6+
|
7+
note: required by a bound in `StateContext`
8+
--> $DIR/issue-80409.rs:33:31
9+
|
10+
LL | struct StateContext<'a, TFsm: Fsm> {
11+
| ^^^ required by this bound in `StateContext`
12+
help: consider restricting type parameter `TFsm`
13+
|
14+
LL | impl<TFsm: Fsm> FsmStateBuilder<TFsm> {
15+
| +++++
16+
17+
error: aborting due to 1 previous error
18+
19+
For more information about this error, try `rustc --explain E0277`.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
error: internal compiler error: error performing operation: fully_perform
2-
--> $DIR/issue-80409.rs:49:30
1+
error[E0277]: the trait bound `TFsm: Fsm` is not satisfied
2+
--> $DIR/issue-80409.rs:25:26
33
|
4-
LL | builder.state().on_entry(|_| {});
5-
| ^^^
4+
LL | fn on_entry<TAction: Fn(&mut StateContext<'_, TFsm>)>(&self, _action: TAction) {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Fsm` is not implemented for `TFsm`
66
|
7-
note:
8-
--> $DIR/issue-80409.rs:49:30
7+
note: required by a bound in `StateContext`
8+
--> $DIR/issue-80409.rs:33:31
99
|
10-
LL | builder.state().on_entry(|_| {});
11-
| ^^^
10+
LL | struct StateContext<'a, TFsm: Fsm> {
11+
| ^^^ required by this bound in `StateContext`
12+
help: consider restricting type parameter `TFsm`
13+
|
14+
LL | impl<TFsm: Fsm> FsmStateBuilder<TFsm> {
15+
| +++++
16+
17+
error: aborting due to 1 previous error
1218

13-
query stack during panic:
14-
end of query stack
19+
For more information about this error, try `rustc --explain E0277`.

‎tests/ui/inference/issue-80409.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
// This should not pass, because `usize: Fsm` does not hold. However, it currently ICEs.
22

3-
// ignore-tidy-linelength
4-
53
//@ revisions: compat no-compat
6-
//@[compat] check-pass
74
//@[no-compat] compile-flags: -Zno-implied-bounds-compat
8-
//@[no-compat] check-fail
9-
//@[no-compat] known-bug: #80409
10-
//@[no-compat] failure-status: 101
11-
//@[no-compat] normalize-stderr-test "delayed at.*" -> ""
12-
//@[no-compat] normalize-stderr-test "note: .*\n\n" -> ""
13-
//@[no-compat] normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
14-
//@[no-compat] normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "
15-
//@[no-compat] rustc-env:RUST_BACKTRACE=0
165

176
#![allow(unreachable_code, unused)]
187

@@ -34,6 +23,7 @@ struct FsmStateBuilder<TFsm> {
3423

3524
impl<TFsm> FsmStateBuilder<TFsm> {
3625
fn on_entry<TAction: Fn(&mut StateContext<'_, TFsm>)>(&self, _action: TAction) {}
26+
//~^ ERROR the trait bound `TFsm: Fsm` is not satisfied
3727
}
3828

3929
trait Fsm {

0 commit comments

Comments
 (0)
Failed to load comments.