diff options
| author | bors <bors@rust-lang.org> | 2022-08-17 14:49:05 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-08-17 14:49:05 +0000 |
| commit | 9c20b2a8cc7588decb6de25ac6a7912dcef24d65 (patch) | |
| tree | 099d3858d3f4e681d153efb1761fb8951b08afa5 /compiler/rustc_interface/src | |
| parent | 86c6ebee8fa0a5ad1e18e375113b06bd2849b634 (diff) | |
| parent | 1199dbdcf5f651060c1cf1ab089c3feafcd54100 (diff) | |
| download | rust-9c20b2a8cc7588decb6de25ac6a7912dcef24d65.tar.gz rust-9c20b2a8cc7588decb6de25ac6a7912dcef24d65.zip | |
Auto merge of #100677 - matthiaskrgr:rollup-au41ho1, r=matthiaskrgr
Rollup of 15 pull requests
Successful merges:
- #99474 (Rustdoc json tests: New `@hasexact` test command)
- #99972 (interpret: only consider 1-ZST when searching for receiver)
- #100018 (Clean up `LitKind`)
- #100379 (triagebot: add translation-related mention groups)
- #100389 (Do not report cycle error when inferring return type for suggestion)
- #100489 (`is_knowable` use `Result` instead of `Option`)
- #100532 (unwind: don't build dependency when building for Miri)
- #100608 (needless separation of impl blocks)
- #100621 (Pass +atomics-32 feature for {arm,thumb}v4t-none-eabi)
- #100646 (Migrate emoji identifier diagnostics to `SessionDiagnostic` in rustc_interface)
- #100652 (Remove deferred sized checks (make them eager))
- #100655 (Update books)
- #100656 (Update cargo)
- #100660 (Fixed a few documentation errors)
- #100661 (Fixed a few documentation errors)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_interface/src')
| -rw-r--r-- | compiler/rustc_interface/src/passes.rs | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 8f083591786..e00d0b7d0d8 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -8,11 +8,12 @@ use rustc_borrowck as mir_borrowck; use rustc_codegen_ssa::traits::CodegenBackend; use rustc_data_structures::parallel; use rustc_data_structures::sync::{Lrc, OnceCell, WorkerLocal}; -use rustc_errors::{Applicability, ErrorGuaranteed, MultiSpan, PResult}; +use rustc_errors::{ErrorGuaranteed, PResult}; use rustc_expand::base::{ExtCtxt, LintStoreExpand, ResolverExpand}; use rustc_hir::def_id::StableCrateId; use rustc_hir::definitions::Definitions; use rustc_lint::{BufferedEarlyLint, EarlyCheckNode, LintStore}; +use rustc_macros::SessionDiagnostic; use rustc_metadata::creader::CStore; use rustc_middle::arena::Arena; use rustc_middle::dep_graph::DepGraph; @@ -30,7 +31,7 @@ use rustc_session::output::filename_for_input; use rustc_session::search_paths::PathKind; use rustc_session::{Limit, Session}; use rustc_span::symbol::{sym, Symbol}; -use rustc_span::FileName; +use rustc_span::{FileName, Span}; use rustc_trait_selection::traits; use rustc_typeck as typeck; use tracing::{info, warn}; @@ -263,6 +264,23 @@ impl LintStoreExpand for LintStoreExpandImpl<'_> { } } +#[derive(SessionDiagnostic)] +#[error(interface::ferris_identifier)] +struct FerrisIdentifier { + #[primary_span] + spans: Vec<Span>, + #[suggestion(code = "ferris", applicability = "maybe-incorrect")] + first_span: Span, +} + +#[derive(SessionDiagnostic)] +#[error(interface::emoji_identifier)] +struct EmojiIdentifier { + #[primary_span] + spans: Vec<Span>, + ident: Symbol, +} + /// Runs the "early phases" of the compiler: initial `cfg` processing, loading compiler plugins, /// syntax expansion, secondary `cfg` expansion, synthesis of a test /// harness if one is to be provided, injection of a dependency on the @@ -443,23 +461,9 @@ pub fn configure_and_expand( spans.sort(); if ident == sym::ferris { let first_span = spans[0]; - sess.diagnostic() - .struct_span_err( - MultiSpan::from(spans), - "Ferris cannot be used as an identifier", - ) - .span_suggestion( - first_span, - "try using their name instead", - "ferris", - Applicability::MaybeIncorrect, - ) - .emit(); + sess.emit_err(FerrisIdentifier { spans, first_span }); } else { - sess.diagnostic().span_err( - MultiSpan::from(spans), - &format!("identifiers cannot contain emoji: `{}`", ident), - ); + sess.emit_err(EmojiIdentifier { spans, ident }); } } }); |
