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
This commit is contained in:
Jacob Pratt 2025-03-07 21:57:53 -05:00 committed by GitHub
commit 9aac24d68a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 1 deletions

View file

@ -124,7 +124,10 @@ pub(crate) fn check_negative_auto_trait_impl<'tcx>(
// be implemented here to handle non-ADT rigid types.
Ok(())
} else {
span_bug!(tcx.def_span(impl_def_id), "incoherent impl of negative auto trait");
Err(tcx.dcx().span_delayed_bug(
tcx.def_span(impl_def_id),
"incoherent impl of negative auto trait",
))
}
}
}

View file

@ -0,0 +1,7 @@
auto trait MyTrait {}
//~^ ERROR auto traits are experimental and possibly buggy
impl<T> !MyTrait for *mut T {}
//~^ ERROR negative trait bounds are not fully implemented
fn main() {}

View file

@ -0,0 +1,23 @@
error[E0658]: auto traits are experimental and possibly buggy
--> $DIR/ungated-impl.rs:1:1
|
LL | auto trait MyTrait {}
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #13231 <https://github.com/rust-lang/rust/issues/13231> for more information
= help: add `#![feature(auto_traits)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: negative trait bounds are not fully implemented; use marker types for now
--> $DIR/ungated-impl.rs:4:9
|
LL | impl<T> !MyTrait for *mut T {}
| ^^^^^^^^
|
= note: see issue #68318 <https://github.com/rust-lang/rust/issues/68318> for more information
= help: add `#![feature(negative_impls)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.