Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay bug for negative auto trait rather than ICEing #138173

Merged
merged 1 commit into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion compiler/rustc_hir_analysis/src/check/always_applicable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
))
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/auto-traits/ungated-impl.rs
Original file line number Diff line number Diff line change
@@ -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() {}
23 changes: 23 additions & 0 deletions tests/ui/auto-traits/ungated-impl.stderr
Original file line number Diff line number Diff line change
@@ -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`.
Loading