Skip to content

Commit 9aac24d

Browse files
authored
Rollup merge of #138173 - compiler-errors:incoherent-negative-impl, r=oli-obk
Delay bug for negative auto trait rather than ICEing Fixes #138149 r? oli-obk
2 parents b160477 + bbc80a8 commit 9aac24d

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

compiler/rustc_hir_analysis/src/check/always_applicable.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ pub(crate) fn check_negative_auto_trait_impl<'tcx>(
124124
// be implemented here to handle non-ADT rigid types.
125125
Ok(())
126126
} else {
127-
span_bug!(tcx.def_span(impl_def_id), "incoherent impl of negative auto trait");
127+
Err(tcx.dcx().span_delayed_bug(
128+
tcx.def_span(impl_def_id),
129+
"incoherent impl of negative auto trait",
130+
))
128131
}
129132
}
130133
}

tests/ui/auto-traits/ungated-impl.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
auto trait MyTrait {}
2+
//~^ ERROR auto traits are experimental and possibly buggy
3+
4+
impl<T> !MyTrait for *mut T {}
5+
//~^ ERROR negative trait bounds are not fully implemented
6+
7+
fn main() {}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0658]: auto traits are experimental and possibly buggy
2+
--> $DIR/ungated-impl.rs:1:1
3+
|
4+
LL | auto trait MyTrait {}
5+
| ^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
8+
= help: add `#![feature(auto_traits)]` to the crate attributes to enable
9+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
10+
11+
error[E0658]: negative trait bounds are not fully implemented; use marker types for now
12+
--> $DIR/ungated-impl.rs:4:9
13+
|
14+
LL | impl<T> !MyTrait for *mut T {}
15+
| ^^^^^^^^
16+
|
17+
= note: see issue #68318 <https://github.com/rust-lang/rust/issues/68318> for more information
18+
= help: add `#![feature(negative_impls)]` to the crate attributes to enable
19+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
20+
21+
error: aborting due to 2 previous errors
22+
23+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)