Skip to content

Commit ecd7809

Browse files
Don't ICE in new solver when auto traits have associated types
1 parent a9baa16 commit ecd7809

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

compiler/rustc_trait_selection/src/solve/project_goals.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,14 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
193193
}
194194

195195
fn consider_auto_trait_candidate(
196-
_ecx: &mut EvalCtxt<'_, 'tcx>,
196+
ecx: &mut EvalCtxt<'_, 'tcx>,
197197
goal: Goal<'tcx, Self>,
198198
) -> QueryResult<'tcx> {
199-
bug!("auto traits do not have associated types: {:?}", goal);
199+
ecx.tcx().sess.delay_span_bug(
200+
ecx.tcx().def_span(goal.predicate.def_id()),
201+
"associated types not allowed on auto traits",
202+
);
203+
Err(NoSolution)
200204
}
201205

202206
fn consider_trait_alias_candidate(

tests/ui/auto-traits/issue-23080-2.stderr tests/ui/auto-traits/issue-23080-2.current.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0380]: auto traits cannot have associated items
2-
--> $DIR/issue-23080-2.rs:5:10
2+
--> $DIR/issue-23080-2.rs:8:10
33
|
44
LL | unsafe auto trait Trait {
55
| ----- auto traits cannot have associated items
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0380]: auto traits cannot have associated items
2+
--> $DIR/issue-23080-2.rs:8:10
3+
|
4+
LL | unsafe auto trait Trait {
5+
| ----- auto traits cannot have associated items
6+
LL | type Output;
7+
| -----^^^^^^- help: remove these associated items
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0380`.

tests/ui/auto-traits/issue-23080-2.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// revisions: current next
2+
//[next] compile-flags: -Ztrait-solver=next
3+
14
#![feature(auto_traits)]
25
#![feature(negative_impls)]
36

0 commit comments

Comments
 (0)