about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2023-06-02 16:02:07 -0700
committerGitHub <noreply@github.com>2023-06-02 16:02:07 -0700
commit18763cb464e911a840ee5bd45093cd3fbadaf52d (patch)
tree9e318c68a45ffbb209396b34288b23bfb9cceddb
parent163ce686bedd1f8ca86a6066d26ed480e65c5e2e (diff)
parentecd7809784ddb1e96c9f292347d73d074106e4e9 (diff)
downloadrust-18763cb464e911a840ee5bd45093cd3fbadaf52d.tar.gz
rust-18763cb464e911a840ee5bd45093cd3fbadaf52d.zip
Rollup merge of #112223 - compiler-errors:new-solver-auto-proj, r=BoxyUwU
Don't ICE in new solver when auto traits have associated types

People can write malformed auto traits, and that shouldn't cause the new solver to ICE
-rw-r--r--compiler/rustc_trait_selection/src/solve/project_goals.rs8
-rw-r--r--tests/ui/auto-traits/issue-23080-2.current.stderr (renamed from tests/ui/auto-traits/issue-23080-2.stderr)2
-rw-r--r--tests/ui/auto-traits/issue-23080-2.next.stderr11
-rw-r--r--tests/ui/auto-traits/issue-23080-2.rs3
4 files changed, 21 insertions, 3 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/project_goals.rs b/compiler/rustc_trait_selection/src/solve/project_goals.rs
index 23601f668ff..242f9ba8747 100644
--- a/compiler/rustc_trait_selection/src/solve/project_goals.rs
+++ b/compiler/rustc_trait_selection/src/solve/project_goals.rs
@@ -226,10 +226,14 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
     }
 
     fn consider_auto_trait_candidate(
-        _ecx: &mut EvalCtxt<'_, 'tcx>,
+        ecx: &mut EvalCtxt<'_, 'tcx>,
         goal: Goal<'tcx, Self>,
     ) -> QueryResult<'tcx> {
-        bug!("auto traits do not have associated types: {:?}", goal);
+        ecx.tcx().sess.delay_span_bug(
+            ecx.tcx().def_span(goal.predicate.def_id()),
+            "associated types not allowed on auto traits",
+        );
+        Err(NoSolution)
     }
 
     fn consider_trait_alias_candidate(
diff --git a/tests/ui/auto-traits/issue-23080-2.stderr b/tests/ui/auto-traits/issue-23080-2.current.stderr
index fed485612da..a57c6d9b0cb 100644
--- a/tests/ui/auto-traits/issue-23080-2.stderr
+++ b/tests/ui/auto-traits/issue-23080-2.current.stderr
@@ -1,5 +1,5 @@
 error[E0380]: auto traits cannot have associated items
-  --> $DIR/issue-23080-2.rs:5:10
+  --> $DIR/issue-23080-2.rs:8:10
    |
 LL | unsafe auto trait Trait {
    |                   ----- auto traits cannot have associated items
diff --git a/tests/ui/auto-traits/issue-23080-2.next.stderr b/tests/ui/auto-traits/issue-23080-2.next.stderr
new file mode 100644
index 00000000000..a57c6d9b0cb
--- /dev/null
+++ b/tests/ui/auto-traits/issue-23080-2.next.stderr
@@ -0,0 +1,11 @@
+error[E0380]: auto traits cannot have associated items
+  --> $DIR/issue-23080-2.rs:8:10
+   |
+LL | unsafe auto trait Trait {
+   |                   ----- auto traits cannot have associated items
+LL |     type Output;
+   |     -----^^^^^^- help: remove these associated items
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0380`.
diff --git a/tests/ui/auto-traits/issue-23080-2.rs b/tests/ui/auto-traits/issue-23080-2.rs
index cb4cf6de1ef..882b8f39384 100644
--- a/tests/ui/auto-traits/issue-23080-2.rs
+++ b/tests/ui/auto-traits/issue-23080-2.rs
@@ -1,3 +1,6 @@
+// revisions: current next
+//[next] compile-flags: -Ztrait-solver=next
+
 #![feature(auto_traits)]
 #![feature(negative_impls)]