Skip to content

Commit 62b6529

Browse files
committed
Turn assert_eq into a delay_span_bug
1 parent 6f308b8 commit 62b6529

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

compiler/rustc_hir_analysis/src/coherence/orphan.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,13 @@ fn lint_auto_trait_impl<'tcx>(
452452
trait_ref: ty::TraitRef<'tcx>,
453453
impl_def_id: LocalDefId,
454454
) {
455-
assert_eq!(trait_ref.args.len(), 1);
455+
if trait_ref.args.len() != 1 {
456+
tcx.sess.diagnostic().delay_span_bug(
457+
tcx.def_span(impl_def_id),
458+
"auto traits cannot have generic parameters",
459+
);
460+
return;
461+
}
456462
let self_ty = trait_ref.self_ty();
457463
let (self_type_did, args) = match self_ty.kind() {
458464
ty::Adt(def, args) => (def.did(), args),

tests/ui/auto-traits/issue-117789.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![deny(suspicious_auto_trait_impls)]
2+
3+
auto trait Trait<P> {} //~ ERROR auto traits cannot have generic parameters
4+
//~^ ERROR auto traits are experimental and possibly buggy
5+
impl<P> Trait<P> for () {}
6+
7+
fn main() {}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0567]: auto traits cannot have generic parameters
2+
--> $DIR/issue-117789.rs:3:17
3+
|
4+
LL | auto trait Trait<P> {}
5+
| -----^^^ help: remove the parameters
6+
| |
7+
| auto trait cannot have generic parameters
8+
9+
error[E0658]: auto traits are experimental and possibly buggy
10+
--> $DIR/issue-117789.rs:3:1
11+
|
12+
LL | auto trait Trait<P> {}
13+
| ^^^^^^^^^^^^^^^^^^^^^^
14+
|
15+
= note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
16+
= help: add `#![feature(auto_traits)]` to the crate attributes to enable
17+
18+
error: aborting due to 2 previous errors
19+
20+
Some errors have detailed explanations: E0567, E0658.
21+
For more information about an error, try `rustc --explain E0567`.

0 commit comments

Comments
 (0)