diff options
| author | Cameron Steffen <cam.steffen94@gmail.com> | 2025-07-30 16:13:22 -0500 |
|---|---|---|
| committer | Cameron Steffen <cam.steffen94@gmail.com> | 2025-08-11 16:58:20 -0500 |
| commit | 39c5d6d1cac012095771902d4782908ae0df4789 (patch) | |
| tree | 63fa061d183253c299ac2c7e96b9be1daf1b51ed /compiler/rustc_ast_passes | |
| parent | 6355cd39c81e9699b1925c58d2ed3165bcab1715 (diff) | |
| download | rust-39c5d6d1cac012095771902d4782908ae0df4789.tar.gz rust-39c5d6d1cac012095771902d4782908ae0df4789.zip | |
Factor out InherentImplCannotUnsafe
Diffstat (limited to 'compiler/rustc_ast_passes')
| -rw-r--r-- | compiler/rustc_ast_passes/src/ast_validation.rs | 18 | ||||
| -rw-r--r-- | compiler/rustc_ast_passes/src/errors.rs | 12 |
2 files changed, 11 insertions, 19 deletions
diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 9d3b0969ef3..355721b66f9 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -26,7 +26,7 @@ use rustc_ast::visit::{AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor, walk_list} use rustc_ast::*; use rustc_ast_pretty::pprust::{self, State}; use rustc_data_structures::fx::FxIndexMap; -use rustc_errors::DiagCtxtHandle; +use rustc_errors::{DiagCtxtHandle, E0197}; use rustc_feature::Features; use rustc_parse::validate_attr; use rustc_session::Session; @@ -1016,12 +1016,16 @@ impl<'a> Visitor<'a> for AstValidator<'a> { errors::VisibilityNotPermittedNote::IndividualImplItems, ); if let &Safety::Unsafe(span) = safety { - self.dcx().emit_err(errors::InherentImplCannotUnsafe { - span: self_ty.span, - annotation_span: span, - annotation: "unsafe", - self_ty: self_ty.span, - }); + self.dcx() + .create_err(errors::InherentImplCannot { + span: self_ty.span, + annotation_span: span, + annotation: "unsafe", + self_ty: self_ty.span, + only_trait: true, + }) + .with_code(E0197) + .emit(); } if let &ImplPolarity::Negative(span) = polarity { self.dcx().emit_err(error(span, "negative", false)); diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs index 60f47490f12..4448945cd6d 100644 --- a/compiler/rustc_ast_passes/src/errors.rs +++ b/compiler/rustc_ast_passes/src/errors.rs @@ -479,18 +479,6 @@ pub(crate) struct InherentImplCannot<'a> { } #[derive(Diagnostic)] -#[diag(ast_passes_inherent_cannot_be, code = E0197)] -pub(crate) struct InherentImplCannotUnsafe<'a> { - #[primary_span] - pub span: Span, - #[label(ast_passes_because)] - pub annotation_span: Span, - pub annotation: &'a str, - #[label(ast_passes_type)] - pub self_ty: Span, -} - -#[derive(Diagnostic)] #[diag(ast_passes_unsafe_item)] pub(crate) struct UnsafeItem { #[primary_span] |
