Skip to content

Commit 14e1628

Browse files
committed
Auto merge of rust-lang#3336 - RalfJung:rustup, r=RalfJung
Rustup Also add regression test for rust-lang#121508.
2 parents 5717e52 + 2a376ce commit 14e1628

File tree

119 files changed

+2319
-1250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+2319
-1250
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1640,9 +1640,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
16401640

16411641
[[package]]
16421642
name = "hermit-abi"
1643-
version = "0.3.6"
1643+
version = "0.3.9"
16441644
source = "registry+https://github.com/rust-lang/crates.io-index"
1645-
checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd"
1645+
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
16461646
dependencies = [
16471647
"compiler_builtins",
16481648
"rustc-std-workspace-alloc",

compiler/rustc_builtin_macros/src/errors.rs

-21
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,6 @@ pub(crate) struct BenchSig {
136136
pub(crate) span: Span,
137137
}
138138

139-
#[derive(Diagnostic)]
140-
#[diag(builtin_macros_test_arg_non_lifetime)]
141-
pub(crate) struct TestArgNonLifetime {
142-
#[primary_span]
143-
pub(crate) span: Span,
144-
}
145-
146-
#[derive(Diagnostic)]
147-
#[diag(builtin_macros_should_panic)]
148-
pub(crate) struct ShouldPanic {
149-
#[primary_span]
150-
pub(crate) span: Span,
151-
}
152-
153-
#[derive(Diagnostic)]
154-
#[diag(builtin_macros_test_args)]
155-
pub(crate) struct TestArgs {
156-
#[primary_span]
157-
pub(crate) span: Span,
158-
}
159-
160139
#[derive(Diagnostic)]
161140
#[diag(builtin_macros_alloc_must_statics)]
162141
pub(crate) struct AllocMustStatics {

compiler/rustc_errors/src/diagnostic.rs

+22-5
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,25 @@ impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
108108

109109
/// Trait implemented by error types. This is rarely implemented manually. Instead, use
110110
/// `#[derive(Diagnostic)]` -- see [rustc_macros::Diagnostic].
111+
///
112+
/// When implemented manually, it should be generic over the emission
113+
/// guarantee, i.e.:
114+
/// ```ignore (fragment)
115+
/// impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for Foo { ... }
116+
/// ```
117+
/// rather than being specific:
118+
/// ```ignore (fragment)
119+
/// impl<'a> IntoDiagnostic<'a> for Bar { ... } // the default type param is `ErrorGuaranteed`
120+
/// impl<'a> IntoDiagnostic<'a, ()> for Baz { ... }
121+
/// ```
122+
/// There are two reasons for this.
123+
/// - A diagnostic like `Foo` *could* be emitted at any level -- `level` is
124+
/// passed in to `into_diagnostic` from outside. Even if in practice it is
125+
/// always emitted at a single level, we let the diagnostic creation/emission
126+
/// site determine the level (by using `create_err`, `emit_warn`, etc.)
127+
/// rather than the `IntoDiagnostic` impl.
128+
/// - Derived impls are always generic, and it's good for the hand-written
129+
/// impls to be consistent with them.
111130
#[rustc_diagnostic_item = "IntoDiagnostic"]
112131
pub trait IntoDiagnostic<'a, G: EmissionGuarantee = ErrorGuaranteed> {
113132
/// Write out as a diagnostic out of `DiagCtxt`.
@@ -1289,11 +1308,9 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
12891308
drop(self);
12901309
}
12911310

1292-
/// Stashes diagnostic for possible later improvement in a different,
1293-
/// later stage of the compiler. The diagnostic can be accessed with
1294-
/// the provided `span` and `key` through [`DiagCtxt::steal_diagnostic()`].
1295-
pub fn stash(mut self, span: Span, key: StashKey) {
1296-
self.dcx.stash_diagnostic(span, key, self.take_diag());
1311+
/// See `DiagCtxt::stash_diagnostic` for details.
1312+
pub fn stash(mut self, span: Span, key: StashKey) -> Option<ErrorGuaranteed> {
1313+
self.dcx.stash_diagnostic(span, key, self.take_diag())
12971314
}
12981315

12991316
/// Delay emission of this diagnostic as a bug.

0 commit comments

Comments
 (0)