Skip to content

Commit b893193

Browse files
Mark GAT WC as GoalSource::AliasWellFormed so that we recurse into them in error reporting
1 parent 454df5c commit b893193

File tree

4 files changed

+9
-25
lines changed

4 files changed

+9
-25
lines changed

compiler/rustc_next_trait_solver/src/solve/normalizes_to/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ where
134134
// Add GAT where clauses from the trait's definition
135135
// FIXME: We don't need these, since these are the type's own WF obligations.
136136
ecx.add_goals(
137-
GoalSource::Misc,
137+
GoalSource::AliasWellFormed,
138138
cx.own_predicates_of(goal.predicate.def_id())
139139
.iter_instantiated(cx, goal.predicate.alias.args)
140140
.map(|pred| goal.with(cx, pred)),
@@ -199,7 +199,7 @@ where
199199
// Add GAT where clauses from the trait's definition.
200200
// FIXME: We don't need these, since these are the type's own WF obligations.
201201
ecx.add_goals(
202-
GoalSource::Misc,
202+
GoalSource::AliasWellFormed,
203203
cx.own_predicates_of(goal.predicate.def_id())
204204
.iter_instantiated(cx, goal.predicate.alias.args)
205205
.map(|pred| goal.with(cx, pred)),

compiler/rustc_type_ir/src/solve/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,11 @@ pub enum GoalSource {
8383
/// Instantiating a higher-ranked goal and re-proving it.
8484
InstantiateHigherRanked,
8585
/// Predicate required for an alias projection to be well-formed.
86-
/// This is used in two places: projecting to an opaque whose hidden type
87-
/// is already registered in the opaque type storage, and for rigid projections.
86+
/// This is used in three places:
87+
/// 1. projecting to an opaque whose hidden type is already registered in
88+
/// the opaque type storage,
89+
/// 2. for rigid projections's trait goal,
90+
/// 3. for GAT where clauses.
8891
AliasWellFormed,
8992
/// In case normalizing aliases in nested goals cycles, eagerly normalizing these
9093
/// aliases in the context of the parent may incorrectly change the cycle kind.

tests/ui/traits/trivial-unsized-projection.bad_new.stderr

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
error[E0271]: type mismatch resolving `<[()] as Bad>::Assert normalizes-to <[()] as Bad>::Assert`
2-
--> $DIR/trivial-unsized-projection.rs:20:12
3-
|
4-
LL | const FOO: <[()] as Bad>::Assert = todo!();
5-
| ^^^^^^^^^^^^^^^^^^^^^ types differ
6-
|
7-
= note: statics and constants must have a statically known size
8-
91
error[E0277]: the size for values of type `[()]` cannot be known at compilation time
102
--> $DIR/trivial-unsized-projection.rs:20:12
113
|
@@ -47,15 +39,6 @@ help: consider relaxing the implicit `Sized` restriction
4739
LL | type Assert: ?Sized
4840
| ++++++++
4941

50-
error[E0271]: type mismatch resolving `<[()] as Bad>::Assert normalizes-to <[()] as Bad>::Assert`
51-
--> $DIR/trivial-unsized-projection.rs:20:36
52-
|
53-
LL | const FOO: <[()] as Bad>::Assert = todo!();
54-
| ^^^^^^^ types differ
55-
|
56-
= note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)
57-
58-
error: aborting due to 4 previous errors
42+
error: aborting due to 2 previous errors
5943

60-
Some errors have detailed explanations: E0271, E0277.
61-
For more information about an error, try `rustc --explain E0271`.
44+
For more information about this error, try `rustc --explain E0277`.

tests/ui/traits/trivial-unsized-projection.rs

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ const FOO: <[()] as Bad>::Assert = todo!();
2222
//[bad]~| ERROR the size for values of type `[()]` cannot be known at compilation time
2323
//[bad_new]~^^^ ERROR the size for values of type `[()]` cannot be known at compilation time
2424
//[bad_new]~| ERROR the size for values of type `[()]` cannot be known at compilation time
25-
//[bad_new]~| ERROR type mismatch resolving `<[()] as Bad>::Assert normalizes-to <[()] as Bad>::Assert`
26-
//[bad_new]~| ERROR type mismatch resolving `<[()] as Bad>::Assert normalizes-to <[()] as Bad>::Assert`
2725

2826
#[cfg(any(good, good_new))]
2927
// Well-formed in trivially false param-env

0 commit comments

Comments
 (0)