From 97f3b66d636d2788b3cdb929a266693de3a455a6 Mon Sep 17 00:00:00 2001 From: Yukang Date: Fri, 28 Aug 2026 09:01:12 +0800 Subject: [PATCH 01/21] Add regression test for parenthesized raw borrow suggestions --- ...a-references-parenthesized-issue-161693.rs | 22 +++++++++++++ ...ferences-parenthesized-issue-161693.stderr | 31 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.rs create mode 100644 tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.stderr diff --git a/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.rs b/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.rs new file mode 100644 index 0000000000000..d395c0929c34d --- /dev/null +++ b/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.rs @@ -0,0 +1,22 @@ +//@ check-pass + +// Parenthesized reference-to-pointer casts should produce syntactically valid suggestions. + +#![feature(const_volatile)] +#![warn(raw_borrows_via_references)] + +const READ: () = unsafe { + let x = 42i32; + let y = (&x as *const i32).read_volatile(); + //~^ WARN creating an intermediate reference implies aliasing requirements + assert!(x == y); +}; + +const WRITE: () = unsafe { + let mut x = 42i32; + (&mut x as *mut i32).write_volatile(13); + //~^ WARN creating an intermediate reference implies aliasing requirements + assert!(x == 13); +}; + +fn main() {} diff --git a/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.stderr b/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.stderr new file mode 100644 index 0000000000000..75081f5991215 --- /dev/null +++ b/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.stderr @@ -0,0 +1,31 @@ +warning: creating an intermediate reference implies aliasing requirements even when immediately cast to a raw pointers + --> $DIR/raw-borrows-via-references-parenthesized-issue-161693.rs:10:13 + | +LL | let y = (&x as *const i32).read_volatile(); + | ^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/raw-borrows-via-references-parenthesized-issue-161693.rs:6:9 + | +LL | #![warn(raw_borrows_via_references)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: consider using `&raw const` for a safer and more explicit raw pointer + | +LL - let y = (&x as *const i32).read_volatile(); +LL + let y = &raw const x).read_volatile(); + | + +warning: creating an intermediate reference implies aliasing requirements even when immediately cast to a raw pointers + --> $DIR/raw-borrows-via-references-parenthesized-issue-161693.rs:17:5 + | +LL | (&mut x as *mut i32).write_volatile(13); + | ^^^^^^^^^^^^^^^^^^^^ + | +help: consider using `&raw mut` for a safer and more explicit raw pointer + | +LL - (&mut x as *mut i32).write_volatile(13); +LL + &raw mut x).write_volatile(13); + | + +warning: 2 warnings emitted + From ec711b914b16718c5c6bd14cec12cd469d88c1c1 Mon Sep 17 00:00:00 2001 From: Yukang Date: Fri, 28 Aug 2026 09:17:09 +0800 Subject: [PATCH 02/21] Preserve parentheses in raw borrow suggestions --- .../src/raw_borrows_via_references.rs | 9 ++--- ...eferences-parenthesized-issue-161693.fixed | 35 +++++++++++++++++++ ...a-references-parenthesized-issue-161693.rs | 17 +++++++-- ...ferences-parenthesized-issue-161693.stderr | 18 ++++++++-- 4 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.fixed diff --git a/compiler/rustc_lint/src/raw_borrows_via_references.rs b/compiler/rustc_lint/src/raw_borrows_via_references.rs index 2d17d6c301c3d..4db8f2a243678 100644 --- a/compiler/rustc_lint/src/raw_borrows_via_references.rs +++ b/compiler/rustc_lint/src/raw_borrows_via_references.rs @@ -57,15 +57,16 @@ impl<'tcx> LateLintPass<'tcx> for RawBorrowsViaReferences { && let TyKind::Ptr(_) = ty.kind && addr_of_exp.is_syntactic_place_expr() { - let suggestion = if let Some(addr_of_span) = - addr_of_exp.span.find_ancestor_in_same_ctxt(expr.span) + let suggestion = if let Some(borrow_span) = + exp.span.find_ancestor_inside_same_ctxt(expr.span) + && let Some(addr_of_span) = addr_of_exp.span.find_ancestor_in_same_ctxt(expr.span) && let Some(ty_span) = ty.span.find_ancestor_in_same_ctxt(expr.span) - && expr.span.can_be_used_for_suggestions() + && borrow_span.can_be_used_for_suggestions() && addr_of_span.can_be_used_for_suggestions() && ty_span.can_be_used_for_suggestions() { RawBorrowViaReferenceSuggestion::Spanful { - left: expr.span.until(addr_of_span), + left: borrow_span.until(addr_of_span), right: addr_of_span.shrink_to_hi().until(ty_span.shrink_to_hi()), mutbl: mutbl.ptr_str(), } diff --git a/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.fixed b/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.fixed new file mode 100644 index 0000000000000..2f5bc99add2d1 --- /dev/null +++ b/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.fixed @@ -0,0 +1,35 @@ +//@ check-pass +//@ run-rustfix + +#![feature(const_volatile)] +#![allow(dead_code, unused_macros)] +#![warn(raw_borrows_via_references)] + +const READ: () = unsafe { + let x = 42i32; + let y = (&raw const x).read_volatile(); + //~^ WARN creating an intermediate reference implies aliasing requirements + assert!(x == y); +}; + +const WRITE: () = unsafe { + let mut x = 42i32; + (&raw mut x).write_volatile(13); + //~^ WARN creating an intermediate reference implies aliasing requirements + assert!(x == 13); +}; + +macro_rules! make_borrow { + ($value:expr) => { + &$value + }; +} + +fn macro_generated_borrow() { + let value = 0; + // the scenario of macro should also get valid fix suggestion + let _ = &raw const value; + //~^ WARN creating an intermediate reference implies aliasing requirements +} + +fn main() {} diff --git a/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.rs b/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.rs index d395c0929c34d..b19fafdeca28c 100644 --- a/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.rs +++ b/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.rs @@ -1,8 +1,8 @@ //@ check-pass - -// Parenthesized reference-to-pointer casts should produce syntactically valid suggestions. +//@ run-rustfix #![feature(const_volatile)] +#![allow(dead_code, unused_macros)] #![warn(raw_borrows_via_references)] const READ: () = unsafe { @@ -19,4 +19,17 @@ const WRITE: () = unsafe { assert!(x == 13); }; +macro_rules! make_borrow { + ($value:expr) => { + &$value + }; +} + +fn macro_generated_borrow() { + let value = 0; + // the scenario of macro should also get valid fix suggestion + let _ = make_borrow!(value) as *const i32; + //~^ WARN creating an intermediate reference implies aliasing requirements +} + fn main() {} diff --git a/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.stderr b/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.stderr index 75081f5991215..0c43a891d1d86 100644 --- a/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.stderr +++ b/tests/ui/lint/raw-borrows-via-references-parenthesized-issue-161693.stderr @@ -12,7 +12,7 @@ LL | #![warn(raw_borrows_via_references)] help: consider using `&raw const` for a safer and more explicit raw pointer | LL - let y = (&x as *const i32).read_volatile(); -LL + let y = &raw const x).read_volatile(); +LL + let y = (&raw const x).read_volatile(); | warning: creating an intermediate reference implies aliasing requirements even when immediately cast to a raw pointers @@ -24,8 +24,20 @@ LL | (&mut x as *mut i32).write_volatile(13); help: consider using `&raw mut` for a safer and more explicit raw pointer | LL - (&mut x as *mut i32).write_volatile(13); -LL + &raw mut x).write_volatile(13); +LL + (&raw mut x).write_volatile(13); | -warning: 2 warnings emitted +warning: creating an intermediate reference implies aliasing requirements even when immediately cast to a raw pointers + --> $DIR/raw-borrows-via-references-parenthesized-issue-161693.rs:31:13 + | +LL | let _ = make_borrow!(value) as *const i32; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: consider using `&raw const` for a safer and more explicit raw pointer + | +LL - let _ = make_borrow!(value) as *const i32; +LL + let _ = &raw const value; + | + +warning: 3 warnings emitted From a757a1355310f18667039f79862d1411a497e18c Mon Sep 17 00:00:00 2001 From: kulinsky Date: Tue, 15 Sep 2026 23:48:57 +0500 Subject: [PATCH 03/21] Avoid suggesting closures when captures cross associated item boundaries --- .../rustc_resolve/src/diagnostics/impls.rs | 7 +++-- compiler/rustc_resolve/src/diagnostics/mod.rs | 3 +- compiler/rustc_resolve/src/ident.rs | 8 +++++- compiler/rustc_resolve/src/lib.rs | 2 +- .../ui/resolve/closure-suggestion-in-impl.rs | 28 +++++++++++++++++++ .../resolve/closure-suggestion-in-impl.stderr | 23 +++++++++++++++ .../impl-method-cant-capture-env.stderr | 2 -- ...mpl-trait-for-type-cant-capture-env.stderr | 2 -- .../trait-impl-cant-capture-env.stderr | 4 --- 9 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 tests/ui/resolve/closure-suggestion-in-impl.rs create mode 100644 tests/ui/resolve/closure-suggestion-in-impl.stderr diff --git a/compiler/rustc_resolve/src/diagnostics/impls.rs b/compiler/rustc_resolve/src/diagnostics/impls.rs index 3fc2f55bbaec6..116d95c59d100 100644 --- a/compiler/rustc_resolve/src/diagnostics/impls.rs +++ b/compiler/rustc_resolve/src/diagnostics/impls.rs @@ -1180,8 +1180,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { err } - ResolutionError::CannotCaptureDynamicEnvironmentInFnItem => { - self.dcx().create_err(diagnostics::CannotCaptureDynamicEnvironmentInFnItem { span }) + ResolutionError::CannotCaptureDynamicEnvironmentInFnItem { suggest_closure } => { + self.dcx().create_err(diagnostics::CannotCaptureDynamicEnvironmentInFnItem { + span, + suggest_closure, + }) } ResolutionError::AttemptToUseNonConstantValueInConstant { ident, diff --git a/compiler/rustc_resolve/src/diagnostics/mod.rs b/compiler/rustc_resolve/src/diagnostics/mod.rs index b581777901195..755f0769419d2 100644 --- a/compiler/rustc_resolve/src/diagnostics/mod.rs +++ b/compiler/rustc_resolve/src/diagnostics/mod.rs @@ -268,10 +268,11 @@ pub(crate) struct UnreachableLabelWithSimilarNameExists { #[derive(Diagnostic)] #[diag("can't capture dynamic environment in a fn item", code = E0434)] -#[help("use the `|| {\"{\"} ... {\"}\"}` closure form instead")] pub(crate) struct CannotCaptureDynamicEnvironmentInFnItem { #[primary_span] pub(crate) span: Span, + #[help("use the `|| {\"{\"} ... {\"}\"}` closure form instead")] + pub(crate) suggest_closure: bool, } #[derive(Diagnostic)] diff --git a/compiler/rustc_resolve/src/ident.rs b/compiler/rustc_resolve/src/ident.rs index 85457bbba5da7..0d801696ca389 100644 --- a/compiler/rustc_resolve/src/ident.rs +++ b/compiler/rustc_resolve/src/ident.rs @@ -1506,6 +1506,9 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { use ResolutionError::*; let mut res_err = None; + let suggest_closure = + !ribs.iter().any(|rib| matches!(rib.kind, RibKind::AssocItem)); + for rib in ribs { match rib.kind { RibKind::Normal @@ -1525,7 +1528,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // we want certain other resolution errors (namely those // emitted for `ConstantItemRibKind` below) to take // precedence. - res_err = Some((span, CannotCaptureDynamicEnvironmentInFnItem)); + res_err = Some(( + span, + CannotCaptureDynamicEnvironmentInFnItem { suggest_closure }, + )); } } RibKind::ConstantItem(_, item, requires_type) => { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index ce03e1a70399c..055e4f56d2710 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -275,7 +275,7 @@ enum ResolutionError<'ra> { message: String, }, /// Error E0434: can't capture dynamic environment in a fn item. - CannotCaptureDynamicEnvironmentInFnItem, + CannotCaptureDynamicEnvironmentInFnItem { suggest_closure: bool }, /// Error E0435: attempt to use a non-constant value in a constant. AttemptToUseNonConstantValueInConstant { ident: Ident, diff --git a/tests/ui/resolve/closure-suggestion-in-impl.rs b/tests/ui/resolve/closure-suggestion-in-impl.rs new file mode 100644 index 0000000000000..ab05e67f9538e --- /dev/null +++ b/tests/ui/resolve/closure-suggestion-in-impl.rs @@ -0,0 +1,28 @@ +trait T { + fn t() -> impl FnOnce() -> (); +} + +fn f(x: String) { + struct S; + impl T for S { + fn t() -> impl FnOnce() -> () { + move || { + let _ = x; //~ ERROR can't capture dynamic environment in a fn item + } + } + } + + impl S { + fn foo() { + let bar = 42; + + fn inner() { + let _ = bar; //~ ERROR can't capture dynamic environment in a fn item + + let _ = x; //~ ERROR can't capture dynamic environment in a fn item + } + } + } +} + +fn main() {} diff --git a/tests/ui/resolve/closure-suggestion-in-impl.stderr b/tests/ui/resolve/closure-suggestion-in-impl.stderr new file mode 100644 index 0000000000000..6382df9c61b55 --- /dev/null +++ b/tests/ui/resolve/closure-suggestion-in-impl.stderr @@ -0,0 +1,23 @@ +error[E0434]: can't capture dynamic environment in a fn item + --> $DIR/closure-suggestion-in-impl.rs:10:25 + | +LL | let _ = x; + | ^ + +error[E0434]: can't capture dynamic environment in a fn item + --> $DIR/closure-suggestion-in-impl.rs:20:25 + | +LL | let _ = bar; + | ^^^ + | + = help: use the `|| { ... }` closure form instead + +error[E0434]: can't capture dynamic environment in a fn item + --> $DIR/closure-suggestion-in-impl.rs:22:25 + | +LL | let _ = x; + | ^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0434`. diff --git a/tests/ui/resolve/impl-method-cant-capture-env.stderr b/tests/ui/resolve/impl-method-cant-capture-env.stderr index 360598dee5827..4a525db70ae2c 100644 --- a/tests/ui/resolve/impl-method-cant-capture-env.stderr +++ b/tests/ui/resolve/impl-method-cant-capture-env.stderr @@ -3,8 +3,6 @@ error[E0434]: can't capture dynamic environment in a fn item | LL | self.v0 = k0 ^ 0x736f6d6570736575; | ^^ - | - = help: use the `|| { ... }` closure form instead error: aborting due to 1 previous error diff --git a/tests/ui/resolve/impl-trait-for-type-cant-capture-env.stderr b/tests/ui/resolve/impl-trait-for-type-cant-capture-env.stderr index 2c25f6b1b8954..4a7c5263ff8df 100644 --- a/tests/ui/resolve/impl-trait-for-type-cant-capture-env.stderr +++ b/tests/ui/resolve/impl-trait-for-type-cant-capture-env.stderr @@ -3,8 +3,6 @@ error[E0434]: can't capture dynamic environment in a fn item | LL | self.v0 = k0 ^ 0x736f6d6570736575; | ^^ - | - = help: use the `|| { ... }` closure form instead error: aborting due to 1 previous error diff --git a/tests/ui/resolve/trait-impl-cant-capture-env.stderr b/tests/ui/resolve/trait-impl-cant-capture-env.stderr index 3c80960a235cb..257e30ea0d85b 100644 --- a/tests/ui/resolve/trait-impl-cant-capture-env.stderr +++ b/tests/ui/resolve/trait-impl-cant-capture-env.stderr @@ -3,16 +3,12 @@ error[E0434]: can't capture dynamic environment in a fn item | LL | self.v0 = k0 ^ 0x736f6d6570736575; | ^^ - | - = help: use the `|| { ... }` closure form instead error[E0434]: can't capture dynamic environment in a fn item --> $DIR/trait-impl-cant-capture-env.rs:25:23 | LL | self.v1 = k1 ^ 0x646f72616e646f6d; | ^^ - | - = help: use the `|| { ... }` closure form instead error: aborting due to 2 previous errors From f330047c2b4d36fb62320277be57f9d2d01fc30b Mon Sep 17 00:00:00 2001 From: cezarbbb Date: Fri, 7 Aug 2026 17:01:51 +0800 Subject: [PATCH 04/21] Add COFF support to -Zstaticlib-rename-internal-symbols --- compiler/rustc_codegen_ssa/src/back/link.rs | 42 ++-- .../rustc_codegen_ssa/src/back/symbol_edit.rs | 156 +++++++++++++- compiler/rustc_codegen_ssa/src/diagnostics.rs | 2 +- .../rmake.rs | 200 ++++++++++++++++++ 4 files changed, 383 insertions(+), 17 deletions(-) create mode 100644 tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index c283e464821e5..221998abf6128 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -834,24 +834,33 @@ fn link_staticlib( let hide = sess.opts.unstable_opts.staticlib_hide_internal_symbols; let rename = sess.opts.unstable_opts.staticlib_rename_internal_symbols; + let hide_supported = + matches!(sess.target.binary_format, BinaryFormat::Elf | BinaryFormat::MachO); + // Rename only rewrites symbol names, so it also works on COFF; hide + // needs a visibility concept COFF lacks. + let rename_supported = matches!( + sess.target.binary_format, + BinaryFormat::Elf | BinaryFormat::MachO | BinaryFormat::Coff + ); + let exported_symbols = if hide || rename { - if !matches!(sess.target.binary_format, BinaryFormat::Elf | BinaryFormat::MachO) { - if hide { - sess.dcx().emit_warn(diagnostics::StaticlibHideInternalSymbolsUnsupported { - binary_format: sess.target.archive_format.to_string(), - }); - } - if rename { - sess.dcx().emit_warn(diagnostics::StaticlibRenameInternalSymbolsUnsupported { - binary_format: sess.target.archive_format.to_string(), - }); - } - None - } else { + if hide && !hide_supported { + sess.dcx().emit_warn(diagnostics::StaticlibHideInternalSymbolsUnsupported { + binary_format: sess.target.archive_format.to_string(), + }); + } + if rename && !rename_supported { + sess.dcx().emit_warn(diagnostics::StaticlibRenameInternalSymbolsUnsupported { + binary_format: sess.target.archive_format.to_string(), + }); + } + if (hide && hide_supported) || (rename && rename_supported) { crate_info .exported_symbols .get(&CrateType::StaticLib) .map(|symbols| symbols.iter().map(|symbol| symbol.name.clone()).collect()) + } else { + None } } else { None @@ -859,8 +868,11 @@ fn link_staticlib( let symbols = exported_symbols.map(|exported| ArchiveSymbols { exported, - rename_suffix: rename.then(|| crate_info.symbol_rename_suffix.clone()), - hide, + rename_suffix: (rename && rename_supported) + .then(|| crate_info.symbol_rename_suffix.clone()), + // A warning was already emitted above if hiding was requested for an + // unsupported format; don't also ask the backend to hide there. + hide: hide && hide_supported, }); ab.build(out_filename, symbols); diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs b/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs index ef8008216187a..490c634a1845a 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs @@ -7,9 +7,10 @@ use std::borrow::Cow; use std::mem; +use object::read::coff::{CoffHeader, ImageSymbol as _}; use object::read::elf::{SectionHeader as _, Sym as _}; use object::read::macho::Nlist; -use object::{Endianness, elf, macho}; +use object::{Endianness, elf, macho, pe}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; struct Patch { @@ -57,6 +58,20 @@ pub(super) fn apply_edits<'a>( rename, mem::offset_of!(macho::Nlist32, n_type), ), + Some(object::File::Coff(f)) => coff_edit_impl( + data, + f.coff_header(), + hide, + rename, + coff_strip_underscore(f.coff_header()), + ), + Some(object::File::CoffBig(f)) => coff_edit_impl( + data, + f.coff_header(), + hide, + rename, + coff_strip_underscore(f.coff_header()), + ), _ => None, }; match result { @@ -84,10 +99,30 @@ pub(super) fn collect_internal_names( object::File::MachO32(_) => { macho_collect_impl::>(data, exported, out) } + object::File::Coff(f) => coff_collect_impl( + data, + f.coff_header(), + exported, + out, + coff_strip_underscore(f.coff_header()), + ), + object::File::CoffBig(f) => coff_collect_impl( + data, + f.coff_header(), + exported, + out, + coff_strip_underscore(f.coff_header()), + ), _ => {} } } +/// Whether this machine's COFF ABI decorates external symbols with a leading `_` +/// (i686 only). +fn coff_strip_underscore(header: &impl CoffHeader) -> bool { + header.machine() == pe::IMAGE_FILE_MACHINE_I386 +} + fn elf_collect_impl>( data: &[u8], exported: &FxHashSet, @@ -441,6 +476,125 @@ fn macho_rebuild_strtab( Some(result) } +// --------------------------------------------------------------------------- +// COFF: single-pass collection + apply +// --------------------------------------------------------------------------- + +fn coff_collect_impl<'data, Coff: CoffHeader>( + data: &'data [u8], + header: &'data Coff, + exported: &FxHashSet, + out: &mut FxHashSet, + strip_underscore: bool, +) { + let Ok(symbols) = header.symbols(data) else { return }; + let strings = symbols.strings(); + + for (_index, sym) in symbols.iter() { + let sclass = sym.storage_class(); + if sclass != pe::IMAGE_SYM_CLASS_EXTERNAL && sclass != pe::IMAGE_SYM_CLASS_WEAK_EXTERNAL { + continue; + } + if sym.section_number() <= 0 { + continue; + } + let Ok(name_bytes) = sym.name(strings) else { continue }; + let Ok(mut name) = str::from_utf8(name_bytes).map(String::from) else { continue }; + if strip_underscore { + name = name.strip_prefix('_').unwrap_or(&name).to_string(); + } + if !exported.contains(&name) { + out.insert(name); + } + } +} + +fn coff_edit_impl<'data, Coff: CoffHeader>( + data: &'data [u8], + header: &'data Coff, + hide: bool, + rename: Option<&(FxHashSet, &str)>, + strip_underscore: bool, +) -> Option> { + // COFF has no visibility concept, so hiding is unsupported; the caller + // has already warned and does not request it. + assert!(!hide); + + let pointer_to_symbol_table = header.pointer_to_symbol_table() as usize; + let number_of_symbols = header.number_of_symbols() as usize; + // ImageSymbol is 18 bytes; ImageSymbolEx (bigobj) is 20. + let sym_size = mem::size_of::(); + + let symbol_bytes_offset = pointer_to_symbol_table; + let strtab_base = pointer_to_symbol_table + number_of_symbols * sym_size; + if strtab_base > data.len() { + return None; + } + + if data.len() < strtab_base + 4 { + return None; + } + let old_len = + u32::from_le_bytes(data[strtab_base..strtab_base + 4].try_into().unwrap()) as usize; + if strtab_base + old_len > data.len() { + return None; + } + + let Ok(symbols) = header.symbols(data) else { return None }; + let strings = symbols.strings(); + + let mut renames = Vec::new(); + for (index, sym) in symbols.iter() { + let sclass = sym.storage_class(); + if sclass != pe::IMAGE_SYM_CLASS_EXTERNAL && sclass != pe::IMAGE_SYM_CLASS_WEAK_EXTERNAL { + continue; + } + let Ok(name_bytes) = sym.name(strings) else { continue }; + let Ok(name) = str::from_utf8(name_bytes) else { continue }; + let check_name = + if strip_underscore { name.strip_prefix('_').unwrap_or(name) } else { name }; + if rename.is_some_and(|(rename_set, _)| rename_set.contains(check_name)) { + renames.push(RenameEntry { + name_field_offset: symbol_bytes_offset + index.0 * sym_size, + name: name.to_string(), + }); + } + } + if renames.is_empty() { + return None; + } + let suffix = rename.unwrap().1; + + let mut new_strtab = Vec::new(); + let mut map: FxHashMap = FxHashMap::default(); + let mut sorted_names: Vec<&str> = renames.iter().map(|r| r.name.as_str()).collect(); + sorted_names.sort(); + sorted_names.dedup(); + for name in &sorted_names { + let rel_offset = (old_len + new_strtab.len()) as u32; + new_strtab.extend_from_slice(name.as_bytes()); + new_strtab.extend_from_slice(suffix.as_bytes()); + new_strtab.push(0); + map.insert(name.to_string(), rel_offset); + } + + let mut result = data.to_vec(); + let new_len = (old_len + new_strtab.len()) as u32; + result[strtab_base..strtab_base + 4].copy_from_slice(&new_len.to_le_bytes()); + result.extend_from_slice(&new_strtab); + + // Long names are stored as all-zero name[0..4] plus the string table + // offset in name[4..8]. + for r in &renames { + let rel = map[&r.name]; + let field = &mut result[r.name_field_offset..r.name_field_offset + 8]; + field[..4].fill(0); + field[4..].copy_from_slice(&rel.to_le_bytes()); + } + + Some(result) +} + // --------------------------------------------------------------------------- // Shared helpers // --------------------------------------------------------------------------- diff --git a/compiler/rustc_codegen_ssa/src/diagnostics.rs b/compiler/rustc_codegen_ssa/src/diagnostics.rs index 8aa2da904bd07..0e03a592165e7 100644 --- a/compiler/rustc_codegen_ssa/src/diagnostics.rs +++ b/compiler/rustc_codegen_ssa/src/diagnostics.rs @@ -695,7 +695,7 @@ pub(crate) struct StaticlibHideInternalSymbolsUnsupported { #[derive(Diagnostic)] #[diag( - "-Zstaticlib-rename-internal-symbols only supports ELF and Mach-O targets, but the target uses `{$binary_format}`" + "-Zstaticlib-rename-internal-symbols only supports ELF, Mach-O, and COFF targets, but the target uses `{$binary_format}`" )] pub(crate) struct StaticlibRenameInternalSymbolsUnsupported { pub binary_format: String, diff --git a/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs b/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs new file mode 100644 index 0000000000000..38cf724ee7d1b --- /dev/null +++ b/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs @@ -0,0 +1,200 @@ +//@ only-windows +//@ ignore-cross-compile + +use std::collections::HashSet; + +use run_make_support::object::read::archive::ArchiveFile; +use run_make_support::object::read::coff::ImageSymbol as _; +use run_make_support::object::{File, pe}; +use run_make_support::path_helpers::source_root; +use run_make_support::{cc, extra_c_flags, rfs, run, rustc, static_lib_name}; + +const EXPORTED: &[&str] = &["my_add", "my_hash_lookup", "call_internal", "my_safe_div"]; + +fn main() { + let hide_sibling = source_root().join("tests/run-make/staticlib-hide-internal-symbols"); + let rename_sibling = source_root().join("tests/run-make/staticlib-rename-internal-symbols"); + rfs::copy(hide_sibling.join("lib.rs"), "lib.rs"); + rfs::copy(hide_sibling.join("main.c"), "main.c"); + rfs::copy(rename_sibling.join("liba.rs"), "liba.rs"); + rfs::copy(rename_sibling.join("libb.rs"), "libb.rs"); + rfs::copy(rename_sibling.join("dual_main.c"), "dual_main.c"); + + test_basic_functionality(); + test_rs_suffix_present(); + test_dual_staticlib_linking(); + test_hide_and_rename(); +} + +fn test_basic_functionality() { + let lib_name = static_lib_name("lib"); + + rustc() + .input("lib.rs") + .crate_type("staticlib") + .arg("-Zstaticlib-rename-internal-symbols") + .opt() + .run(); + + cc().input("main.c").input(&lib_name).out_exe("main").args(extra_c_flags()).run(); + run("main"); + + rfs::remove_file(&lib_name); +} + +fn test_rs_suffix_present() { + let lib_name = static_lib_name("lib"); + + rustc() + .input("lib.rs") + .crate_type("staticlib") + .arg("-Zstaticlib-rename-internal-symbols") + .opt() + .run(); + + let data = rfs::read(&lib_name); + check_rename_symbols(&data); + + rfs::remove_file(&lib_name); +} + +fn test_dual_staticlib_linking() { + let liba_name = static_lib_name("liba"); + let libb_name = static_lib_name("libb"); + + rustc() + .input("liba.rs") + .crate_type("staticlib") + .arg("-Zstaticlib-rename-internal-symbols") + .opt() + .run(); + + rustc() + .input("libb.rs") + .crate_type("staticlib") + .arg("-Zstaticlib-rename-internal-symbols") + .opt() + .run(); + + cc().input("dual_main.c") + .input(&liba_name) + .input(&libb_name) + .out_exe("dual_main") + .args(extra_c_flags()) + .run(); + run("dual_main"); +} + +/// On COFF, hiding is unsupported and must only produce a warning, while +/// renaming still applies. +fn test_hide_and_rename() { + let lib_name = static_lib_name("lib"); + + rustc() + .input("lib.rs") + .crate_type("staticlib") + .arg("-Zstaticlib-hide-internal-symbols") + .arg("-Zstaticlib-rename-internal-symbols") + .opt() + .run_unchecked() + .assert_stderr_contains( + "-Zstaticlib-hide-internal-symbols only supports ELF and Mach-O targets", + ) + .assert_exit_code(0); + + let data = rfs::read(&lib_name); + check_rename_symbols(&data); + + cc().input("main.c").input(&lib_name).out_exe("main").args(extra_c_flags()).run(); + run("main"); + + rfs::remove_file(&lib_name); +} + +fn check_rename_symbols(archive_data: &[u8]) { + let archive = ArchiveFile::parse(archive_data).unwrap(); + let mut found_exported = HashSet::new(); + let mut found_rs_suffix = false; + + for member in archive.members() { + let member = member.unwrap(); + if !member.name().ends_with(b".rcgu.o") { + continue; + } + // COFF header/symbol types have alignment 1, so odd-offset members + // parse directly from the borrowed slice. + let data = member.data(archive_data).unwrap(); + match File::parse(data) { + Ok(File::Coff(f)) => { + check_coff_symbols(f.coff_header(), data, &mut found_exported, &mut found_rs_suffix) + } + Ok(File::CoffBig(f)) => { + check_coff_symbols(f.coff_header(), data, &mut found_exported, &mut found_rs_suffix) + } + Ok(_) => panic!("unexpected object file format in archive member"), + Err(e) => panic!("failed to parse archive member: {e}"), + } + } + + assert!(found_rs_suffix, "expected to find at least one renamed symbol with .rs suffix"); + for expected in EXPORTED { + assert!( + found_exported.contains(*expected), + "expected to find exported symbol `{expected}` in archive" + ); + } +} + +fn check_coff_symbols( + header: &Coff, + data: &[u8], + found_exported: &mut HashSet, + found_rs_suffix: &mut bool, +) { + // ImageSymbol is 18 bytes; ImageSymbolEx (bigobj) is 20. + let sym_size = std::mem::size_of::(); + // i686 decorates symbol names with a leading underscore. + let strip_underscore = header.machine() == pe::IMAGE_FILE_MACHINE_I386; + let Ok(symbols) = header.symbols(data) else { return }; + let strings = symbols.strings(); + let symtab_base = header.pointer_to_symbol_table() as usize; + + for (index, symbol) in symbols.iter() { + let storage_class = symbol.storage_class(); + if storage_class != pe::IMAGE_SYM_CLASS_EXTERNAL + && storage_class != pe::IMAGE_SYM_CLASS_WEAK_EXTERNAL + { + continue; + } + if symbol.section_number() <= 0 { + continue; + } + // String-table references keep all four leading name bytes zero. + let name_field = symtab_base + index.0 * sym_size; + if data[name_field] == 0 { + assert!( + data[name_field + 1..name_field + 4] == [0, 0, 0], + "long-name symbol reference at offset {name_field} has non-zero padding bytes" + ); + } + let Ok(name_bytes) = symbol.name(strings) else { continue }; + let Ok(mut name) = str::from_utf8(name_bytes).map(String::from) else { continue }; + if strip_underscore { + name = name.strip_prefix('_').unwrap_or(&name).to_string(); + } + + if EXPORTED.contains(&name.as_str()) { + assert!( + !name.contains(".rs"), + "exported symbol `{name}` should not contain .rs suffix" + ); + found_exported.insert(name); + } else { + assert!( + name.contains(".rs"), + "internal symbol `{name}` should contain .rs suffix after rename" + ); + *found_rs_suffix = true; + } + } +} From c654d4d01ac933b8841129f7ecf46a4ac92fc945 Mon Sep 17 00:00:00 2001 From: albab-hasan Date: Sun, 20 Sep 2026 19:45:35 +0600 Subject: [PATCH 05/21] label the path segment that is not an associated item of the trait E0782 pointed only at the trait, leaving the segment that actually failed to resolve unmarked unless it was close enough to suggest a typo fix. --- .../src/hir_ty_lowering/dyn_trait.rs | 9 +++++++ .../dyn-keyword/unresolved-associated-item.rs | 26 +++++++++++++++++++ .../unresolved-associated-item.stderr | 14 ++++++++++ tests/ui/editions/dyn-trait-sugg-2021.stderr | 2 +- tests/ui/resolve/issue-111312.stderr | 2 +- tests/ui/resolve/issue-111727.stderr | 2 +- 6 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 tests/ui/dyn-keyword/unresolved-associated-item.rs create mode 100644 tests/ui/dyn-keyword/unresolved-associated-item.stderr diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs index beacb3f188cd9..2ef1922e45e4e 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs @@ -1085,6 +1085,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { typo, Applicability::MaybeIncorrect, ); + } else { + diag.span_label( + segment.ident.span, + format!( + "not an associated item of trait `{trait_name}`, so `{trait_name}` is \ + interpreted as a type", + trait_name = tcx.item_name(trait_def_id), + ), + ); } } } diff --git a/tests/ui/dyn-keyword/unresolved-associated-item.rs b/tests/ui/dyn-keyword/unresolved-associated-item.rs new file mode 100644 index 0000000000000..420183b323dc1 --- /dev/null +++ b/tests/ui/dyn-keyword/unresolved-associated-item.rs @@ -0,0 +1,26 @@ +//! Checks the E0782 label when a `Trait::item` path matches nothing on the trait. +//! There is no typo to suggest, so the label is the only thing pointing at the real mistake. +//! +//! This is the negative counterpart of `misspelled-associated-item.rs`, which covers the +//! near-miss arm. +//! Keep `nonexistent` far from `exists` so `find_best_match_for_name` returns `None`. +//! If the names get closer, this test silently turns into a copy of that one and still passes. +//! +//! The label is a `span_label`, not a sub-diagnostic, so it has no `// ~` annotation. +//! Only the `.stderr` checks it. +//! +//! See . + +//@ edition: 2021 +// E0782 only fires on 2021+. On 2018 this is just the bare-trait-object lint and the label +// never appears. + +trait Trait { + fn exists() -> Self; +} + +fn main() { + Trait::nonexistent(); + //~^ ERROR expected a type, found a trait + //~| HELP you can add the `dyn` keyword if you want a trait object +} diff --git a/tests/ui/dyn-keyword/unresolved-associated-item.stderr b/tests/ui/dyn-keyword/unresolved-associated-item.stderr new file mode 100644 index 0000000000000..4720a559f2c74 --- /dev/null +++ b/tests/ui/dyn-keyword/unresolved-associated-item.stderr @@ -0,0 +1,14 @@ +error[E0782]: expected a type, found a trait + --> $DIR/unresolved-associated-item.rs:23:5 + | +LL | Trait::nonexistent(); + | ^^^^^ ----------- not an associated item of trait `Trait`, so `Trait` is interpreted as a type + | +help: you can add the `dyn` keyword if you want a trait object + | +LL | ::nonexistent(); + | ++++ + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0782`. diff --git a/tests/ui/editions/dyn-trait-sugg-2021.stderr b/tests/ui/editions/dyn-trait-sugg-2021.stderr index 3aea8ac491d40..65245ae180368 100644 --- a/tests/ui/editions/dyn-trait-sugg-2021.stderr +++ b/tests/ui/editions/dyn-trait-sugg-2021.stderr @@ -2,7 +2,7 @@ error[E0782]: expected a type, found a trait --> $DIR/dyn-trait-sugg-2021.rs:10:5 | LL | Foo::hi(123); - | ^^^ + | ^^^ -- not an associated item of trait `Foo`, so `Foo` is interpreted as a type | help: you can add the `dyn` keyword if you want a trait object | diff --git a/tests/ui/resolve/issue-111312.stderr b/tests/ui/resolve/issue-111312.stderr index a1f8d6bc46c59..d5fa9ce6f31d7 100644 --- a/tests/ui/resolve/issue-111312.stderr +++ b/tests/ui/resolve/issue-111312.stderr @@ -2,7 +2,7 @@ error[E0782]: expected a type, found a trait --> $DIR/issue-111312.rs:10:5 | LL | HasNot::has(); - | ^^^^^^ + | ^^^^^^ --- not an associated item of trait `HasNot`, so `HasNot` is interpreted as a type | help: you can add the `dyn` keyword if you want a trait object | diff --git a/tests/ui/resolve/issue-111727.stderr b/tests/ui/resolve/issue-111727.stderr index 71ea989ac349f..b93960093c83b 100644 --- a/tests/ui/resolve/issue-111727.stderr +++ b/tests/ui/resolve/issue-111727.stderr @@ -2,7 +2,7 @@ error[E0782]: expected a type, found a trait --> $DIR/issue-111727.rs:4:5 | LL | std::any::Any::create(); - | ^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ ------ not an associated item of trait `Any`, so `Any` is interpreted as a type | help: you can add the `dyn` keyword if you want a trait object | From 65dd911de72d8b433f0884302975ebc4facd83b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 20 Sep 2026 05:52:52 +0000 Subject: [PATCH 06/21] Use span context for enclosing item(s) of unmet bound Point at item that introduced an unmet bound and in the case of associated items, their container (trait/impl), without using a span label. This adds bits of code to the diagnostic, without explicitly pointing to it. ``` error[E0277]: cannot add `::ActualSize` to `::ActualSize` --> $DIR/issue-54108.rs:23:17 | LL | type Size = ::ActualSize; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `::ActualSize + ::ActualSize` | = help: the trait `Add` is not implemented for `::ActualSize` note: required by a bound in `Encoder::Size` --> $DIR/issue-54108.rs:8:16 | LL | pub trait Encoder { LL | type Size: Add; | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Encoder::Size` ``` --- .../src/error_reporting/traits/suggestions.rs | 21 +++---- .../unsatisfied-bounds-inferred-type.stderr | 2 +- ...ied-bounds-where-clause-on-assoc-ty.stderr | 1 - .../duplicate-bound-err.stderr | 1 + .../path-unsatisfied.stderr | 1 - .../associated-types-eq-hr.stderr | 2 - .../defaults-suitability.current.stderr | 18 +++++- .../defaults-suitability.next.stderr | 18 +++++- .../defaults-unsound-62211-1.current.stderr | 8 +++ .../defaults-unsound-62211-1.next.stderr | 8 +++ .../defaults-unsound-62211-2.current.stderr | 8 +++ .../defaults-unsound-62211-2.next.stderr | 8 +++ .../hr-associated-type-bound-1.stderr | 5 +- .../hr-associated-type-bound-object.stderr | 7 +-- .../hr-associated-type-bound-param-1.stderr | 5 +- .../hr-associated-type-bound-param-2.stderr | 13 ++--- .../hr-associated-type-bound-param-3.stderr | 5 +- .../hr-associated-type-bound-param-4.stderr | 5 +- .../hr-associated-type-bound-param-5.stderr | 6 +- .../hr-associated-type-bound-param-6.stderr | 4 +- .../hr-associated-type-projection-1.stderr | 5 +- .../issue-43784-associated-type.stderr | 1 + tests/ui/associated-types/issue-43924.stderr | 1 + .../issue-54108.current.stderr | 1 + .../associated-types/issue-54108.next.stderr | 1 + .../issue-63593.current.stderr | 1 + .../associated-types/issue-63593.next.stderr | 1 + .../ui/associated-types/issue-65774-1.stderr | 1 + .../ui/associated-types/issue-65774-2.stderr | 1 + tests/ui/associated-types/issue-72806.stderr | 2 + ...int-at-type-on-obligation-failure-2.stderr | 9 ++- ...point-at-type-on-obligation-failure.stderr | 2 + .../trailing-where-clause.stderr | 1 - .../expect-infer-var-appearing-twice.stderr | 1 - .../closure-arg-assoc-type-mismatch.stderr | 3 - ...closure-arg-borrow-ice-issue-152331.stderr | 1 - ...on-assoc-const-allowed-and-enforced.stderr | 2 + ...ismatched-types-with-generic-in-ace.stderr | 4 ++ .../associated-type-bound-fail.stderr | 1 + ...-param-has-ty-goal-in-error-implies.stderr | 1 - .../defaults/doesnt_infer.stderr | 2 +- .../ui/const-generics/defaults/wfness.stderr | 2 - .../ensure_is_evaluatable.stderr | 1 - .../fn_with_two_const_inputs.stderr | 1 - .../generic_const_exprs/adt_wf_hang.stderr | 1 - .../const_kind_expr/issue_114151.stderr | 1 - .../cross_crate_predicate.stderr | 2 - .../issue-62504.full.stderr | 2 +- .../issue-62504.min.stderr | 2 +- ...ue-72819-generic-in-const-eval.full.stderr | 2 - .../generic_const_exprs/issue-83765.stderr | 1 + .../generic_const_exprs/obligation-cause.rs | 1 - .../obligation-cause.stderr | 7 +-- .../issues/issue-67185-2.stderr | 4 -- .../const-generics/issues/issue-73260.stderr | 2 - .../const-generics/issues/issue-79674.stderr | 1 - .../const-generics/issues/issue-83765.stderr | 6 ++ .../const-generics/issues/issue-86530.stderr | 1 - .../mgca/const-ctor-overflow-eval.stderr | 5 -- .../occurs-check/unused-substs-1.stderr | 1 - .../ct-var-in-collect_all_mismatches.stderr | 1 - ...outine-yielding-or-returning-itself.stderr | 2 - .../const-predicates-ice-158675.stderr | 5 +- .../generics/free-fn-to-free-fn.stderr | 2 +- .../generics/free-fn-to-trait-method.stderr | 4 +- .../generics/free-to-trait-self-reuse.stderr | 5 +- .../free-to-trait-static-reuse.stderr | 5 +- .../generics/impl-to-trait-method.stderr | 2 +- .../inherent-impls-parent-generics.stderr | 12 ++-- .../as_expression.current.stderr | 2 +- .../as_expression.next.stderr | 4 +- .../single-impl-candidate.stderr | 1 - .../drop/dropck-normalize-errors.nll.stderr | 1 + .../dropck-normalize-errors.polonius.stderr | 1 + tests/ui/dropck/dropck-only-error-gat.stderr | 1 + .../assoc_type_bounds_implicit_sized.stderr | 1 + .../assoc_type_bounds_sized_used.stderr | 6 +- ...malization-for-nested-goals.current.stderr | 1 + ...normalization-for-nested-goals.next.stderr | 1 + .../cross-crate-bounds.stderr | 1 + .../issue-101020.stderr | 3 +- ...gat-bound-during-assoc-ty-selection.stderr | 1 + .../issue-68641-check-gat-bounds.stderr | 1 + .../issue-68642-broken-llvm-ir.stderr | 1 + .../issue-68643-broken-mir.stderr | 1 + .../issue-68644-codegen-selection.stderr | 1 + .../issue-68645-codegen-fulfillment.stderr | 1 + .../issue-68656-unsized-values.stderr | 1 + .../issue-74816.current.stderr | 2 + .../issue-74816.next.stderr | 2 + .../issue-74824.current.stderr | 2 + .../issue-74824.next.stderr | 2 + .../issue-79636-1.stderr | 1 - ...issue-87429-associated-type-default.stderr | 2 + .../issue-87429-specialization.stderr | 1 + ...tiple-type-params-with-unmet-bounds.stderr | 1 + .../own-bound-span.stderr | 1 + .../type-param-defaults.stderr | 2 - ...vially-unsatisfied-bounds.mentioned.stderr | 1 - .../unsatisfied-bounds.stderr | 6 +- .../hrtb-with-assoc-type-projection.stderr | 1 - .../relate-bound-region-ice-144033.stderr | 2 +- .../higher-trait-bounds-ice-60218.stderr | 1 - ...igher-ranker-supertraits-transitive.stderr | 1 - .../trait-bounds/issue-62203-hrtb-ice.stderr | 4 +- .../trait-bounds/issue-95230.stderr | 1 - .../normalize-under-binder/issue-89118.stderr | 3 - .../in-assoc-type-unconstrained.stderr | 1 + .../impl-trait/in-trait/doesnt-satisfy.stderr | 1 + .../in-trait/not-inferred-generic.stderr | 2 + .../in-trait/refine-resolution-errors.stderr | 1 + .../return-dont-satisfy-bounds.stderr | 1 + .../issue-99348-impl-compatibility.stderr | 1 + tests/ui/implied-bounds/issue-100690.stderr | 1 - tests/ui/inference/issue-12028.stderr | 2 +- .../methods/filter-relevant-fn-bounds.stderr | 1 - .../ui/methods/inherent-bound-in-probe.stderr | 1 - tests/ui/methods/issues/issue-61525.stderr | 1 + tests/ui/mismatched_types/issue-47706.stderr | 1 - ...ver-as-spec-default-associated-type.stderr | 1 + .../dyn-trait-ice-153366.stderr | 2 - ...c-const-exprs-deadlock-issue-120757.stderr | 6 ++ .../issue-103052-2.stderr | 1 + .../default-associated-type-bound-1.stderr | 1 + .../default-associated-type-bound-2.stderr | 1 + ...fault-generic-associated-type-bound.stderr | 1 + .../fuzzed/fuzzing-ice-134905.stderr | 1 + tests/ui/specialization/issue-33017.stderr | 1 + tests/ui/specialization/issue-38091.stderr | 1 + tests/ui/specialization/issue-44861.stderr | 2 + tests/ui/specialization/issue-59435.stderr | 1 + .../splat/splat-dyn-asref-tuple-fail.stderr | 1 - .../closure-arg-trailing-semicolon.stderr | 2 +- ...ect-binder-for-arbitrary-bound-sugg.stderr | 1 - tests/ui/suggestions/fn-trait-notation.stderr | 1 - ...-trait-object-literal-bound-regions.stderr | 1 - tests/ui/suggestions/issue-84973.stderr | 2 +- .../suggest-maybe-sized-bound.stderr | 1 + .../trait-bounds/super-assoc-mismatch.stderr | 2 +- .../ui/traits/bad-method-typaram-kind.stderr | 1 + .../const-traits/assoc-type.current.stderr | 1 + .../const-traits/assoc-type.next.stderr | 1 + .../conditionally-const-invalid-places.stderr | 1 + .../item-bound-entailment-fails.stderr | 2 + .../trait-where-clause-const.stderr | 4 ++ .../const-traits/trait-where-clause.stderr | 4 ++ tests/ui/traits/cross-fn-cache-hole.stderr | 1 - tests/ui/traits/cycle-cache-err-60010.stderr | 1 + .../maybe-bounds-in-traits.stderr | 2 + .../explicit-reference-cast-hrtb.stderr | 1 - ...licit-reference-cast-unrelated-leaf.stderr | 2 - .../suggest-wrap-parens-method.stderr | 1 + .../inductive-overflow/two-traits.stderr | 1 + .../multidispatch-convert-ambig-dest.stderr | 1 - ...ndependent-projection-error.current.stderr | 2 - ...s-independent-projection-error.next.stderr | 2 - .../iterator-item-suggest-no-ice.stderr | 2 +- .../rpitit-fulfillment-error.stderr | 1 + .../next-solver/more-object-bound.stderr | 1 - .../normalize/normalize-param-env-2.stderr | 3 +- ...paque-hidden-in-closure-sig.current.stderr | 4 -- ...due-to-normalization-failure-no-ice.stderr | 1 - ...dont-drop-obligations-on-overflow-2.stderr | 1 - .../transmute-from-unconstrained.stderr | 1 - .../bad-sized-cond.stderr | 3 - .../traits/non_lifetime_binders/fail.stderr | 2 - .../foreach-partial-eq-next-solver.stderr | 1 - .../foreach-partial-eq.stderr | 1 - .../universe-error-host-effect.stderr | 1 - .../universe-error1.current.stderr | 1 - .../universe-error1.next.stderr | 1 - ...-projection-normalization-2.current.stderr | 1 + ...ned-projection-normalization-2.next.stderr | 1 + ...ed-projection-normalization.current.stderr | 1 + ...ained-projection-normalization.next.stderr | 1 + .../enforce-supertrait-projection.stderr | 1 - ...tion-no-progress-cycle-issue-157516.stderr | 1 + .../dont-suggest-unsize-deref.stderr | 1 - .../trivial-unsized-projection-2.bad.stderr | 4 +- ...rivial-unsized-projection-2.bad_new.stderr | 2 +- .../trivial-unsized-projection.bad.stderr | 4 +- .../trivial-unsized-projection.bad_new.stderr | 2 +- ...unsize-goal-escaping-bounds.current.stderr | 1 - tests/ui/traits/vtable-res-trait-param.stderr | 1 + .../alignment/align-fail.stderr | 1 - .../ui/transmutability/arrays/huge-len.stderr | 2 - .../should_require_well_defined_layout.stderr | 6 -- tests/ui/transmutability/assoc-bound.stderr | 2 + tests/ui/transmutability/char.stderr | 3 - ...dont-assume-err-is-yes-issue-126377.stderr | 1 - ...ve_reprs_should_have_correct_length.stderr | 20 ------- .../enums/should_pad_variants.stderr | 1 - .../enums/should_respect_endianness.stderr | 1 - .../unknown_dst_field.stderr | 2 - .../unknown_src_field.stderr | 2 - tests/ui/transmutability/maybeuninit.stderr | 1 - .../primitives/bool-mut.stderr | 1 - .../primitives/bool.current.stderr | 1 - .../primitives/bool.next.stderr | 1 - .../primitives/numbers.current.stderr | 57 ------------------- .../primitives/numbers.next.stderr | 57 ------------------- .../primitives/unit.current.stderr | 1 - .../primitives/unit.next.stderr | 1 - ...ve-wrapper-types-bit-compatible-mut.stderr | 1 - ...sive-wrapper-types-bit-incompatible.stderr | 1 - .../references/reject_extension.stderr | 1 - .../references/unit-to-u8.stderr | 1 - .../references/unsafecell.stderr | 4 -- tests/ui/transmutability/region-infer.stderr | 1 - ..._reject_if_dst_has_safety_invariant.stderr | 1 - ...ect_if_ref_src_has_safety_invariant.stderr | 1 - tests/ui/transmutability/uninhabited.stderr | 5 -- .../transmutability/unions/extension.stderr | 1 - .../unions/should_pad_variants.stderr | 1 - .../unions/should_reject_contraction.stderr | 1 - .../unions/should_reject_disjoint.stderr | 2 - .../unions/should_reject_intersecting.stderr | 2 - .../type-alias-impl-trait/issue-57961.stderr | 1 + tests/ui/typeck/method-chain-gats.stderr | 2 +- ...nference-for-associated-types-69683.stderr | 4 +- ...-infer-fn-once-move-from-projection.stderr | 1 - .../unstable-impl-assoc-type.fail.stderr | 1 + ...unstable_feature_bound_free_fn.fail.stderr | 2 +- ...nstable_feature_bound_on_trait.fail.stderr | 5 +- .../return-type-non-wf-no-ice.current.stderr | 1 - .../higher-ranked-fn-type.quiet.stderr | 1 - .../higher-ranked-fn-type.verbose.stderr | 1 - .../self-in-where-clause-allowed.stderr | 2 + .../where-clause-method-substituion.stderr | 1 + ...-clauses-method-unsatisfied.current.stderr | 1 - ...ere-clauses-method-unsatisfied.next.stderr | 1 - .../where-clauses-unsatisfied.current.stderr | 1 - .../where-clauses-unsatisfied.next.stderr | 1 - 233 files changed, 280 insertions(+), 382 deletions(-) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 8de0514b9ef27..fe4d14ebb4bdc 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -3962,21 +3962,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let short_item_name = with_forced_trimmed_paths!(tcx.def_path_str(item_def_id)); let mut multispan = MultiSpan::from(span); let sm = tcx.sess.source_map(); + if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy = + tcx.def_kind(item_def_id) + && let Some(ident) = tcx.opt_item_ident(tcx.parent(item_def_id)) + { + multispan.push_span_context(ident.span); + } if let Some(ident) = tcx.opt_item_ident(item_def_id) { - let same_line = - match (sm.lookup_line(ident.span.hi()), sm.lookup_line(span.lo())) { - (Ok(l), Ok(r)) => l.line == r.line, - _ => true, - }; - if ident.span.is_visible(sm) && !ident.span.overlaps(span) && !same_line { - multispan.push_span_label( - ident.span, - format!( - "required by a bound in this {}", - tcx.def_kind(item_def_id).descr(item_def_id) - ), - ); - } + multispan.push_span_context(ident.span); } let mut a = "a"; let mut this = "this bound"; diff --git a/tests/ui/associated-inherent-types/unsatisfied-bounds-inferred-type.stderr b/tests/ui/associated-inherent-types/unsatisfied-bounds-inferred-type.stderr index 7ce69a94bf8c1..faf4a599734d6 100644 --- a/tests/ui/associated-inherent-types/unsatisfied-bounds-inferred-type.stderr +++ b/tests/ui/associated-inherent-types/unsatisfied-bounds-inferred-type.stderr @@ -10,7 +10,7 @@ note: required by a bound in `S::T` LL | impl S { | ^^^^ required by this bound in `S::T` LL | type T = T; - | - required by a bound in this associated type + | error: aborting due to 1 previous error diff --git a/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.stderr b/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.stderr index cb35cdde0b4be..047fb90c8d8ae 100644 --- a/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.stderr +++ b/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.stderr @@ -8,7 +8,6 @@ note: required by a bound in `S::X` --> $DIR/unsatisfied-bounds-where-clause-on-assoc-ty.rs:9:12 | LL | type X = () - | - required by a bound in this associated type LL | where LL | T: Copy; | ^^^^ required by this bound in `S::X` diff --git a/tests/ui/associated-type-bounds/duplicate-bound-err.stderr b/tests/ui/associated-type-bounds/duplicate-bound-err.stderr index 04c9f33c0889b..accee989fe02d 100644 --- a/tests/ui/associated-type-bounds/duplicate-bound-err.stderr +++ b/tests/ui/associated-type-bounds/duplicate-bound-err.stderr @@ -125,6 +125,7 @@ LL | fn foo() -> impl Iterator { note: required by a bound in `Trait3::foo::{anon_assoc#0}` --> $DIR/duplicate-bound-err.rs:99:31 | +LL | trait Trait3 { LL | fn foo() -> impl Iterator; | ^^^^^^^^^^ required by this bound in `Trait3::foo::{anon_assoc#0}` diff --git a/tests/ui/associated-type-bounds/return-type-notation/path-unsatisfied.stderr b/tests/ui/associated-type-bounds/return-type-notation/path-unsatisfied.stderr index 90d0feb521743..f54e71f999a0c 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/path-unsatisfied.stderr +++ b/tests/ui/associated-type-bounds/return-type-notation/path-unsatisfied.stderr @@ -17,7 +17,6 @@ note: required by a bound in `test` --> $DIR/path-unsatisfied.rs:17:20 | LL | fn test() - | ---- required by a bound in this function LL | where LL | T::method(..): Send, | ^^^^ required by this bound in `test` diff --git a/tests/ui/associated-types/associated-types-eq-hr.stderr b/tests/ui/associated-types/associated-types-eq-hr.stderr index 3a70189dd9f94..40a84eb25d384 100644 --- a/tests/ui/associated-types/associated-types-eq-hr.stderr +++ b/tests/ui/associated-types/associated-types-eq-hr.stderr @@ -15,7 +15,6 @@ note: required by a bound in `foo` --> $DIR/associated-types-eq-hr.rs:45:36 | LL | fn foo() - | --- required by a bound in this function LL | where LL | T: for<'x> TheTrait<&'x isize, A = &'x isize>, | ^^^^^^^^^^^^^ required by this bound in `foo` @@ -37,7 +36,6 @@ note: required by a bound in `bar` --> $DIR/associated-types-eq-hr.rs:52:36 | LL | fn bar() - | --- required by a bound in this function LL | where LL | T: for<'x> TheTrait<&'x isize, A = &'x usize>, | ^^^^^^^^^^^^^ required by this bound in `bar` diff --git a/tests/ui/associated-types/defaults-suitability.current.stderr b/tests/ui/associated-types/defaults-suitability.current.stderr index 0018181f480d8..64b43e91f2ebf 100644 --- a/tests/ui/associated-types/defaults-suitability.current.stderr +++ b/tests/ui/associated-types/defaults-suitability.current.stderr @@ -7,6 +7,7 @@ LL | type Ty: Clone = NotClone; note: required by a bound in `Tr::Ty` --> $DIR/defaults-suitability.rs:16:14 | +LL | trait Tr { LL | type Ty: Clone = NotClone; | ^^^^^ required by this bound in `Tr::Ty` help: consider annotating `NotClone` with `#[derive(Clone)]` @@ -24,11 +25,13 @@ LL | type Ty = NotClone; note: required by a bound in `Tr2::Ty` --> $DIR/defaults-suitability.rs:23:15 | +LL | trait Tr2 +LL | where LL | Self::Ty: Clone, | ^^^^^ required by this bound in `Tr2::Ty` LL | { LL | type Ty = NotClone; - | -- required by a bound in this associated type + | help: consider annotating `NotClone` with `#[derive(Clone)]` | LL + #[derive(Clone)] @@ -45,6 +48,7 @@ LL | type Bar: Clone = Vec; note: required by a bound in `Foo::Bar` --> $DIR/defaults-suitability.rs:31:15 | +LL | trait Foo { LL | type Bar: Clone = Vec; | ^^^^^ required by this bound in `Foo::Bar` help: consider restricting type parameter `T` with trait `Clone` @@ -66,6 +70,8 @@ LL | trait Foo { note: required by a bound in `Bar::Assoc` --> $DIR/defaults-suitability.rs:37:17 | +LL | trait Bar: Sized { +LL | // `(): Foo` might hold for some possible impls but not all. LL | type Assoc: Foo = (); | ^^^^^^^^^ required by this bound in `Bar::Assoc` @@ -83,11 +89,13 @@ LL | struct NotClone; note: required by a bound in `D::Assoc` --> $DIR/defaults-suitability.rs:56:18 | +LL | trait D where +LL | Vec: Clone, LL | Self::Assoc: IsU8, | ^^^^^^^^^^^^^^^^^ required by this bound in `D::Assoc` ... LL | type Assoc = NotClone; - | ----- required by a bound in this associated type + | error[E0277]: the trait bound `>::Baz: Clone` is not satisfied --> $DIR/defaults-suitability.rs:68:23 @@ -99,6 +107,7 @@ LL | type Bar: Clone = Vec; note: required by a bound in `Foo2::Bar` --> $DIR/defaults-suitability.rs:68:15 | +LL | trait Foo2 { LL | type Bar: Clone = Vec; | ^^^^^ required by this bound in `Foo2::Bar` help: consider further restricting the associated type @@ -116,6 +125,7 @@ LL | type Bar: Clone = Vec; note: required by a bound in `Foo25::Bar` --> $DIR/defaults-suitability.rs:77:15 | +LL | trait Foo25 { LL | type Bar: Clone = Vec; | ^^^^^ required by this bound in `Foo25::Bar` help: consider further restricting the associated type @@ -132,11 +142,13 @@ LL | type Baz = T; note: required by a bound in `Foo3::Baz` --> $DIR/defaults-suitability.rs:87:16 | +LL | trait Foo3 +... LL | Self::Baz: Clone, | ^^^^^ required by this bound in `Foo3::Baz` ... LL | type Baz = T; - | --- required by a bound in this associated type + | help: consider further restricting type parameter `T` with trait `Clone` | LL | Self::Baz: Clone, T: std::clone::Clone diff --git a/tests/ui/associated-types/defaults-suitability.next.stderr b/tests/ui/associated-types/defaults-suitability.next.stderr index 0018181f480d8..64b43e91f2ebf 100644 --- a/tests/ui/associated-types/defaults-suitability.next.stderr +++ b/tests/ui/associated-types/defaults-suitability.next.stderr @@ -7,6 +7,7 @@ LL | type Ty: Clone = NotClone; note: required by a bound in `Tr::Ty` --> $DIR/defaults-suitability.rs:16:14 | +LL | trait Tr { LL | type Ty: Clone = NotClone; | ^^^^^ required by this bound in `Tr::Ty` help: consider annotating `NotClone` with `#[derive(Clone)]` @@ -24,11 +25,13 @@ LL | type Ty = NotClone; note: required by a bound in `Tr2::Ty` --> $DIR/defaults-suitability.rs:23:15 | +LL | trait Tr2 +LL | where LL | Self::Ty: Clone, | ^^^^^ required by this bound in `Tr2::Ty` LL | { LL | type Ty = NotClone; - | -- required by a bound in this associated type + | help: consider annotating `NotClone` with `#[derive(Clone)]` | LL + #[derive(Clone)] @@ -45,6 +48,7 @@ LL | type Bar: Clone = Vec; note: required by a bound in `Foo::Bar` --> $DIR/defaults-suitability.rs:31:15 | +LL | trait Foo { LL | type Bar: Clone = Vec; | ^^^^^ required by this bound in `Foo::Bar` help: consider restricting type parameter `T` with trait `Clone` @@ -66,6 +70,8 @@ LL | trait Foo { note: required by a bound in `Bar::Assoc` --> $DIR/defaults-suitability.rs:37:17 | +LL | trait Bar: Sized { +LL | // `(): Foo` might hold for some possible impls but not all. LL | type Assoc: Foo = (); | ^^^^^^^^^ required by this bound in `Bar::Assoc` @@ -83,11 +89,13 @@ LL | struct NotClone; note: required by a bound in `D::Assoc` --> $DIR/defaults-suitability.rs:56:18 | +LL | trait D where +LL | Vec: Clone, LL | Self::Assoc: IsU8, | ^^^^^^^^^^^^^^^^^ required by this bound in `D::Assoc` ... LL | type Assoc = NotClone; - | ----- required by a bound in this associated type + | error[E0277]: the trait bound `>::Baz: Clone` is not satisfied --> $DIR/defaults-suitability.rs:68:23 @@ -99,6 +107,7 @@ LL | type Bar: Clone = Vec; note: required by a bound in `Foo2::Bar` --> $DIR/defaults-suitability.rs:68:15 | +LL | trait Foo2 { LL | type Bar: Clone = Vec; | ^^^^^ required by this bound in `Foo2::Bar` help: consider further restricting the associated type @@ -116,6 +125,7 @@ LL | type Bar: Clone = Vec; note: required by a bound in `Foo25::Bar` --> $DIR/defaults-suitability.rs:77:15 | +LL | trait Foo25 { LL | type Bar: Clone = Vec; | ^^^^^ required by this bound in `Foo25::Bar` help: consider further restricting the associated type @@ -132,11 +142,13 @@ LL | type Baz = T; note: required by a bound in `Foo3::Baz` --> $DIR/defaults-suitability.rs:87:16 | +LL | trait Foo3 +... LL | Self::Baz: Clone, | ^^^^^ required by this bound in `Foo3::Baz` ... LL | type Baz = T; - | --- required by a bound in this associated type + | help: consider further restricting type parameter `T` with trait `Clone` | LL | Self::Baz: Clone, T: std::clone::Clone diff --git a/tests/ui/associated-types/defaults-unsound-62211-1.current.stderr b/tests/ui/associated-types/defaults-unsound-62211-1.current.stderr index b17e26b608d93..7d76b53e2bcc5 100644 --- a/tests/ui/associated-types/defaults-unsound-62211-1.current.stderr +++ b/tests/ui/associated-types/defaults-unsound-62211-1.current.stderr @@ -7,6 +7,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-1.rs:24:86 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` @@ -23,6 +25,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-1.rs:24:47 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` @@ -39,6 +43,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-1.rs:24:25 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^^^^^^^^^^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` @@ -55,6 +61,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-1.rs:24:18 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` diff --git a/tests/ui/associated-types/defaults-unsound-62211-1.next.stderr b/tests/ui/associated-types/defaults-unsound-62211-1.next.stderr index a858c9c1ba04a..7d71df095e9b2 100644 --- a/tests/ui/associated-types/defaults-unsound-62211-1.next.stderr +++ b/tests/ui/associated-types/defaults-unsound-62211-1.next.stderr @@ -7,6 +7,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-1.rs:24:86 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` @@ -23,6 +25,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-1.rs:24:47 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` @@ -39,6 +43,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-1.rs:24:31 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^^^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` @@ -55,6 +61,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-1.rs:24:18 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` diff --git a/tests/ui/associated-types/defaults-unsound-62211-2.current.stderr b/tests/ui/associated-types/defaults-unsound-62211-2.current.stderr index facfec85afe38..c31afadbdb1ac 100644 --- a/tests/ui/associated-types/defaults-unsound-62211-2.current.stderr +++ b/tests/ui/associated-types/defaults-unsound-62211-2.current.stderr @@ -7,6 +7,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-2.rs:24:86 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` @@ -23,6 +25,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-2.rs:24:47 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` @@ -39,6 +43,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-2.rs:24:25 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^^^^^^^^^^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` @@ -55,6 +61,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-2.rs:24:18 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` diff --git a/tests/ui/associated-types/defaults-unsound-62211-2.next.stderr b/tests/ui/associated-types/defaults-unsound-62211-2.next.stderr index 1360843172f96..35d7f7c5dae9c 100644 --- a/tests/ui/associated-types/defaults-unsound-62211-2.next.stderr +++ b/tests/ui/associated-types/defaults-unsound-62211-2.next.stderr @@ -7,6 +7,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-2.rs:24:86 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` @@ -23,6 +25,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-2.rs:24:47 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` @@ -39,6 +43,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-2.rs:24:31 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^^^^^^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` @@ -55,6 +61,8 @@ LL | type Output: Copy + Deref + AddAssign<&'static str> + Fro note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-2.rs:24:18 | +LL | trait UncheckedCopy: Sized { +... LL | type Output: Copy + Deref + AddAssign<&'static str> + From + Display = Self; | ^^^^ required by this bound in `UncheckedCopy::Output` help: consider further restricting `Self` diff --git a/tests/ui/associated-types/hr-associated-type-bound-1.stderr b/tests/ui/associated-types/hr-associated-type-bound-1.stderr index 3815a5bc28c53..c299fe2085de2 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-1.stderr +++ b/tests/ui/associated-types/hr-associated-type-bound-1.stderr @@ -10,7 +10,6 @@ note: required by a bound in `X` --> $DIR/hr-associated-type-bound-1.rs:3:33 | LL | trait X<'a> - | - required by a bound in this trait LL | where LL | for<'b> >::U: Clone, | ^^^^^ required by this bound in `X` @@ -26,11 +25,13 @@ help: the trait `Clone` is implemented for `String` note: required by a bound in `X::f` --> $DIR/hr-associated-type-bound-1.rs:3:33 | +LL | trait X<'a> +LL | where LL | for<'b> >::U: Clone, | ^^^^^ required by this bound in `X::f` ... LL | fn f(&self, x: &Self::U) { - | - required by a bound in this associated function + | error: aborting due to 2 previous errors diff --git a/tests/ui/associated-types/hr-associated-type-bound-object.stderr b/tests/ui/associated-types/hr-associated-type-bound-object.stderr index 5144cfe6d3e7d..d1563c923bc7a 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-object.stderr +++ b/tests/ui/associated-types/hr-associated-type-bound-object.stderr @@ -8,7 +8,6 @@ note: required by a bound in `X` --> $DIR/hr-associated-type-bound-object.rs:3:33 | LL | trait X<'a> - | - required by a bound in this trait LL | where LL | for<'b> >::U: Clone, | ^^^^^ required by this bound in `X` @@ -26,11 +25,13 @@ LL | <>::U>::clone(x); note: required by a bound in `X::U` --> $DIR/hr-associated-type-bound-object.rs:3:33 | +LL | trait X<'a> +LL | where LL | for<'b> >::U: Clone, | ^^^^^ required by this bound in `X::U` LL | { LL | type U: ?Sized; - | - required by a bound in this associated type + | help: consider further restricting the associated type | LL | fn f<'a, T: X<'a> + ?Sized>(x: &>::U) where for<'b> >::U: Clone { @@ -57,7 +58,6 @@ note: required by a bound in `X` --> $DIR/hr-associated-type-bound-object.rs:3:33 | LL | trait X<'a> - | - required by a bound in this trait LL | where LL | for<'b> >::U: Clone, | ^^^^^ required by this bound in `X` @@ -76,7 +76,6 @@ note: required by a bound in `X` --> $DIR/hr-associated-type-bound-object.rs:3:33 | LL | trait X<'a> - | - required by a bound in this trait LL | where LL | for<'b> >::U: Clone, | ^^^^^ required by this bound in `X` diff --git a/tests/ui/associated-types/hr-associated-type-bound-param-1.stderr b/tests/ui/associated-types/hr-associated-type-bound-param-1.stderr index c4398e24dde3b..1a89819ab8082 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-param-1.stderr +++ b/tests/ui/associated-types/hr-associated-type-bound-param-1.stderr @@ -10,7 +10,6 @@ note: required by a bound in `Y` --> $DIR/hr-associated-type-bound-param-1.rs:4:36 | LL | trait Y<'a, T: ?Sized> - | - required by a bound in this trait ... LL | for<'b> >::V: Clone, | ^^^^^ required by this bound in `Y` @@ -26,11 +25,13 @@ help: the trait `Clone` is implemented for `String` note: required by a bound in `Y::g` --> $DIR/hr-associated-type-bound-param-1.rs:4:36 | +LL | trait Y<'a, T: ?Sized> +... LL | for<'b> >::V: Clone, | ^^^^^ required by this bound in `Y::g` ... LL | fn g(&self, x: &Self::V) { - | - required by a bound in this associated function + | error: aborting due to 2 previous errors diff --git a/tests/ui/associated-types/hr-associated-type-bound-param-2.stderr b/tests/ui/associated-types/hr-associated-type-bound-param-2.stderr index ef402b79c8dfa..f025798750a58 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-param-2.stderr +++ b/tests/ui/associated-types/hr-associated-type-bound-param-2.stderr @@ -10,7 +10,6 @@ note: required by a bound in `Z` --> $DIR/hr-associated-type-bound-param-2.rs:6:35 | LL | trait Z<'a, T: ?Sized> - | - required by a bound in this trait ... LL | for<'b> >::W: Clone, | ^^^^^ required by this bound in `Z` @@ -27,7 +26,6 @@ note: required by a bound in `Z` --> $DIR/hr-associated-type-bound-param-2.rs:6:35 | LL | trait Z<'a, T: ?Sized> - | - required by a bound in this trait ... LL | for<'b> >::W: Clone, | ^^^^^ required by this bound in `Z` @@ -44,7 +42,6 @@ note: required by a bound in `Z` --> $DIR/hr-associated-type-bound-param-2.rs:6:35 | LL | trait Z<'a, T: ?Sized> - | - required by a bound in this trait ... LL | for<'b> >::W: Clone, | ^^^^^ required by this bound in `Z` @@ -61,11 +58,13 @@ help: the trait `Clone` is implemented for `String` note: required by a bound in `Z::W` --> $DIR/hr-associated-type-bound-param-2.rs:6:35 | +LL | trait Z<'a, T: ?Sized> +... LL | for<'b> >::W: Clone, | ^^^^^ required by this bound in `Z::W` LL | { LL | type W: ?Sized; - | - required by a bound in this associated type + | error[E0277]: the trait bound `str: Clone` is not satisfied --> $DIR/hr-associated-type-bound-param-2.rs:10:9 @@ -79,7 +78,6 @@ note: required by a bound in `Z` --> $DIR/hr-associated-type-bound-param-2.rs:6:35 | LL | trait Z<'a, T: ?Sized> - | - required by a bound in this trait ... LL | for<'b> >::W: Clone, | ^^^^^ required by this bound in `Z` @@ -96,7 +94,6 @@ note: required by a bound in `Z` --> $DIR/hr-associated-type-bound-param-2.rs:6:35 | LL | trait Z<'a, T: ?Sized> - | - required by a bound in this trait ... LL | for<'b> >::W: Clone, | ^^^^^ required by this bound in `Z` @@ -112,11 +109,13 @@ help: the trait `Clone` is implemented for `String` note: required by a bound in `Z::h` --> $DIR/hr-associated-type-bound-param-2.rs:6:35 | +LL | trait Z<'a, T: ?Sized> +... LL | for<'b> >::W: Clone, | ^^^^^ required by this bound in `Z::h` ... LL | fn h(&self, x: &T::W) { - | - required by a bound in this associated function + | error: aborting due to 7 previous errors diff --git a/tests/ui/associated-types/hr-associated-type-bound-param-3.stderr b/tests/ui/associated-types/hr-associated-type-bound-param-3.stderr index 0b5c9543fb024..25e2a8fa5ae13 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-param-3.stderr +++ b/tests/ui/associated-types/hr-associated-type-bound-param-3.stderr @@ -10,7 +10,6 @@ note: required by a bound in `X` --> $DIR/hr-associated-type-bound-param-3.rs:4:33 | LL | trait X<'a, T> - | - required by a bound in this trait ... LL | for<'b> >::U: Clone, | ^^^^^ required by this bound in `X` @@ -26,11 +25,13 @@ help: the trait `Clone` is implemented for `String` note: required by a bound in `X::f` --> $DIR/hr-associated-type-bound-param-3.rs:4:33 | +LL | trait X<'a, T> +... LL | for<'b> >::U: Clone, | ^^^^^ required by this bound in `X::f` ... LL | fn f(x: &>::U) { - | - required by a bound in this associated function + | error: aborting due to 2 previous errors diff --git a/tests/ui/associated-types/hr-associated-type-bound-param-4.stderr b/tests/ui/associated-types/hr-associated-type-bound-param-4.stderr index f0ceeb12c7383..dc8e42aad5e15 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-param-4.stderr +++ b/tests/ui/associated-types/hr-associated-type-bound-param-4.stderr @@ -10,7 +10,6 @@ note: required by a bound in `X` --> $DIR/hr-associated-type-bound-param-4.rs:4:36 | LL | trait X<'a, T> - | - required by a bound in this trait ... LL | for<'b> <(T,) as X<'b, T>>::U: Clone, | ^^^^^ required by this bound in `X` @@ -26,11 +25,13 @@ help: the trait `Clone` is implemented for `String` note: required by a bound in `X::f` --> $DIR/hr-associated-type-bound-param-4.rs:4:36 | +LL | trait X<'a, T> +... LL | for<'b> <(T,) as X<'b, T>>::U: Clone, | ^^^^^ required by this bound in `X::f` ... LL | fn f(x: &<(T,) as X<'_, T>>::U) { - | - required by a bound in this associated function + | error: aborting due to 2 previous errors diff --git a/tests/ui/associated-types/hr-associated-type-bound-param-5.stderr b/tests/ui/associated-types/hr-associated-type-bound-param-5.stderr index e4bc5f89a3749..72465d82aee5d 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-param-5.stderr +++ b/tests/ui/associated-types/hr-associated-type-bound-param-5.stderr @@ -10,7 +10,6 @@ note: required by a bound in `X` --> $DIR/hr-associated-type-bound-param-5.rs:17:45 | LL | trait X<'a, T: Cycle + for<'b> X<'b, T>> - | - required by a bound in this trait ... LL | for<'b> >::U: Clone, | ^^^^^ required by this bound in `X` @@ -27,7 +26,6 @@ note: required by a bound in `X` --> $DIR/hr-associated-type-bound-param-5.rs:17:45 | LL | trait X<'a, T: Cycle + for<'b> X<'b, T>> - | - required by a bound in this trait ... LL | for<'b> >::U: Clone, | ^^^^^ required by this bound in `X` @@ -43,11 +41,13 @@ help: the trait `Clone` is implemented for `String` note: required by a bound in `X::f` --> $DIR/hr-associated-type-bound-param-5.rs:15:33 | +LL | trait X<'a, T: Cycle + for<'b> X<'b, T>> +LL | where LL | for<'b> >::U: Clone, | ^^^^^ required by this bound in `X::f` ... LL | fn f(x: &>::U) { - | - required by a bound in this associated function + | error: aborting due to 3 previous errors diff --git a/tests/ui/associated-types/hr-associated-type-bound-param-6.stderr b/tests/ui/associated-types/hr-associated-type-bound-param-6.stderr index 83e84938d74ba..1f5dda9fc0eff 100644 --- a/tests/ui/associated-types/hr-associated-type-bound-param-6.stderr +++ b/tests/ui/associated-types/hr-associated-type-bound-param-6.stderr @@ -23,11 +23,13 @@ LL | impl X<'_, T> for (S,) { note: required by a bound in `X::f` --> $DIR/hr-associated-type-bound-param-6.rs:3:16 | +LL | trait X<'a, T> +LL | where LL | for<'b> T: X<'b, T>, | ^^^^^^^^ required by this bound in `X::f` ... LL | fn f(x: &>::U) { - | - required by a bound in this associated function + | error[E0277]: the trait bound `for<'b> i32: X<'b, i32>` is not satisfied --> $DIR/hr-associated-type-bound-param-6.rs:18:5 diff --git a/tests/ui/associated-types/hr-associated-type-projection-1.stderr b/tests/ui/associated-types/hr-associated-type-projection-1.stderr index b871bb51ae313..5e7c95299e31d 100644 --- a/tests/ui/associated-types/hr-associated-type-projection-1.stderr +++ b/tests/ui/associated-types/hr-associated-type-projection-1.stderr @@ -12,7 +12,6 @@ note: required by a bound in `UnsafeCopy` --> $DIR/hr-associated-type-projection-1.rs:3:64 | LL | trait UnsafeCopy<'a, T: Copy> - | ---------- required by a bound in this trait LL | where LL | for<'b> >::Item: std::ops::Deref, | ^^^^^^^^^^ required by this bound in `UnsafeCopy` @@ -30,11 +29,13 @@ LL | <&'static str>::bug(&""); note: required by a bound in `UnsafeCopy::bug` --> $DIR/hr-associated-type-projection-1.rs:3:64 | +LL | trait UnsafeCopy<'a, T: Copy> +LL | where LL | for<'b> >::Item: std::ops::Deref, | ^^^^^^^^^^ required by this bound in `UnsafeCopy::bug` ... LL | fn bug(item: &Self::Item) -> () { - | --- required by a bound in this associated function + | error: aborting due to 2 previous errors diff --git a/tests/ui/associated-types/issue-43784-associated-type.stderr b/tests/ui/associated-types/issue-43784-associated-type.stderr index ba4e683194f10..fa856f68e520a 100644 --- a/tests/ui/associated-types/issue-43784-associated-type.stderr +++ b/tests/ui/associated-types/issue-43784-associated-type.stderr @@ -12,6 +12,7 @@ LL | pub trait Partial: Copy { note: required by a bound in `Complete::Assoc` --> $DIR/issue-43784-associated-type.rs:5:17 | +LL | pub trait Complete { LL | type Assoc: Partial; | ^^^^^^^^^^^^^ required by this bound in `Complete::Assoc` help: consider restricting type parameter `T` with trait `Copy` diff --git a/tests/ui/associated-types/issue-43924.stderr b/tests/ui/associated-types/issue-43924.stderr index 5bf8ee730e618..6dbcd80a1cc98 100644 --- a/tests/ui/associated-types/issue-43924.stderr +++ b/tests/ui/associated-types/issue-43924.stderr @@ -7,6 +7,7 @@ LL | type Out: Default + ToString + ?Sized = dyn ToString; note: required by a bound in `Foo::Out` --> $DIR/issue-43924.rs:8:15 | +LL | trait Foo { LL | type Out: Default + ToString + ?Sized = dyn ToString; | ^^^^^^^ required by this bound in `Foo::Out` diff --git a/tests/ui/associated-types/issue-54108.current.stderr b/tests/ui/associated-types/issue-54108.current.stderr index 115a591c68f16..74892042166e0 100644 --- a/tests/ui/associated-types/issue-54108.current.stderr +++ b/tests/ui/associated-types/issue-54108.current.stderr @@ -8,6 +8,7 @@ LL | type Size = ::ActualSize; note: required by a bound in `Encoder::Size` --> $DIR/issue-54108.rs:8:16 | +LL | pub trait Encoder { LL | type Size: Add; | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Encoder::Size` help: consider further restricting the associated type diff --git a/tests/ui/associated-types/issue-54108.next.stderr b/tests/ui/associated-types/issue-54108.next.stderr index e6d65d8246a11..6600857ff4551 100644 --- a/tests/ui/associated-types/issue-54108.next.stderr +++ b/tests/ui/associated-types/issue-54108.next.stderr @@ -8,6 +8,7 @@ LL | type Size = ::ActualSize; note: required by a bound in `Encoder::Size` --> $DIR/issue-54108.rs:8:20 | +LL | pub trait Encoder { LL | type Size: Add; | ^^^^^^^^^^^^^^^^^^^ required by this bound in `Encoder::Size` help: consider further restricting the associated type diff --git a/tests/ui/associated-types/issue-63593.current.stderr b/tests/ui/associated-types/issue-63593.current.stderr index 76fdefeb4e521..7cb095eef59e1 100644 --- a/tests/ui/associated-types/issue-63593.current.stderr +++ b/tests/ui/associated-types/issue-63593.current.stderr @@ -7,6 +7,7 @@ LL | type This = Self; note: required by a bound in `MyTrait::This` --> $DIR/issue-63593.rs:13:5 | +LL | trait MyTrait { LL | type This = Self; | ^^^^^^^^^^^^^^^^^ required by this bound in `MyTrait::This` help: consider further restricting `Self` diff --git a/tests/ui/associated-types/issue-63593.next.stderr b/tests/ui/associated-types/issue-63593.next.stderr index 76fdefeb4e521..7cb095eef59e1 100644 --- a/tests/ui/associated-types/issue-63593.next.stderr +++ b/tests/ui/associated-types/issue-63593.next.stderr @@ -7,6 +7,7 @@ LL | type This = Self; note: required by a bound in `MyTrait::This` --> $DIR/issue-63593.rs:13:5 | +LL | trait MyTrait { LL | type This = Self; | ^^^^^^^^^^^^^^^^^ required by this bound in `MyTrait::This` help: consider further restricting `Self` diff --git a/tests/ui/associated-types/issue-65774-1.stderr b/tests/ui/associated-types/issue-65774-1.stderr index 1cc335f4159a0..151e0bd1b4679 100644 --- a/tests/ui/associated-types/issue-65774-1.stderr +++ b/tests/ui/associated-types/issue-65774-1.stderr @@ -17,6 +17,7 @@ LL | impl<'a, T: MyDisplay> MyDisplay for &'a mut T { } note: required by a bound in `MPU::MpuConfig` --> $DIR/issue-65774-1.rs:10:21 | +LL | trait MPU { LL | type MpuConfig: MyDisplay = T; | ^^^^^^^^^ required by this bound in `MPU::MpuConfig` diff --git a/tests/ui/associated-types/issue-65774-2.stderr b/tests/ui/associated-types/issue-65774-2.stderr index 6ef4289a90ef0..2a93b1944dff9 100644 --- a/tests/ui/associated-types/issue-65774-2.stderr +++ b/tests/ui/associated-types/issue-65774-2.stderr @@ -17,6 +17,7 @@ LL | impl<'a, T: MyDisplay> MyDisplay for &'a mut T { } note: required by a bound in `MPU::MpuConfig` --> $DIR/issue-65774-2.rs:10:21 | +LL | trait MPU { LL | type MpuConfig: MyDisplay = T; | ^^^^^^^^^ required by this bound in `MPU::MpuConfig` diff --git a/tests/ui/associated-types/issue-72806.stderr b/tests/ui/associated-types/issue-72806.stderr index 9cb615bbb2882..4943b318b9969 100644 --- a/tests/ui/associated-types/issue-72806.stderr +++ b/tests/ui/associated-types/issue-72806.stderr @@ -12,6 +12,8 @@ LL | type Ok = u32; note: required by a bound in `Bar::Sibling` --> $DIR/issue-72806.rs:3:24 | +LL | trait Bar { +LL | type Ok; LL | type Sibling: Bar2; | ^^^^^^^ required by this bound in `Bar::Sibling` diff --git a/tests/ui/associated-types/point-at-type-on-obligation-failure-2.stderr b/tests/ui/associated-types/point-at-type-on-obligation-failure-2.stderr index 056d9201b4abb..6bfcaa72bcfe6 100644 --- a/tests/ui/associated-types/point-at-type-on-obligation-failure-2.stderr +++ b/tests/ui/associated-types/point-at-type-on-obligation-failure-2.stderr @@ -12,6 +12,7 @@ LL | trait Bar {} note: required by a bound in `Foo::Assoc` --> $DIR/point-at-type-on-obligation-failure-2.rs:4:17 | +LL | trait Foo { LL | type Assoc: Bar; | ^^^ required by this bound in `Foo::Assoc` @@ -29,11 +30,13 @@ LL | trait Bar {} note: required by a bound in `Baz::Assoc` --> $DIR/point-at-type-on-obligation-failure-2.rs:13:18 | +LL | trait Baz +LL | where LL | Self::Assoc: Bar, | ^^^ required by this bound in `Baz::Assoc` LL | { LL | type Assoc; - | ----- required by a bound in this associated type + | error[E0277]: the trait bound `bool: Bar` is not satisfied --> $DIR/point-at-type-on-obligation-failure-2.rs:30:18 @@ -49,11 +52,13 @@ LL | trait Bar {} note: required by a bound in `Bat::Assoc` --> $DIR/point-at-type-on-obligation-failure-2.rs:24:27 | +LL | trait Bat +LL | where LL | ::Assoc: Bar, | ^^^ required by this bound in `Bat::Assoc` LL | { LL | type Assoc; - | ----- required by a bound in this associated type + | error: aborting due to 3 previous errors diff --git a/tests/ui/associated-types/point-at-type-on-obligation-failure.stderr b/tests/ui/associated-types/point-at-type-on-obligation-failure.stderr index 1c9de509e683e..7d032069b92c9 100644 --- a/tests/ui/associated-types/point-at-type-on-obligation-failure.stderr +++ b/tests/ui/associated-types/point-at-type-on-obligation-failure.stderr @@ -12,6 +12,8 @@ LL | type Ok = u32; note: required by a bound in `Bar::Sibling` --> $DIR/point-at-type-on-obligation-failure.rs:3:24 | +LL | trait Bar { +LL | type Ok; LL | type Sibling: Bar2; | ^^^^^^^^^^^ required by this bound in `Bar::Sibling` diff --git a/tests/ui/checked-type-alias/trailing-where-clause.stderr b/tests/ui/checked-type-alias/trailing-where-clause.stderr index 170bc3bca78d3..e87db6a47ae79 100644 --- a/tests/ui/checked-type-alias/trailing-where-clause.stderr +++ b/tests/ui/checked-type-alias/trailing-where-clause.stderr @@ -15,7 +15,6 @@ note: required by a bound in `Alias` --> $DIR/trailing-where-clause.rs:8:13 | LL | type Alias = T - | ----- required by a bound in this type alias LL | where LL | String: From; | ^^^^^^^ required by this bound in `Alias` diff --git a/tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr b/tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr index c0f222b016db7..3a4dbd2b9e0e2 100644 --- a/tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr +++ b/tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr @@ -15,7 +15,6 @@ note: required by a bound in `with_closure` --> $DIR/expect-infer-var-appearing-twice.rs:2:14 | LL | fn with_closure(_: F) - | ------------ required by a bound in this function LL | where F: FnOnce(A, A) | ^^^^^^^^^^^^ required by this bound in `with_closure` diff --git a/tests/ui/closures/closure-arg-assoc-type-mismatch.stderr b/tests/ui/closures/closure-arg-assoc-type-mismatch.stderr index 09ae41b30945b..013476f3a3487 100644 --- a/tests/ui/closures/closure-arg-assoc-type-mismatch.stderr +++ b/tests/ui/closures/closure-arg-assoc-type-mismatch.stderr @@ -16,7 +16,6 @@ note: required by a bound in `needs_unit_item` --> $DIR/closure-arg-assoc-type-mismatch.rs:19:24 | LL | fn needs_unit_item S>(_f: F) - | --------------- required by a bound in this function LL | where LL | F::Output: MyTrait, | ^^^^^^^^^ required by this bound in `needs_unit_item` @@ -39,7 +38,6 @@ note: required by a bound in `needs_unit_item` --> $DIR/closure-arg-assoc-type-mismatch.rs:19:24 | LL | fn needs_unit_item S>(_f: F) - | --------------- required by a bound in this function LL | where LL | F::Output: MyTrait, | ^^^^^^^^^ required by this bound in `needs_unit_item` @@ -62,7 +60,6 @@ note: required by a bound in `needs_unit_item` --> $DIR/closure-arg-assoc-type-mismatch.rs:19:24 | LL | fn needs_unit_item S>(_f: F) - | --------------- required by a bound in this function LL | where LL | F::Output: MyTrait, | ^^^^^^^^^ required by this bound in `needs_unit_item` diff --git a/tests/ui/closures/closure-arg-borrow-ice-issue-152331.stderr b/tests/ui/closures/closure-arg-borrow-ice-issue-152331.stderr index 7cfc9f0576ecc..fdc9798a3acb3 100644 --- a/tests/ui/closures/closure-arg-borrow-ice-issue-152331.stderr +++ b/tests/ui/closures/closure-arg-borrow-ice-issue-152331.stderr @@ -13,7 +13,6 @@ note: required by a bound in `h2` --> $DIR/closure-arg-borrow-ice-issue-152331.rs:8:8 | LL | fn h2(_: F) - | -- required by a bound in this function LL | where LL | F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `h2` diff --git a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.stderr b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.stderr index 25eeba203209d..770e7b561fadd 100644 --- a/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.stderr +++ b/tests/ui/const-generics/associated-const-bindings/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.stderr @@ -12,6 +12,8 @@ LL | trait Bound {} note: required by a bound in `Trait::N` --> $DIR/dyn-compat-self-bound-on-assoc-const-allowed-and-enforced.rs:10:30 | +LL | trait Trait { +LL | #[rustc_always_gca] LL | const N: i32 where Self: Bound; | ^^^^^ required by this bound in `Trait::N` diff --git a/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.stderr b/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.stderr index 72a783f8d06d4..e879cafdc86ea 100644 --- a/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.stderr +++ b/tests/ui/const-generics/associated-const-bindings/mismatched-types-with-generic-in-ace.stderr @@ -7,6 +7,8 @@ LL | fn bar = { N }>>() {} note: required by a const generic parameter in `Foo::ASSOC` --> $DIR/mismatched-types-with-generic-in-ace.rs:6:17 | +LL | trait Foo { +LL | #[rustc_always_gca] LL | const ASSOC: u32; | ^^^^^^^^^^^^ required by this const generic parameter in `Foo::ASSOC` @@ -19,6 +21,8 @@ LL | bar::<10_u64, ()>(); note: required by a const generic parameter in `Foo::ASSOC` --> $DIR/mismatched-types-with-generic-in-ace.rs:6:17 | +LL | trait Foo { +LL | #[rustc_always_gca] LL | const ASSOC: u32; | ^^^^^^^^^^^^ required by this const generic parameter in `Foo::ASSOC` diff --git a/tests/ui/const-generics/associated-type-bound-fail.stderr b/tests/ui/const-generics/associated-type-bound-fail.stderr index 86e667408c732..6191f44dd4f31 100644 --- a/tests/ui/const-generics/associated-type-bound-fail.stderr +++ b/tests/ui/const-generics/associated-type-bound-fail.stderr @@ -13,6 +13,7 @@ LL | impl Bar<3> for u16 {} note: required by a bound in `Foo::Assoc` --> $DIR/associated-type-bound-fail.rs:4:17 | +LL | trait Foo { LL | type Assoc: Bar; | ^^^^^^ required by this bound in `Foo::Assoc` diff --git a/tests/ui/const-generics/const-param-has-ty-goal-in-error-implies.stderr b/tests/ui/const-generics/const-param-has-ty-goal-in-error-implies.stderr index 77bba4945523a..a059ad8c32fa2 100644 --- a/tests/ui/const-generics/const-param-has-ty-goal-in-error-implies.stderr +++ b/tests/ui/const-generics/const-param-has-ty-goal-in-error-implies.stderr @@ -13,7 +13,6 @@ note: required by a bound in `unsatisfied` --> $DIR/const-param-has-ty-goal-in-error-implies.rs:31:8 | LL | fn unsatisfied() - | ----------- required by a bound in this function LL | where LL | T: Foo, | ^^^ required by this bound in `unsatisfied` diff --git a/tests/ui/const-generics/defaults/doesnt_infer.stderr b/tests/ui/const-generics/defaults/doesnt_infer.stderr index ef39cef70cbc2..b9b27019ea239 100644 --- a/tests/ui/const-generics/defaults/doesnt_infer.stderr +++ b/tests/ui/const-generics/defaults/doesnt_infer.stderr @@ -26,7 +26,7 @@ note: required by a const generic parameter in `Foo::::foo` LL | impl Foo { | ^^^^^^^^^^^^ required by this const generic parameter in `Foo::::foo` LL | fn foo() -> Self { - | --- required by a bound in this associated function + | help: consider giving `foo` an explicit type, where the value of const parameter `N` is specified | LL | let foo: Foo = Foo::foo(); diff --git a/tests/ui/const-generics/defaults/wfness.stderr b/tests/ui/const-generics/defaults/wfness.stderr index 8604499392204..42d538817978c 100644 --- a/tests/ui/const-generics/defaults/wfness.stderr +++ b/tests/ui/const-generics/defaults/wfness.stderr @@ -20,7 +20,6 @@ note: required by a bound in `WhereClause` --> $DIR/wfness.rs:8:9 | LL | struct WhereClause - | ----------- required by a bound in this struct LL | where LL | (): Trait; | ^^^^^^^^ required by this bound in `WhereClause` @@ -41,7 +40,6 @@ note: required by a bound in `WhereClause` --> $DIR/wfness.rs:8:9 | LL | struct WhereClause - | ----------- required by a bound in this struct LL | where LL | (): Trait; | ^^^^^^^^ required by this bound in `WhereClause` diff --git a/tests/ui/const-generics/ensure_is_evaluatable.stderr b/tests/ui/const-generics/ensure_is_evaluatable.stderr index 0a03ea49de179..599add4af1596 100644 --- a/tests/ui/const-generics/ensure_is_evaluatable.stderr +++ b/tests/ui/const-generics/ensure_is_evaluatable.stderr @@ -8,7 +8,6 @@ note: required by a bound in `bar` --> $DIR/ensure_is_evaluatable.rs:15:10 | LL | fn bar() -> [(); N] - | --- required by a bound in this function LL | where LL | [(); N + 1]:, | ^^^^^ required by this bound in `bar` diff --git a/tests/ui/const-generics/fn_with_two_const_inputs.stderr b/tests/ui/const-generics/fn_with_two_const_inputs.stderr index 7fb79da2d6143..9c270c549e0fb 100644 --- a/tests/ui/const-generics/fn_with_two_const_inputs.stderr +++ b/tests/ui/const-generics/fn_with_two_const_inputs.stderr @@ -8,7 +8,6 @@ note: required by a bound in `bar` --> $DIR/fn_with_two_const_inputs.rs:18:10 | LL | fn bar() -> [(); N] - | --- required by a bound in this function LL | where LL | [(); N + 1]:, | ^^^^^ required by this bound in `bar` diff --git a/tests/ui/const-generics/generic_const_exprs/adt_wf_hang.stderr b/tests/ui/const-generics/generic_const_exprs/adt_wf_hang.stderr index 1eb2890d4cbcd..c56152e12e9e7 100644 --- a/tests/ui/const-generics/generic_const_exprs/adt_wf_hang.stderr +++ b/tests/ui/const-generics/generic_const_exprs/adt_wf_hang.stderr @@ -8,7 +8,6 @@ note: required by a bound in `S` --> $DIR/adt_wf_hang.rs:11:5 | LL | struct S() - | - required by a bound in this struct LL | where LL | S<{ U }>:; | ^^^^^^^^ required by this bound in `S` diff --git a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr index 3c79cbeb730d5..a7b1c69c21522 100644 --- a/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr +++ b/tests/ui/const-generics/generic_const_exprs/const_kind_expr/issue_114151.stderr @@ -41,7 +41,6 @@ note: required by a bound in `foo` --> $DIR/issue_114151.rs:5:13 | LL | fn foo( - | --- required by a bound in this function LL | _: [u8; { | _____________^ LL | | { diff --git a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr index 1aac357d60e43..5c2d9d22c48f0 100644 --- a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr +++ b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr @@ -8,7 +8,6 @@ note: required by a bound in `test1` --> $DIR/auxiliary/const_evaluatable_lib.rs:5:10 | LL | pub fn test1() -> [u8; std::mem::size_of::() - 1] - | ----- required by a bound in this function LL | where LL | [u8; std::mem::size_of::() - 1]: Sized, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1` @@ -54,7 +53,6 @@ note: required by a bound in `test1` --> $DIR/auxiliary/const_evaluatable_lib.rs:5:10 | LL | pub fn test1() -> [u8; std::mem::size_of::() - 1] - | ----- required by a bound in this function LL | where LL | [u8; std::mem::size_of::() - 1]: Sized, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1` diff --git a/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr b/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr index 6b79b32d13e3b..b64c1c17df601 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-62504.full.stderr @@ -46,7 +46,7 @@ note: required by a const generic parameter in `ArrayHolder::::new` LL | impl ArrayHolder { | ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder::::new` LL | pub const fn new() -> Self { - | --- required by a bound in this associated function + | help: consider giving `array` an explicit type, where the value of const parameter `X` is specified | LL | let mut array: ArrayHolder = ArrayHolder::new(); diff --git a/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr b/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr index c53a6598d34ed..ef4655c8dc21f 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-62504.min.stderr @@ -48,7 +48,7 @@ note: required by a const generic parameter in `ArrayHolder::::new` LL | impl ArrayHolder { | ^^^^^^^^^^^^^^ required by this const generic parameter in `ArrayHolder::::new` LL | pub const fn new() -> Self { - | --- required by a bound in this associated function + | help: consider giving `array` an explicit type, where the value of const parameter `X` is specified | LL | let mut array: ArrayHolder = ArrayHolder::new(); diff --git a/tests/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.full.stderr b/tests/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.full.stderr index 996b75493e618..14d9f70e7611d 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.full.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.full.stderr @@ -10,7 +10,6 @@ note: required by a bound in `Arr` --> $DIR/issue-72819-generic-in-const-eval.rs:8:39 | LL | struct Arr - | --- required by a bound in this struct LL | where Assert::<{N < usize::MAX / 2}>: IsTrue, | ^^^^^^ required by this bound in `Arr` @@ -26,7 +25,6 @@ note: required by a bound in `Arr` --> $DIR/issue-72819-generic-in-const-eval.rs:8:39 | LL | struct Arr - | --- required by a bound in this struct LL | where Assert::<{N < usize::MAX / 2}>: IsTrue, | ^^^^^^ required by this bound in `Arr` diff --git a/tests/ui/const-generics/generic_const_exprs/issue-83765.stderr b/tests/ui/const-generics/generic_const_exprs/issue-83765.stderr index ca6681b635a4a..d73aef53313bc 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-83765.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-83765.stderr @@ -16,6 +16,7 @@ LL | self.reference.size() note: required by a bound in `TensorSize::size` --> $DIR/issue-83765.rs:9:31 | +LL | trait TensorSize: TensorDimension { LL | fn size(&self) -> [usize; Self::DIM]; | ^^^^^^^^^ required by this bound in `TensorSize::size` help: try adding a `where` bound diff --git a/tests/ui/const-generics/generic_const_exprs/obligation-cause.rs b/tests/ui/const-generics/generic_const_exprs/obligation-cause.rs index e7c8e4f667d05..d1b8c0b408006 100644 --- a/tests/ui/const-generics/generic_const_exprs/obligation-cause.rs +++ b/tests/ui/const-generics/generic_const_exprs/obligation-cause.rs @@ -8,7 +8,6 @@ struct Is; impl True for Is {} fn g() -//~^ NOTE required by a bound in this where Is<{ std::mem::size_of::() == 0 }>: True, //~^ NOTE required by a bound in `g` diff --git a/tests/ui/const-generics/generic_const_exprs/obligation-cause.stderr b/tests/ui/const-generics/generic_const_exprs/obligation-cause.stderr index 7f6a154865ceb..d759d349a4121 100644 --- a/tests/ui/const-generics/generic_const_exprs/obligation-cause.stderr +++ b/tests/ui/const-generics/generic_const_exprs/obligation-cause.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/obligation-cause.rs:20:5 + --> $DIR/obligation-cause.rs:19:5 | LL | g::(); | ^^^^^^^^^^^^ expected `false`, found `true` @@ -7,11 +7,10 @@ LL | g::(); = note: expected constant `false` found constant `true` note: required by a bound in `g` - --> $DIR/obligation-cause.rs:13:44 + --> $DIR/obligation-cause.rs:12:44 | LL | fn g() - | - required by a bound in this function -... +LL | where LL | Is<{ std::mem::size_of::() == 0 }>: True, | ^^^^ required by this bound in `g` diff --git a/tests/ui/const-generics/issues/issue-67185-2.stderr b/tests/ui/const-generics/issues/issue-67185-2.stderr index 8a170201832c9..5d055f5cc6843 100644 --- a/tests/ui/const-generics/issues/issue-67185-2.stderr +++ b/tests/ui/const-generics/issues/issue-67185-2.stderr @@ -51,7 +51,6 @@ note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:15:25 | LL | trait Foo - | --- required by a bound in this trait ... LL | ::Quaks: Bar, | ^^^ required by this bound in `Foo` @@ -73,7 +72,6 @@ note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:14:30 | LL | trait Foo - | --- required by a bound in this trait LL | where LL | [::Quaks; 2]: Bar, | ^^^ required by this bound in `Foo` @@ -95,7 +93,6 @@ note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:14:30 | LL | trait Foo - | --- required by a bound in this trait LL | where LL | [::Quaks; 2]: Bar, | ^^^ required by this bound in `Foo` @@ -117,7 +114,6 @@ note: required by a bound in `Foo` --> $DIR/issue-67185-2.rs:15:25 | LL | trait Foo - | --- required by a bound in this trait ... LL | ::Quaks: Bar, | ^^^ required by this bound in `Foo` diff --git a/tests/ui/const-generics/issues/issue-73260.stderr b/tests/ui/const-generics/issues/issue-73260.stderr index c56b45cc8faf1..71d9f2b6abe65 100644 --- a/tests/ui/const-generics/issues/issue-73260.stderr +++ b/tests/ui/const-generics/issues/issue-73260.stderr @@ -10,7 +10,6 @@ note: required by a bound in `Arr` --> $DIR/issue-73260.rs:5:37 | LL | struct Arr - | --- required by a bound in this struct LL | where LL | Assert::<{N < usize::MAX / 2}>: IsTrue, | ^^^^^^ required by this bound in `Arr` @@ -27,7 +26,6 @@ note: required by a bound in `Arr` --> $DIR/issue-73260.rs:5:37 | LL | struct Arr - | --- required by a bound in this struct LL | where LL | Assert::<{N < usize::MAX / 2}>: IsTrue, | ^^^^^^ required by this bound in `Arr` diff --git a/tests/ui/const-generics/issues/issue-79674.stderr b/tests/ui/const-generics/issues/issue-79674.stderr index 595bb6faf8c00..07a532ca0173e 100644 --- a/tests/ui/const-generics/issues/issue-79674.stderr +++ b/tests/ui/const-generics/issues/issue-79674.stderr @@ -10,7 +10,6 @@ note: required by a bound in `requires_distinct` --> $DIR/issue-79674.rs:23:37 | LL | fn requires_distinct(_a: A, _b: B) where - | ----------------- required by a bound in this function LL | A: MiniTypeId, B: MiniTypeId, LL | Lift<{is_same_type::()}>: IsFalse {} | ^^^^^^^ required by this bound in `requires_distinct` diff --git a/tests/ui/const-generics/issues/issue-83765.stderr b/tests/ui/const-generics/issues/issue-83765.stderr index 5a06ee7ddbc03..2e401eb6d5d00 100644 --- a/tests/ui/const-generics/issues/issue-83765.stderr +++ b/tests/ui/const-generics/issues/issue-83765.stderr @@ -61,6 +61,8 @@ LL | if !self.inbounds(index) { note: required by a bound in `TensorSize::inbounds` --> $DIR/issue-83765.rs:14:39 | +LL | trait TensorSize: TensorDimension { +LL | fn size(&self) -> [usize; Self::DIM]; LL | fn inbounds(&self, index: [usize; Self::DIM]) -> bool { | ^^^^^^^^^ required by this bound in `TensorSize::inbounds` help: try adding a `where` bound @@ -86,6 +88,7 @@ LL | let size = self.size(); note: required by a bound in `TensorSize::size` --> $DIR/issue-83765.rs:13:31 | +LL | trait TensorSize: TensorDimension { LL | fn size(&self) -> [usize; Self::DIM]; | ^^^^^^^^^ required by this bound in `TensorSize::size` help: try adding a `where` bound @@ -113,6 +116,7 @@ LL | self.reference.size() note: required by a bound in `TensorSize::size` --> $DIR/issue-83765.rs:13:31 | +LL | trait TensorSize: TensorDimension { LL | fn size(&self) -> [usize; Self::DIM]; | ^^^^^^^^^ required by this bound in `TensorSize::size` help: try adding a `where` bound @@ -138,6 +142,8 @@ LL | self.reference.bget(index).map(&self.closure) note: required by a bound in `Broadcastable::bget` --> $DIR/issue-83765.rs:21:35 | +LL | trait Broadcastable: TensorSize + Sized { +LL | type Element; LL | fn bget(&self, index: [usize; Self::DIM]) -> Option; | ^^^^^^^^^ required by this bound in `Broadcastable::bget` help: try adding a `where` bound diff --git a/tests/ui/const-generics/issues/issue-86530.stderr b/tests/ui/const-generics/issues/issue-86530.stderr index aa8aa4e10a81e..eabdceb835936 100644 --- a/tests/ui/const-generics/issues/issue-86530.stderr +++ b/tests/ui/const-generics/issues/issue-86530.stderr @@ -15,7 +15,6 @@ note: required by a bound in `z` --> $DIR/issue-86530.rs:10:8 | LL | fn z(t: T) - | - required by a bound in this function LL | where LL | T: X, | ^ required by this bound in `z` diff --git a/tests/ui/const-generics/mgca/const-ctor-overflow-eval.stderr b/tests/ui/const-generics/mgca/const-ctor-overflow-eval.stderr index bb393cad567e5..48ff5fb457b5d 100644 --- a/tests/ui/const-generics/mgca/const-ctor-overflow-eval.stderr +++ b/tests/ui/const-generics/mgca/const-ctor-overflow-eval.stderr @@ -8,7 +8,6 @@ note: required by a bound in `S` --> $DIR/const-ctor-overflow-eval.rs:14:5 | LL | struct S() - | - required by a bound in this struct LL | where LL | S<{ U }>:; | ^^^^^^^^ required by this bound in `S` @@ -23,7 +22,6 @@ note: required by a bound in `S` --> $DIR/const-ctor-overflow-eval.rs:14:5 | LL | struct S() - | - required by a bound in this struct LL | where LL | S<{ U }>:; | ^^^^^^^^ required by this bound in `S` @@ -39,7 +37,6 @@ note: required by a bound in `S` --> $DIR/const-ctor-overflow-eval.rs:14:5 | LL | struct S() - | - required by a bound in this struct LL | where LL | S<{ U }>:; | ^^^^^^^^ required by this bound in `S` @@ -55,7 +52,6 @@ note: required by a bound in `S` --> $DIR/const-ctor-overflow-eval.rs:14:5 | LL | struct S() - | - required by a bound in this struct LL | where LL | S<{ U }>:; | ^^^^^^^^ required by this bound in `S` @@ -70,7 +66,6 @@ note: required by a bound in `S` --> $DIR/const-ctor-overflow-eval.rs:14:5 | LL | struct S() - | - required by a bound in this struct LL | where LL | S<{ U }>:; | ^^^^^^^^ required by this bound in `S` diff --git a/tests/ui/const-generics/occurs-check/unused-substs-1.stderr b/tests/ui/const-generics/occurs-check/unused-substs-1.stderr index 9fd48b1472e40..1dce0f0ae9330 100644 --- a/tests/ui/const-generics/occurs-check/unused-substs-1.stderr +++ b/tests/ui/const-generics/occurs-check/unused-substs-1.stderr @@ -14,7 +14,6 @@ note: required by a bound in `A` --> $DIR/unused-substs-1.rs:9:11 | LL | struct A - | - required by a bound in this unit struct LL | where LL | A: Bar; | ^^^^^^ required by this bound in `A` diff --git a/tests/ui/consts/ct-var-in-collect_all_mismatches.stderr b/tests/ui/consts/ct-var-in-collect_all_mismatches.stderr index 74ec052f6ecb7..b5c8d335e85d6 100644 --- a/tests/ui/consts/ct-var-in-collect_all_mismatches.stderr +++ b/tests/ui/consts/ct-var-in-collect_all_mismatches.stderr @@ -8,7 +8,6 @@ note: required by a bound in `Foo::::unsatisfied` --> $DIR/ct-var-in-collect_all_mismatches.rs:15:12 | LL | fn unsatisfied(self) - | ----------- required by a bound in this associated function LL | where LL | T: Bar, | ^^^^^^ required by this bound in `Foo::::unsatisfied` diff --git a/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr index 1b640ebe2b894..77949cdb22803 100644 --- a/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr +++ b/tests/ui/coroutine/coroutine-yielding-or-returning-itself.stderr @@ -19,7 +19,6 @@ note: required by a bound in `want_cyclic_coroutine_return` --> $DIR/coroutine-yielding-or-returning-itself.rs:10:36 | LL | pub fn want_cyclic_coroutine_return(_: T) - | ---------------------------- required by a bound in this function LL | where T: Coroutine | ^^^^^^^^^^ required by this bound in `want_cyclic_coroutine_return` @@ -44,7 +43,6 @@ note: required by a bound in `want_cyclic_coroutine_yield` --> $DIR/coroutine-yielding-or-returning-itself.rs:23:24 | LL | pub fn want_cyclic_coroutine_yield(_: T) - | --------------------------- required by a bound in this function LL | where T: Coroutine | ^^^^^^^^^ required by this bound in `want_cyclic_coroutine_yield` diff --git a/tests/ui/delegation/generics/const-predicates-ice-158675.stderr b/tests/ui/delegation/generics/const-predicates-ice-158675.stderr index 6dbf017294822..7e99c18b5be37 100644 --- a/tests/ui/delegation/generics/const-predicates-ice-158675.stderr +++ b/tests/ui/delegation/generics/const-predicates-ice-158675.stderr @@ -10,7 +10,7 @@ note: required by a const generic parameter in `original_ice::Trait::fun` LL | trait Trait { | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::fun` LL | fn fun(); - | --- required by a bound in this associated function + | error: the constant `N` is not of type `bool` --> $DIR/const-predicates-ice-158675.rs:24:29 @@ -24,7 +24,7 @@ note: required by a const generic parameter in `with_child_constants::Trait::fun LL | trait Trait { | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::fun` LL | fn fun(); - | --- required by a bound in this associated function + | error: the constant `N` is not of type `char` --> $DIR/const-predicates-ice-158675.rs:24:39 @@ -35,6 +35,7 @@ LL | reuse Trait::, N>::fun::; note: required by a const generic parameter in `with_child_constants::Trait::fun` --> $DIR/const-predicates-ice-158675.rs:20:16 | +LL | trait Trait { LL | fn fun(); | ^^^^^^^^^^^^^ required by this const generic parameter in `Trait::fun` diff --git a/tests/ui/delegation/generics/free-fn-to-free-fn.stderr b/tests/ui/delegation/generics/free-fn-to-free-fn.stderr index 3032dd53a50b7..b0f73bb725110 100644 --- a/tests/ui/delegation/generics/free-fn-to-free-fn.stderr +++ b/tests/ui/delegation/generics/free-fn-to-free-fn.stderr @@ -27,7 +27,7 @@ LL | pub fn bounds(_: T) {} | ^^^^^ required by this bound in `bounds` ... LL | reuse to_reuse::bounds; - | ------ required by a bound in this function + | help: consider annotating `S` with `#[derive(Clone)]` | LL + #[derive(Clone)] diff --git a/tests/ui/delegation/generics/free-fn-to-trait-method.stderr b/tests/ui/delegation/generics/free-fn-to-trait-method.stderr index 8b2e603b4c9b2..a50b9f17dae23 100644 --- a/tests/ui/delegation/generics/free-fn-to-trait-method.stderr +++ b/tests/ui/delegation/generics/free-fn-to-trait-method.stderr @@ -13,7 +13,7 @@ LL | fn foo(&self, t: T, u: U) where T: Copy {} | ^^^^ required by this bound in `bounds` ... LL | reuse bounds::Trait::foo as bounds; - | ------ required by a bound in this function + | help: consider annotating `S` with `#[derive(Copy)]` | LL + #[derive(Copy)] @@ -35,7 +35,7 @@ LL | fn foo(&self, t: T, u: U) where T: Copy {} | ^^^^^ required by this bound in `bounds` ... LL | reuse bounds::Trait::foo as bounds; - | ------ required by a bound in this function + | help: consider annotating `U` with `#[derive(Clone)]` | LL + #[derive(Clone)] diff --git a/tests/ui/delegation/generics/free-to-trait-self-reuse.stderr b/tests/ui/delegation/generics/free-to-trait-self-reuse.stderr index a37a1b777d4d1..8284034a36338 100644 --- a/tests/ui/delegation/generics/free-to-trait-self-reuse.stderr +++ b/tests/ui/delegation/generics/free-to-trait-self-reuse.stderr @@ -18,7 +18,6 @@ note: required by a bound in `Trait` --> $DIR/free-to-trait-self-reuse.rs:7:11 | LL | trait Trait<'a, T, const X: usize> - | ----- required by a bound in this trait LL | where LL | Self: Bound + Sized, | ^^^^^^^^ required by this bound in `Trait` @@ -57,11 +56,13 @@ LL | impl Bound for usize {} note: required by a bound in `Trait::method` --> $DIR/free-to-trait-self-reuse.rs:7:11 | +LL | trait Trait<'a, T, const X: usize> +LL | where LL | Self: Bound + Sized, | ^^^^^^^^ required by this bound in `Trait::method` LL | { LL | fn method(&self, x: U) {} - | ------ required by a bound in this associated function + | error[E0107]: function takes 3 generic arguments but 2 generic arguments were supplied --> $DIR/free-to-trait-self-reuse.rs:43:5 diff --git a/tests/ui/delegation/generics/free-to-trait-static-reuse.stderr b/tests/ui/delegation/generics/free-to-trait-static-reuse.stderr index 04f5e60044cdc..62484ec134be4 100644 --- a/tests/ui/delegation/generics/free-to-trait-static-reuse.stderr +++ b/tests/ui/delegation/generics/free-to-trait-static-reuse.stderr @@ -18,7 +18,6 @@ note: required by a bound in `Trait` --> $DIR/free-to-trait-static-reuse.rs:9:11 | LL | trait Trait<'a, T, const X: usize> - | ----- required by a bound in this trait LL | where LL | Self: Bound, | ^^^^^^^^ required by this bound in `Trait` @@ -57,11 +56,13 @@ LL | impl Bound for usize {} note: required by a bound in `Trait::static_method` --> $DIR/free-to-trait-static-reuse.rs:9:11 | +LL | trait Trait<'a, T, const X: usize> +LL | where LL | Self: Bound, | ^^^^^^^^ required by this bound in `Trait::static_method` LL | { LL | fn static_method<'c: 'c, U, const B: bool>(x: usize) {} - | ------------- required by a bound in this associated function + | error: aborting due to 3 previous errors diff --git a/tests/ui/delegation/generics/impl-to-trait-method.stderr b/tests/ui/delegation/generics/impl-to-trait-method.stderr index 34259d49a1bd9..cb1c2d55c09e9 100644 --- a/tests/ui/delegation/generics/impl-to-trait-method.stderr +++ b/tests/ui/delegation/generics/impl-to-trait-method.stderr @@ -40,8 +40,8 @@ LL | trait Trait0 {} note: required by a bound in `Trait1::foo` --> $DIR/impl-to-trait-method.rs:11:19 | +LL | trait Trait1 { LL | fn foo(&self) - | --- required by a bound in this associated function ... LL | Self: Trait0, | ^^^^^^ required by this bound in `Trait1::foo` diff --git a/tests/ui/delegation/inherent-impls-parent-generics.stderr b/tests/ui/delegation/inherent-impls-parent-generics.stderr index b1001e193a9cd..4e5850338b600 100644 --- a/tests/ui/delegation/inherent-impls-parent-generics.stderr +++ b/tests/ui/delegation/inherent-impls-parent-generics.stderr @@ -101,7 +101,7 @@ note: required by a const generic parameter in `E::<'a, A, C>::foo_static` LL | impl<'a, 'b, 'c, A: 'a, const C: usize> E<'a, A, C> { | ^^^^^^^^^^^^^^ required by this const generic parameter in `E::<'a, A, C>::foo_static` LL | fn foo_static<'d: 'd, 'e, T, const B: bool>() {} - | ---------- required by a bound in this associated function + | help: consider specifying the generic arguments | LL - reuse E::foo_static as e; @@ -171,7 +171,7 @@ note: required by a const generic parameter in `E::<'a, A, C>::foo_static` LL | impl<'a, 'b, 'c, A: 'a, const C: usize> E<'a, A, C> { | ^^^^^^^^^^^^^^ required by this const generic parameter in `E::<'a, A, C>::foo_static` LL | fn foo_static<'d: 'd, 'e, T, const B: bool>() {} - | ---------- required by a bound in this associated function + | help: consider specifying the generic arguments | LL - reuse E::foo_static::<'static, (), true> as e2; @@ -220,7 +220,7 @@ note: required by a const generic parameter in `E::<'a, A, C>::foo_static` LL | impl<'a, 'b, 'c, A: 'a, const C: usize> E<'a, A, C> { | ^^^^^^^^^^^^^^ required by this const generic parameter in `E::<'a, A, C>::foo_static` LL | fn foo_static<'d: 'd, 'e, T, const B: bool>() {} - | ---------- required by a bound in this associated function + | error[E0284]: type annotations needed --> $DIR/inherent-impls-parent-generics.rs:37:23 @@ -284,7 +284,7 @@ note: required by a const generic parameter in `S::::foo_static` LL | impl<'a, 'b, 'c, A, const C: usize> S { | ^^^^^^^^^^^^^^ required by this const generic parameter in `S::::foo_static` LL | fn foo_static<'d: 'd, 'e, T, const B: bool>() {} - | ---------- required by a bound in this associated function + | help: consider specifying the generic arguments | LL | reuse S::::foo_static as s; @@ -352,7 +352,7 @@ note: required by a const generic parameter in `S::::foo_static` LL | impl<'a, 'b, 'c, A, const C: usize> S { | ^^^^^^^^^^^^^^ required by this const generic parameter in `S::::foo_static` LL | fn foo_static<'d: 'd, 'e, T, const B: bool>() {} - | ---------- required by a bound in this associated function + | help: consider specifying the generic arguments | LL | reuse S::::foo_static::<'static, (), true> as s2; @@ -400,7 +400,7 @@ note: required by a const generic parameter in `S::::foo_static` LL | impl<'a, 'b, 'c, A, const C: usize> S { | ^^^^^^^^^^^^^^ required by this const generic parameter in `S::::foo_static` LL | fn foo_static<'d: 'd, 'e, T, const B: bool>() {} - | ---------- required by a bound in this associated function + | error[E0284]: type annotations needed --> $DIR/inherent-impls-parent-generics.rs:78:19 diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr index fb5a3e2172da5..c13e25c7a77ad 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.current.stderr @@ -28,8 +28,8 @@ LL | struct X; note: required by a bound in `Ext::foo` --> $DIR/as_expression.rs:79:23 | +LL | trait Ext { LL | fn foo(self) -> Self - | --- required by a bound in this associated function LL | where LL | Self: Sized + A; | ^ required by this bound in `Ext::foo` diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr index d47424abcf10d..12a9743ca3e5a 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/as_expression.next.stderr @@ -16,8 +16,8 @@ LL | impl AsExpression for &'_ str { note: required by a bound in `Foo::check` --> $DIR/as_expression.rs:47:12 | +LL | trait Foo: Expression + Sized { LL | fn check(&self, _: T) -> ::SqlType>>::Expression - | ----- required by a bound in this associated function LL | where LL | T: AsExpression, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::check` @@ -36,8 +36,8 @@ LL | struct X; note: required by a bound in `Ext::foo` --> $DIR/as_expression.rs:79:23 | +LL | trait Ext { LL | fn foo(self) -> Self - | --- required by a bound in this associated function LL | where LL | Self: Sized + A; | ^ required by this bound in `Ext::foo` diff --git a/tests/ui/diagnostic_namespace/do_not_recommend/single-impl-candidate.stderr b/tests/ui/diagnostic_namespace/do_not_recommend/single-impl-candidate.stderr index a0d0e73a1172b..04bbb56442f6e 100644 --- a/tests/ui/diagnostic_namespace/do_not_recommend/single-impl-candidate.stderr +++ b/tests/ui/diagnostic_namespace/do_not_recommend/single-impl-candidate.stderr @@ -12,7 +12,6 @@ note: required by a bound in `foo` --> $DIR/single-impl-candidate.rs:14:8 | LL | fn foo<'a, T>(_t: T) - | --- required by a bound in this function LL | where LL | T: Into<&'a str>, | ^^^^^^^^^^^^^ required by this bound in `foo` diff --git a/tests/ui/drop/dropck-normalize-errors.nll.stderr b/tests/ui/drop/dropck-normalize-errors.nll.stderr index a4c13b03d2f72..e650af44cab5c 100644 --- a/tests/ui/drop/dropck-normalize-errors.nll.stderr +++ b/tests/ui/drop/dropck-normalize-errors.nll.stderr @@ -50,6 +50,7 @@ LL | pub struct BDecoder { note: required by a bound in `Decode::Decoder` --> $DIR/dropck-normalize-errors.rs:9:5 | +LL | trait Decode<'a> { LL | type Decoder; | ^^^^^^^^^^^^^ required by this bound in `Decode::Decoder` help: consider relaxing the implicit `Sized` restriction diff --git a/tests/ui/drop/dropck-normalize-errors.polonius.stderr b/tests/ui/drop/dropck-normalize-errors.polonius.stderr index a4c13b03d2f72..e650af44cab5c 100644 --- a/tests/ui/drop/dropck-normalize-errors.polonius.stderr +++ b/tests/ui/drop/dropck-normalize-errors.polonius.stderr @@ -50,6 +50,7 @@ LL | pub struct BDecoder { note: required by a bound in `Decode::Decoder` --> $DIR/dropck-normalize-errors.rs:9:5 | +LL | trait Decode<'a> { LL | type Decoder; | ^^^^^^^^^^^^^ required by this bound in `Decode::Decoder` help: consider relaxing the implicit `Sized` restriction diff --git a/tests/ui/dropck/dropck-only-error-gat.stderr b/tests/ui/dropck/dropck-only-error-gat.stderr index 53982c0826a74..bee5caa6f2481 100644 --- a/tests/ui/dropck/dropck-only-error-gat.stderr +++ b/tests/ui/dropck/dropck-only-error-gat.stderr @@ -7,6 +7,7 @@ LL | pub fn new() -> Self { note: required by a bound in `GatTrait::Gat` --> $DIR/dropck-only-error-gat.rs:14:17 | +LL | pub trait GatTrait { LL | type Gat; | ^^^^^ required by this bound in `GatTrait::Gat` diff --git a/tests/ui/dyn-compatibility/assoc_type_bounds_implicit_sized.stderr b/tests/ui/dyn-compatibility/assoc_type_bounds_implicit_sized.stderr index 9bb770ce43199..a80e78f567d10 100644 --- a/tests/ui/dyn-compatibility/assoc_type_bounds_implicit_sized.stderr +++ b/tests/ui/dyn-compatibility/assoc_type_bounds_implicit_sized.stderr @@ -8,6 +8,7 @@ LL | type Item = dyn Trait; note: required by a bound in `TraitWithAType::Item` --> $DIR/assoc_type_bounds_implicit_sized.rs:4:5 | +LL | trait TraitWithAType { LL | type Item; | ^^^^^^^^^^ required by this bound in `TraitWithAType::Item` help: consider relaxing the implicit `Sized` restriction diff --git a/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.stderr b/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.stderr index fe048c87775a9..26f00fc72f868 100644 --- a/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.stderr +++ b/tests/ui/dyn-compatibility/assoc_type_bounds_sized_used.stderr @@ -9,8 +9,8 @@ LL | let _ = ::Bar::default(); note: required by a bound in `Bop::Bar` --> $DIR/assoc_type_bounds_sized_used.rs:7:15 | +LL | trait Bop { LL | type Bar: Default - | --- required by a bound in this associated type LL | where LL | Self: Sized; | ^^^^^ required by this bound in `Bop::Bar` @@ -35,8 +35,8 @@ LL | let _ = ::Bar::default(); note: required by a bound in `Bop::Bar` --> $DIR/assoc_type_bounds_sized_used.rs:7:15 | +LL | trait Bop { LL | type Bar: Default - | --- required by a bound in this associated type LL | where LL | Self: Sized; | ^^^^^ required by this bound in `Bop::Bar` @@ -61,8 +61,8 @@ LL | let _ = ::Bar::default(); note: required by a bound in `Bop::Bar` --> $DIR/assoc_type_bounds_sized_used.rs:7:15 | +LL | trait Bop { LL | type Bar: Default - | --- required by a bound in this associated type LL | where LL | Self: Sized; | ^^^^^ required by this bound in `Bop::Bar` diff --git a/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.current.stderr b/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.current.stderr index 8779bab593a29..a9ea102e4a9be 100644 --- a/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.current.stderr +++ b/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.current.stderr @@ -12,6 +12,7 @@ LL | impl Baz for i32 where T::Bar<()>: Eq {} note: required by a bound in `Foo::Bar` --> $DIR/assume-gat-normalization-for-nested-goals.rs:9:18 | +LL | trait Foo { LL | type Bar: Baz = i32; | ^^^^^^^^^ required by this bound in `Foo::Bar` help: consider further restricting the associated type diff --git a/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.next.stderr b/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.next.stderr index 8779bab593a29..a9ea102e4a9be 100644 --- a/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.next.stderr +++ b/tests/ui/generic-associated-types/assume-gat-normalization-for-nested-goals.next.stderr @@ -12,6 +12,7 @@ LL | impl Baz for i32 where T::Bar<()>: Eq {} note: required by a bound in `Foo::Bar` --> $DIR/assume-gat-normalization-for-nested-goals.rs:9:18 | +LL | trait Foo { LL | type Bar: Baz = i32; | ^^^^^^^^^ required by this bound in `Foo::Bar` help: consider further restricting the associated type diff --git a/tests/ui/generic-associated-types/cross-crate-bounds.stderr b/tests/ui/generic-associated-types/cross-crate-bounds.stderr index ebd733c2ef1f8..05df8baeea09c 100644 --- a/tests/ui/generic-associated-types/cross-crate-bounds.stderr +++ b/tests/ui/generic-associated-types/cross-crate-bounds.stderr @@ -7,6 +7,7 @@ LL | type Bar = (); note: required by a bound in `foo_defn::Foo::Bar` --> $DIR/auxiliary/foo_defn.rs:4:15 | +LL | pub trait Foo { LL | type Bar: AsRef<()>; | ^^^^^^^^^ required by this bound in `Foo::Bar` diff --git a/tests/ui/generic-associated-types/issue-101020.stderr b/tests/ui/generic-associated-types/issue-101020.stderr index 9c3753c2d1809..302d3da4f9785 100644 --- a/tests/ui/generic-associated-types/issue-101020.stderr +++ b/tests/ui/generic-associated-types/issue-101020.stderr @@ -17,8 +17,9 @@ LL | impl<'a, T, F: 'a> FuncInput<'a, F> for T where F: Foo {} note: required by a bound in `LendingIterator::consume` --> $DIR/issue-101020.rs:9:33 | +LL | pub trait LendingIterator { +... LL | fn consume(self, _f: F) - | ------- required by a bound in this associated function ... LL | for<'a> Self::Item<'a>: FuncInput<'a, Self::Item<'a>>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `LendingIterator::consume` diff --git a/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr index 674e28829073f..f58d06ab04769 100644 --- a/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr +++ b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr @@ -8,6 +8,7 @@ LL | type Pointer = dyn Deref; note: required by a bound in `PointerFamily::Pointer` --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:4:5 | +LL | trait PointerFamily { LL | type Pointer: Deref; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `PointerFamily::Pointer` help: consider relaxing the implicit `Sized` restriction diff --git a/tests/ui/generic-associated-types/issue-68641-check-gat-bounds.stderr b/tests/ui/generic-associated-types/issue-68641-check-gat-bounds.stderr index ac91bdcf3e932..501693efc7e15 100644 --- a/tests/ui/generic-associated-types/issue-68641-check-gat-bounds.stderr +++ b/tests/ui/generic-associated-types/issue-68641-check-gat-bounds.stderr @@ -7,6 +7,7 @@ LL | type Item<'a> = T; note: required by a bound in `UnsafeCopy::Item` --> $DIR/issue-68641-check-gat-bounds.rs:4:20 | +LL | trait UnsafeCopy { LL | type Item<'a>: Copy; | ^^^^ required by this bound in `UnsafeCopy::Item` help: consider restricting type parameter `T` with trait `Copy` diff --git a/tests/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr b/tests/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr index 7821560d96090..a12f51a47eafb 100644 --- a/tests/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr +++ b/tests/ui/generic-associated-types/issue-68642-broken-llvm-ir.stderr @@ -8,6 +8,7 @@ LL | type F<'a> = Self; note: required by a bound in `Fun::F` --> $DIR/issue-68642-broken-llvm-ir.rs:4:17 | +LL | trait Fun { LL | type F<'a>: Fn() -> u32; | ^^^^^^^^^^^ required by this bound in `Fun::F` help: consider restricting type parameter `T` with trait `Fn` diff --git a/tests/ui/generic-associated-types/issue-68643-broken-mir.stderr b/tests/ui/generic-associated-types/issue-68643-broken-mir.stderr index 99b56dd061933..8c2ba9e66e94e 100644 --- a/tests/ui/generic-associated-types/issue-68643-broken-mir.stderr +++ b/tests/ui/generic-associated-types/issue-68643-broken-mir.stderr @@ -8,6 +8,7 @@ LL | type F<'a> = Self; note: required by a bound in `Fun::F` --> $DIR/issue-68643-broken-mir.rs:4:17 | +LL | trait Fun { LL | type F<'a>: Fn() -> u32; | ^^^^^^^^^^^ required by this bound in `Fun::F` help: consider restricting type parameter `T` with trait `Fn` diff --git a/tests/ui/generic-associated-types/issue-68644-codegen-selection.stderr b/tests/ui/generic-associated-types/issue-68644-codegen-selection.stderr index 4537091a60915..8d347ace78176 100644 --- a/tests/ui/generic-associated-types/issue-68644-codegen-selection.stderr +++ b/tests/ui/generic-associated-types/issue-68644-codegen-selection.stderr @@ -8,6 +8,7 @@ LL | type F<'a> = Self; note: required by a bound in `Fun::F` --> $DIR/issue-68644-codegen-selection.rs:4:17 | +LL | trait Fun { LL | type F<'a>: Fn() -> u32; | ^^^^^^^^^^^ required by this bound in `Fun::F` help: consider restricting type parameter `T` with trait `Fn` diff --git a/tests/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr b/tests/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr index cc324f91d75eb..750c4005bc607 100644 --- a/tests/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr +++ b/tests/ui/generic-associated-types/issue-68645-codegen-fulfillment.stderr @@ -8,6 +8,7 @@ LL | type F<'a> = Self; note: required by a bound in `Fun::F` --> $DIR/issue-68645-codegen-fulfillment.rs:4:17 | +LL | trait Fun { LL | type F<'a>: Fn() -> u32; | ^^^^^^^^^^^ required by this bound in `Fun::F` help: consider restricting type parameter `T` with trait `Fn` diff --git a/tests/ui/generic-associated-types/issue-68656-unsized-values.stderr b/tests/ui/generic-associated-types/issue-68656-unsized-values.stderr index ecb337bbceb91..f3161fb5c7803 100644 --- a/tests/ui/generic-associated-types/issue-68656-unsized-values.stderr +++ b/tests/ui/generic-associated-types/issue-68656-unsized-values.stderr @@ -11,6 +11,7 @@ LL | type Item<'a> = T; note: required by a bound in `UnsafeCopy::Item` --> $DIR/issue-68656-unsized-values.rs:4:36 | +LL | trait UnsafeCopy { LL | type Item<'a>: std::ops::Deref; | ^^^^^^^^^^ required by this bound in `UnsafeCopy::Item` help: consider further restricting this bound diff --git a/tests/ui/generic-associated-types/issue-74816.current.stderr b/tests/ui/generic-associated-types/issue-74816.current.stderr index 335486c6538c1..e7b7c56a42fe8 100644 --- a/tests/ui/generic-associated-types/issue-74816.current.stderr +++ b/tests/ui/generic-associated-types/issue-74816.current.stderr @@ -7,6 +7,7 @@ LL | type Associated: Trait1 = Self; note: required by a bound in `Trait2::Associated` --> $DIR/issue-74816.rs:12:22 | +LL | trait Trait2 { LL | type Associated: Trait1 = Self; | ^^^^^^ required by this bound in `Trait2::Associated` help: consider further restricting `Self` @@ -23,6 +24,7 @@ LL | type Associated: Trait1 = Self; note: required by a bound in `Trait2::Associated` --> $DIR/issue-74816.rs:12:5 | +LL | trait Trait2 { LL | type Associated: Trait1 = Self; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Trait2::Associated` help: consider further restricting `Self` diff --git a/tests/ui/generic-associated-types/issue-74816.next.stderr b/tests/ui/generic-associated-types/issue-74816.next.stderr index 335486c6538c1..e7b7c56a42fe8 100644 --- a/tests/ui/generic-associated-types/issue-74816.next.stderr +++ b/tests/ui/generic-associated-types/issue-74816.next.stderr @@ -7,6 +7,7 @@ LL | type Associated: Trait1 = Self; note: required by a bound in `Trait2::Associated` --> $DIR/issue-74816.rs:12:22 | +LL | trait Trait2 { LL | type Associated: Trait1 = Self; | ^^^^^^ required by this bound in `Trait2::Associated` help: consider further restricting `Self` @@ -23,6 +24,7 @@ LL | type Associated: Trait1 = Self; note: required by a bound in `Trait2::Associated` --> $DIR/issue-74816.rs:12:5 | +LL | trait Trait2 { LL | type Associated: Trait1 = Self; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Trait2::Associated` help: consider further restricting `Self` diff --git a/tests/ui/generic-associated-types/issue-74824.current.stderr b/tests/ui/generic-associated-types/issue-74824.current.stderr index 3a72db27097f7..8d5499db2d75d 100644 --- a/tests/ui/generic-associated-types/issue-74824.current.stderr +++ b/tests/ui/generic-associated-types/issue-74824.current.stderr @@ -7,6 +7,7 @@ LL | type Copy: Copy = Box; note: required by a bound in `UnsafeCopy::Copy` --> $DIR/issue-74824.rs:10:19 | +LL | trait UnsafeCopy { LL | type Copy: Copy = Box; | ^^^^ required by this bound in `UnsafeCopy::Copy` @@ -21,6 +22,7 @@ LL | type Copy: Copy = Box; note: required by a bound in `UnsafeCopy::Copy` --> $DIR/issue-74824.rs:10:19 | +LL | trait UnsafeCopy { LL | type Copy: Copy = Box; | ^^^^ required by this bound in `UnsafeCopy::Copy` help: consider restricting type parameter `T` with trait `Clone` diff --git a/tests/ui/generic-associated-types/issue-74824.next.stderr b/tests/ui/generic-associated-types/issue-74824.next.stderr index 3a72db27097f7..8d5499db2d75d 100644 --- a/tests/ui/generic-associated-types/issue-74824.next.stderr +++ b/tests/ui/generic-associated-types/issue-74824.next.stderr @@ -7,6 +7,7 @@ LL | type Copy: Copy = Box; note: required by a bound in `UnsafeCopy::Copy` --> $DIR/issue-74824.rs:10:19 | +LL | trait UnsafeCopy { LL | type Copy: Copy = Box; | ^^^^ required by this bound in `UnsafeCopy::Copy` @@ -21,6 +22,7 @@ LL | type Copy: Copy = Box; note: required by a bound in `UnsafeCopy::Copy` --> $DIR/issue-74824.rs:10:19 | +LL | trait UnsafeCopy { LL | type Copy: Copy = Box; | ^^^^ required by this bound in `UnsafeCopy::Copy` help: consider restricting type parameter `T` with trait `Clone` diff --git a/tests/ui/generic-associated-types/issue-79636-1.stderr b/tests/ui/generic-associated-types/issue-79636-1.stderr index c31064dec6296..fdcd5645f377a 100644 --- a/tests/ui/generic-associated-types/issue-79636-1.stderr +++ b/tests/ui/generic-associated-types/issue-79636-1.stderr @@ -47,7 +47,6 @@ note: required by a bound in `join` --> $DIR/issue-79636-1.rs:13:13 | LL | fn join(outer: MOuter) -> MOuter::Wrapped - | ---- required by a bound in this function LL | where LL | MOuter: Monad, | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `join` diff --git a/tests/ui/generic-associated-types/issue-87429-associated-type-default.stderr b/tests/ui/generic-associated-types/issue-87429-associated-type-default.stderr index c85b72fbfe11b..fedffd8bc3907 100644 --- a/tests/ui/generic-associated-types/issue-87429-associated-type-default.stderr +++ b/tests/ui/generic-associated-types/issue-87429-associated-type-default.stderr @@ -8,6 +8,8 @@ LL | type Member<'a>: for<'b> PartialEq> = Foo; note: required by a bound in `Family2::Member` --> $DIR/issue-87429-associated-type-default.rs:13:22 | +LL | trait Family2 { +LL | // Not fine, not Foo: PartialEq LL | type Member<'a>: for<'b> PartialEq> = Foo; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Family2::Member` help: consider annotating `Foo` with `#[derive(PartialEq)]` diff --git a/tests/ui/generic-associated-types/issue-87429-specialization.stderr b/tests/ui/generic-associated-types/issue-87429-specialization.stderr index dbe97bdb74318..91263af3e071e 100644 --- a/tests/ui/generic-associated-types/issue-87429-specialization.stderr +++ b/tests/ui/generic-associated-types/issue-87429-specialization.stderr @@ -8,6 +8,7 @@ LL | default type Member<'a> = Foo; note: required by a bound in `Family::Member` --> $DIR/issue-87429-specialization.rs:6:22 | +LL | trait Family { LL | type Member<'a>: for<'b> PartialEq>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Family::Member` help: consider annotating `Foo` with `#[derive(PartialEq)]` diff --git a/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.stderr b/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.stderr index 57bff7c9e054f..3155d78210c95 100644 --- a/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.stderr +++ b/tests/ui/generic-associated-types/multiple-type-params-with-unmet-bounds.stderr @@ -7,6 +7,7 @@ LL | let _: <() as Trait>::P; note: required by a bound in `Trait::P` --> $DIR/multiple-type-params-with-unmet-bounds.rs:2:15 | +LL | trait Trait { LL | type P; | ^^^^ required by this bound in `Trait::P` diff --git a/tests/ui/generic-associated-types/own-bound-span.stderr b/tests/ui/generic-associated-types/own-bound-span.stderr index 7c34a0acdbe08..4d0688111e0d0 100644 --- a/tests/ui/generic-associated-types/own-bound-span.stderr +++ b/tests/ui/generic-associated-types/own-bound-span.stderr @@ -7,6 +7,7 @@ LL | let _: ::P; note: required by a bound in `D::P` --> $DIR/own-bound-span.rs:4:15 | +LL | trait D { LL | type P; | ^^^^ required by this bound in `D::P` diff --git a/tests/ui/generic-associated-types/type-param-defaults.stderr b/tests/ui/generic-associated-types/type-param-defaults.stderr index 87e9a4d779485..76adedeee782a 100644 --- a/tests/ui/generic-associated-types/type-param-defaults.stderr +++ b/tests/ui/generic-associated-types/type-param-defaults.stderr @@ -31,7 +31,6 @@ note: required by a bound in `foo` --> $DIR/type-param-defaults.rs:25:14 | LL | fn foo() - | --- required by a bound in this function LL | where LL | T: Trait, | ^^^^^^^^^^^ required by this bound in `foo` @@ -51,7 +50,6 @@ note: required by a bound in `foo` --> $DIR/type-param-defaults.rs:26:15 | LL | fn foo() - | --- required by a bound in this function ... LL | T::Assoc: Other { | ^^^^^ required by this bound in `foo` diff --git a/tests/ui/generic-const-items/trivially-unsatisfied-bounds.mentioned.stderr b/tests/ui/generic-const-items/trivially-unsatisfied-bounds.mentioned.stderr index d0d65a030841c..45182d08d4b5d 100644 --- a/tests/ui/generic-const-items/trivially-unsatisfied-bounds.mentioned.stderr +++ b/tests/ui/generic-const-items/trivially-unsatisfied-bounds.mentioned.stderr @@ -16,7 +16,6 @@ note: required by a bound in `UNUSABLE` --> $DIR/trivially-unsatisfied-bounds.rs:19:26 | LL | const UNUSABLE: () = () - | -------- required by a bound in this constant LL | where LL | for<'_delay> String: Copy; | ^^^^ required by this bound in `UNUSABLE` diff --git a/tests/ui/generic-const-items/unsatisfied-bounds.stderr b/tests/ui/generic-const-items/unsatisfied-bounds.stderr index 06cd935fae4c0..bb18ad92b9bd6 100644 --- a/tests/ui/generic-const-items/unsatisfied-bounds.stderr +++ b/tests/ui/generic-const-items/unsatisfied-bounds.stderr @@ -20,7 +20,6 @@ note: required by a bound in `K` --> $DIR/unsatisfied-bounds.rs:12:17 | LL | const K: () = () - | - required by a bound in this constant LL | where LL | Infallible: From; | ^^^^^^^ required by this bound in `K` @@ -34,8 +33,8 @@ LL | let _ = <() as Trait>>::A; note: required by a bound in `Trait::A` --> $DIR/unsatisfied-bounds.rs:17:12 | +LL | trait Trait

{ LL | const A: u32 - | - required by a bound in this associated constant LL | where LL | P: Copy; | ^^^^ required by this bound in `Trait::A` @@ -49,8 +48,9 @@ LL | let _ = <() as Trait<&'static str>>::B::<()>; note: required by a bound in `Trait::B` --> $DIR/unsatisfied-bounds.rs:21:21 | +LL | trait Trait

{ - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a, P: std::fmt::Debug> Diagnostic<'a> for AssertLint

{ + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new( dcx, level, @@ -218,7 +218,7 @@ pub(crate) struct UnusedAssignOverwrite { } impl Subdiagnostic for UnusedAssignOverwrite { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { diag.span_label(self.assigned_span, "this value is reassigned later and never used"); diag.span_label( self.overwrite_span, @@ -297,7 +297,7 @@ pub(crate) struct UnusedVariableStringInterp { } impl Subdiagnostic for UnusedVariableStringInterp { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { diag.span_label( self.lit, msg!("you might have meant to use string interpolation in this string literal"), @@ -338,8 +338,8 @@ pub(crate) struct MustNotSupend<'a, 'tcx> { } // Needed for def_path_str -impl<'a> Diagnostic<'a, ()> for MustNotSupend<'_, '_> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for MustNotSupend<'_, '_> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new( dcx, level, diff --git a/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs b/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs index a31a3cfcd6af9..7e91890a08cc2 100644 --- a/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs +++ b/compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs @@ -523,7 +523,7 @@ struct LocalLabel<'a> { /// A custom `Subdiagnostic` implementation so that the notes are delivered in a specific order impl Subdiagnostic for LocalLabel<'_> { - fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_, G>) { + fn add_to_diag(self, diag: &mut rustc_errors::Diag<'_>) { diag.span_label( self.span, msg!( diff --git a/compiler/rustc_mir_transform/src/pass_manager.rs b/compiler/rustc_mir_transform/src/pass_manager.rs index 74910ce3acde4..0e707688d72b4 100644 --- a/compiler/rustc_mir_transform/src/pass_manager.rs +++ b/compiler/rustc_mir_transform/src/pass_manager.rs @@ -314,7 +314,7 @@ fn run_passes_inner<'tcx>( for name in rest { err.note(format!("pass `{name}` is also not declared in `PASS_NAMES`")); } - err.emit(); + err.emit_bug(); } } diff --git a/compiler/rustc_parse/src/diagnostics.rs b/compiler/rustc_parse/src/diagnostics.rs index 4f3c702c77ef9..566b257d1058d 100644 --- a/compiler/rustc_parse/src/diagnostics.rs +++ b/compiler/rustc_parse/src/diagnostics.rs @@ -1537,9 +1537,9 @@ pub(crate) struct ExpectedIdentifier { pub help_cannot_start_number: Option, } -impl<'a, G> Diagnostic<'a, G> for ExpectedIdentifier { +impl<'a> Diagnostic<'a> for ExpectedIdentifier { #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let token_descr = TokenDescription::from_token(&self.token); let mut add_token = true; @@ -1603,9 +1603,9 @@ pub(crate) struct ExpectedSemi { pub sugg: ExpectedSemiSugg, } -impl<'a, G> Diagnostic<'a, G> for ExpectedSemi { +impl<'a> Diagnostic<'a> for ExpectedSemi { #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let token_descr = TokenDescription::from_token(&self.token); let mut add_token = true; @@ -2010,7 +2010,7 @@ pub(crate) struct FnTraitMissingParen { } impl Subdiagnostic for FnTraitMissingParen { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { diag.span_label(self.span, msg!("`Fn` bounds require arguments in parentheses")); diag.span_suggestion_short( self.span.shrink_to_hi(), @@ -3697,7 +3697,7 @@ pub(crate) struct UseDerefMacro { } impl Subdiagnostic for UseDerefMacro { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { let Self { field, before, after } = self; let mut parts = Vec::new(); @@ -4355,7 +4355,7 @@ pub(crate) struct HiddenUnicodeCodepointsDiagLabels { } impl Subdiagnostic for HiddenUnicodeCodepointsDiagLabels { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { for (c, span) in self.spans { diag.span_label(span, format!("{c:?}")); } @@ -4369,7 +4369,7 @@ pub(crate) enum HiddenUnicodeCodepointsDiagSub { // Used because of multiple multipart_suggestion and note impl Subdiagnostic for HiddenUnicodeCodepointsDiagSub { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { match self { HiddenUnicodeCodepointsDiagSub::Escape { spans } => { diag.multipart_suggestion_with_style( diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 2afb55b02e2e6..6a362b1b1cde0 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -970,7 +970,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> { escaped_char(bad_char) ), ) - .emit() + .emit_fatal() } fn report_unterminated_raw_string( @@ -1004,7 +1004,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> { ); } - err.emit() + err.emit_fatal() } fn report_unterminated_block_comment(&self, start: BytePos, doc_style: Option) -> ! { @@ -1050,7 +1050,7 @@ impl<'psess, 'src> Lexer<'psess, 'src> { ); } - err.emit(); + err.emit_fatal(); } // RFC 3101 introduced the idea of (reserved) prefixes. As of Rust 2021, diff --git a/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs b/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs index 9176192c95640..f01caf8d9efed 100644 --- a/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs +++ b/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs @@ -177,7 +177,7 @@ pub(crate) fn emit_unescape_error( foreign_escape_suggestion(&mut diag, (&ec, span), err_span); } - diag.emit() + diag.emit_err() } EscapeError::TooShortHexEscape => dcx.emit_err(UnescapeError::TooShortHexEscape(err_span)), EscapeError::InvalidCharInHexEscape | EscapeError::InvalidCharInUnicodeEscape => { @@ -227,7 +227,7 @@ pub(crate) fn emit_unescape_error( Applicability::MaybeIncorrect, ); } - err.emit() + err.emit_err() } EscapeError::OutOfRangeHexEscape => { let mut err = dcx.struct_span_err(err_span, "out of range hex escape"); @@ -247,7 +247,7 @@ pub(crate) fn emit_unescape_error( )); } - err.emit() + err.emit_err() } EscapeError::LeadingUnderscoreUnicodeEscape => { let (c, span) = last_char(); diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 16a438b5387ee..8a73215351aea 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -160,16 +160,16 @@ pub fn new_parser_from_file<'a>( if let Some(sp) = sp { err.span(sp); } - err.emit() + err.emit_fatal() }); new_parser_from_source_file(psess, source_file, strip_tokens) } -pub fn utf8_error( +pub fn utf8_error( sm: &SourceMap, path: &str, sp: Option, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, utf8err: Utf8Error, contents: &[u8], ) { diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index f5fa592585099..18489162257f6 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -609,7 +609,7 @@ impl<'a> Parser<'a> { if self.check_too_many_raw_str_terminators(&mut err) { if expected.contains(&TokenType::Semi) && self.eat(exp!(Semi)) { - let guar = err.emit(); + let guar = err.emit_err(); return Ok(guar); } else { return Err(err); @@ -770,7 +770,7 @@ impl<'a> Parser<'a> { Ok(next_attr) => next_attr, Err(inner_err) => { inner_err.cancel(); - return err.emit(); + return err.emit_err(); } } && let ast::AttrKind::Normal(next_attr_kind) = next_attr.kind @@ -782,7 +782,7 @@ impl<'a> Parser<'a> { Ok(next_expr) => next_expr, Err(inner_err) => { inner_err.cancel(); - return err.emit(); + return err.emit_err(); } }; // We have for sure @@ -816,7 +816,7 @@ impl<'a> Parser<'a> { } } - err.emit() + err.emit_err() } fn check_too_many_raw_str_terminators(&mut self, err: &mut Diag<'_>) -> bool { @@ -941,7 +941,7 @@ impl<'a> Parser<'a> { ], Applicability::MaybeIncorrect, ); - let guar = err.emit(); + let guar = err.emit_err(); self.eat_to_tokens(&[exp!(CloseBrace)]); guar } @@ -958,7 +958,7 @@ impl<'a> Parser<'a> { ], Applicability::MaybeIncorrect, ); - err.emit() + err.emit_err() } _ if token.kind != token::OpenBrace => { // We don't have a heuristic to correctly identify where the block @@ -1175,7 +1175,7 @@ impl<'a> Parser<'a> { // The subsequent expression is valid. Mark // `expr` as erroneous and emit `e` now, but // return `Ok` so parsing can continue. - let guar = e.emit(); + let guar = e.emit_err(); *expr = self.mk_expr_err(expr.span.to(self.prev_token.span), guar); return Ok(guar); } @@ -1834,7 +1834,7 @@ impl<'a> Parser<'a> { "r#", Applicability::MachineApplicable, ); - let guar = err.emit(); + let guar = err.emit_err(); Ok(self.mk_expr_err(lo.to(hi), guar)) } else { Err(self.expected_expression_found()) // The user isn't trying to invoke the try! macro @@ -1881,7 +1881,7 @@ impl<'a> Parser<'a> { lo: Span, err: Diag<'a>, ) -> Box { - let guar = err.emit(); + let guar = err.emit_err(); // Recover from parse error, callers expect the closing delim to be consumed. self.consume_block(open, close, ConsumeClosingDelim::Yes); self.mk_expr(lo.to(self.prev_token.span), ExprKind::Err(guar)) @@ -2410,7 +2410,7 @@ impl<'a> Parser<'a> { "=", Applicability::MaybeIncorrect, ); - let guar = err.emit(); + let guar = err.emit_err(); let value = self.mk_expr_err(start.to(expr.span), guar); return Ok(GenericArg::Const(AnonConst { id: ast::DUMMY_NODE_ID, value })); } else if snapshot.token == token::Colon @@ -2424,7 +2424,7 @@ impl<'a> Parser<'a> { "::", Applicability::MaybeIncorrect, ); - let guar = err.emit(); + let guar = err.emit_err(); return Ok(GenericArg::Type( self.mk_ty(start.to(expr.span), TyKind::Err(guar)), )); @@ -2476,7 +2476,7 @@ impl<'a> Parser<'a> { vec![(span.shrink_to_lo(), "{ ".to_string()), (span.shrink_to_hi(), " }".to_string())], Applicability::MaybeIncorrect, ); - let guar = err.emit(); + let guar = err.emit_err(); let value = self.mk_expr_err(span, guar); GenericArg::Const(AnonConst { id: ast::DUMMY_NODE_ID, value }) } diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 31e2d15a5ebb3..a615d4afcba77 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1115,7 +1115,7 @@ impl<'a> Parser<'a> { Err(err) if self.is_expected_raw_ref_mut() && self.token_cursor.depth() == call_depth => { - let guar = err.emit(); + let guar = err.emit_err(); // Preserve the call expression so later passes can still diagnose the callee, // while treating the malformed `&raw ` argument as an error expression. let args = self.recover_raw_ref_call_args(guar); @@ -1194,7 +1194,7 @@ impl<'a> Parser<'a> { }, }) } else { - err.emit() + err.emit_err() }; Ok(self.mk_expr_err(span, guar)) } @@ -1715,7 +1715,7 @@ impl<'a> Parser<'a> { "'", Applicability::MaybeIncorrect, ) - .emit() + .emit_err() }); let name = ident.without_first_quote().name; mk_lit_char(name, ident.span) @@ -3054,7 +3054,7 @@ impl<'a> Parser<'a> { Ok(arm) => arms.push(arm), Err(e) => { // Recover by skipping to the end of the block. - let guar = e.emit(); + let guar = e.emit_err(); self.recover_stmt(); let span = lo.to(self.token.span); if self.token == token::CloseBrace { @@ -3768,7 +3768,7 @@ impl<'a> Parser<'a> { return Err(e); } - let guar = e.emit(); + let guar = e.emit_err(); if pth == kw::Async { recovered_async = Some(guar); } @@ -3826,7 +3826,7 @@ impl<'a> Parser<'a> { if !recover { return Err(e); } - let guar = e.emit(); + let guar = e.emit_err(); if pth == kw::Async { recovered_async = Some(guar); } else if let Some(f) = field_ident(self, guar) { diff --git a/compiler/rustc_parse/src/parser/function.rs b/compiler/rustc_parse/src/parser/function.rs index e44423e46b0c3..27e671c0d9c52 100644 --- a/compiler/rustc_parse/src/parser/function.rs +++ b/compiler/rustc_parse/src/parser/function.rs @@ -176,7 +176,7 @@ impl<'a> Parser<'a> { // The enclosing `mod`, `trait` or `impl` is being closed, so keep the `fn` in // the AST for typechecking. err.span_label(ident_span, "while parsing this `fn`"); - Ok(err.emit()) + Ok(err.emit_err()) } else if self.token == token::RArrow && let Some(fn_params_end) = fn_params_end { @@ -701,7 +701,7 @@ impl<'a> Parser<'a> { p.recover_vcs_conflict_marker(); let snapshot = p.create_snapshot_for_diagnostic(); let param = p.parse_param_general(fn_parse_mode, first_param).or_else(|e| { - let guar = e.emit(); + let guar = e.emit_err(); // When parsing a param failed, we should check to make the span of the param // not contain '(' before it. // For example when parsing `*mut Self` in function `fn oof(*mut Self)`. @@ -777,7 +777,7 @@ impl<'a> Parser<'a> { first_param, fn_parse_mode, ) { - let guar = err.emit(); + let guar = err.emit_err(); let mut arg = dummy_arg(ident, guar); arg.span = pat_span; Ok((arg, Trailing::No, UsePreAttrPos::No)) diff --git a/compiler/rustc_parse/src/parser/generics.rs b/compiler/rustc_parse/src/parser/generics.rs index d47f8c4c264dd..5d2aa1bed5b6e 100644 --- a/compiler/rustc_parse/src/parser/generics.rs +++ b/compiler/rustc_parse/src/parser/generics.rs @@ -119,7 +119,7 @@ impl<'a> Parser<'a> { ": /* Type */".to_string(), Applicability::HasPlaceholders, ); - let kind = TyKind::Err(err.emit()); + let kind = TyKind::Err(err.emit_err()); let ty = self.mk_ty(span, kind); Ok(GenericParam { ident, diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 2ab012e0ecc2f..efeaa0653a44a 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1954,7 +1954,7 @@ impl<'a> Parser<'a> { this.bump(); // } err.span_label(span, "while parsing this enum"); err.help(help); - let guar = err.emit(); + let guar = err.emit_err(); (thin_vec![], Recovered::Yes(guar)) } }; @@ -2130,7 +2130,7 @@ impl<'a> Parser<'a> { ConsumeClosingDelim::No, ); err.span_label(ident_span, format!("while parsing this {adt_ty}")); - let guar = err.emit(); + let guar = err.emit_err(); recovered = Recovered::Yes(guar); break; } diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index b2afd1c51256a..3ec3b7cf6fc3d 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -1289,7 +1289,7 @@ impl<'a> Parser<'a> { .with_help( "use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead", ) - .emit(); + .emit_err(); ExprKind::Err(guar) } else { ExprKind::ConstBlock(anon_const) @@ -1795,7 +1795,7 @@ impl<'a> Parser<'a> { ";", Applicability::MaybeIncorrect, ); - return Some((lhs.span, err.emit())); + return Some((lhs.span, err.emit_err())); } None } diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 8508941f459f2..e3a5902196acb 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -1561,7 +1561,7 @@ impl<'a> Parser<'a> { self.bump(); let (fields, etc) = self.parse_pat_fields().unwrap_or_else(|mut e| { e.span_label(path.span, "while parsing the fields for this pattern"); - let guar = e.emit(); + let guar = e.emit_err(); self.recover_stmt(); // When recovering, pretend we had `Foo { .. }`, to avoid cascading errors. (ThinVec::new(), PatFieldsRest::Recovered(guar)) diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 6bc7195b8371c..2174dbefaa321 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -626,7 +626,7 @@ impl<'a> Parser<'a> { // When encountering severely malformed code where there are several levels of // nested unclosed angle args (`f:: 0 => { self.angle_bracket_nesting -= 1; diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 4fd3649a6dc3c..9056b67dc4f13 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -796,7 +796,7 @@ impl<'a> Parser<'a> { } } - let guar = err.emit(); + let guar = err.emit_err(); self.recover_stmt_(SemiColonMode::Ignore, BlockMode::Ignore); self.mk_stmt_err(self.token.span, guar) } @@ -1073,7 +1073,7 @@ impl<'a> Parser<'a> { } else { res.unwrap_or_else(|mut e| { self.recover_missing_dot(&mut e); - let guar = e.emit(); + let guar = e.emit_err(); self.recover_stmt(); guar }) diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 42fb9121076f4..8ce81c6ab8c3d 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -527,7 +527,7 @@ impl<'a> Parser<'a> { err.span_label(lo, "expected type"); return Ok(match self.maybe_recover_ref_ty_no_leading_ampersand(lt, lo, err) { Ok(ref_ty) => ref_ty, - Err(err) => TyKind::Err(err.emit()), + Err(err) => TyKind::Err(err.emit_err()), }); } @@ -791,7 +791,7 @@ impl<'a> Parser<'a> { .struct_span_err(span, "`typeof` is a reserved keyword but unimplemented") .with_note("consider replacing `typeof(...)` with an actual type") .with_code(E0516) - .emit(); + .emit_err(); Ok(TyKind::Err(guar)) } @@ -1155,7 +1155,7 @@ impl<'a> Parser<'a> { vec![(lo, String::new()), (hi, String::new())], Applicability::MachineApplicable, ); - diag.emit() + diag.emit_err() } /// Emits an error if any trait bound modifiers were present. diff --git a/compiler/rustc_passes/src/diagnostics.rs b/compiler/rustc_passes/src/diagnostics.rs index 55f8ac9a585de..59c1005885903 100644 --- a/compiler/rustc_passes/src/diagnostics.rs +++ b/compiler/rustc_passes/src/diagnostics.rs @@ -392,9 +392,9 @@ pub(crate) struct NoMainErr { pub add_teach_note: bool, } -impl<'a, G> Diagnostic<'a, G> for NoMainErr { +impl<'a> Diagnostic<'a> for NoMainErr { #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new(dcx, level, msg!("`main` function not found in crate `{$crate_name}`")); diag.span(DUMMY_SP); @@ -458,9 +458,9 @@ pub(crate) struct DuplicateLangItem { pub(crate) duplicate: Duplicate, } -impl Diagnostic<'_, G> for DuplicateLangItem { +impl Diagnostic<'_> for DuplicateLangItem { #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { let mut diag = Diag::new( dcx, level, diff --git a/compiler/rustc_query_impl/src/handle_cycle_error.rs b/compiler/rustc_query_impl/src/handle_cycle_error.rs index b47de985224e2..83e95b9195580 100644 --- a/compiler/rustc_query_impl/src/handle_cycle_error.rs +++ b/compiler/rustc_query_impl/src/handle_cycle_error.rs @@ -17,7 +17,7 @@ use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, bug}; // Default cycle handler used for all queries that don't use the `handle_cycle_error` query // modifier. pub(crate) fn default(err: Diag<'_>) -> ! { - let guar = err.emit(); + let guar = err.emit_err(); guar.raise_fatal() } @@ -207,7 +207,7 @@ pub(crate) fn layout_of<'tcx>( || create_cycle_error(tcx, &cycle, false), ); - diag.emit().raise_fatal() + diag.emit_err().raise_fatal() } // item_and_field_ids should form a cycle where each field contains the @@ -292,7 +292,7 @@ fn recursive_type_error( suggestion, Applicability::HasPlaceholders, ) - .emit() + .emit_err() } fn find_item_ty_spans( diff --git a/compiler/rustc_resolve/src/diagnostics/impls.rs b/compiler/rustc_resolve/src/diagnostics/impls.rs index 6ddfff9f88d83..89b70065f8adc 100644 --- a/compiler/rustc_resolve/src/diagnostics/impls.rs +++ b/compiler/rustc_resolve/src/diagnostics/impls.rs @@ -326,7 +326,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } } - let guar = diag.emit(); + let guar = diag.emit_err(); if glob_error { self.glob_error = Some(guar); } @@ -787,7 +787,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { span: Span, resolution_error: ResolutionError<'ra>, ) -> ErrorGuaranteed { - self.into_struct_error(span, resolution_error).emit() + self.into_struct_error(span, resolution_error).emit_err() } pub(crate) fn into_struct_error( @@ -1460,7 +1460,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { self.dcx().create_err(diagnostics::ModuleOnly(span)) } } - .emit() + .emit_err() } pub(crate) fn def_path_str(&self, mut def_id: DefId) -> String { diff --git a/compiler/rustc_resolve/src/diagnostics/mod.rs b/compiler/rustc_resolve/src/diagnostics/mod.rs index b581777901195..119cc130282be 100644 --- a/compiler/rustc_resolve/src/diagnostics/mod.rs +++ b/compiler/rustc_resolve/src/diagnostics/mod.rs @@ -1380,7 +1380,7 @@ pub(crate) enum ItemWas { } impl Subdiagnostic for FoundItemConfigureOut { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { let mut multispan: MultiSpan = self.span.into(); match self.item_was { ItemWas::BehindFeature { feature, span } => { @@ -1522,8 +1522,8 @@ pub(crate) struct Ambiguity { pub is_error: bool, } -impl<'a, G> Diagnostic<'a, G> for Ambiguity { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { +impl<'a> Diagnostic<'a> for Ambiguity { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { ident, ambig_vis, diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index fe46287373dee..7d90b93b62375 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -2018,7 +2018,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { }, ); self.point_at_impl_lifetimes(&mut err, i, lifetime.ident.span); - err.emit() + err.emit_err() } } else if self.diag_metadata.in_assoc_ty_binding { // For associated type bindings, e.g. @@ -2035,7 +2035,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { &mut err, lifetime.ident.span, ); - err.emit() + err.emit_err() } else { self.r.dcx().emit_err( crate::diagnostics::ElidedAnonymousLifetimeReportError { @@ -3211,7 +3211,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> { .create_err(crate::diagnostics::UnderscoreLifetimeIsReserved { span: param.ident.span, }) - .emit_unless_delay(is_raw_underscore_lifetime); + .emit_err_unless_delay(is_raw_underscore_lifetime); // Record lifetime res, so lowering knows there is something fishy. self.record_lifetime_err(param.id, guar); continue; diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 611e7147757fe..2d8fef78bafa6 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -3930,7 +3930,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { ); } - err.emit() + err.emit_err() } fn suggest_introducing_lifetime( @@ -4191,7 +4191,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { lifetime_refs, function_param_lifetimes, ); - err.emit() + err.emit_err() } fn add_missing_lifetime_specifiers_label<'a>( @@ -4732,7 +4732,7 @@ pub(super) fn signal_lifetime_shadowing( ) .with_span_label(orig.span, "first declared here") .with_span_label(shadower.span, format!("lifetime `{}` already in scope", orig.name)) - .emit() + .emit_err() } struct LifetimeFinder<'ast> { diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 0633fcd253b4f..753a4ed0d779a 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1866,7 +1866,7 @@ pub fn build_target_config( { err.help(format!("did you mean `{suggestion}`?")); } - err.emit() + err.emit_fatal() } } } @@ -2571,7 +2571,7 @@ pub fn parse_externs( let mut externs: BTreeMap = BTreeMap::new(); for arg in matches.opt_strs("extern") { let ExternOpt { crate_name: name, path, options } = - split_extern_opt(early_dcx, unstable_opts, &arg).unwrap_or_else(|e| e.emit()); + split_extern_opt(early_dcx, unstable_opts, &arg).unwrap_or_else(|e| e.emit_fatal()); let entry = externs.entry(name.to_owned()); diff --git a/compiler/rustc_session/src/config/externs.rs b/compiler/rustc_session/src/config/externs.rs index ff76eaaeaf4fc..0534821b3aec3 100644 --- a/compiler/rustc_session/src/config/externs.rs +++ b/compiler/rustc_session/src/config/externs.rs @@ -2,7 +2,7 @@ use std::path::PathBuf; -use rustc_errors::{Diag, FatalAbort}; +use rustc_errors::Diag; use super::UnstableOptions; use crate::EarlyDiagCtxt; @@ -21,11 +21,13 @@ pub(crate) struct ExternOpt { /// /// The options field will be a string containing comma-separated options that will need further /// parsing and processing. +/// +/// On error, the returned `Diag` is fatal. pub(crate) fn split_extern_opt<'a>( early_dcx: &'a EarlyDiagCtxt, unstable_opts: &UnstableOptions, extern_opt: &str, -) -> Result> { +) -> Result> { let (name, path) = match extern_opt.split_once('=') { None => (extern_opt.to_string(), None), Some((name, path)) => (name.to_string(), Some(PathBuf::from(path))), diff --git a/compiler/rustc_session/src/config/print_request.rs b/compiler/rustc_session/src/config/print_request.rs index b41ceb1699eaa..e48b99626033a 100644 --- a/compiler/rustc_session/src/config/print_request.rs +++ b/compiler/rustc_session/src/config/print_request.rs @@ -339,5 +339,5 @@ fn emit_unknown_print_request_help( diag.help("for more information, see the rustc book: https://doc.rust-lang.org/rustc/command-line-arguments.html#--print-print-compiler-information"); } - diag.emit() + diag.emit_fatal() } diff --git a/compiler/rustc_session/src/diagnostics.rs b/compiler/rustc_session/src/diagnostics.rs index a2bf9a0d2dfc3..4ec8ca42edbee 100644 --- a/compiler/rustc_session/src/diagnostics.rs +++ b/compiler/rustc_session/src/diagnostics.rs @@ -95,7 +95,7 @@ pub fn feature_warn_issue( /// Adds the diagnostics for a feature to an existing error. /// Must be a language feature! -pub fn add_feature_diagnostics(err: &mut Diag<'_, G>, sess: &Session, feature: Symbol) { +pub fn add_feature_diagnostics(err: &mut Diag<'_>, sess: &Session, feature: Symbol) { add_feature_diagnostics_for_issue(err, sess, feature, GateIssue::Language, false, None); } @@ -104,8 +104,8 @@ pub fn add_feature_diagnostics(err: &mut Diag<'_, G>, sess: &Session, feature /// This variant allows you to control whether it is a library or language feature. /// Almost always, you want to use this for a language feature. If so, prefer /// `add_feature_diagnostics`. -pub fn add_feature_diagnostics_for_issue( - err: &mut Diag<'_, G>, +pub fn add_feature_diagnostics_for_issue( + err: &mut Diag<'_>, sess: &Session, feature: Symbol, issue: GateIssue, @@ -192,9 +192,9 @@ pub(crate) struct FeatureGateError { pub(crate) explain: DiagMessage, } -impl<'a, G> Diagnostic<'a, G> for FeatureGateError { +impl<'a> Diagnostic<'a> for FeatureGateError { #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { Diag::new(dcx, level, self.explain).with_span(self.span).with_code(E0658) } } @@ -578,7 +578,7 @@ pub fn report_lit_error( lit: token::Lit, span: Span, ) -> ErrorGuaranteed { - create_lit_error(psess, err, lit, span).emit() + create_lit_error(psess, err, lit, span).emit_err() } pub fn create_lit_error(psess: &ParseSess, err: LitError, lit: token::Lit, span: Span) -> Diag<'_> { diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index 0e79d220b3962..b9555e6520087 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -148,7 +148,7 @@ impl ParseSess { } pub fn dyn_buffer_lint< - F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level) -> Diag<'a, ()> + DynSync + DynSend + 'static, + F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level) -> Diag<'a> + DynSync + DynSend + 'static, >( &self, lint: &'static Lint, @@ -165,7 +165,7 @@ impl ParseSess { } pub fn dyn_buffer_lint_sess< - F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &Session) -> Diag<'a, ()> + F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &Session) -> Diag<'a> + DynSync + DynSend + 'static, diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 274cfe8d7eb8a..96b48ef3289eb 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -17,8 +17,7 @@ use rustc_errors::emitter::{DynEmitter, HumanReadableErrorType, OutputTheme, std use rustc_errors::json::JsonEmitter; use rustc_errors::timings::TimingSectionHandler; use rustc_errors::{ - Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, Diagnostic, ErrorGuaranteed, FatalAbort, PResult, - TerminalUrl, + Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, Diagnostic, ErrorGuaranteed, PResult, TerminalUrl, }; use rustc_feature::UnstableFeatures; use rustc_macros::StableHash; @@ -1880,7 +1879,7 @@ impl EarlyDiagCtxt { self.dcx.handle().fatal(msg) } - pub fn early_struct_fatal(&self, msg: impl Into) -> Diag<'_, FatalAbort> { + pub fn early_struct_fatal(&self, msg: impl Into) -> Diag<'_> { self.dcx.handle().struct_fatal(msg) } @@ -1888,7 +1887,7 @@ impl EarlyDiagCtxt { self.dcx.handle().warn(msg) } - pub fn early_struct_warn(&self, msg: impl Into) -> Diag<'_, ()> { + pub fn early_struct_warn(&self, msg: impl Into) -> Diag<'_> { self.dcx.handle().struct_warn(msg) } } diff --git a/compiler/rustc_trait_selection/src/diagnostics.rs b/compiler/rustc_trait_selection/src/diagnostics.rs index 02a181adfadb7..4b7be976cdb30 100644 --- a/compiler/rustc_trait_selection/src/diagnostics.rs +++ b/compiler/rustc_trait_selection/src/diagnostics.rs @@ -36,9 +36,9 @@ pub(crate) struct NegativePositiveConflict<'tcx> { pub positive_impl_span: Result, } -impl Diagnostic<'_, G> for NegativePositiveConflict<'_> { +impl Diagnostic<'_> for NegativePositiveConflict<'_> { #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { let mut diag = Diag::new( dcx, level, @@ -89,7 +89,7 @@ pub(crate) enum AdjustSignatureBorrow { } impl Subdiagnostic for AdjustSignatureBorrow { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { match self { AdjustSignatureBorrow::Borrow { to_borrow } => { diag.arg("borrow_len", to_borrow.len()); @@ -437,8 +437,8 @@ pub(crate) enum RegionOriginNote<'a> { } impl Subdiagnostic for RegionOriginNote<'_> { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { - let label_or_note = |diag: &mut Diag<'_, G>, span, msg: DiagMessage| { + fn add_to_diag(self, diag: &mut Diag<'_>) { + let label_or_note = |diag: &mut Diag<'_>, span, msg: DiagMessage| { let sub_count = diag.children.iter().filter(|d| d.span.is_dummy()).count(); let expanded_sub_count = diag.children.iter().filter(|d| !d.span.is_dummy()).count(); let span_is_primary = diag.span.primary_spans().iter().all(|&sp| sp == span); @@ -532,7 +532,7 @@ pub(crate) enum LifetimeMismatchLabels { } impl Subdiagnostic for LifetimeMismatchLabels { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { match self { LifetimeMismatchLabels::InRet { param_span, ret_span, span, label_var1 } => { diag.span_label(param_span, msg!("this parameter and the return type are declared with different lifetimes...")); @@ -605,7 +605,7 @@ pub(crate) struct AddLifetimeParamsSuggestion<'a> { } impl Subdiagnostic for AddLifetimeParamsSuggestion<'_> { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { let mut mk_suggestion = || { let Some(anon_reg) = self.tcx.is_suitable_region(self.generic_param_scope, self.sub) else { @@ -789,7 +789,7 @@ pub(crate) struct IntroducesStaticBecauseUnmetLifetimeReq { } impl Subdiagnostic for IntroducesStaticBecauseUnmetLifetimeReq { - fn add_to_diag(mut self, diag: &mut Diag<'_, G>) { + fn add_to_diag(mut self, diag: &mut Diag<'_>) { self.unmet_requirements.push_span_label( self.binding_span, msg!("introduces a `'static` lifetime requirement"), @@ -1184,7 +1184,7 @@ pub(crate) struct ConsiderBorrowingParamHelp { } impl Subdiagnostic for ConsiderBorrowingParamHelp { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { let mut type_param_span: MultiSpan = self.spans.clone().into(); for &span in &self.spans { // Seems like we can't call f() here as Into is required @@ -1661,7 +1661,7 @@ pub(crate) struct SuggestTuplePatternMany { } impl Subdiagnostic for SuggestTuplePatternMany { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { diag.arg("path", self.path); let message = msg!("try wrapping the pattern in a variant of `{$path}`"); diag.multipart_suggestions( @@ -1907,7 +1907,7 @@ pub(crate) struct AddPreciseCapturingAndParams { } impl Subdiagnostic for AddPreciseCapturingAndParams { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { diag.arg("new_lifetime", self.new_lifetime); diag.multipart_suggestion( msg!("add a `use<...>` bound to explicitly capture `{$new_lifetime}` after turning all argument-position `impl Trait` into type parameters, noting that this possibly affects the API of this crate"), @@ -2047,7 +2047,7 @@ pub struct AddPreciseCapturingForOvercapture { } impl Subdiagnostic for AddPreciseCapturingForOvercapture { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { let applicability = if self.apit_spans.is_empty() { Applicability::MachineApplicable } else { diff --git a/compiler/rustc_trait_selection/src/diagnostics/note_and_explain.rs b/compiler/rustc_trait_selection/src/diagnostics/note_and_explain.rs index 76a071543d318..906fdd7f963c7 100644 --- a/compiler/rustc_trait_selection/src/diagnostics/note_and_explain.rs +++ b/compiler/rustc_trait_selection/src/diagnostics/note_and_explain.rs @@ -162,7 +162,7 @@ impl RegionExplanation<'_> { } impl Subdiagnostic for RegionExplanation<'_> { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { let msg = msg!( "{$pref_kind -> *[should_not_happen] [{$pref_kind}] diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mod.rs index c0b4bdab84945..2fb05084a381a 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/mod.rs @@ -73,7 +73,7 @@ impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx> { pub fn try_report(&self) -> Option { self.try_report_from_nll() - .map(|diag| diag.emit()) + .map(|diag| diag.emit_err()) .or_else(|| self.try_report_impl_not_conforming_to_trait()) .or_else(|| self.try_report_anon_anon_conflict()) .or_else(|| self.try_report_static_impl_trait()) diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs index 6c6d68e63ed63..166c320cda28a 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/static_impl_trait.rs @@ -128,8 +128,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { Some(anon_reg_sup.scope), ); - let reported = err.emit(); - Some(reported) + let guar = err.emit_err(); + Some(guar) } } diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs index f1be118896b01..03baa5c2acbfb 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/nice_region_error/trait_impl_difference.rs @@ -165,7 +165,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> { }, )); } - diag.emit() + diag.emit_err() } } diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs index 26aadefb69f1a..b9f70cea5f5ab 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs @@ -72,10 +72,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { RegionResolutionError::ConcreteFailure(origin, sub, sup) => { if sub.is_placeholder() || sup.is_placeholder() { self.report_placeholder_failure(generic_param_scope, origin, sub, sup) - .emit() + .emit_err() } else { self.report_concrete_failure(generic_param_scope, origin, sub, sup) - .emit() + .emit_err() } } @@ -104,7 +104,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { sub_r, sup_r, ) - .emit() + .emit_err() } else if sup_r.is_placeholder() { self.report_placeholder_failure( generic_param_scope, @@ -112,7 +112,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { sub_r, sup_r, ) - .emit() + .emit_err() } else { self.report_sub_sup_conflict( generic_param_scope, @@ -147,7 +147,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { sub_r, sup_r, ) - .emit() + .emit_err() } RegionResolutionError::CannotNormalize(clause, origin) => { @@ -156,7 +156,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { self.tcx .dcx() .struct_span_err(origin.span(), format!("cannot normalize `{clause}`")) - .emit() + .emit_err() } } }; @@ -704,7 +704,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { sub: Region<'tcx>, ) -> ErrorGuaranteed { self.construct_generic_bound_failure(generic_param_scope, span, origin, bound_kind, sub) - .emit() + .emit_err() } pub fn construct_generic_bound_failure( @@ -1051,7 +1051,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { return if sub_region.is_error() | sup_region.is_error() { err.delay_as_bug() } else { - err.emit() + err.emit_err() }; } @@ -1068,7 +1068,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); self.note_region_origin(&mut err, &sub_origin); - if sub_region.is_error() | sup_region.is_error() { err.delay_as_bug() } else { err.emit() } + if sub_region.is_error() | sup_region.is_error() { + err.delay_as_bug() + } else { + err.emit_err() + } } fn report_inference_failure(&self, var_origin: RegionVariableOrigin<'tcx>) -> Diag<'_> { diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs index a44d53cdfdd05..62ac12a8edd24 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/ambiguity.rs @@ -266,7 +266,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { TypeAnnotationNeeded::E0282, false, ) - .emit(), + .emit_err(), Some(e) => e, }; } @@ -779,7 +779,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { self.note_obligation_cause(&mut err, &error.obligation); } } - err.emit() + err.emit_err() } /// The `impl`s and `where` clauses that could have satisfied `trait_pred`, when listing them diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs index 26d768e5b22e8..cf729def2f46c 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs @@ -98,13 +98,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { trait_item_def_id, &format!("`{}`", obligation.predicate), ) - .emit(); + .emit_err(); } // Report a const-param specific error if let ObligationCauseCode::ConstParam(ty) = *obligation.cause.code().peel_derives() { - return self.report_const_param_not_wf(ty, &obligation).emit(); + return self.report_const_param_not_wf(ty, &obligation).emit_err(); } let bound_predicate = obligation.predicate.kind(); @@ -374,7 +374,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { have_alt_message, ) { self.note_obligation_cause(&mut err, &obligation); - return err.emit(); + return err.emit_err(); } let ty_span = match leaf_trait_predicate.self_ty().skip_binder().kind() { @@ -524,11 +524,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { &mut err, leaf_trait_predicate, ) { - return err.emit(); + return err.emit_err(); } if self.suggest_impl_trait(&mut err, &obligation, leaf_trait_predicate) { - return err.emit(); + return err.emit_err(); } if is_unsize { @@ -632,7 +632,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { Some(sym::Debug | sym::Display) ) { - return err.emit(); + return err.emit_err(); } err @@ -828,7 +828,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { }; self.note_obligation_cause(&mut err, &obligation); - err.emit() + err.emit_err() } } @@ -1078,7 +1078,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); self.suggest_change_mut_ref_for_closure(&mut err, &obligation); self.note_obligation_cause(&mut err, &obligation); - return Some(err.emit()); + return Some(err.emit_err()); } // If the closure has captures, then perhaps the reason that the trait @@ -1099,7 +1099,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { coro_kind, }); self.note_obligation_cause(&mut err, &obligation); - return Some(err.emit()); + return Some(err.emit_err()); } None @@ -1901,7 +1901,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { if mention_bounds { self.note_obligation_cause(&mut diag, obligation); } - diag.emit() + diag.emit_err() }) } @@ -3993,7 +3993,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // Note that with `feature(generic_const_exprs)` this case should not // be reachable. .with_note("this may fail depending on what value the parameter takes") - .emit(); + .emit_err(); return Err(guar); } diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs index b0a513f692c38..c120df4e2c3ef 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs @@ -425,7 +425,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { error.obligation.cause.span, "higher-ranked lifetime bound could not be satisfied", ) - .emit(), + .emit_err(), FulfillmentErrorCode::Ambiguity { overflow: None } => { self.maybe_report_ambiguity(&error.obligation, related) } @@ -440,7 +440,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { expected_found.found, *err, ) - .emit(), + .emit_err(), FulfillmentErrorCode::ConstEquate(ref expected_found, ref err) => { let mut diag = self.report_mismatched_consts( &error.obligation.cause, @@ -463,7 +463,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { &mut Default::default(), ); } - diag.emit() + diag.emit_err() } FulfillmentErrorCode::Cycle(ref cycle) => self.report_overflow_obligation_cycle(cycle), } diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs index cea5c2f5a3d53..ac0bb13f8fc35 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/overflow.rs @@ -17,7 +17,7 @@ pub enum OverflowCause<'tcx> { TraitSolver(ty::Predicate<'tcx>), } -pub fn suggest_new_overflow_limit<'tcx, G>(tcx: TyCtxt<'tcx>, err: &mut Diag<'_, G>) { +pub fn suggest_new_overflow_limit<'tcx>(tcx: TyCtxt<'tcx>, err: &mut Diag<'_>) { let suggested_limit = match tcx.recursion_limit() { Limit(0) => Limit(2), limit => limit * 2, @@ -46,7 +46,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ) -> ! { let mut err = self.build_overflow_error(cause, span, suggest_increasing_limit); mutate(&mut err); - err.emit().raise_fatal(); + err.emit_err().raise_fatal(); } pub fn build_overflow_error( @@ -190,6 +190,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { suggest_increasing_limit, ); self.note_obligation_cause(&mut err, &obligation); - err.emit() + err.emit_err() } } diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index fffe80be255ce..277ba8f3d3bac 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -119,12 +119,12 @@ fn predicate_constraint(generics: &hir::Generics<'_>, pred: ty::Predicate<'_>) - /// Type parameter needs more bounds. The trivial case is `T` `where T: Bound`, but /// it can also be an `impl Trait` param that needs to be decomposed to a type /// param for cleaner code. -pub fn suggest_restriction<'tcx, G>( +pub fn suggest_restriction<'tcx>( tcx: TyCtxt<'tcx>, item_id: LocalDefId, hir_generics: &hir::Generics<'tcx>, msg: &str, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, fn_sig: Option<&hir::FnSig<'_>>, projection: Option>, trait_pred: ty::PolyTraitClause<'tcx>, @@ -2758,10 +2758,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { false } - pub(super) fn suggest_borrow_for_unsized_closure_return( + pub(super) fn suggest_borrow_for_unsized_closure_return( &self, body_def_id: LocalDefId, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, predicate: ty::Predicate<'tcx>, ) { let Some(pred) = predicate.as_trait_clause() else { @@ -3303,9 +3303,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { /// /// Returns `true` if an async-await specific note was added to the diagnostic. #[instrument(level = "debug", skip_all, fields(?obligation.predicate, ?obligation.cause.span))] - pub fn maybe_note_obligation_cause_for_async_await( + pub fn maybe_note_obligation_cause_for_async_await( &self, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, obligation: &PredicateObligation<'tcx>, ) -> bool { // Attempt to detect an async-await error by looking at the obligation causes, looking @@ -3535,9 +3535,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { /// Unconditionally adds the diagnostic note described in /// `maybe_note_obligation_cause_for_async_await`'s documentation comment. #[instrument(level = "debug", skip_all)] - fn note_obligation_cause_for_async_await( + fn note_obligation_cause_for_async_await( &self, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, interior_or_upvar_span: CoroutineInteriorOrUpvar, is_async: bool, outer_coroutine: Option, @@ -3769,9 +3769,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); } - fn note_closure_capture( + fn note_closure_capture( &self, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, closure_def_id: DefId, upvar_args: ty::UpvarArgs<'tcx>, capture_ty: Option>, @@ -3822,10 +3822,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { true } - pub(super) fn note_obligation_cause_code( + pub(super) fn note_obligation_cause_code( &self, body_def_id: LocalDefId, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, predicate: T, param_env: ty::ParamEnv<'tcx>, cause_code: &ObligationCauseCode<'tcx>, @@ -3851,10 +3851,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { ); } - fn note_obligation_cause_code_inner( + fn note_obligation_cause_code_inner( &self, body_def_id: LocalDefId, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, predicate: T, param_env: ty::ParamEnv<'tcx>, cause_code: &ObligationCauseCode<'tcx>, @@ -3866,7 +3866,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { { let tcx = self.tcx; let predicate = predicate.upcast(tcx); - let suggest_remove_deref = |err: &mut Diag<'_, G>, expr: &hir::Expr<'_>| { + let suggest_remove_deref = |err: &mut Diag<'_>, expr: &hir::Expr<'_>| { if let Some(pred) = predicate.as_trait_clause() && tcx.is_lang_item(pred.def_id(), LangItem::Sized) && let hir::ExprKind::Unary(hir::UnOp::Deref, inner) = expr.kind @@ -5211,10 +5211,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } } - fn note_function_argument_obligation( + fn note_function_argument_obligation( &self, body_def_id: LocalDefId, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, arg_hir_id: HirId, parent_code: &ObligationCauseCode<'tcx>, param_env: ty::ParamEnv<'tcx>, @@ -5450,11 +5450,11 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } } - fn suggest_option_method_if_applicable( + fn suggest_option_method_if_applicable( &self, failed_pred: ty::Predicate<'tcx>, param_env: ty::ParamEnv<'tcx>, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, expr: &hir::Expr<'_>, ) { let tcx = self.tcx; @@ -5525,7 +5525,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } } - fn look_for_iterator_item_mistakes( + fn look_for_iterator_item_mistakes( &self, assocs_in_this_method: &[Option<(Span, (DefId, Ty<'tcx>))>], typeck_results: &TypeckResults<'tcx>, @@ -5534,7 +5534,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { path_segment: &hir::PathSegment<'_>, args: &[hir::Expr<'_>], prev_ty: Ty<'_>, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, ) { let tcx = self.tcx; // Special case for iterator chains, we look at potential failures of `Iterator::Item` @@ -5674,13 +5674,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { } } - fn point_at_chain( + fn point_at_chain( &self, expr: &hir::Expr<'_>, typeck_results: &TypeckResults<'tcx>, type_diffs: Vec>, param_env: ty::ParamEnv<'tcx>, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, ) { let mut primary_spans = vec![]; let mut span_labels = vec![]; @@ -5923,13 +5923,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { /// | | `Iterator::Item` is `&mut Vec` here /// | this expression has type `Vec>` /// ``` - fn point_at_chain_in_return_position( + fn point_at_chain_in_return_position( &self, body_def_id: LocalDefId, expr: &hir::Expr<'_>, typeck_results: &TypeckResults<'tcx>, param_env: ty::ParamEnv<'tcx>, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, ) { let tcx = self.tcx; if !matches!(tcx.def_kind(body_def_id), DefKind::Fn | DefKind::AssocFn) { @@ -7111,9 +7111,9 @@ pub fn suggest_desugaring_async_fn_to_impl_future_in_trait<'tcx>( /// On `impl` evaluation cycles, look for `Self::AssocTy` restrictions in `where` clauses, explain /// they are not allowed and if possible suggest alternatives. -fn point_at_assoc_type_restriction( +fn point_at_assoc_type_restriction( tcx: TyCtxt<'_>, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, self_ty_str: &str, trait_name: &str, predicate: ty::Predicate<'_>, diff --git a/compiler/rustc_trait_selection/src/opaque_types.rs b/compiler/rustc_trait_selection/src/opaque_types.rs index 10d5202905c72..4370935ead285 100644 --- a/compiler/rustc_trait_selection/src/opaque_types.rs +++ b/compiler/rustc_trait_selection/src/opaque_types.rs @@ -51,7 +51,7 @@ impl<'tcx> NonDefiningUseReason<'tcx> { .dcx() .struct_span_err(span, "non-defining opaque type use in defining scope") .with_span_note(spans, format!("{descr} used multiple times")) - .emit() + .emit_err() } } } @@ -231,5 +231,5 @@ pub fn report_item_does_not_constrain_error<'tcx>( format!("this use of `{opaque_ty}` does not have unique universal generic arguments"), ); } - err.emit() + err.emit_err() } diff --git a/compiler/rustc_trait_selection/src/traits/coherence.rs b/compiler/rustc_trait_selection/src/traits/coherence.rs index 2b7e7ac1c6642..d3c118b33e8ce 100644 --- a/compiler/rustc_trait_selection/src/traits/coherence.rs +++ b/compiler/rustc_trait_selection/src/traits/coherence.rs @@ -60,16 +60,16 @@ pub struct OverlapResult<'tcx> { pub overflowing_predicates: Vec>, } -pub fn add_placeholder_note(err: &mut Diag<'_, G>) { +pub fn add_placeholder_note(err: &mut Diag<'_>) { err.note( "this behavior recently changed as a result of a bug fix; \ see rust-lang/rust#56105 for details", ); } -pub(crate) fn suggest_increasing_recursion_limit<'tcx, G>( +pub(crate) fn suggest_increasing_recursion_limit<'tcx>( tcx: TyCtxt<'tcx>, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, overflowing_predicates: &[ty::Predicate<'tcx>], ) { for pred in overflowing_predicates { diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index aa8ab84243f7c..9bcbf393dd05b 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -127,7 +127,7 @@ pub fn is_const_evaluatable<'tcx>( "#![feature(generic_const_exprs)]\n", rustc_errors::Applicability::MaybeIncorrect, ) - .emit() + .emit_fatal() } Err(EvaluateConstErr::HasGenericsOrInfers) => { diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index f1a6c002dc584..c1f4e74119744 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -737,7 +737,7 @@ fn project<'cx, 'tcx>( ) } else { let violations = tcx.dyn_compatibility_violations(def_id); - report_dyn_incompatibility(tcx, span, None, def_id, &violations).emit() + report_dyn_incompatibility(tcx, span, None, def_id, &violations).emit_err() }; return Ok(Projected::Progress(Progress::error_for_term( tcx, diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index cf8672814ff70..f8619fcd120a2 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -63,7 +63,7 @@ pub enum IntercrateAmbiguityCause<'tcx> { impl<'tcx> IntercrateAmbiguityCause<'tcx> { /// Emits notes when the overlap is caused by complex intercrate ambiguities. /// See #23980 for details. - pub fn add_intercrate_ambiguity_hint(&self, err: &mut Diag<'_, G>) { + pub fn add_intercrate_ambiguity_hint(&self, err: &mut Diag<'_>) { err.note(self.intercrate_ambiguity_hint()); } diff --git a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs index 35c6f60f36035..987e2af81984b 100644 --- a/compiler/rustc_trait_selection/src/traits/specialize/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/specialize/mod.rs @@ -513,7 +513,7 @@ fn report_negative_positive_conflict<'tcx>( cause.add_intercrate_ambiguity_hint(&mut diag); } - diag.emit() + diag.emit_err() } fn report_conflicting_impls<'tcx>( @@ -527,11 +527,11 @@ fn report_conflicting_impls<'tcx>( // Work to be done after we've built the Diag. We have to define it now // because the lint emit methods don't return back the Diag that's passed // in. - fn decorate<'tcx, G>( + fn decorate<'tcx>( tcx: TyCtxt<'tcx>, overlap: &OverlapError<'tcx>, impl_span: Span, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, ) { match tcx.span_of_impl(overlap.with_impl) { Ok(span) => { @@ -594,7 +594,7 @@ fn report_conflicting_impls<'tcx>( let mut err = tcx.dcx().struct_span_err(impl_span, msg()); err.code(E0119); decorate(tcx, &overlap, impl_span, &mut err); - err.emit() + err.emit_err() } else { tcx.dcx().span_delayed_bug(impl_span, "impl should have failed the orphan check") }; diff --git a/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md b/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md index 7ca97b7b059e4..f8df01ba5e1cb 100644 --- a/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md +++ b/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md @@ -93,8 +93,8 @@ In the end, the `Diagnostic` derive will generate an implementation of `Diagnostic` that looks like the following: ```rust,ignore -impl<'a, G> Diagnostic<'a> for FieldAlreadyDeclared { - fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { +impl<'a> Diagnostic<'a> for FieldAlreadyDeclared { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new(dcx, level, "field `{$field_name}` is already declared"); diag.set_span(self.span); diag.span_label( diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index c2c58a345fa22..fb89a6547a931 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -752,12 +752,12 @@ impl Options { if !theme_file.is_file() { dcx.struct_fatal(format!("invalid argument: \"{theme_s}\"")) .with_help("arguments to --theme must be files") - .emit(); + .emit_fatal(); } if theme_file.extension() != Some(OsStr::new("css")) { dcx.struct_fatal(format!("invalid argument: \"{theme_s}\"")) .with_help("arguments to --theme must have a .css extension") - .emit(); + .emit_fatal(); } let (success, ret) = theme::test_theme_against(&theme_file, &paths, dcx); if !success { diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index af1cd195266cb..43c825c889907 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -875,7 +875,7 @@ impl<'doc, 'tcx> ExtraInfo<'doc, 'tcx> { fn error_invalid_codeblock_attr_with_help( &self, msg: impl Into, - f: impl for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>), + f: impl for<'a, 'b> FnOnce(&'b mut Diag<'a>), ) { self.tcx.emit_node_span_lint( crate::lint::INVALID_CODEBLOCK_ATTRIBUTES, diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 1ae23d58448a3..1f6d15147dcb3 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1471,7 +1471,7 @@ impl LinkCollector<'_, '_> { ) { // The resolved item did not match the disambiguator; give a better error than 'not found' let msg = format!("incompatible link kind for `{path_str}`"); - let callback = |diag: &mut Diag<'_, ()>, sp: Option, link_range| { + let callback = |diag: &mut Diag<'_>, sp: Option, link_range| { let note = format!( "this link resolved to {} {}, which is not {} {}", resolved.article(), @@ -1929,7 +1929,7 @@ fn report_diagnostic( lint: &'static Lint, msg: impl Into + Display, DiagnosticInfo { item, ori_link: _, dox, link_range }: &DiagnosticInfo<'_>, - decorate: impl FnOnce(&mut Diag<'_, ()>, Option, MarkdownLinkRange), + decorate: impl FnOnce(&mut Diag<'_>, Option, MarkdownLinkRange), ) { let Some(hir_id) = DocContext::as_local_hir_id(tcx, item.item_id) else { // If non-local, no need to check anything. @@ -2007,7 +2007,7 @@ fn report_diagnostic( fn suggest_path_name_typo( collector: &LinkCollector<'_, '_>, - diag: &mut Diag<'_, ()>, + diag: &mut Diag<'_>, span: Option, link_range: &MarkdownLinkRange, dox: &str, @@ -2522,7 +2522,7 @@ fn ambiguity_error( /// disambiguator. fn suggest_disambiguator( res: Res, - diag: &mut Diag<'_, ()>, + diag: &mut Diag<'_>, path_str: &str, link_range: MarkdownLinkRange, sp: Option, diff --git a/src/librustdoc/passes/lint/check_code_block_syntax.rs b/src/librustdoc/passes/lint/check_code_block_syntax.rs index b25d081f6ae80..cd838a4a83b20 100644 --- a/src/librustdoc/passes/lint/check_code_block_syntax.rs +++ b/src/librustdoc/passes/lint/check_code_block_syntax.rs @@ -41,8 +41,8 @@ fn check_rust_syntax( is_precise_span: bool, } - impl<'a, 'b> Diagnostic<'a, ()> for CodeblockError<'b> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a, 'b> Diagnostic<'a> for CodeblockError<'b> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { buffer, code_block, span, is_precise_span } = self; let mut lint = Diag::new( diff --git a/src/librustdoc/passes/lint/redundant_explicit_links.rs b/src/librustdoc/passes/lint/redundant_explicit_links.rs index d2f244e7bba0b..902054c917699 100644 --- a/src/librustdoc/passes/lint/redundant_explicit_links.rs +++ b/src/librustdoc/passes/lint/redundant_explicit_links.rs @@ -164,8 +164,8 @@ struct RedundantExplicitLinksWithoutSuggestion { dest_link: String, } -impl<'a> Diagnostic<'a, ()> for RedundantExplicitLinksWithoutSuggestion { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for RedundantExplicitLinksWithoutSuggestion { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { attr_span, display_link, dest_link } = self; Diag::new(dcx, level, "redundant explicit link target") @@ -199,8 +199,8 @@ fn check_inline_or_reference_unknown_redundancy( display_link: String, } - impl<'a> Diagnostic<'a, ()> for RedundantExplicitLinks { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a> Diagnostic<'a> for RedundantExplicitLinks { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { explicit_span, display_span, link_span, display_link } = self; Diag::new(dcx, level, "redundant explicit link target") @@ -318,8 +318,8 @@ fn check_reference_redundancy( display_link: String, } - impl<'a> Diagnostic<'a, ()> for RedundantExplicitLinkTarget { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a> Diagnostic<'a> for RedundantExplicitLinkTarget { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { explicit_span, display_span, def_span, link_span, display_link } = self; Diag::new(dcx, level, "redundant explicit link target") diff --git a/src/librustdoc/passes/lint/unescaped_backticks.rs b/src/librustdoc/passes/lint/unescaped_backticks.rs index 9c86c50dcca7c..dd6a1b26de76f 100644 --- a/src/librustdoc/passes/lint/unescaped_backticks.rs +++ b/src/librustdoc/passes/lint/unescaped_backticks.rs @@ -413,7 +413,7 @@ fn suggest_insertion( cx: &DocContext<'_>, item: &Item, dox: &str, - lint: &mut Diag<'_, ()>, + lint: &mut Diag<'_>, insert_index: usize, suggestion: char, message: &'static str, diff --git a/src/tools/clippy/clippy_config/src/types.rs b/src/tools/clippy/clippy_config/src/types.rs index 53df7f4e2581b..a9a04e8a5c0a9 100644 --- a/src/tools/clippy/clippy_config/src/types.rs +++ b/src/tools/clippy/clippy_config/src/types.rs @@ -141,7 +141,7 @@ impl DisallowedPath { &self.path.node } - pub fn diag_amendment(&self, span: Span) -> impl FnOnce(&mut Diag<'_, ()>) { + pub fn diag_amendment(&self, span: Span) -> impl FnOnce(&mut Diag<'_>) { move |diag| { if let Some(replacement) = &self.replacement { diag.span_suggestion( diff --git a/src/tools/clippy/clippy_lints/src/casts/cast_possible_truncation.rs b/src/tools/clippy/clippy_lints/src/casts/cast_possible_truncation.rs index f758fb0042301..ce03afac4c102 100644 --- a/src/tools/clippy/clippy_lints/src/casts/cast_possible_truncation.rs +++ b/src/tools/clippy/clippy_lints/src/casts/cast_possible_truncation.rs @@ -181,7 +181,7 @@ fn offer_suggestion( expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_to_span: Span, - diag: &mut Diag<'_, ()>, + diag: &mut Diag<'_>, ) { let cast_to_snip = snippet(cx, cast_to_span, ".."); let mut applicability = Applicability::Unspecified; diff --git a/src/tools/clippy/clippy_lints/src/empty_line_after.rs b/src/tools/clippy/clippy_lints/src/empty_line_after.rs index aa5b8ec2f727a..805f5dca1bf5d 100644 --- a/src/tools/clippy/clippy_lints/src/empty_line_after.rs +++ b/src/tools/clippy/clippy_lints/src/empty_line_after.rs @@ -431,7 +431,7 @@ impl EmptyLineAfter { /// If the node the attributes/docs apply to is the first in the module/crate suggest converting /// them to inner attributes/docs - fn suggest_inner(&self, diag: &mut Diag<'_, ()>, kind: StopKind, gaps: &[Gap<'_>], id: NodeId) { + fn suggest_inner(&self, diag: &mut Diag<'_>, kind: StopKind, gaps: &[Gap<'_>], id: NodeId) { if let Some(parent) = self.items.iter().rev().nth(1) && matches!(parent.kind, ItemKindDescr::Module | ItemKindDescr::Crate) && parent.mod_items == Some(id) diff --git a/src/tools/clippy/clippy_lints/src/functions/result.rs b/src/tools/clippy/clippy_lints/src/functions/result.rs index 6a7013e0f1737..a2121bb431b4e 100644 --- a/src/tools/clippy/clippy_lints/src/functions/result.rs +++ b/src/tools/clippy/clippy_lints/src/functions/result.rs @@ -174,7 +174,7 @@ fn check_result_large_err<'tcx>( RESULT_LARGE_ERR, hir_ty_span, format!("the `Err`-variant returned from this {subject} is very large"), - |diag: &mut Diag<'_, ()>| { + |diag: &mut Diag<'_>| { diag.span_label(hir_ty_span, format!("the `Err`-variant is at least {ty_size} bytes")); diag.help(format!("try reducing the size of `{err_ty}`, for example by boxing large elements or replacing it with `Box<{err_ty}>`")); }, diff --git a/src/tools/clippy/clippy_lints/src/if_let_mutex.rs b/src/tools/clippy/clippy_lints/src/if_let_mutex.rs index 310b45ca408cf..4e9cf7925f286 100644 --- a/src/tools/clippy/clippy_lints/src/if_let_mutex.rs +++ b/src/tools/clippy/clippy_lints/src/if_let_mutex.rs @@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for IfLetMutex { && let Some(arm_mutex) = for_each_expr_without_closures((if_then, if_else), |e| mutex_lock_call(cx, ctxt, e, Some(op_mutex))) { - let diag = |diag: &mut Diag<'_, ()>| { + let diag = |diag: &mut Diag<'_>| { diag.span_label( op_mutex.span, "this Mutex will remain locked for the entire `if let`-block...", diff --git a/src/tools/clippy/clippy_lints/src/implicit_hasher.rs b/src/tools/clippy/clippy_lints/src/implicit_hasher.rs index e39ff754a5b3b..02f8170fedc27 100644 --- a/src/tools/clippy/clippy_lints/src/implicit_hasher.rs +++ b/src/tools/clippy/clippy_lints/src/implicit_hasher.rs @@ -61,7 +61,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitHasher { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) { fn suggestion( cx: &LateContext<'_>, - diag: &mut Diag<'_, ()>, + diag: &mut Diag<'_>, generics_span: Span, generics_suggestion_span: Span, target: &ImplicitHasherType<'_>, diff --git a/src/tools/clippy/clippy_lints/src/large_stack_frames.rs b/src/tools/clippy/clippy_lints/src/large_stack_frames.rs index 3d3539bc70458..77357538461f5 100644 --- a/src/tools/clippy/clippy_lints/src/large_stack_frames.rs +++ b/src/tools/clippy/clippy_lints/src/large_stack_frames.rs @@ -183,7 +183,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackFrames { return; } - let explain_lint = |diag: &mut Diag<'_, ()>, ctxt: SyntaxContext| { + let explain_lint = |diag: &mut Diag<'_>, ctxt: SyntaxContext| { // Point out the largest individual contribution to this size, because // it is the most likely to be unintentionally large. if let Some((local, size)) = sizes_of_locals.iter().max_by_key(|&(_, size)| size) diff --git a/src/tools/clippy/clippy_lints/src/manual_clamp.rs b/src/tools/clippy/clippy_lints/src/manual_clamp.rs index 41f8fff98a21c..8a30e01d0aaf0 100644 --- a/src/tools/clippy/clippy_lints/src/manual_clamp.rs +++ b/src/tools/clippy/clippy_lints/src/manual_clamp.rs @@ -205,7 +205,7 @@ fn maybe_emit_suggestion<'tcx>(cx: &LateContext<'tcx>, suggestion: &ClampSuggest }; let suggestion = format!("{assignment}{input}.clamp({min}, {max}){semicolon}"); let msg = "clamp-like pattern without using clamp function"; - let lint_builder = |d: &mut Diag<'_, ()>| { + let lint_builder = |d: &mut Diag<'_>| { d.span_suggestion(*span, "replace with clamp", suggestion, Applicability::MaybeIncorrect); if *is_float { d.note("clamp will panic if max < min, min.is_nan(), or max.is_nan()") diff --git a/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs b/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs index db1e4f2717bd9..3581f7a93ef07 100644 --- a/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs +++ b/src/tools/clippy/clippy_lints/src/matches/significant_drop_in_scrutinee.rs @@ -121,7 +121,7 @@ fn check<'tcx>( } } -fn set_suggestion<'tcx>(diag: &mut Diag<'_, ()>, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, found: FoundSigDrop) { +fn set_suggestion<'tcx>(diag: &mut Diag<'_>, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, found: FoundSigDrop) { let original = snippet(cx, found.found_span, ".."); let trailing_indent = " ".repeat(indent_of(cx, found.found_span).unwrap_or(0)); diff --git a/src/tools/clippy/clippy_lints/src/matches/single_match.rs b/src/tools/clippy/clippy_lints/src/matches/single_match.rs index f3e7d080237c8..3d9a634f2008f 100644 --- a/src/tools/clippy/clippy_lints/src/matches/single_match.rs +++ b/src/tools/clippy/clippy_lints/src/matches/single_match.rs @@ -90,7 +90,7 @@ fn report_single_pattern( ) { let lint = if els.is_some() { SINGLE_MATCH_ELSE } else { SINGLE_MATCH }; let ctxt = expr.span.ctxt(); - let note = |diag: &mut Diag<'_, ()>| { + let note = |diag: &mut Diag<'_>| { if contains_comments { diag.note("you might want to preserve the comments from inside the `match`"); } diff --git a/src/tools/clippy/clippy_lints/src/methods/suspicious_command_arg_space.rs b/src/tools/clippy/clippy_lints/src/methods/suspicious_command_arg_space.rs index 185baf592f2e1..b596e710e5307 100644 --- a/src/tools/clippy/clippy_lints/src/methods/suspicious_command_arg_space.rs +++ b/src/tools/clippy/clippy_lints/src/methods/suspicious_command_arg_space.rs @@ -24,7 +24,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, recv: &'tcx hir::Expr<'_>, arg SUSPICIOUS_COMMAND_ARG_SPACE, arg.span, "single argument that looks like it should be multiple arguments", - |diag: &mut Diag<'_, ()>| { + |diag: &mut Diag<'_>| { diag.multipart_suggestion( "consider splitting the argument", vec![(span, "args".to_string()), (arg.span, format!("[{arg1:?}, {arg2:?}]"))], diff --git a/src/tools/clippy/clippy_lints/src/methods/swap_with_temporary.rs b/src/tools/clippy/clippy_lints/src/methods/swap_with_temporary.rs index 0b8f6ae9f2779..b04b9140adf2e 100644 --- a/src/tools/clippy/clippy_lints/src/methods/swap_with_temporary.rs +++ b/src/tools/clippy/clippy_lints/src/methods/swap_with_temporary.rs @@ -76,7 +76,7 @@ impl<'tcx> ArgKind<'tcx> { // Emits a note either on the temporary expression if it can be found in the same context as the // base and returns `true`, or on the mutable reference to the temporary expression otherwise and // returns `false`. -fn emit_note(diag: &mut Diag<'_, ()>, base: &Expr<'_>, expr: &Expr<'_>, expr_temp: &Expr<'_>) -> bool { +fn emit_note(diag: &mut Diag<'_>, base: &Expr<'_>, expr: &Expr<'_>, expr_temp: &Expr<'_>) -> bool { if base.span.eq_ctxt(expr.span) { diag.span_note(expr_temp.span.source_callsite(), MSG_TEMPORARY); true diff --git a/src/tools/clippy/clippy_lints/src/methods/unnecessary_fold.rs b/src/tools/clippy/clippy_lints/src/methods/unnecessary_fold.rs index 1e6e27afc6775..edb1c9c53ded7 100644 --- a/src/tools/clippy/clippy_lints/src/methods/unnecessary_fold.rs +++ b/src/tools/clippy/clippy_lints/src/methods/unnecessary_fold.rs @@ -75,7 +75,7 @@ impl Replacement { } } - fn maybe_add_note(&self, diag: &mut Diag<'_, ()>) { + fn maybe_add_note(&self, diag: &mut Diag<'_>) { if self.is_short_circuiting { diag.note(format!( "the `{}` method is short circuiting and may change the program semantics if the iterator has side effects", diff --git a/src/tools/clippy/clippy_lints/src/missing_asserts_for_indexing.rs b/src/tools/clippy/clippy_lints/src/missing_asserts_for_indexing.rs index 98f8b63532cc5..bb615ff4ef110 100644 --- a/src/tools/clippy/clippy_lints/src/missing_asserts_for_indexing.rs +++ b/src/tools/clippy/clippy_lints/src/missing_asserts_for_indexing.rs @@ -68,7 +68,7 @@ declare_lint_pass!(MissingAssertsForIndexing => [MISSING_ASSERTS_FOR_INDEXING]); fn report_lint(cx: &LateContext<'_>, index_spans: Vec, msg: &'static str, f: F) where - F: FnOnce(&mut Diag<'_, ()>), + F: FnOnce(&mut Diag<'_>), { span_lint_and_then(cx, MISSING_ASSERTS_FOR_INDEXING, index_spans, msg, |diag| { f(diag); diff --git a/src/tools/clippy/clippy_lints/src/mutex_atomic.rs b/src/tools/clippy/clippy_lints/src/mutex_atomic.rs index 52797d43a045f..b3ee09c71af17 100644 --- a/src/tools/clippy/clippy_lints/src/mutex_atomic.rs +++ b/src/tools/clippy/clippy_lints/src/mutex_atomic.rs @@ -135,7 +135,7 @@ fn check_expr<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, ty_ascription: &T && let Some(atomic_name) = get_atomic_name(mutex_param) { let msg = "using a `Mutex` where an atomic would do"; - let diag = |diag: &mut Diag<'_, _>| { + let diag = |diag: &mut Diag<'_>| { // if `expr = Mutex::new(arg)`, we can try emitting a suggestion if let ExprKind::Call(qpath, [arg]) = expr.kind && let ExprKind::Path(QPath::TypeRelative(_mutex, new)) = qpath.kind diff --git a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs index c332b332cbd41..d6f30e1865853 100644 --- a/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs +++ b/src/tools/clippy/clippy_lints/src/needless_pass_by_value.rs @@ -203,7 +203,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { && !moved_vars.contains(&canonical_id) { // Dereference suggestion - let sugg = |diag: &mut Diag<'_, ()>| { + let sugg = |diag: &mut Diag<'_>| { if let ty::Adt(def, ..) = ty.kind() && let Some(span) = cx.tcx.hir_span_if_local(def.did()) && type_allowed_to_implement_copy( diff --git a/src/tools/clippy/clippy_lints/src/pointers_in_nomem_asm_block.rs b/src/tools/clippy/clippy_lints/src/pointers_in_nomem_asm_block.rs index 58d6fa24ce13b..eeaed34abac50 100644 --- a/src/tools/clippy/clippy_lints/src/pointers_in_nomem_asm_block.rs +++ b/src/tools/clippy/clippy_lints/src/pointers_in_nomem_asm_block.rs @@ -81,7 +81,7 @@ fn has_in_operand_pointer(cx: &LateContext<'_>, asm_op: &InlineAsmOperand<'_>) - cx.typeck_results().expr_ty(asm_in_expr).is_any_ptr() } -fn additional_notes(diag: &mut rustc_errors::Diag<'_, ()>) { +fn additional_notes(diag: &mut rustc_errors::Diag<'_>) { diag.note("`nomem` means that no memory write or read happens inside the asm! block"); diag.note("if this is intentional and no pointers are read or written to, consider allowing the lint"); } diff --git a/src/tools/clippy/clippy_utils/src/diagnostics.rs b/src/tools/clippy/clippy_utils/src/diagnostics.rs index 4cda9c4aeb568..e063b3d6cc632 100644 --- a/src/tools/clippy/clippy_utils/src/diagnostics.rs +++ b/src/tools/clippy/clippy_utils/src/diagnostics.rs @@ -16,7 +16,7 @@ use rustc_lint::{LateContext, Lint, LintContext}; use rustc_span::Span; use std::env; -fn docs_link(diag: &mut Diag<'_, ()>, lint: &'static Lint) { +fn docs_link(diag: &mut Diag<'_>, lint: &'static Lint) { if env::var("CLIPPY_DISABLE_DOCS_LINKS").is_err() && let Some(lint) = lint.name_lower().strip_prefix("clippy::") { @@ -43,7 +43,7 @@ fn docs_link(diag: &mut Diag<'_, ()>, lint: &'static Lint) { /// /// This function makes sure we also validate them in debug clippy builds. #[cfg(debug_assertions)] -fn validate_diag(diag: &Diag<'_, G>) { +fn validate_diag(diag: &Diag<'_>) { let suggestions = match &diag.suggestions { Suggestions::Enabled(suggs) => &**suggs, Suggestions::Sealed(suggs) => &**suggs, @@ -238,12 +238,12 @@ where C: LintContext, S: Into, M: Into, - F: FnOnce(&mut Diag<'_, ()>), + F: FnOnce(&mut Diag<'_>), { - struct ClippyDiag)>(F); + struct ClippyDiag)>(F); - impl<'a, F: FnOnce(&mut Diag<'_, ()>)> Diagnostic<'a, ()> for ClippyDiag { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a, F: FnOnce(&mut Diag<'_>)> Diagnostic<'a> for ClippyDiag { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut lint = Diag::new(dcx, level, ""); (self.0)(&mut lint); lint @@ -255,7 +255,7 @@ where cx.emit_span_lint( lint, sp.clone(), - ClippyDiag(|diag: &mut Diag<'_, ()>| { + ClippyDiag(|diag: &mut Diag<'_>| { diag.primary_message(msg); diag.span(sp); f(diag); @@ -327,7 +327,7 @@ pub fn span_lint_hir_and_then( hir_id: HirId, sp: impl Into, msg: impl Into, - f: impl FnOnce(&mut Diag<'_, ()>), + f: impl FnOnce(&mut Diag<'_>), ) { #[expect(clippy::disallowed_methods)] cx.tcx.emit_node_span_lint( diff --git a/src/tools/clippy/clippy_utils/src/sugg.rs b/src/tools/clippy/clippy_utils/src/sugg.rs index 702bbd0be46dc..3d4645f72fce3 100644 --- a/src/tools/clippy/clippy_utils/src/sugg.rs +++ b/src/tools/clippy/clippy_utils/src/sugg.rs @@ -744,7 +744,7 @@ pub trait DiagExt { fn suggest_remove_item(&mut self, cx: &T, item: Span, msg: &str, applicability: Applicability); } -impl DiagExt for rustc_errors::Diag<'_, ()> { +impl DiagExt for rustc_errors::Diag<'_> { fn suggest_item_with_attr( &mut self, cx: &T, diff --git a/src/tools/miri/src/diagnostics.rs b/src/tools/miri/src/diagnostics.rs index 1d88a792734f9..4d25aed007416 100644 --- a/src/tools/miri/src/diagnostics.rs +++ b/src/tools/miri/src/diagnostics.rs @@ -572,7 +572,7 @@ fn report_msg<'tcx>( DiagLevel::Warning => Level::Warning, DiagLevel::Note => Level::Note, }; - let mut err = Diag::<()>::new(tcx.sess.dcx(), level, title); + let mut err = Diag::new(tcx.sess.dcx(), level, title); err.span(span); // Show main message. diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs index b30d33091c47f..c744c03f8649a 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs @@ -2,7 +2,7 @@ // Tests that a doc comment will not preclude a field from being considered a diagnostic argument //@ normalize-stderr: "the following other types implement trait `IntoDiagArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr" //@ normalize-stderr: "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC" -//@ normalize-stderr: "rustc_errors::Diag::<'a, G>::arg" -> "Diag::<'a, G>::arg" +//@ normalize-stderr: "rustc_errors::Diag::<'a>::arg" -> "Diag::<'a>::arg" // The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, // changing the output of this test. Since Subdiagnostic is strictly internal to the compiler diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr index feee6eed4593f..24f01051bb6f7 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr @@ -14,7 +14,7 @@ LL | struct NotIntoDiagArg; | ^^^^^^^^^^^^^^^^^^^^^ = help: normalized in stderr = note: there's an inherent method on `DiagInner` of the same name, which can be auto-dereferenced from `&mut DiagInner` -note: required by a bound in `Diag::<'a, G>::arg` +note: required by a bound in `Diag::<'a>::arg` --> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC ::: $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC | From df1b5c96717c5839af6c7fa314b55c046043dbfa Mon Sep 17 00:00:00 2001 From: James Barford-Evans Date: Mon, 21 Sep 2026 08:57:51 +0100 Subject: [PATCH 12/21] `f16b` Implementation and documentation --- compiler/rustc_attr_ir/src/lang_items.rs | 1 + compiler/rustc_feature/src/builtin_attrs.rs | 5 + compiler/rustc_feature/src/unstable.rs | 4 + .../rustc_hir_analysis/src/check/check.rs | 2 + compiler/rustc_interface/src/util.rs | 4 + compiler/rustc_middle/src/ty/layout.rs | 5 + compiler/rustc_span/src/symbol.rs | 3 + compiler/rustc_ty_utils/src/layout.rs | 10 +- library/core/Cargo.toml | 1 + library/core/src/num/bfloat.rs | 183 ++++++++++++++++++ library/core/src/num/mod.rs | 3 + .../src/language-features/f16b.md | 11 ++ 12 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 library/core/src/num/bfloat.rs create mode 100644 src/doc/unstable-book/src/language-features/f16b.md diff --git a/compiler/rustc_attr_ir/src/lang_items.rs b/compiler/rustc_attr_ir/src/lang_items.rs index c1ad05dc8e4a8..60890f7799290 100644 --- a/compiler/rustc_attr_ir/src/lang_items.rs +++ b/compiler/rustc_attr_ir/src/lang_items.rs @@ -281,6 +281,7 @@ language_item_table! { PartialEq, sym::eq, eq_trait, Target::Trait, GenericRequirement::Exact(1); PartialOrd, sym::partial_ord, partial_ord_trait, Target::Trait, GenericRequirement::Exact(1); CVoid, sym::c_void, c_void, Target::Enum, GenericRequirement::None; + F16B, sym::f16b, f16b, Target::Struct, GenericRequirement::Exact(0); Type, sym::type_info, type_struct, Target::Struct, GenericRequirement::None; TypeGeneric, sym::type_info_generic, type_generic, Target::Enum, GenericRequirement::None; diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index bb35a3281ccdc..0f96eb7f158ed 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -40,6 +40,11 @@ const GATED_CFGS: &[GatedCfg] = &[ sym::cfg_target_has_reliable_f16_f128, Features::cfg_target_has_reliable_f16_f128, ), + ( + sym::target_has_reliable_f16b, + sym::cfg_target_has_reliable_f16b, + Features::cfg_target_has_reliable_f16b, + ), ( sym::target_has_reliable_f128, sym::cfg_target_has_reliable_f16_f128, diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index a7138a88ee399..94e3b77c6b575 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -227,6 +227,8 @@ declare_features! ( (unstable, anonymous_lifetime_in_impl_trait, "1.63.0", None), /// Allows checking whether or not the backend correctly supports unstable float types. (internal, cfg_target_has_reliable_f16_f128, "1.88.0", None), + /// Allows checking whether or not the backend correctly supports the unstable `f16b` type. + (internal, cfg_target_has_reliable_f16b, "CURRENT_RUSTC_VERSION", None), /// Allows checking whether or not the target might have thread support. (internal, cfg_target_has_threads, "1.99.0", None), /// Allows identifying the `compiler_builtins` crate. @@ -520,6 +522,8 @@ declare_features! ( (unstable, f128, "1.78.0", Some(116909)), /// Allow using 16-bit (half precision) floating point numbers. (unstable, f16, "1.78.0", Some(116909)), + /// Allow using bfloat16 floating point numbers. + (unstable, f16b, "CURRENT_RUSTC_VERSION", Some(160630)), /// Allows the use of `#[ffi_const]` on foreign functions. (unstable, ffi_const, "1.45.0", Some(58328)), /// Allows the use of `#[ffi_pure]` on foreign functions. diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 705bb780a3ecf..7cebf6dd16711 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -1592,6 +1592,8 @@ fn check_scalable_vector(tcx: TyCtxt<'_>, span: Span, def_id: LocalDefId, scalab // bools match element_ty.kind() { ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Bool => (), + // We need to treat a `bfloat` (`f16b`) as a primitive scalar + ty::Adt(def, _) if tcx.is_lang_item(def.did(), LangItem::F16B) => (), _ => { let mut err = tcx.dcx().struct_span_err( span, diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 87b2bb94cd4f9..5c6aef8676716 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -74,6 +74,9 @@ pub(crate) fn add_configuration( if target_config.has_reliable_f16_math { cfg.insert((sym::target_has_reliable_f16_math, None)); } + if target_config.has_reliable_f16b { + cfg.insert((sym::target_has_reliable_f16b, None)); + } if target_config.has_reliable_f128 { cfg.insert((sym::target_has_reliable_f128, None)); } @@ -419,6 +422,7 @@ impl CodegenBackend for DummyCodegenBackend { internal_target_features, has_reliable_f16: true, has_reliable_f16_math: true, + has_reliable_f16b: true, has_reliable_f128: true, has_reliable_f128_math: true, } diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 22fbb306849da..8f2bb97e12a8f 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -137,6 +137,11 @@ impl abi::Float { use abi::Float::*; match *self { F16 => tcx.types.f16, + F16B => Ty::new_adt( + tcx, + tcx.adt_def(tcx.require_lang_item(LangItem::F16B, DUMMY_SP)), + ty::List::empty(), + ), F32 => tcx.types.f32, F64 => tcx.types.f64, F128 => tcx.types.f128, diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 39d9d2b7b05ce..098b6595f166e 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -621,6 +621,7 @@ symbols! { cfg_target_has_atomic, cfg_target_has_atomic_equal_alignment, cfg_target_has_reliable_f16_f128, + cfg_target_has_reliable_f16b, cfg_target_has_threads, cfg_target_object_format, cfg_target_thread_local, @@ -958,6 +959,7 @@ symbols! { external_doc, f16, f16_nan, + f16b, f16c_target_feature, f32, f32_nan, @@ -2125,6 +2127,7 @@ symbols! { target_has_atomic_primitive_alignment, target_has_reliable_f16, target_has_reliable_f16_math, + target_has_reliable_f16b, target_has_reliable_f128, target_has_reliable_f128_math, target_has_threads, diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index fe093adcbf3f4..dee4b785e418d 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -11,6 +11,7 @@ use rustc_abi::{ }; use rustc_hashes::Hash64; use rustc_hir as hir; +use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::find_attr; use rustc_index::{Idx as _, IndexVec}; use rustc_middle::query::Providers; @@ -737,7 +738,7 @@ fn layout_of_uncached<'tcx>( .is_sized(tcx, typing_env) }); - let layout = cx + let mut layout = cx .calc .layout_of_struct_or_enum( &def.repr(), @@ -804,6 +805,13 @@ fn layout_of_uncached<'tcx>( } } + if tcx.is_lang_item(def.did(), LangItem::F16B) { + let bfloat = scalar_unit(Primitive::Float(abi::Float::F16B)); + assert_eq!(layout.size, abi::Float::F16B.size()); + layout.align = abi::Float::F16B.align(cx); + layout.backend_repr = BackendRepr::Scalar(bfloat); + } + tcx.mk_layout(layout) } diff --git a/library/core/Cargo.toml b/library/core/Cargo.toml index 3f5f9f454a99d..d8f4ec0528dee 100644 --- a/library/core/Cargo.toml +++ b/library/core/Cargo.toml @@ -36,6 +36,7 @@ check-cfg = [ # gate tests. 'cfg(target_has_reliable_f16)', 'cfg(target_has_reliable_f16_math)', + 'cfg(target_has_reliable_f16b)', 'cfg(target_has_reliable_f128)', 'cfg(target_has_reliable_f128_math)', # Prevents use of a static variable for providing platform specific RawOsError diff --git a/library/core/src/num/bfloat.rs b/library/core/src/num/bfloat.rs new file mode 100644 index 0000000000000..4937dd8448c60 --- /dev/null +++ b/library/core/src/num/bfloat.rs @@ -0,0 +1,183 @@ +//! The 16-bit brain floating-point type. + +#![unstable(feature = "f16b", issue = "160630")] + +use crate::{fmt, mem}; + +/// A 16-bit brain floating-point value. +/// +/// This type stores values using the bfloat16 encoding. It deliberately +/// exposes only raw-bit construction, comparison, formatting, and lossless +/// widening to [`f32`]. +/// +/// The 16-bit brain floating-point intends to preserve the dynamic range of +/// a 32-bit floating-point value while using half the storage. It does +/// this by using 8 bits for the exponent, the same as `f32`, but only +/// using 7 bits for the mantissa. See [Wikipedia on bfloat16][wikipedia] for +/// more information. +/// +/// [wikipedia]: https://en.wikipedia.org/wiki/Bfloat16_floating-point_format +#[lang = "f16b"] +#[doc(alias = "bf16")] // what hardware often names it +#[doc(alias = "bfloat")] // LLVM's name +#[doc(alias = "bfloat16")] // Wikipedia's name +#[doc(alias = "bfloat16_t")] // The C++ `stdfloat` name +#[allow(non_camel_case_types)] +#[repr(transparent)] +#[unstable(feature = "f16b", issue = "160630")] +pub struct f16b(u16); + +#[doc(test(attr( + feature(cfg_target_has_reliable_f16b), + allow(internal_features, unused_features) +)))] +impl f16b { + /// Raw transmutation from `u16`. + /// + /// This is currently identical to `transmute::(v)` on all platforms. + /// It turns out this is incredibly portable, for two reasons: + /// + /// * Floats and Ints have the same endianness on all supported platforms. + /// * IEEE 754 very precisely specifies the bit layout of floats. + /// + /// However there is one caveat: prior to the 2008 version of IEEE 754, how + /// to interpret the NaN signaling bit wasn't actually specified. Most platforms + /// (notably x86 and ARM) picked the interpretation that was ultimately + /// standardized in 2008, but some didn't (notably MIPS). As a result, all + /// signaling NaNs on MIPS are quiet NaNs on x86, and vice-versa. + /// + /// Rather than trying to preserve signaling-ness cross-platform, this + /// implementation favors preserving the exact bits. This means that + /// any payloads encoded in NaNs will be preserved even if the result of + /// this method is sent over the network from an x86 machine to a MIPS one. + /// + /// If the results of this method are only manipulated by the same + /// architecture that produced them, then there is no portability concern. + /// + /// If the input isn't NaN, then there is no portability concern. + /// + /// If you don't care about signalingness (very likely), then there is no + /// portability concern. + /// + /// Note that this function is distinct from `as` casting, which attempts to + /// preserve the *numeric* value, and not the bitwise value. + /// + /// ```no_run + /// #![feature(f16b)] + /// # #[cfg(target_has_reliable_f16b)] { + /// use core::num::f16b; + /// + /// let v = f16b::from_bits(0x4148); + /// assert_eq!(f32::from(v), 12.5); + /// # } + /// ``` + #[inline] + #[must_use] + #[unstable(feature = "f16b", issue = "160630")] + pub const fn from_bits(bits: u16) -> Self { + // SAFETY: `f16b` and `u16` have the same size, and every bit pattern is valid. + unsafe { mem::transmute(bits) } + } + + /// Raw transmutation to `u16`. + /// + /// This is currently identical to `transmute::(self)` on all platforms. + /// + /// See [`from_bits`](#method.from_bits) for some discussion of the + /// portability of this operation (there are almost no issues). + /// + /// Note that this function is distinct from `as` casting, which attempts to + /// preserve the *numeric* value, and not the bitwise value. + /// + /// ```no_run + /// #![feature(f16b)] + /// # #[cfg(target_has_reliable_f16b)] { + /// use core::num::f16b; + /// + /// assert_eq!(f16b::from_bits(0x4148).to_bits(), 0x4148); + /// # } + /// ``` + #[inline] + #[unstable(feature = "f16b", issue = "160630")] + #[must_use = "this returns the result of the operation, without modifying the original"] + pub const fn to_bits(self) -> u16 { + // SAFETY: `f16b` and `u16` have the same size, and every bit pattern is valid. + unsafe { mem::transmute(self) } + } +} + +// FIXME(f16b) - This should be a `#[rustc_intrinsic]` using LLVM's `fpext` +// with this implementation constituting the fallback. +#[inline] +const fn widen(value: f16b) -> f32 { + f32::from_bits((value.to_bits() as u32) << 16) +} + +#[unstable(feature = "f16b", issue = "160630")] +impl Copy for f16b {} + +#[unstable(feature = "f16b", issue = "160630")] +impl Clone for f16b { + #[inline] + fn clone(&self) -> Self { + *self + } +} + +#[unstable(feature = "f16b", issue = "160630")] +impl Default for f16b { + #[inline] + fn default() -> Self { + Self::from_bits(0) + } +} + +#[unstable(feature = "f16b", issue = "160630")] +impl PartialEq for f16b { + #[inline] + fn eq(&self, other: &Self) -> bool { + widen(*self).eq(&widen(*other)) + } +} + +#[unstable(feature = "f16b", issue = "160630")] +impl PartialOrd for f16b { + #[inline] + fn partial_cmp(&self, other: &Self) -> Option { + widen(*self).partial_cmp(&widen(*other)) + } +} + +#[unstable(feature = "f16b", issue = "160630")] +impl From for f32 { + #[inline] + fn from(value: f16b) -> Self { + widen(value) + } +} + +#[unstable(feature = "f16b", issue = "160630")] +impl fmt::Debug for f16b { + #[inline] + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(&widen(*self), formatter) + } +} + +#[cfg(not(no_fp_fmt_parse))] +#[unstable(feature = "f16b", issue = "160630")] +impl fmt::LowerExp for f16b { + #[inline] + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::LowerExp::fmt(&widen(*self), formatter) + } +} + +#[cfg(not(no_fp_fmt_parse))] +#[unstable(feature = "f16b", issue = "160630")] +impl fmt::UpperExp for f16b { + #[inline] + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::UpperExp::fmt(&widen(*self), formatter) + } +} diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index db41d23770477..f5c7c853ef590 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -43,6 +43,7 @@ mod int_macros; // import int_impl! #[macro_use] mod uint_macros; // import uint_impl! +mod bfloat; mod complex; mod error; #[cfg(not(no_fp_fmt_parse))] @@ -56,6 +57,8 @@ mod wrapping; #[doc(hidden)] pub mod niche_types; +#[unstable(feature = "f16b", issue = "160630")] +pub use bfloat::f16b; #[unstable(feature = "complex_numbers", issue = "154023")] pub use complex::Complex; #[stable(feature = "int_error_matching", since = "1.55.0")] diff --git a/src/doc/unstable-book/src/language-features/f16b.md b/src/doc/unstable-book/src/language-features/f16b.md new file mode 100644 index 0000000000000..c18289921e032 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/f16b.md @@ -0,0 +1,11 @@ +# `f16b` + +The tracking issue for this feature is: [#160630] + +[#160630]: https://github.com/rust-lang/rust/issues/160630 + +--- + +Enable the `core::num::f16b` type for values stored in the bfloat16 format. + +`f16b` is a nominal library type, not a primitive floating-point type: it has no literal suffix, arithmetic operators, or numeric `as` casts. A compiler lang item connects its layout to the chosen backend's representation. From cdde2f00b571b6f84a07cdc1c5d1a27335657c6c Mon Sep 17 00:00:00 2001 From: James Barford-Evans Date: Mon, 21 Sep 2026 08:57:51 +0100 Subject: [PATCH 13/21] Add `F16B` to `Float` enum & wireup trivial matches --- compiler/rustc_abi/src/layout/ty.rs | 2 +- compiler/rustc_abi/src/lib.rs | 8 +++++++- compiler/rustc_codegen_llvm/src/va_arg.rs | 6 +++++- compiler/rustc_codegen_ssa/src/mir/naked_asm.rs | 3 +++ compiler/rustc_codegen_ssa/src/traits/type_.rs | 2 ++ compiler/rustc_public/src/abi.rs | 3 ++- compiler/rustc_public/src/unstable/convert/stable/abi.rs | 1 + compiler/rustc_target/src/callconv/mips64.rs | 1 + compiler/rustc_target/src/callconv/sparc64.rs | 1 + 9 files changed, 23 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_abi/src/layout/ty.rs b/compiler/rustc_abi/src/layout/ty.rs index 5033f887a60f9..e51255dc5963f 100644 --- a/compiler/rustc_abi/src/layout/ty.rs +++ b/compiler/rustc_abi/src/layout/ty.rs @@ -342,7 +342,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> { Primitive::Float(float @ (Float::F16 | Float::F32 | Float::F64 | Float::F128)) => { Some(Numeric::Float(float)) } - Primitive::Pointer(..) => None, + Primitive::Pointer(..) | Primitive::Float(Float::F16B) => None, } } diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index b056fdc73d40b..f10f9990debb4 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -1420,6 +1420,10 @@ impl Integer { #[cfg_attr(feature = "nightly", derive(StableHash))] pub enum Float { F16, + /// `f16b`. This is not a builtin type in Rust (it is exposed as a lang item), + /// but it is a builtin type in LLVM so needs to be explicitly represented + /// in the backend. + F16B, F32, F64, F128, @@ -1431,6 +1435,7 @@ impl Float { match self { F16 => Size::from_bits(16), + F16B => Size::from_bits(16), F32 => Size::from_bits(32), F64 => Size::from_bits(64), F128 => Size::from_bits(128), @@ -1442,7 +1447,7 @@ impl Float { let dl = cx.data_layout(); AbiAlign::new(match self { - F16 => dl.f16_align, + F16 | F16B => dl.f16_align, F32 => dl.f32_align, F64 => dl.f64_align, F128 => dl.f128_align, @@ -1454,6 +1459,7 @@ impl Float { match self { F16 => "f16", + F16B => "f16b", F32 => "f32", F64 => "f64", F128 => "f128", diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index ca57bee3e6271..e7883871f57e8 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -95,7 +95,7 @@ fn get_param_type_alignment<'ll, 'tcx>( Integer::I128 => return Align::EIGHT, }, Primitive::Float(float) => match float { - Float::F16 | Float::F32 => unreachable!(), + Float::F16 | Float::F16B | Float::F32 => unreachable!(), Float::F64 => { /* fall through */ } Float::F128 => return Align::from_bytes(16).unwrap(), }, @@ -481,7 +481,11 @@ fn emit_s390x_va_arg<'ll, 'tcx>( Primitive::Float(Float::F16 | Float::F32 | Float::F64) => true, Primitive::Float(Float::F128) => false, Primitive::Int(_, _) | Primitive::Pointer(_) => false, + Primitive::Float(Float::F16B) => { + bug!("`f16b` use in varadics unsupported on s390x") + } }, + _ => false, } }; diff --git a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs index ea58b1cd3c53c..3162463d222ee 100644 --- a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs +++ b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs @@ -508,6 +508,9 @@ fn wasm_primitive(primitive: Primitive, ptr_type: &'static str) -> &'static str Integer::I128 => "i64, i64", }, Primitive::Float(float) => match float { + // This could probably use an f32 for WASM however has not been + // verified so leaving as a `bug!(...)` for now. + Float::F16B => bug!("`f16b` unsupported on wasm"), Float::F16 | Float::F32 => "f32", Float::F64 => "f64", Float::F128 => "i64, i64", diff --git a/compiler/rustc_codegen_ssa/src/traits/type_.rs b/compiler/rustc_codegen_ssa/src/traits/type_.rs index 1b70d38dc9e85..986481e7f132f 100644 --- a/compiler/rustc_codegen_ssa/src/traits/type_.rs +++ b/compiler/rustc_codegen_ssa/src/traits/type_.rs @@ -18,6 +18,7 @@ pub trait BaseTypeCodegenMethods: BackendTypes { fn type_isize(&self) -> Self::Type; fn type_f16(&self) -> Self::Type; + fn type_f16b(&self) -> Self::Type; fn type_f32(&self) -> Self::Type; fn type_f64(&self) -> Self::Type; fn type_f128(&self) -> Self::Type; @@ -67,6 +68,7 @@ pub trait DerivedTypeCodegenMethods<'tcx>: use Float::*; match f { F16 => self.type_f16(), + F16B => self.type_f16b(), F32 => self.type_f32(), F64 => self.type_f64(), F128 => self.type_f128(), diff --git a/compiler/rustc_public/src/abi.rs b/compiler/rustc_public/src/abi.rs index b760ed98c7111..67d609c780c42 100644 --- a/compiler/rustc_public/src/abi.rs +++ b/compiler/rustc_public/src/abi.rs @@ -496,6 +496,7 @@ pub enum IntegerLength { #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize)] pub enum FloatLength { F16, + F16B, F32, F64, F128, @@ -516,7 +517,7 @@ impl IntegerLength { impl FloatLength { pub fn bits(self) -> usize { match self { - FloatLength::F16 => 16, + FloatLength::F16 | FloatLength::F16B => 16, FloatLength::F32 => 32, FloatLength::F64 => 64, FloatLength::F128 => 128, diff --git a/compiler/rustc_public/src/unstable/convert/stable/abi.rs b/compiler/rustc_public/src/unstable/convert/stable/abi.rs index 766c522958db7..3c268a6dd23a4 100644 --- a/compiler/rustc_public/src/unstable/convert/stable/abi.rs +++ b/compiler/rustc_public/src/unstable/convert/stable/abi.rs @@ -463,6 +463,7 @@ impl<'tcx> Stable<'tcx> for rustc_abi::Float { fn stable(&self, _: &mut Tables<'_, BridgeTys>, _: &CompilerCtxt<'_, BridgeTys>) -> Self::T { match self { rustc_abi::Float::F16 => FloatLength::F16, + rustc_abi::Float::F16B => FloatLength::F16B, rustc_abi::Float::F32 => FloatLength::F32, rustc_abi::Float::F64 => FloatLength::F64, rustc_abi::Float::F128 => FloatLength::F128, diff --git a/compiler/rustc_target/src/callconv/mips64.rs b/compiler/rustc_target/src/callconv/mips64.rs index 8002f98507ba8..0e3ccf33c3ffe 100644 --- a/compiler/rustc_target/src/callconv/mips64.rs +++ b/compiler/rustc_target/src/callconv/mips64.rs @@ -31,6 +31,7 @@ where match float { // C does not have the f16 type Float::F16 => None, + Float::F16B => unreachable!("`f16b` unsupported on mips64"), Float::F32 => Some(Reg::f32()), Float::F64 => Some(Reg::f64()), Float::F128 => Some(Reg::f128()), diff --git a/compiler/rustc_target/src/callconv/sparc64.rs b/compiler/rustc_target/src/callconv/sparc64.rs index bfaa3f3cb19c8..abef388ef2e12 100644 --- a/compiler/rustc_target/src/callconv/sparc64.rs +++ b/compiler/rustc_target/src/callconv/sparc64.rs @@ -58,6 +58,7 @@ fn classify<'a, Ty, C>( Float::F16 => { // Match LLVM by passing `f16` in integer registers. } + Float::F16B => unreachable!("`f16b` unsupported on sparc64"), } } else { /* pass unaligned floats in integer registers */ From c56a9917d80ad618d18888b14b55895a6838cd66 Mon Sep 17 00:00:00 2001 From: James Barford-Evans Date: Mon, 21 Sep 2026 08:57:52 +0100 Subject: [PATCH 14/21] Wire up f16b in backends --- compiler/rustc_codegen_cranelift/src/common.rs | 1 + compiler/rustc_codegen_cranelift/src/lib.rs | 1 + compiler/rustc_codegen_gcc/src/base.rs | 2 ++ compiler/rustc_codegen_gcc/src/context.rs | 3 +++ compiler/rustc_codegen_gcc/src/lib.rs | 2 ++ compiler/rustc_codegen_gcc/src/type_.rs | 8 ++++++++ compiler/rustc_codegen_llvm/src/abi.rs | 1 + compiler/rustc_codegen_llvm/src/intrinsic.rs | 3 +++ compiler/rustc_codegen_llvm/src/llvm_util.rs | 16 ++++++++++++++++ compiler/rustc_codegen_llvm/src/type_.rs | 4 ++++ compiler/rustc_codegen_ssa/src/lib.rs | 3 +++ compiler/rustc_codegen_ssa/src/traits/backend.rs | 1 + compiler/rustc_session/src/config/cfg.rs | 1 + src/tools/miri/src/bin/miri.rs | 1 + 14 files changed, 47 insertions(+) diff --git a/compiler/rustc_codegen_cranelift/src/common.rs b/compiler/rustc_codegen_cranelift/src/common.rs index d31c8fc810b2c..30bd2f28af53f 100644 --- a/compiler/rustc_codegen_cranelift/src/common.rs +++ b/compiler/rustc_codegen_cranelift/src/common.rs @@ -35,6 +35,7 @@ pub(crate) fn scalar_to_clif_type(tcx: TyCtxt<'_>, scalar: Scalar) -> Type { }, Primitive::Float(float) => match float { Float::F16 => types::F16, + Float::F16B => bug!("f16b is not supported by the Cranelift codegen backend"), Float::F32 => types::F32, Float::F64 => types::F64, Float::F128 => types::F128, diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index d4773e8199aed..6629cc834bbd6 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -196,6 +196,7 @@ impl CodegenBackend for CraneliftCodegenBackend { // available in Cranelift. has_reliable_f16: has_reliable_f16_f128, has_reliable_f16_math: has_reliable_f16_f128, + has_reliable_f16b: false, has_reliable_f128: has_reliable_f16_f128, has_reliable_f128_math, } diff --git a/compiler/rustc_codegen_gcc/src/base.rs b/compiler/rustc_codegen_gcc/src/base.rs index 101af0bb0bff1..498ea4b45a8f8 100644 --- a/compiler/rustc_codegen_gcc/src/base.rs +++ b/compiler/rustc_codegen_gcc/src/base.rs @@ -214,6 +214,7 @@ pub fn compile_codegen_unit( // -fsyntax-only), forbid the compilation when get_target_info() is called on a // context. let f16_type_supported = target_info.supports_target_dependent_type(CType::Float16); + let f16b_type_supported = target_info.supports_target_dependent_type(CType::BFloat16); let f32_type_supported = target_info.supports_target_dependent_type(CType::Float32); let f64_type_supported = target_info.supports_target_dependent_type(CType::Float64); let f128_type_supported = target_info.supports_target_dependent_type(CType::Float128); @@ -225,6 +226,7 @@ pub fn compile_codegen_unit( tcx, u128_type_supported, f16_type_supported, + f16b_type_supported, f32_type_supported, f64_type_supported, f128_type_supported, diff --git a/compiler/rustc_codegen_gcc/src/context.rs b/compiler/rustc_codegen_gcc/src/context.rs index 38e0e5f329f76..a41255be9e1ea 100644 --- a/compiler/rustc_codegen_gcc/src/context.rs +++ b/compiler/rustc_codegen_gcc/src/context.rs @@ -72,6 +72,7 @@ pub struct CodegenCx<'gcc, 'tcx> { pub supports_128bit_integers: bool, pub supports_f16_type: bool, + pub supports_f16b_type: bool, pub supports_f32_type: bool, pub supports_f64_type: bool, pub supports_f128_type: bool, @@ -140,6 +141,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { tcx: TyCtxt<'tcx>, supports_128bit_integers: bool, supports_f16_type: bool, + supports_f16b_type: bool, supports_f32_type: bool, supports_f64_type: bool, supports_f128_type: bool, @@ -276,6 +278,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> { supports_128bit_integers, supports_f16_type, + supports_f16b_type, supports_f32_type, supports_f64_type, supports_f128_type, diff --git a/compiler/rustc_codegen_gcc/src/lib.rs b/compiler/rustc_codegen_gcc/src/lib.rs index d7a3ef3b4a6c5..79802a670a3f0 100644 --- a/compiler/rustc_codegen_gcc/src/lib.rs +++ b/compiler/rustc_codegen_gcc/src/lib.rs @@ -503,6 +503,7 @@ fn target_config(sess: &EarlySession, target_info: &SharedTargetInfo) -> TargetC ); let has_reliable_f16 = target_info.supports_target_dependent_type(CType::Float16); + let has_reliable_f16b = target_info.supports_target_dependent_type(CType::BFloat16); let has_reliable_f128 = target_info.supports_target_dependent_type(CType::Float128); TargetConfig { @@ -510,6 +511,7 @@ fn target_config(sess: &EarlySession, target_info: &SharedTargetInfo) -> TargetC // There are no known bugs with GCC support for f16 or f128 has_reliable_f16, has_reliable_f16_math: has_reliable_f16, + has_reliable_f16b, has_reliable_f128, has_reliable_f128_math: has_reliable_f128, } diff --git a/compiler/rustc_codegen_gcc/src/type_.rs b/compiler/rustc_codegen_gcc/src/type_.rs index 27b0d2079e63e..1d8582fe337ad 100644 --- a/compiler/rustc_codegen_gcc/src/type_.rs +++ b/compiler/rustc_codegen_gcc/src/type_.rs @@ -157,6 +157,14 @@ impl<'gcc, 'tcx> BaseTypeCodegenMethods for CodegenCx<'gcc, 'tcx> { bug!("unsupported float width 16") } + fn type_f16b(&self) -> Type<'gcc> { + #[cfg(feature = "master")] + if self.supports_f16b_type { + return self.context.new_c_type(CType::BFloat16); + } + bug!("unsupported type bfloat16") + } + fn type_f32(&self) -> Type<'gcc> { #[cfg(feature = "master")] if self.supports_f32_type { diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index a45138849e4e0..dce8db6841b7f 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -159,6 +159,7 @@ impl LlvmType for Reg { }, Primitive::Float(float) => match float { Float::F16 => cx.type_f16(), + Float::F16B => cx.type_f16b(), Float::F32 => cx.type_f32(), Float::F64 => cx.type_f64(), Float::F128 => cx.type_f128(), diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index db896fa9c0f2b..9a898429d0384 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -337,6 +337,9 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> { Primitive::Float(Float::F16) => { bug!("the va_arg intrinsic does not support `f16`") } + Primitive::Float(Float::F16B) => { + bug!("the va_arg intrinsic does not support `f16b`") + } Primitive::Float(Float::F32) => { // c_double is actually f32 on avr. if self.cx().sess().target.arch != Arch::Avr { diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 90f31e0598f2d..f32e6559a8bfc 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -382,6 +382,7 @@ pub(crate) fn target_config(sess: &EarlySession) -> TargetConfig { internal_target_features, has_reliable_f16: true, has_reliable_f16_math: true, + has_reliable_f16b: true, has_reliable_f128: true, has_reliable_f128_math: true, }; @@ -419,6 +420,21 @@ fn update_target_reliable_float_cfg(target: &Target, cfg: &mut TargetConfig) { _ => true, }; + // The heuristic for evaluating to true is twofold, namely; + // + // 1. Can LLVM compile an IR snippet containing `fpext bfloat % to float` + // 2. Does the documentation indicate `bf16` support, can be seen in the + // tracking issue; + cfg.has_reliable_f16b = match (target_arch, target_os) { + // This is similar to , however + // does not work until LLVM 23 on Windows. + (Arch::Arm64EC, _) => major >= 23, + (Arch::AArch64 | Arch::RiscV64 | Arch::LoongArch64, _) => true, + // FIXME(f16b) until + // is resolved `Arch::X86_64` does not have a reliable `f16b`. + _ => false, + }; + cfg.has_reliable_f128 = match (target_arch, target_os) { // Unsupported https://github.com/llvm/llvm-project/issues/121122 (Arch::AmdGpu, _) => false, diff --git a/compiler/rustc_codegen_llvm/src/type_.rs b/compiler/rustc_codegen_llvm/src/type_.rs index 881b8e3a8bd0e..ff1b5851db0f9 100644 --- a/compiler/rustc_codegen_llvm/src/type_.rs +++ b/compiler/rustc_codegen_llvm/src/type_.rs @@ -214,6 +214,10 @@ impl<'ll, CX: Borrow>> BaseTypeCodegenMethods for GenericCx<'ll, CX> { unsafe { llvm::LLVMHalfTypeInContext(self.llcx()) } } + fn type_f16b(&self) -> &'ll Type { + unsafe { llvm::LLVMBFloatTypeInContext(self.llcx()) } + } + fn type_f32(&self) -> &'ll Type { unsafe { llvm::LLVMFloatTypeInContext(self.llcx()) } } diff --git a/compiler/rustc_codegen_ssa/src/lib.rs b/compiler/rustc_codegen_ssa/src/lib.rs index 1272b26ca0612..7a29ca383b24b 100644 --- a/compiler/rustc_codegen_ssa/src/lib.rs +++ b/compiler/rustc_codegen_ssa/src/lib.rs @@ -315,6 +315,9 @@ pub struct TargetConfig { pub has_reliable_f16: bool, /// Option for `cfg(target_has_reliable_f16_math)`, true if `f16` math calls work. pub has_reliable_f16_math: bool, + /// Option for `cfg(target_has_reliable_f16b)`, presently true if both the ABI + /// and LLVM version supports `f16b`. + pub has_reliable_f16b: bool, /// Option for `cfg(target_has_reliable_f128)`, true if `f128` basic arithmetic works. pub has_reliable_f128: bool, /// Option for `cfg(target_has_reliable_f128_math)`, true if `f128` math calls work. diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs index 38d562d028f34..e06ac36fd758a 100644 --- a/compiler/rustc_codegen_ssa/src/traits/backend.rs +++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs @@ -52,6 +52,7 @@ pub trait CodegenBackend { // support the float types, rather than accidentally quietly skipping all tests. has_reliable_f16: true, has_reliable_f16_math: true, + has_reliable_f16b: true, has_reliable_f128: true, has_reliable_f128_math: true, } diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index a6decd5898689..05e3c346cd767 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -154,6 +154,7 @@ pub(crate) fn disallow_cfgs(sess: &Session, user_cfgs: &Cfg) { | (sym::target_has_atomic_load_store, Some(_)) | (sym::target_has_reliable_f16, None | Some(_)) | (sym::target_has_reliable_f16_math, None | Some(_)) + | (sym::target_has_reliable_f16b, None | Some(_)) | (sym::target_has_reliable_f128, None | Some(_)) | (sym::target_has_reliable_f128_math, None | Some(_)) | (sym::target_thread_local, None) => disallow(cfg, "--target"), diff --git a/src/tools/miri/src/bin/miri.rs b/src/tools/miri/src/bin/miri.rs index 62280f641e9fd..7b3f166b3bf87 100644 --- a/src/tools/miri/src/bin/miri.rs +++ b/src/tools/miri/src/bin/miri.rs @@ -221,6 +221,7 @@ impl CodegenBackend for MiriCodegenBackend { internal_target_features: native_target_config.internal_target_features, // The basic types and ABI always work. + has_reliable_f16b: true, has_reliable_f16: true, has_reliable_f128: true, // We always provide the f16 intrinsics, but some are provided via the host, From bec4db66e5f3d21e54da4a4ce4904eb58bce1aa0 Mon Sep 17 00:00:00 2001 From: James Barford-Evans Date: Mon, 21 Sep 2026 08:57:52 +0100 Subject: [PATCH 15/21] Update Tidy rules to allow for `//@ revision` --- src/tools/tidy/src/style.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index 6066ad5805006..6d8a6371f89e3 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -74,6 +74,7 @@ const ANNOTATIONS_TO_IGNORE: &[&str] = &[ "//@ lldb", "//@ cdb", "//@ normalize-stderr", + "//@ revisions", ]; fn generate_problems<'a>( From e1303802277558e6f6cd2f5a37a2503cf8e1440a Mon Sep 17 00:00:00 2001 From: James Barford-Evans Date: Mon, 21 Sep 2026 08:57:52 +0100 Subject: [PATCH 16/21] Update and write tests --- tests/assembly-llvm/f16b.rs | 124 ++++++++++++++++++ tests/auxiliary/minicore.rs | 43 +++++- tests/codegen-llvm/float/f16b.rs | 40 ++++++ .../scalable-vectors/bf16-intrinsic.rs | 34 +++++ ...ature-gate-cfg-target-has-reliable-f16b.rs | 6 + ...e-gate-cfg-target-has-reliable-f16b.stderr | 12 ++ tests/ui/feature-gates/feature-gate-f16b.rs | 30 +++++ .../ui/feature-gates/feature-gate-f16b.stderr | 121 +++++++++++++++++ tests/ui/float/f16b-restrictions.rs | 20 +++ tests/ui/float/f16b-restrictions.stderr | 43 ++++++ tests/ui/float/f16b.rs | 54 ++++++++ tests/ui/parser/f16b.rs | 14 ++ tests/ui/parser/f16b.stderr | 10 ++ 13 files changed, 549 insertions(+), 2 deletions(-) create mode 100644 tests/assembly-llvm/f16b.rs create mode 100644 tests/codegen-llvm/float/f16b.rs create mode 100644 tests/codegen-llvm/scalable-vectors/bf16-intrinsic.rs create mode 100644 tests/ui/feature-gates/feature-gate-cfg-target-has-reliable-f16b.rs create mode 100644 tests/ui/feature-gates/feature-gate-cfg-target-has-reliable-f16b.stderr create mode 100644 tests/ui/feature-gates/feature-gate-f16b.rs create mode 100644 tests/ui/feature-gates/feature-gate-f16b.stderr create mode 100644 tests/ui/float/f16b-restrictions.rs create mode 100644 tests/ui/float/f16b-restrictions.stderr create mode 100644 tests/ui/float/f16b.rs create mode 100644 tests/ui/parser/f16b.rs create mode 100644 tests/ui/parser/f16b.stderr diff --git a/tests/assembly-llvm/f16b.rs b/tests/assembly-llvm/f16b.rs new file mode 100644 index 0000000000000..373ebd0ac566d --- /dev/null +++ b/tests/assembly-llvm/f16b.rs @@ -0,0 +1,124 @@ +//@ add-minicore +//@ assembly-output: emit-asm +// +//@ revisions: AARCH64_LINUX AARCH64_BE AARCH64_DARWIN AARCH64_MSVC ARM64EC_MSVC X64_LINUX X64_WINDOWS_GNU X64_WINDOWS_MSVC RISCV64 LOONGARCH64 +//@[AARCH64_LINUX] compile-flags: -Copt-level=3 --target aarch64-unknown-linux-gnu +//@[AARCH64_LINUX] needs-llvm-components: aarch64 +//@[AARCH64_LINUX] filecheck-flags: --check-prefixes AARCH64,AARCH64-NOTAPPLE +//@[AARCH64_BE] compile-flags: -Copt-level=3 --target aarch64_be-unknown-linux-gnu +//@[AARCH64_BE] needs-llvm-components: aarch64 +//@[AARCH64_BE] filecheck-flags: --check-prefixes AARCH64,AARCH64-NOTAPPLE +//@[AARCH64_DARWIN] compile-flags: -Copt-level=3 --target aarch64-apple-darwin +//@[AARCH64_DARWIN] needs-llvm-components: aarch64 +//@[AARCH64_DARWIN] filecheck-flags: --check-prefixes AARCH64,AARCH64-APPLE +//@[AARCH64_MSVC] compile-flags: -Copt-level=3 --target aarch64-pc-windows-msvc +//@[AARCH64_MSVC] needs-llvm-components: aarch64 +//@[AARCH64_MSVC] filecheck-flags: --check-prefixes AARCH64,AARCH64-NOTAPPLE +//@[ARM64EC_MSVC] compile-flags: -Copt-level=3 --target arm64ec-pc-windows-msvc +//@[ARM64EC_MSVC] needs-llvm-components: aarch64 +//@[ARM64EC_MSVC] min-llvm-version: 23 +//@[ARM64EC_MSVC] filecheck-flags: --check-prefixes AARCH64,AARCH64-NOTAPPLE +//@[X64_LINUX] compile-flags: -Copt-level=3 -Cllvm-args=-x86-asm-syntax=intel --target x86_64-unknown-linux-gnu +//@[X64_LINUX] needs-llvm-components: x86 +//@[X64_LINUX] filecheck-flags: --check-prefixes X64,X64-LINUX +//@[X64_WINDOWS_GNU] compile-flags: -Copt-level=3 -Cllvm-args=-x86-asm-syntax=intel --target x86_64-pc-windows-gnu +//@[X64_WINDOWS_GNU] needs-llvm-components: x86 +//@[X64_WINDOWS_GNU] filecheck-flags: --check-prefixes X64,X64-WINDOWS +//@[X64_WINDOWS_MSVC] compile-flags: -Copt-level=3 -Cllvm-args=-x86-asm-syntax=intel --target x86_64-pc-windows-msvc +//@[X64_WINDOWS_MSVC] needs-llvm-components: x86 +//@[X64_WINDOWS_MSVC] filecheck-flags: --check-prefixes X64,X64-WINDOWS +//@[RISCV64] compile-flags: -Copt-level=3 --target riscv64gc-unknown-linux-gnu +//@[RISCV64] needs-llvm-components: riscv +//@[LOONGARCH64] compile-flags: -Copt-level=3 --target loongarch64-unknown-linux-gnu +//@[LOONGARCH64] needs-llvm-components: loongarch + +#![feature(f16b, no_core)] +#![no_core] +#![crate_type = "lib"] +#![allow(improper_ctypes_definitions)] + +// Check that the assembly that rustc generates matches what clang emits. + +extern crate minicore; + +use minicore::From; +use minicore::num::f16b; + +// CHECK-LABEL: identity_f16b +// AARCH64: ret +// X64: ret +// RISCV64: fmv.x.w a0, fa0 +// RISCV64-NEXT: lui a1, 1048560 +// RISCV64-NEXT: or a0, a0, a1 +// RISCV64-NEXT: fmv.w.x fa0, a0 +// RISCV64-NEXT: ret +// LOONGARCH64: movfr2gr.s $a0, $fa0 +// LOONGARCH64-NEXT: lu12i.w $a1, -16 +// LOONGARCH64-NEXT: or $a0, $a0, $a1 +// LOONGARCH64-NEXT: movgr2fr.w $fa0, $a0 +// LOONGARCH64-NEXT: ret +#[unsafe(no_mangle)] +pub extern "C" fn identity_f16b(value: f16b) -> f16b { + value +} + +// CHECK-LABEL: f16b_to_bits +// AARCH64-NOTAPPLE: fmov w0, s0 +// AARCH64-APPLE: fmov w8, s0 +// AARCH64-APPLE-NEXT: and w0, w8, #0xffff +// AARCH64-NEXT: ret +// X64: pextrw eax, xmm0, 0 +// X64-NEXT: ret +// RISCV64: fmv.x.w a0, fa0 +// RISCV64-NEXT: slli a0, a0, 48 +// RISCV64-NEXT: srli a0, a0, 48 +// RISCV64-NEXT: ret +// LOONGARCH64: movfr2gr.s $a0, $fa0 +// LOONGARCH64-NEXT: bstrpick.d $a0, $a0, 15, 0 +// LOONGARCH64-NEXT: ret +#[unsafe(no_mangle)] +pub extern "C" fn f16b_to_bits(value: f16b) -> u16 { + value.to_bits() +} + +// CHECK-LABEL: f16b_from_bits +// AARCH64: fmov s0, w0 +// AARCH64-NEXT: ret +// X64-LINUX: pinsrw xmm0, edi, 0 +// X64-LINUX-NEXT: ret +// X64-WINDOWS: pinsrw xmm0, ecx, 0 +// X64-WINDOWS-NEXT: ret +// RISCV64: lui a1, 1048560 +// RISCV64-NEXT: or a0, a0, a1 +// RISCV64-NEXT: fmv.w.x fa0, a0 +// RISCV64-NEXT: ret +// LOONGARCH64: lu12i.w $a1, -16 +// LOONGARCH64-NEXT: or $a0, $a0, $a1 +// LOONGARCH64-NEXT: movgr2fr.w $fa0, $a0 +// LOONGARCH64-NEXT: ret +#[unsafe(no_mangle)] +pub extern "C" fn f16b_from_bits(bits: u16) -> f16b { + f16b::from_bits(bits) +} + +// CHECK-LABEL: widen_f16b +// AARCH64: fmov w8, s0 +// AARCH64-NEXT: lsl w8, w8, #16 +// AARCH64-NEXT: fmov s0, w8 +// AARCH64-NEXT: ret +// X64: pextrw eax, xmm0, 0 +// X64-NEXT: shl eax, 16 +// X64-NEXT: movd xmm0, eax +// X64-NEXT: ret +// RISCV64: fmv.x.w a0, fa0 +// RISCV64-NEXT: slli a0, a0, 16 +// RISCV64-NEXT: fmv.w.x fa0, a0 +// RISCV64-NEXT: ret +// LOONGARCH64: movfr2gr.s $a0, $fa0 +// LOONGARCH64-NEXT: slli.d $a0, $a0, 16 +// LOONGARCH64-NEXT: movgr2fr.w $fa0, $a0 +// LOONGARCH64-NEXT: ret +#[unsafe(no_mangle)] +pub extern "C" fn widen_f16b(value: f16b) -> f32 { + f32::from(value) +} diff --git a/tests/auxiliary/minicore.rs b/tests/auxiliary/minicore.rs index 2b7eb0b9afbcf..f0ccc341a567d 100644 --- a/tests/auxiliary/minicore.rs +++ b/tests/auxiliary/minicore.rs @@ -29,6 +29,8 @@ rustc_attrs, decl_macro, f16, + f16b, + cfg_target_has_reliable_f16b, f128, repr_simd, transparent_unions, @@ -80,6 +82,10 @@ impl LegacyReceiver for &mut T {} #[lang = "copy"] pub trait Copy: Sized {} +pub trait From: Sized { + fn from(value: T) -> Self; +} + #[lang = "bikeshed_guaranteed_no_drop"] pub trait BikeshedGuaranteedNoDrop {} @@ -360,7 +366,7 @@ pub const unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: us pub mod mem { #[rustc_nounwind] #[rustc_intrinsic] - pub unsafe fn transmute(src: Src) -> Dst; + pub const unsafe fn transmute(src: Src) -> Dst; #[rustc_nounwind] #[rustc_intrinsic] @@ -392,7 +398,40 @@ pub mod hint { } pub mod num { - use super::Copy; + use super::{Copy, From, mem}; + + #[rustc_intrinsic] + const unsafe fn unchecked_shl(value: T, shift: U) -> T; + + #[cfg(target_has_reliable_f16b)] + #[allow(non_camel_case_types)] + #[lang = "f16b"] + #[repr(transparent)] + pub struct f16b(u16); + + #[cfg(target_has_reliable_f16b)] + impl f16b { + #[inline] + pub const fn from_bits(bits: u16) -> Self { + unsafe { mem::transmute(bits) } + } + + #[inline] + pub const fn to_bits(self) -> u16 { + unsafe { mem::transmute(self) } + } + } + + #[cfg(target_has_reliable_f16b)] + impl Copy for f16b {} + + #[cfg(target_has_reliable_f16b)] + impl From for f32 { + #[inline] + fn from(value: f16b) -> Self { + unsafe { mem::transmute(unchecked_shl(value.to_bits() as u32, 16u32)) } + } + } #[repr(C)] #[lang = "complex"] diff --git a/tests/codegen-llvm/float/f16b.rs b/tests/codegen-llvm/float/f16b.rs new file mode 100644 index 0000000000000..7de6a776190c9 --- /dev/null +++ b/tests/codegen-llvm/float/f16b.rs @@ -0,0 +1,40 @@ +//@ compile-flags: -Copt-level=3 + +#![crate_type = "lib"] +#![feature(f16b)] +#![allow(improper_ctypes_definitions)] + +extern crate core; + +use core::num::f16b; + +// CHECK-LABEL: define{{.*}} bfloat @identity_f16b(bfloat +#[no_mangle] +pub extern "C" fn identity_f16b(value: f16b) -> f16b { + // CHECK: ret bfloat + value +} + +// CHECK-LABEL: define{{.*}} i16 @f16b_to_bits(bfloat +#[no_mangle] +pub extern "C" fn f16b_to_bits(value: f16b) -> u16 { + // CHECK: bitcast bfloat %value to i16 + value.to_bits() +} + +// CHECK-LABEL: define{{.*}} bfloat @f16b_from_bits(i16 +#[no_mangle] +pub extern "C" fn f16b_from_bits(bits: u16) -> f16b { + // CHECK: bitcast i16 %bits to bfloat + f16b::from_bits(bits) +} + +// CHECK-LABEL: define{{.*}} float @widen_f16b(bfloat +#[no_mangle] +pub extern "C" fn widen_f16b(value: f16b) -> f32 { + // CHECK: bitcast bfloat %value to i16 + // CHECK: zext i16 + // CHECK: shl nuw i32 {{.*}}, 16 + // CHECK: bitcast i32 {{.*}} to float + f32::from(value) +} diff --git a/tests/codegen-llvm/scalable-vectors/bf16-intrinsic.rs b/tests/codegen-llvm/scalable-vectors/bf16-intrinsic.rs new file mode 100644 index 0000000000000..a080b36382389 --- /dev/null +++ b/tests/codegen-llvm/scalable-vectors/bf16-intrinsic.rs @@ -0,0 +1,34 @@ +//@ add-minicore +//@ revisions: OPT-0 OPT-3 +//@[OPT-0] compile-flags: -Copt-level=0 +//@[OPT-3] compile-flags: -Copt-level=3 +//@ compile-flags: --target aarch64-unknown-linux-gnu +//@ needs-llvm-components: aarch64 + +#![crate_type = "lib"] +#![feature(f16b, link_llvm_intrinsics, no_core, simd_ffi)] +#![no_core] +#![allow(non_camel_case_types)] + +extern crate minicore; + +use minicore::num::f16b; +use minicore::simd::{Simd, f32x4}; + +type bfloat16x8_t = Simd; + +#[unsafe(no_mangle)] +#[target_feature(enable = "neon,bf16")] +// CHECK-LABEL: define <4 x float> @vbfmmlaq_f32( +// CHECK-SAME: <4 x float> %acc, <8 x bfloat> %lhs, <8 x bfloat> %rhs) +pub unsafe extern "C" fn vbfmmlaq_f32(acc: f32x4, lhs: bfloat16x8_t, rhs: bfloat16x8_t) -> f32x4 { + unsafe extern "llvm-intrinsic" { + #[link_name = "llvm.aarch64.neon.bfmmla"] + fn bfmmla(acc: f32x4, lhs: bfloat16x8_t, rhs: bfloat16x8_t) -> f32x4; + } + + // CHECK: [[RESULT:%.*]] = {{.*}}call <4 x float> @llvm.aarch64.neon.bfmmla( + // CHECK-SAME: <4 x float> %acc, <8 x bfloat> %lhs, <8 x bfloat> %rhs) + // CHECK: ret <4 x float> [[RESULT]] + unsafe { bfmmla(acc, lhs, rhs) } +} diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-has-reliable-f16b.rs b/tests/ui/feature-gates/feature-gate-cfg-target-has-reliable-f16b.rs new file mode 100644 index 0000000000000..a1c2f22782c4c --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-has-reliable-f16b.rs @@ -0,0 +1,6 @@ +//@ compile-flags: --check-cfg=cfg(target_has_reliable_f16b) + +fn main() { + cfg!(target_has_reliable_f16b); + //~^ ERROR `cfg(target_has_reliable_f16b)` is experimental and subject to change +} diff --git a/tests/ui/feature-gates/feature-gate-cfg-target-has-reliable-f16b.stderr b/tests/ui/feature-gates/feature-gate-cfg-target-has-reliable-f16b.stderr new file mode 100644 index 0000000000000..46106f61ad3ae --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-target-has-reliable-f16b.stderr @@ -0,0 +1,12 @@ +error[E0658]: `cfg(target_has_reliable_f16b)` is experimental and subject to change + --> $DIR/feature-gate-cfg-target-has-reliable-f16b.rs:4:10 + | +LL | cfg!(target_has_reliable_f16b); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(cfg_target_has_reliable_f16b)]` 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 1 previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-f16b.rs b/tests/ui/feature-gates/feature-gate-f16b.rs new file mode 100644 index 0000000000000..fc531c19ba5b1 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-f16b.rs @@ -0,0 +1,30 @@ +extern crate core; + +use core::num::f16b; +//~^ ERROR use of unstable library feature `f16b` + +fn main() { + let _ = f16b::from_bits(0); + //~^ ERROR use of unstable library feature `f16b` + //~| ERROR use of unstable library feature `f16b` + + let a = 0.0f16b; + //~^ ERROR invalid suffix `f16b` + + let _: f16b = 1.0; + //~^ ERROR use of unstable library feature `f16b` + //~| ERROR mismatched types + + let x = f16b::from_bits(0x3f80); + //~^ ERROR use of unstable library feature `f16b` + //~| ERROR use of unstable library feature `f16b` + let _ = x + x; + //~^ ERROR cannot add `f16b` to `f16b` + + let _ = 1u16 as f16b; + //~^ ERROR use of unstable library feature `f16b` + //~| ERROR non-primitive cast + + let _ = x as f32; + //~^ ERROR non-primitive cast +} diff --git a/tests/ui/feature-gates/feature-gate-f16b.stderr b/tests/ui/feature-gates/feature-gate-f16b.stderr new file mode 100644 index 0000000000000..3ba9299485276 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-f16b.stderr @@ -0,0 +1,121 @@ +error: invalid suffix `f16b` for float literal + --> $DIR/feature-gate-f16b.rs:11:13 + | +LL | let a = 0.0f16b; + | ^^^^^^^ invalid suffix `f16b` + | + = help: valid suffixes are `f32` and `f64` + +error[E0658]: use of unstable library feature `f16b` + --> $DIR/feature-gate-f16b.rs:3:5 + | +LL | use core::num::f16b; + | ^^^^^^^^^^^^^^^ + | + = note: see issue #160630 for more information + = help: add `#![feature(f16b)]` 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]: use of unstable library feature `f16b` + --> $DIR/feature-gate-f16b.rs:7:13 + | +LL | let _ = f16b::from_bits(0); + | ^^^^ + | + = note: see issue #160630 for more information + = help: add `#![feature(f16b)]` 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]: use of unstable library feature `f16b` + --> $DIR/feature-gate-f16b.rs:14:12 + | +LL | let _: f16b = 1.0; + | ^^^^ + | + = note: see issue #160630 for more information + = help: add `#![feature(f16b)]` 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]: use of unstable library feature `f16b` + --> $DIR/feature-gate-f16b.rs:18:13 + | +LL | let x = f16b::from_bits(0x3f80); + | ^^^^ + | + = note: see issue #160630 for more information + = help: add `#![feature(f16b)]` 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]: use of unstable library feature `f16b` + --> $DIR/feature-gate-f16b.rs:24:21 + | +LL | let _ = 1u16 as f16b; + | ^^^^ + | + = note: see issue #160630 for more information + = help: add `#![feature(f16b)]` 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]: use of unstable library feature `f16b` + --> $DIR/feature-gate-f16b.rs:7:13 + | +LL | let _ = f16b::from_bits(0); + | ^^^^^^^^^^^^^^^ + | + = note: see issue #160630 for more information + = help: add `#![feature(f16b)]` 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[E0308]: mismatched types + --> $DIR/feature-gate-f16b.rs:14:19 + | +LL | let _: f16b = 1.0; + | ---- ^^^ expected `f16b`, found floating-point number + | | + | expected due to this + +error[E0658]: use of unstable library feature `f16b` + --> $DIR/feature-gate-f16b.rs:18:13 + | +LL | let x = f16b::from_bits(0x3f80); + | ^^^^^^^^^^^^^^^ + | + = note: see issue #160630 for more information + = help: add `#![feature(f16b)]` 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[E0369]: cannot add `f16b` to `f16b` + --> $DIR/feature-gate-f16b.rs:21:15 + | +LL | let _ = x + x; + | - ^ - f16b + | | + | f16b + | +note: `f16b` does not implement `Add` + --> $SRC_DIR/core/src/num/bfloat.rs:LL:COL + | + = note: `f16b` is defined in another crate + +error[E0605]: non-primitive cast: `u16` as `f16b` + --> $DIR/feature-gate-f16b.rs:24:13 + | +LL | let _ = 1u16 as f16b; + | ^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object + +error[E0605]: non-primitive cast: `f16b` as `f32` + --> $DIR/feature-gate-f16b.rs:28:13 + | +LL | let _ = x as f32; + | ^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object + | +help: consider using the `From` trait instead + | +LL - let _ = x as f32; +LL + let _ = f32::from(x); + | + +error: aborting due to 12 previous errors + +Some errors have detailed explanations: E0308, E0369, E0605, E0658. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/float/f16b-restrictions.rs b/tests/ui/float/f16b-restrictions.rs new file mode 100644 index 0000000000000..b2dbf1a734be3 --- /dev/null +++ b/tests/ui/float/f16b-restrictions.rs @@ -0,0 +1,20 @@ +#![feature(f16b)] + +extern crate core; + +use core::num::f16b; + +fn main() { + let _: f16b = 1.0; + //~^ ERROR mismatched types + + let x = f16b::from_bits(0x3f80); + let _ = x + x; + //~^ ERROR cannot add `f16b` to `f16b` + + let _ = 1u16 as f16b; + //~^ ERROR non-primitive cast + + let _ = x as f32; + //~^ ERROR non-primitive cast +} diff --git a/tests/ui/float/f16b-restrictions.stderr b/tests/ui/float/f16b-restrictions.stderr new file mode 100644 index 0000000000000..540e92d26b384 --- /dev/null +++ b/tests/ui/float/f16b-restrictions.stderr @@ -0,0 +1,43 @@ +error[E0308]: mismatched types + --> $DIR/f16b-restrictions.rs:8:19 + | +LL | let _: f16b = 1.0; + | ---- ^^^ expected `f16b`, found floating-point number + | | + | expected due to this + +error[E0369]: cannot add `f16b` to `f16b` + --> $DIR/f16b-restrictions.rs:12:15 + | +LL | let _ = x + x; + | - ^ - f16b + | | + | f16b + | +note: `f16b` does not implement `Add` + --> $SRC_DIR/core/src/num/bfloat.rs:LL:COL + | + = note: `f16b` is defined in another crate + +error[E0605]: non-primitive cast: `u16` as `f16b` + --> $DIR/f16b-restrictions.rs:15:13 + | +LL | let _ = 1u16 as f16b; + | ^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object + +error[E0605]: non-primitive cast: `f16b` as `f32` + --> $DIR/f16b-restrictions.rs:18:13 + | +LL | let _ = x as f32; + | ^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object + | +help: consider using the `From` trait instead + | +LL - let _ = x as f32; +LL + let _ = f32::from(x); + | + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0308, E0369, E0605. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/float/f16b.rs b/tests/ui/float/f16b.rs new file mode 100644 index 0000000000000..ed143c2c2b2fa --- /dev/null +++ b/tests/ui/float/f16b.rs @@ -0,0 +1,54 @@ +// FIXME(f16b): +// This file compiled unoptimised in some function calls, such as `to_bits()`, +// emit a call to `__truncsfbf2` which fails in the CI see here for more; +// +// Remove `-C-opt-level=3` once the `__truncsfbf2` symbol is in +// compiler-builtins. +// +//@ compile-flags: --check-cfg=cfg(target_has_reliable_f16b) -Copt-level=3 +//@ run-pass + +#![feature(f16b, cfg_target_has_reliable_f16b)] + +extern crate core; + +use core::num::f16b; +#[cfg(target_has_reliable_f16b)] +use std::fmt::{Debug, LowerExp, UpperExp}; + +#[cfg(target_has_reliable_f16b)] +const ONE: f16b = f16b::from_bits(0x3f80); + +#[cfg(target_has_reliable_f16b)] +const ONE_BITS: u16 = ONE.to_bits(); + +#[cfg(target_has_reliable_f16b)] +fn assert_traits() +where + T: Default + Copy + Clone + Debug + LowerExp + UpperExp + PartialEq + PartialOrd, +{ +} + +fn main() { + assert_eq!(size_of::(), 2); + assert_eq!(align_of::(), 2); + + #[cfg(target_has_reliable_f16b)] + { + assert_traits::(); + + assert_eq!(f16b::default().to_bits(), 0); + assert_eq!(ONE_BITS, 0x3f80); + assert_eq!(f32::from(ONE).to_bits(), 0x3f80_0000); + + let two = f16b::from_bits(0x4000); + let negative_zero = f16b::from_bits(0x8000); + let nan = f16b::from_bits(0x7fc0); + assert!(ONE < two); + assert_eq!(f16b::from_bits(0), negative_zero); + assert!(nan != nan); + assert_eq!(format!("{ONE:?}"), "1.0"); + assert_eq!(format!("{ONE:e}"), "1e0"); + assert_eq!(format!("{ONE:E}"), "1E0"); + } +} diff --git a/tests/ui/parser/f16b.rs b/tests/ui/parser/f16b.rs new file mode 100644 index 0000000000000..bb6f3737a33d5 --- /dev/null +++ b/tests/ui/parser/f16b.rs @@ -0,0 +1,14 @@ +#![feature(f16b)] + +extern crate core; + +use core::num::f16b; + +// `f16b` is a nominal core type, not a floating-point literal type. +fn main() { + let value = f16b::from_bits(0x3f80); + let _: f16b = value; + + let _ = 0.0f16b; + //~^ ERROR invalid suffix `f16b` for float literal +} diff --git a/tests/ui/parser/f16b.stderr b/tests/ui/parser/f16b.stderr new file mode 100644 index 0000000000000..2d89bbe4d8776 --- /dev/null +++ b/tests/ui/parser/f16b.stderr @@ -0,0 +1,10 @@ +error: invalid suffix `f16b` for float literal + --> $DIR/f16b.rs:12:13 + | +LL | let _ = 0.0f16b; + | ^^^^^^^ invalid suffix `f16b` + | + = help: valid suffixes are `f32` and `f64` + +error: aborting due to 1 previous error + From fe048b622eced56ae3e415191192f159d79342f8 Mon Sep 17 00:00:00 2001 From: James Barford-Evans Date: Mon, 21 Sep 2026 09:32:35 +0100 Subject: [PATCH 17/21] Only AArch64 `has_reliable_f16b` presently due to an LLVM codegen issue, also updated test --- compiler/rustc_codegen_llvm/src/llvm_util.rs | 7 ++- tests/assembly-llvm/f16b.rs | 58 +------------------- 2 files changed, 6 insertions(+), 59 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index f32e6559a8bfc..e7cf210747666 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -429,9 +429,12 @@ fn update_target_reliable_float_cfg(target: &Target, cfg: &mut TargetConfig) { // This is similar to , however // does not work until LLVM 23 on Windows. (Arch::Arm64EC, _) => major >= 23, - (Arch::AArch64 | Arch::RiscV64 | Arch::LoongArch64, _) => true, + (Arch::AArch64, _) => true, // FIXME(f16b) until - // is resolved `Arch::X86_64` does not have a reliable `f16b`. + // is resolved the below do not have a reliable `f16b`, on a widening + // path a call to `__truncsfbf2` is emitted. Or when using architectural + // extensions a non-portable narrowing instruction is emitted. + (Arch::X86_64 | Arch::RiscV64 | Arch::LoongArch64, _) => false, _ => false, }; diff --git a/tests/assembly-llvm/f16b.rs b/tests/assembly-llvm/f16b.rs index 373ebd0ac566d..036b6fc087d02 100644 --- a/tests/assembly-llvm/f16b.rs +++ b/tests/assembly-llvm/f16b.rs @@ -1,7 +1,7 @@ //@ add-minicore //@ assembly-output: emit-asm // -//@ revisions: AARCH64_LINUX AARCH64_BE AARCH64_DARWIN AARCH64_MSVC ARM64EC_MSVC X64_LINUX X64_WINDOWS_GNU X64_WINDOWS_MSVC RISCV64 LOONGARCH64 +//@ revisions: AARCH64_LINUX AARCH64_BE AARCH64_DARWIN AARCH64_MSVC ARM64EC_MSVC //@[AARCH64_LINUX] compile-flags: -Copt-level=3 --target aarch64-unknown-linux-gnu //@[AARCH64_LINUX] needs-llvm-components: aarch64 //@[AARCH64_LINUX] filecheck-flags: --check-prefixes AARCH64,AARCH64-NOTAPPLE @@ -18,19 +18,6 @@ //@[ARM64EC_MSVC] needs-llvm-components: aarch64 //@[ARM64EC_MSVC] min-llvm-version: 23 //@[ARM64EC_MSVC] filecheck-flags: --check-prefixes AARCH64,AARCH64-NOTAPPLE -//@[X64_LINUX] compile-flags: -Copt-level=3 -Cllvm-args=-x86-asm-syntax=intel --target x86_64-unknown-linux-gnu -//@[X64_LINUX] needs-llvm-components: x86 -//@[X64_LINUX] filecheck-flags: --check-prefixes X64,X64-LINUX -//@[X64_WINDOWS_GNU] compile-flags: -Copt-level=3 -Cllvm-args=-x86-asm-syntax=intel --target x86_64-pc-windows-gnu -//@[X64_WINDOWS_GNU] needs-llvm-components: x86 -//@[X64_WINDOWS_GNU] filecheck-flags: --check-prefixes X64,X64-WINDOWS -//@[X64_WINDOWS_MSVC] compile-flags: -Copt-level=3 -Cllvm-args=-x86-asm-syntax=intel --target x86_64-pc-windows-msvc -//@[X64_WINDOWS_MSVC] needs-llvm-components: x86 -//@[X64_WINDOWS_MSVC] filecheck-flags: --check-prefixes X64,X64-WINDOWS -//@[RISCV64] compile-flags: -Copt-level=3 --target riscv64gc-unknown-linux-gnu -//@[RISCV64] needs-llvm-components: riscv -//@[LOONGARCH64] compile-flags: -Copt-level=3 --target loongarch64-unknown-linux-gnu -//@[LOONGARCH64] needs-llvm-components: loongarch #![feature(f16b, no_core)] #![no_core] @@ -47,16 +34,6 @@ use minicore::num::f16b; // CHECK-LABEL: identity_f16b // AARCH64: ret // X64: ret -// RISCV64: fmv.x.w a0, fa0 -// RISCV64-NEXT: lui a1, 1048560 -// RISCV64-NEXT: or a0, a0, a1 -// RISCV64-NEXT: fmv.w.x fa0, a0 -// RISCV64-NEXT: ret -// LOONGARCH64: movfr2gr.s $a0, $fa0 -// LOONGARCH64-NEXT: lu12i.w $a1, -16 -// LOONGARCH64-NEXT: or $a0, $a0, $a1 -// LOONGARCH64-NEXT: movgr2fr.w $fa0, $a0 -// LOONGARCH64-NEXT: ret #[unsafe(no_mangle)] pub extern "C" fn identity_f16b(value: f16b) -> f16b { value @@ -67,15 +44,6 @@ pub extern "C" fn identity_f16b(value: f16b) -> f16b { // AARCH64-APPLE: fmov w8, s0 // AARCH64-APPLE-NEXT: and w0, w8, #0xffff // AARCH64-NEXT: ret -// X64: pextrw eax, xmm0, 0 -// X64-NEXT: ret -// RISCV64: fmv.x.w a0, fa0 -// RISCV64-NEXT: slli a0, a0, 48 -// RISCV64-NEXT: srli a0, a0, 48 -// RISCV64-NEXT: ret -// LOONGARCH64: movfr2gr.s $a0, $fa0 -// LOONGARCH64-NEXT: bstrpick.d $a0, $a0, 15, 0 -// LOONGARCH64-NEXT: ret #[unsafe(no_mangle)] pub extern "C" fn f16b_to_bits(value: f16b) -> u16 { value.to_bits() @@ -84,18 +52,6 @@ pub extern "C" fn f16b_to_bits(value: f16b) -> u16 { // CHECK-LABEL: f16b_from_bits // AARCH64: fmov s0, w0 // AARCH64-NEXT: ret -// X64-LINUX: pinsrw xmm0, edi, 0 -// X64-LINUX-NEXT: ret -// X64-WINDOWS: pinsrw xmm0, ecx, 0 -// X64-WINDOWS-NEXT: ret -// RISCV64: lui a1, 1048560 -// RISCV64-NEXT: or a0, a0, a1 -// RISCV64-NEXT: fmv.w.x fa0, a0 -// RISCV64-NEXT: ret -// LOONGARCH64: lu12i.w $a1, -16 -// LOONGARCH64-NEXT: or $a0, $a0, $a1 -// LOONGARCH64-NEXT: movgr2fr.w $fa0, $a0 -// LOONGARCH64-NEXT: ret #[unsafe(no_mangle)] pub extern "C" fn f16b_from_bits(bits: u16) -> f16b { f16b::from_bits(bits) @@ -106,18 +62,6 @@ pub extern "C" fn f16b_from_bits(bits: u16) -> f16b { // AARCH64-NEXT: lsl w8, w8, #16 // AARCH64-NEXT: fmov s0, w8 // AARCH64-NEXT: ret -// X64: pextrw eax, xmm0, 0 -// X64-NEXT: shl eax, 16 -// X64-NEXT: movd xmm0, eax -// X64-NEXT: ret -// RISCV64: fmv.x.w a0, fa0 -// RISCV64-NEXT: slli a0, a0, 16 -// RISCV64-NEXT: fmv.w.x fa0, a0 -// RISCV64-NEXT: ret -// LOONGARCH64: movfr2gr.s $a0, $fa0 -// LOONGARCH64-NEXT: slli.d $a0, $a0, 16 -// LOONGARCH64-NEXT: movgr2fr.w $fa0, $a0 -// LOONGARCH64-NEXT: ret #[unsafe(no_mangle)] pub extern "C" fn widen_f16b(value: f16b) -> f32 { f32::from(value) From 5abfe0f550231cd3020fe2931833e88b9c80747c Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 20 Sep 2026 20:09:15 +0200 Subject: [PATCH 18/21] Add a README in `tests/rustdoc-html` to explain what each folder content is for --- tests/rustdoc-html/README.md | 154 +++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 tests/rustdoc-html/README.md diff --git a/tests/rustdoc-html/README.md b/tests/rustdoc-html/README.md new file mode 100644 index 0000000000000..4acb1d54bbb89 --- /dev/null +++ b/tests/rustdoc-html/README.md @@ -0,0 +1,154 @@ +# rustdoc HTML test suite categories + +This is a high-level summary of the organization of the rustdoc HTML test suite +(`tests/rustdoc-html`). It is not intended to be *prescriptive*, but instead provide a quick survey +of existing groupings. + +For now, only immediate subdirectories under `tests/rustdoc-html` are described. + +## `tests/rustdoc-html/anchors` + +Check for the link anchors. Rustdoc uses anchors when we want to point an element on an item +page, like the method of a type. + +## `tests/rustdoc-html/assoc` + +Contains tests checking how an associated item like a trait method is rendered in the +docs. + +## `tests/rustdoc-html/async` + +Contains tests checking the rendering of `async` items. + +## `tests/rustdoc-html/auto` + +Contains tests related to auto traits implementations. + +## `tests/rustdoc-html/codeblock` + +Contains tests to check the rendering of the code blocks (also called code examples). + +## `tests/rustdoc-html/const-generics` + +Mostly the same as `tests/rustdoc-html/constant` except that this folder focuses on the +rendering of const generics. Same problematics overall. + +## `tests/rustdoc-html/constant` + +Contains tests to check constant items rendering. Constant items can sometimes have +code that needs to be kept as is or inferred, making this a very tricky topic in rustdoc. :) + +## `tests/rustdoc-html/cross-crate-info` + +Contains tests to check how information is used across crates. It only contains folders +which all contain an `auxiliary` subfolder for their own dependencies (and avoid potential naming +conflicts, in particular for simpler crate names). + +## `tests/rustdoc-html/deref` + +Contains tests to check the display of items implementing the `Deref` and/or `DerefMut` traits. + +## `tests/rustdoc-html/doc-cfg` + +Contains tests to check the rustdoc `doc_cfg` feature. + +## `tests/rustdoc-html/enum` + +Contains tests for the rendering of enum types and in particular its variants. + +## `tests/rustdoc-html/extern` + +Contains tests to check how extern items (like `extern "C"` functions) are rendered. + +## `tests/rustdoc-html/footnote` + +Contains tests checking the markdown footnote features and how it is rendered. + +## `tests/rustdoc-html/generic-associated-types` + +Contains tests checking the rendering of items when they have generic associated types, +like `Iterator::Item` where `Item` would instead be `Item<'a> where Self: 'a`. Fun times. :) + +## `tests/rustdoc-html/hidden` + +Contains tests checking both `doc(hidden)` and the `--document-hidden-items` CLI flag. + +## `tests/rustdoc-html/impl` + +Contains tests checking the rendering of impl blocks. More general than +`tests/rustdoc-html/generic-associated-types`. + +## `tests/rustdoc-html/inline_cross` + +Contains tests which check inlined foreign items and how they render based on the limitless +list of corner cases we have to handle with reexports. + +## `tests/rustdoc-html/inline_local` + +Similar to `tests/rustdoc-html/inline_cross` except this time it's reexports of local items. +Still a lot of "fun" and dark magic. + +## `tests/rustdoc-html/intra-doc` + +Contains tests which check the intra doc links feature. This feature is very important in +rustdoc as it allows to simply write the name or the path of an item to get its link +generated. It comes with a lot of corner cases around scope and namespaces (illustrated +by the very high number of tests in this folder). + +## `tests/rustdoc-html/jump-to-def` + +This folder contains tests for the "jump to def(inition)" feature which is enabled with the +`--generate-link-to-definition` CLI flag. + +## `tests/rustdoc-html/macro` + +Contains tests checking the rendering of macro items (both `derive` and `macro_rules!`). + +## `tests/rustdoc-html/macro-expansion` + +Contains tests checking the `--generate-macro-expansion` CLI flag. + +## `tests/rustdoc-html/notable-trait` + +Contains tests checking the `doc(notable_trait)` attribute. + +## `tests/rustdoc-html/primitive` + +Everything related to primitive types, like intra-doc links pointing to them, documenting +them with the `rustc_doc_primitive` attribute, reexporting them, etc. + +## `tests/rustdoc-html/private` + +Everything related to non-`doc(hidden)` items which aren't public. Either it's struct/union +fields, impl blocks containing only private items or the handling of the +`--document-private-items` CLI flag. + +## `tests/rustdoc-html/reexport` + +Another folder about reexports (might be worth merging the three of them?). It checks +everything related to reexports like concatenated docs and attributes, inlining, transitive +reexported crates, etc. + +## `tests/rustdoc-html/sidebar` + +Contains tests checking the content of the sidebar like sections or links to items present on the +page, etc. + +## `tests/rustdoc-html/source-code-pages` + +Contains tests checking the content of the source code pages (when you click on the `source` +links). + +## `tests/rustdoc-html/synthetic_auto` + +Somewhat equivalent to the `auto` folder's tests. Both should likely be merged. + +## `tests/rustdoc-html/typedef` + +Contains tests checking type aliases (`type X = Y`) rendering. In particular when the +alias contains generics, meaning a specialized aliased type, allowing in some cases +more auto traits implementations. + +## `tests/rustdoc-html/union` + +Same as `tests/rustdoc-html/enum` but for union items. From 93bcb0f22214f621dae3d2849431f57c381e0d35 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 21 Sep 2026 12:22:34 +0200 Subject: [PATCH 19/21] Add tidy check for `rustdoc-html/README.md` --- src/tools/tidy/src/lib.rs | 1 + src/tools/tidy/src/main.rs | 1 + src/tools/tidy/src/rustdoc_html_tests.rs | 77 ++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 src/tools/tidy/src/rustdoc_html_tests.rs diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 292808b90cbfc..9975570fa17fc 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -121,6 +121,7 @@ pub mod mir_opt_tests; pub mod pal; pub mod rustdoc_css_themes; pub mod rustdoc_gui_tests; +pub mod rustdoc_html_tests; pub mod rustdoc_json; pub mod rustdoc_templates; pub mod style; diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 1b5baf2a21972..c77ef00be9eaf 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -102,6 +102,7 @@ fn main() { check!(rustdoc_css_themes, &librustdoc_path); check!(rustdoc_templates, &librustdoc_path); check!(rustdoc_json, &src_path); + check!(rustdoc_html_tests, &tests_path); check!(known_bug, &crashes_path); check!(unknown_revision, &tests_path); diff --git a/src/tools/tidy/src/rustdoc_html_tests.rs b/src/tools/tidy/src/rustdoc_html_tests.rs new file mode 100644 index 0000000000000..1cb7cd3efb584 --- /dev/null +++ b/src/tools/tidy/src/rustdoc_html_tests.rs @@ -0,0 +1,77 @@ +//! Tidy check to ensure that rustdoc GUI tests start with a small description. + +use std::collections::BTreeSet; +use std::path::Path; + +use crate::diagnostics::{CheckId, TidyCtx}; + +pub fn check(path: &Path, tidy_ctx: TidyCtx) { + let path = path.join("rustdoc-html"); + let mut check = tidy_ctx.start_check(CheckId::new("rustdoc_html_tests").path(&path)); + + // The list of subdirectories in rustdoc-html tests. + // Compare previous subdirectory with current subdirectory + // to sync with `tests/rustdoc-html/README.md`. + let mut prev_line = String::new(); + let documented_subdirs: BTreeSet<_> = include_str!("../../../../tests/rustdoc-html/README.md") + .lines() + .filter_map(|line| { + static_regex!(r"^##.*?`(?

[^`]+)`").captures(line).map(|cap| { + let dir = &cap["dir"]; + // FIXME(reddevilmidzy) normalize subdirs title in tests/rustdoc-html/README.md + if dir.ends_with('/') { + dir.strip_suffix('/').unwrap().to_string() + } else { + dir.to_string() + } + }) + }) + .inspect(|line| { + if prev_line.as_str() > line.as_str() { + check.error(&format!( + "`tests/rustdoc-html/README.md` is not in order: {prev_line:?} should be after {line:?}" + )); + } + + prev_line = line.clone(); + }) + .collect(); + + let filesystem_subdirs = collect_rustdoc_html_tests_subdirs(&path); + let is_modified = !filesystem_subdirs.eq(&documented_subdirs); + + if is_modified { + for directory in documented_subdirs.symmetric_difference(&filesystem_subdirs) { + if documented_subdirs.contains(directory) { + check.error(format!( + "rustdoc-html subdirectory `{directory}` is listed in `tests/rustdoc-html/README.md` but does not exist in the filesystem" + )); + } else { + check.error(format!( + "rustdoc-html subdirectory `{directory}` exists in the filesystem but is not documented in `tests/rustdoc-html/README.md`" + )); + } + } + check.error( + "`tests/rustdoc-html/README.md` subdirectory listing is out of sync with the filesystem. \ + Please add or remove subdirectory entries (## headers with backtick-wrapped names) to match the actual directories in `tests/rustdoc-html/`" + ); + } +} + +fn collect_rustdoc_html_tests_subdirs(path: &Path) -> BTreeSet { + let entries = std::fs::read_dir(path).unwrap(); + + entries + .filter_map(|entry| entry.ok()) + .map(|entry| entry.path()) + .filter(|path| path.is_dir() && path.file_name().is_some_and(|name| name != "auxiliary")) + .map(|dir_path| { + let dir_path = dir_path.strip_prefix(path).unwrap(); + format!( + "tests/rustdoc-html/{}", + dir_path.to_string_lossy().replace(std::path::MAIN_SEPARATOR_STR, "/") + ) + }) + .collect() +} From 45490f887a38b04b05e5875cb8dff20a238d4f1d Mon Sep 17 00:00:00 2001 From: Max Dexheimer Date: Mon, 21 Sep 2026 13:35:23 +0200 Subject: [PATCH 20/21] Implement Allocator for Pin unstably --- library/core/src/alloc/mod.rs | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/library/core/src/alloc/mod.rs b/library/core/src/alloc/mod.rs index 6069c468f96e4..35932b11e3b5f 100644 --- a/library/core/src/alloc/mod.rs +++ b/library/core/src/alloc/mod.rs @@ -683,6 +683,63 @@ where } } +#[unstable(feature = "allocator_api", issue = "32838")] +#[rustc_const_unstable(feature = "const_heap", issue = "79597")] +#[unstable_feature_bound(allocator_api)] +const unsafe impl

Allocator for core::pin::Pin

+where + P: [const] core::ops::Deref + core::pin::PinSafePointer, +{ + #[inline] + fn allocate(&self, layout: Layout) -> Result, AllocError> { + (**self).allocate(layout) + } + + #[inline] + fn allocate_zeroed(&self, layout: Layout) -> Result, AllocError> { + (**self).allocate_zeroed(layout) + } + + #[inline] + unsafe fn deallocate(&self, ptr: NonNull, layout: Layout) { + // SAFETY: the safety contract must be upheld by the caller + unsafe { (**self).deallocate(ptr, layout) } + } + + #[inline] + unsafe fn grow( + &self, + ptr: NonNull, + old_layout: Layout, + new_layout: Layout, + ) -> Result, AllocError> { + // SAFETY: the safety contract must be upheld by the caller + unsafe { (**self).grow(ptr, old_layout, new_layout) } + } + + #[inline] + unsafe fn grow_zeroed( + &self, + ptr: NonNull, + old_layout: Layout, + new_layout: Layout, + ) -> Result, AllocError> { + // SAFETY: the safety contract must be upheld by the caller + unsafe { (**self).grow_zeroed(ptr, old_layout, new_layout) } + } + + #[inline] + unsafe fn shrink( + &self, + ptr: NonNull, + old_layout: Layout, + new_layout: Layout, + ) -> Result, AllocError> { + // SAFETY: the safety contract must be upheld by the caller + unsafe { (**self).shrink(ptr, old_layout, new_layout) } + } +} + #[unstable(feature = "allocator_api", issue = "32838")] unsafe impl AllocatorClone for &A {} From 32e1cf827d2a7880bb40efbe35e6391d9ba6225d Mon Sep 17 00:00:00 2001 From: lcnr Date: Mon, 21 Sep 2026 14:33:22 +0200 Subject: [PATCH 21/21] remove old solver use of `SolverRelating` --- .../src/coherence/builtin/coerce_shared.rs | 11 ++++++++--- compiler/rustc_type_ir/src/relate/solver_relating.rs | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin/coerce_shared.rs b/compiler/rustc_hir_analysis/src/coherence/builtin/coerce_shared.rs index bd7130ee48bc8..77330e4fa3b34 100644 --- a/compiler/rustc_hir_analysis/src/coherence/builtin/coerce_shared.rs +++ b/compiler/rustc_hir_analysis/src/coherence/builtin/coerce_shared.rs @@ -3,9 +3,8 @@ use rustc_hir as hir; use rustc_hir::ItemKind; use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::def_id::{DefId, LocalDefId}; -use rustc_infer::infer::{InferCtxt, TyCtxtInferExt}; +use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, TyCtxtInferExt}; use rustc_infer::traits::{Obligation, TraitErrors}; -use rustc_middle::ty::relate::solver_relating::RelateExt; use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt, TypingMode, Unnormalized}; use rustc_span::Span; use rustc_trait_selection::error_reporting::InferCtxtErrorExt; @@ -760,6 +759,9 @@ enum FieldRelation { // instantiating a field can expose projections. Each candidate relation uses a // fresh inference context, so failed checks cannot affect the next one; this // intentionally normalizes the fields for each check. +// +// FIXME(field_projections): This function should take `Unnormalized>` for +// `source_ty` and `target_ty`. fn field_tys_satisfy_relation_after_normalization_and_resolution<'tcx>( tcx: TyCtxt<'tcx>, impl_did: LocalDefId, @@ -785,7 +787,10 @@ fn field_tys_satisfy_relation_after_normalization_and_resolution<'tcx>( match relation { FieldRelation::Equal => { - if infcx.relate(param_env, source_ty, ty::Variance::Invariant, target_ty, span).is_err() + if infcx + .at(&cause, param_env) + .relate(DefineOpaqueTypes::Yes, source_ty, ty::Variance::Invariant, target_ty) + .is_err() { return false; } diff --git a/compiler/rustc_type_ir/src/relate/solver_relating.rs b/compiler/rustc_type_ir/src/relate/solver_relating.rs index 1e8ff77e4d395..96a792edd2f9d 100644 --- a/compiler/rustc_type_ir/src/relate/solver_relating.rs +++ b/compiler/rustc_type_ir/src/relate/solver_relating.rs @@ -84,6 +84,7 @@ where param_env: I::ParamEnv, span: I::Span, ) -> Self { + debug_assert!(infcx.next_trait_solver()); SolverRelating { infcx, span,

{ +... LL | const B: u32 - | - required by a bound in this associated constant LL | where LL | Infallible: From; | ^^^^^^^ required by this bound in `Trait::B` diff --git a/tests/ui/higher-ranked/hrtb-with-assoc-type-projection.stderr b/tests/ui/higher-ranked/hrtb-with-assoc-type-projection.stderr index bb54da98c2333..79985580e23b5 100644 --- a/tests/ui/higher-ranked/hrtb-with-assoc-type-projection.stderr +++ b/tests/ui/higher-ranked/hrtb-with-assoc-type-projection.stderr @@ -15,7 +15,6 @@ note: required by a bound in `trigger_error` --> $DIR/hrtb-with-assoc-type-projection.rs:12:72 | LL | pub fn trigger_error(iterable: I, functor: F) - | ------------- required by a bound in this function ... LL | for<'t> ::IntoIter, F> as Iterator>::Item: Foo, | ^^^ required by this bound in `trigger_error` diff --git a/tests/ui/higher-ranked/relate-bound-region-ice-144033.stderr b/tests/ui/higher-ranked/relate-bound-region-ice-144033.stderr index e9ec3e9dc0707..6964e50fb79fb 100644 --- a/tests/ui/higher-ranked/relate-bound-region-ice-144033.stderr +++ b/tests/ui/higher-ranked/relate-bound-region-ice-144033.stderr @@ -20,8 +20,8 @@ LL | let collection = std::iter::empty::<()>().map(|_| &()); note: required by a bound in `FooMut::bar` --> $DIR/relate-bound-region-ice-144033.rs:8:33 | +LL | trait FooMut { LL | fn bar(self, _: I) - | --- required by a bound in this associated function LL | where LL | for<'b> &'b I: Iterator; | ^^^^^^^^^^^^^ required by this bound in `FooMut::bar` diff --git a/tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.stderr b/tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.stderr index b02179f141251..028d3cb104e40 100644 --- a/tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.stderr +++ b/tests/ui/higher-ranked/trait-bounds/higher-trait-bounds-ice-60218.stderr @@ -15,7 +15,6 @@ note: required by a bound in `trigger_error` --> $DIR/higher-trait-bounds-ice-60218.rs:12:72 | LL | pub fn trigger_error(iterable: I, functor: F) - | ------------- required by a bound in this function ... LL | for<'t> ::IntoIter, F> as Iterator>::Item: Foo, | ^^^ required by this bound in `trigger_error` diff --git a/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr b/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr index da6013a4af33f..b7f5557bc7160 100644 --- a/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr +++ b/tests/ui/higher-ranked/trait-bounds/hrtb-higher-ranker-supertraits-transitive.stderr @@ -10,7 +10,6 @@ note: required by a bound in `want_bar_for_any_ccx` --> $DIR/hrtb-higher-ranker-supertraits-transitive.rs:32:15 | LL | fn want_bar_for_any_ccx(b: &B) - | -------------------- required by a bound in this function LL | where B : for<'ccx> Bar<'ccx> | ^^^^^^^^^^^^^^^^^^^ required by this bound in `want_bar_for_any_ccx` help: consider further restricting type parameter `B` with trait `Bar` diff --git a/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.stderr b/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.stderr index 4302570cdbdef..591d5fdd75283 100644 --- a/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.stderr +++ b/tests/ui/higher-ranked/trait-bounds/issue-62203-hrtb-ice.stderr @@ -23,8 +23,8 @@ LL | type O = T::Output; note: required by a bound in `T1::m` --> $DIR/issue-62203-hrtb-ice.rs:27:51 | +LL | trait T1: for<'r> Ty<'r> { LL | fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1 - | - required by a bound in this associated function LL | where LL | F: for<'r> T0<'r, (>::V,), O = >::V>, | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m` @@ -52,8 +52,8 @@ LL | T: FnMut(A) -> Unit3, note: required by a bound in `T1::m` --> $DIR/issue-62203-hrtb-ice.rs:27:12 | +LL | trait T1: for<'r> Ty<'r> { LL | fn m<'a, B: Ty<'a>, F>(&self, f: F) -> Unit1 - | - required by a bound in this associated function LL | where LL | F: for<'r> T0<'r, (>::V,), O = >::V>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `T1::m` diff --git a/tests/ui/higher-ranked/trait-bounds/issue-95230.stderr b/tests/ui/higher-ranked/trait-bounds/issue-95230.stderr index 9e85c689f69df..7f307378f23f1 100644 --- a/tests/ui/higher-ranked/trait-bounds/issue-95230.stderr +++ b/tests/ui/higher-ranked/trait-bounds/issue-95230.stderr @@ -8,7 +8,6 @@ note: required by a bound in `Bar` --> $DIR/issue-95230.rs:7:13 | LL | pub struct Bar - | --- required by a bound in this struct LL | where LL | for<'a> &'a mut Self:; | ^^^^^^^^^^^^ required by this bound in `Bar` diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr index 5ded3a5e76c9d..9d109df0a15a9 100644 --- a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr @@ -20,7 +20,6 @@ note: required by a bound in `StackContext` --> $DIR/issue-89118.rs:9:14 | LL | trait StackContext - | ------------ required by a bound in this trait LL | where LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StackContext` @@ -47,7 +46,6 @@ note: required by a bound in `EthernetWorker` --> $DIR/issue-89118.rs:28:14 | LL | struct EthernetWorker(C) - | -------------- required by a bound in this struct LL | where LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EthernetWorker` @@ -74,7 +72,6 @@ note: required by a bound in `StackContext` --> $DIR/issue-89118.rs:9:14 | LL | trait StackContext - | ------------ required by a bound in this trait LL | where LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `StackContext` diff --git a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr index 2f417d57752d2..39121c99798bf 100644 --- a/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr +++ b/tests/ui/impl-trait/in-assoc-type-unconstrained.stderr @@ -9,6 +9,7 @@ LL | type Ty = Option; note: required by a bound in `compare_ty::Trait::Ty` --> $DIR/in-assoc-type-unconstrained.rs:5:31 | +LL | trait Trait { LL | type Ty: IntoIterator; | ^^^^^^^^^ required by this bound in `Trait::Ty` diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr b/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr index df89ed9f3b56d..83410e4a38d68 100644 --- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr +++ b/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr @@ -7,6 +7,7 @@ LL | fn bar() -> () {} note: required by a bound in `Foo::bar::{anon_assoc#0}` --> $DIR/doesnt-satisfy.rs:2:22 | +LL | trait Foo { LL | fn bar() -> impl std::fmt::Display; | ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::bar::{anon_assoc#0}` diff --git a/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr b/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr index a9232ea9e63df..0c3a0fc91b017 100644 --- a/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr +++ b/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr @@ -9,6 +9,8 @@ LL | ().publish_typed(); note: required by a bound in `TypedClient::publish_typed::{anon_assoc#0}` --> $DIR/not-inferred-generic.rs:4:12 | +LL | trait TypedClient { +... LL | F: Clone; | ^^^^^ required by this bound in `TypedClient::publish_typed::{anon_assoc#0}` help: consider specifying a concrete type for the type parameter `F` diff --git a/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr b/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr index af71e52b87d71..f108d1283ac15 100644 --- a/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr +++ b/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr @@ -16,6 +16,7 @@ LL | type Assoc = T; note: required by a bound in `Mirror::Assoc` --> $DIR/refine-resolution-errors.rs:7:5 | +LL | pub trait Mirror { LL | type Assoc; | ^^^^^^^^^^^ required by this bound in `Mirror::Assoc` help: consider removing the `?Sized` bound to make the type parameter `Sized` diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr index c62e8dbde6feb..471a454a5f522 100644 --- a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr +++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr @@ -21,6 +21,7 @@ LL | impl Foo for Bar { note: required by a bound in `Foo::foo::{anon_assoc#0}` --> $DIR/return-dont-satisfy-bounds.rs:2:30 | +LL | trait Foo { LL | fn foo(self) -> impl Foo; | ^^^^^^ required by this bound in `Foo::foo::{anon_assoc#0}` diff --git a/tests/ui/impl-trait/issues/issue-99348-impl-compatibility.stderr b/tests/ui/impl-trait/issues/issue-99348-impl-compatibility.stderr index a83e0df911b09..75e3cd40369f9 100644 --- a/tests/ui/impl-trait/issues/issue-99348-impl-compatibility.stderr +++ b/tests/ui/impl-trait/issues/issue-99348-impl-compatibility.stderr @@ -17,6 +17,7 @@ LL | type Other = Tait; note: required by a bound in `Foo::Item` --> $DIR/issue-99348-impl-compatibility.rs:17:20 | +LL | trait Foo { LL | type Item: Bar; | ^^^^^^^^^^^^ required by this bound in `Foo::Item` diff --git a/tests/ui/implied-bounds/issue-100690.stderr b/tests/ui/implied-bounds/issue-100690.stderr index b5465e2f3ce08..23c9d61c76d3b 100644 --- a/tests/ui/implied-bounds/issue-100690.stderr +++ b/tests/ui/implied-bounds/issue-100690.stderr @@ -12,7 +12,6 @@ note: required by a bound in `real_dispatch` --> $DIR/issue-100690.rs:8:8 | LL | fn real_dispatch(f: F) -> Result<(), io::Error> - | ------------- required by a bound in this function LL | where LL | F: FnOnce(&mut UIView) -> Result<(), io::Error> + Send + 'static, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `real_dispatch` diff --git a/tests/ui/inference/issue-12028.stderr b/tests/ui/inference/issue-12028.stderr index 92cfd85d96f85..c7ec79389cc4c 100644 --- a/tests/ui/inference/issue-12028.stderr +++ b/tests/ui/inference/issue-12028.stderr @@ -12,7 +12,7 @@ note: required by a bound in `StreamHash::input_stream` LL | trait StreamHash: Hash { | ^^^^^^^^^^^^ required by this bound in `StreamHash::input_stream` LL | fn input_stream(&self, stream: &mut H::S); - | ------------ required by a bound in this associated function + | help: try using a fully qualified path to specify the expected types | LL - self.input_stream(&mut stream); diff --git a/tests/ui/methods/filter-relevant-fn-bounds.stderr b/tests/ui/methods/filter-relevant-fn-bounds.stderr index 9ad0319440e9a..69552e8204575 100644 --- a/tests/ui/methods/filter-relevant-fn-bounds.stderr +++ b/tests/ui/methods/filter-relevant-fn-bounds.stderr @@ -30,7 +30,6 @@ note: required by a bound in `Wrapper::do_something_wrapper` --> $DIR/filter-relevant-fn-bounds.rs:11:12 | LL | fn do_something_wrapper(self, _: F) - | -------------------- required by a bound in this associated function ... LL | F: for<'a> FnOnce(>::Type), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Wrapper::do_something_wrapper` diff --git a/tests/ui/methods/inherent-bound-in-probe.stderr b/tests/ui/methods/inherent-bound-in-probe.stderr index dacb4523234a5..71e8e39692267 100644 --- a/tests/ui/methods/inherent-bound-in-probe.stderr +++ b/tests/ui/methods/inherent-bound-in-probe.stderr @@ -33,7 +33,6 @@ note: required by a bound in `Helper` --> $DIR/inherent-bound-in-probe.rs:17:12 | LL | struct Helper<'a, T> - | ------ required by a bound in this struct LL | where LL | &'a T: IntoIterator, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Helper` diff --git a/tests/ui/methods/issues/issue-61525.stderr b/tests/ui/methods/issues/issue-61525.stderr index 7ac3d3dc0cff0..13310c41f191d 100644 --- a/tests/ui/methods/issues/issue-61525.stderr +++ b/tests/ui/methods/issues/issue-61525.stderr @@ -10,6 +10,7 @@ LL | 1.query::("") note: required by an implicit `Sized` bound in `Example::query` --> $DIR/issue-61525.rs:2:14 | +LL | pub trait Example { LL | fn query(self, q: Q); | ^ required by the implicit `Sized` requirement on this type parameter in `Example::query` help: consider relaxing the implicit `Sized` restriction diff --git a/tests/ui/mismatched_types/issue-47706.stderr b/tests/ui/mismatched_types/issue-47706.stderr index 69d6ee5cbd5a0..12d553225900c 100644 --- a/tests/ui/mismatched_types/issue-47706.stderr +++ b/tests/ui/mismatched_types/issue-47706.stderr @@ -27,7 +27,6 @@ note: required by a bound in `foo` --> $DIR/issue-47706.rs:22:8 | LL | fn foo(f: F) - | --- required by a bound in this function LL | where LL | F: Fn(), | ^^^^ required by this bound in `foo` diff --git a/tests/ui/never_type/regress/never-as-spec-default-associated-type.stderr b/tests/ui/never_type/regress/never-as-spec-default-associated-type.stderr index bcb2c7dfae8e7..f13d27d35f2b3 100644 --- a/tests/ui/never_type/regress/never-as-spec-default-associated-type.stderr +++ b/tests/ui/never_type/regress/never-as-spec-default-associated-type.stderr @@ -8,6 +8,7 @@ LL | default type Out = !; note: required by a bound in `Trait::Out` --> $DIR/never-as-spec-default-associated-type.rs:9:15 | +LL | trait Trait { LL | type Out: Iterator; | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Trait::Out` diff --git a/tests/ui/parallel-rustc/dyn-trait-ice-153366.stderr b/tests/ui/parallel-rustc/dyn-trait-ice-153366.stderr index a9ca104c00d36..2b3e9516b3731 100644 --- a/tests/ui/parallel-rustc/dyn-trait-ice-153366.stderr +++ b/tests/ui/parallel-rustc/dyn-trait-ice-153366.stderr @@ -34,7 +34,6 @@ note: required by a bound in `iso` --> $DIR/dyn-trait-ice-153366.rs:11:22 | LL | fn iso(a: Fn) -> Option<_> - | --- required by a bound in this function ... LL | dyn Fn(A) -> (): Sized, | ^^^^^ required by this bound in `iso` @@ -82,7 +81,6 @@ note: required by a bound in `iso` --> $DIR/dyn-trait-ice-153366.rs:11:22 | LL | fn iso(a: Fn) -> Option<_> - | --- required by a bound in this function ... LL | dyn Fn(A) -> (): Sized, | ^^^^^ required by this bound in `iso` diff --git a/tests/ui/parallel-rustc/generic-const-exprs-deadlock-issue-120757.stderr b/tests/ui/parallel-rustc/generic-const-exprs-deadlock-issue-120757.stderr index 4e8cbdb319511..e3a58fcca7ee9 100644 --- a/tests/ui/parallel-rustc/generic-const-exprs-deadlock-issue-120757.stderr +++ b/tests/ui/parallel-rustc/generic-const-exprs-deadlock-issue-120757.stderr @@ -67,6 +67,8 @@ LL | if !self.inbounds(index) { note: required by a bound in `TensorSize::inbounds` --> $DIR/generic-const-exprs-deadlock-issue-120757.rs:15:39 | +LL | trait TensorSize: TensorDimension { +LL | fn size(&self) -> [usize; Self::DIM]; LL | fn inbounds(&self, index: [usize; Self::DIM]) -> bool { | ^^^^^^^^^ required by this bound in `TensorSize::inbounds` help: try adding a `where` bound @@ -92,6 +94,7 @@ LL | let size = self.size(); note: required by a bound in `TensorSize::size` --> $DIR/generic-const-exprs-deadlock-issue-120757.rs:14:31 | +LL | trait TensorSize: TensorDimension { LL | fn size(&self) -> [usize; Self::DIM]; | ^^^^^^^^^ required by this bound in `TensorSize::size` help: try adding a `where` bound @@ -119,6 +122,7 @@ LL | self.reference.size() note: required by a bound in `TensorSize::size` --> $DIR/generic-const-exprs-deadlock-issue-120757.rs:14:31 | +LL | trait TensorSize: TensorDimension { LL | fn size(&self) -> [usize; Self::DIM]; | ^^^^^^^^^ required by this bound in `TensorSize::size` help: try adding a `where` bound @@ -144,6 +148,8 @@ LL | self.reference.bget(index).map(ns_window) note: required by a bound in `Broadcastable::bget` --> $DIR/generic-const-exprs-deadlock-issue-120757.rs:22:35 | +LL | trait Broadcastable: TensorSize + Sized { +LL | type Element; LL | fn bget(&self, index: [usize; Self::DIM]) -> Option; | ^^^^^^^^^ required by this bound in `Broadcastable::bget` help: try adding a `where` bound diff --git a/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.stderr b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.stderr index 643e3d3b680e0..f20fc381d04dc 100644 --- a/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.stderr +++ b/tests/ui/rfcs/rfc-1937-termination-trait/issue-103052-2.stderr @@ -12,6 +12,7 @@ LL | struct Something; note: required by a bound in `Main::main::{anon_assoc#0}` --> $DIR/issue-103052-2.rs:3:27 | +LL | trait Main { LL | fn main() -> impl std::process::Termination; | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::main::{anon_assoc#0}` diff --git a/tests/ui/specialization/default-associated-type-bound-1.stderr b/tests/ui/specialization/default-associated-type-bound-1.stderr index 70408145e8039..921a892fa7deb 100644 --- a/tests/ui/specialization/default-associated-type-bound-1.stderr +++ b/tests/ui/specialization/default-associated-type-bound-1.stderr @@ -9,6 +9,7 @@ help: the trait `Clone` is implemented for `String` note: required by a bound in `X::U` --> $DIR/default-associated-type-bound-1.rs:7:13 | +LL | trait X { LL | type U: Clone; | ^^^^^ required by this bound in `X::U` diff --git a/tests/ui/specialization/default-associated-type-bound-2.stderr b/tests/ui/specialization/default-associated-type-bound-2.stderr index 3d3fdbad26408..82fb7e4d9e4d4 100644 --- a/tests/ui/specialization/default-associated-type-bound-2.stderr +++ b/tests/ui/specialization/default-associated-type-bound-2.stderr @@ -8,6 +8,7 @@ LL | default type U = &'static B; note: required by a bound in `X::U` --> $DIR/default-associated-type-bound-2.rs:5:13 | +LL | trait X { LL | type U: PartialEq; | ^^^^^^^^^^^^ required by this bound in `X::U` help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement diff --git a/tests/ui/specialization/default-generic-associated-type-bound.stderr b/tests/ui/specialization/default-generic-associated-type-bound.stderr index 7c2bde84a3675..df5ccb00779ee 100644 --- a/tests/ui/specialization/default-generic-associated-type-bound.stderr +++ b/tests/ui/specialization/default-generic-associated-type-bound.stderr @@ -8,6 +8,7 @@ LL | default type U<'a> = &'a T; note: required by a bound in `X::U` --> $DIR/default-generic-associated-type-bound.rs:6:17 | +LL | trait X { LL | type U<'a>: PartialEq<&'a Self> where Self: 'a; | ^^^^^^^^^^^^^^^^^^^ required by this bound in `X::U` help: consider further restricting type parameter `T` with trait `PartialEq` diff --git a/tests/ui/specialization/fuzzed/fuzzing-ice-134905.stderr b/tests/ui/specialization/fuzzed/fuzzing-ice-134905.stderr index 79117229300ae..bc1e57ff00b7c 100644 --- a/tests/ui/specialization/fuzzed/fuzzing-ice-134905.stderr +++ b/tests/ui/specialization/fuzzed/fuzzing-ice-134905.stderr @@ -12,6 +12,7 @@ LL | trait Valid {} note: required by a bound in `Iterate::Ty` --> $DIR/fuzzing-ice-134905.rs:6:14 | +LL | trait Iterate<'a> { LL | type Ty: Valid; | ^^^^^ required by this bound in `Iterate::Ty` diff --git a/tests/ui/specialization/issue-33017.stderr b/tests/ui/specialization/issue-33017.stderr index 29a82a4d87519..89a4e9c6ed0b6 100644 --- a/tests/ui/specialization/issue-33017.stderr +++ b/tests/ui/specialization/issue-33017.stderr @@ -7,6 +7,7 @@ LL | default type Output = Self; note: required by a bound in `UncheckedCopy::Output` --> $DIR/issue-33017.rs:8:31 | +LL | trait UncheckedCopy: Sized { LL | type Output: From + Copy + Into; | ^^^^ required by this bound in `UncheckedCopy::Output` help: consider restricting type parameter `T` with trait `Copy` diff --git a/tests/ui/specialization/issue-38091.stderr b/tests/ui/specialization/issue-38091.stderr index 91ea3db70311f..68a5947e77067 100644 --- a/tests/ui/specialization/issue-38091.stderr +++ b/tests/ui/specialization/issue-38091.stderr @@ -12,6 +12,7 @@ LL | trait Valid {} note: required by a bound in `Iterate::Ty` --> $DIR/issue-38091.rs:4:14 | +LL | trait Iterate<'a> { LL | type Ty: Valid; | ^^^^^ required by this bound in `Iterate::Ty` diff --git a/tests/ui/specialization/issue-44861.stderr b/tests/ui/specialization/issue-44861.stderr index e480f65333fda..6e736589b6acb 100644 --- a/tests/ui/specialization/issue-44861.stderr +++ b/tests/ui/specialization/issue-44861.stderr @@ -7,6 +7,8 @@ LL | default type Data2 = (); note: required by a bound in `Smartass::Data2` --> $DIR/issue-44861.rs:12:17 | +LL | pub trait Smartass { +LL | type Data; LL | type Data2: CoerceUnsized<*const [u8]>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Smartass::Data2` diff --git a/tests/ui/specialization/issue-59435.stderr b/tests/ui/specialization/issue-59435.stderr index 60522e0f587b6..89f6a500bd436 100644 --- a/tests/ui/specialization/issue-59435.stderr +++ b/tests/ui/specialization/issue-59435.stderr @@ -7,6 +7,7 @@ LL | default type MyType = MyStruct; note: required by a bound in `MyTrait::MyType` --> $DIR/issue-59435.rs:7:18 | +LL | trait MyTrait { LL | type MyType: Default; | ^^^^^^^ required by this bound in `MyTrait::MyType` help: consider annotating `MyStruct` with `#[derive(Default)]` diff --git a/tests/ui/splat/splat-dyn-asref-tuple-fail.stderr b/tests/ui/splat/splat-dyn-asref-tuple-fail.stderr index 9308075ae89bb..27116d683d1d1 100644 --- a/tests/ui/splat/splat-dyn-asref-tuple-fail.stderr +++ b/tests/ui/splat/splat-dyn-asref-tuple-fail.stderr @@ -17,7 +17,6 @@ note: required by a bound in `dyn_asref_splat` --> $DIR/splat-dyn-asref-tuple-fail.rs:18:8 | LL | fn dyn_asref_splat(#[rustc_splat] _t: &dyn AsRef) - | --------------- required by a bound in this function ... LL | T: std::marker::Tuple, | ^^^^^^^^^^^^^^^^^^ required by this bound in `dyn_asref_splat` diff --git a/tests/ui/suggestions/closure-arg-trailing-semicolon.stderr b/tests/ui/suggestions/closure-arg-trailing-semicolon.stderr index f0f9ef83345c7..0a625e0f25cda 100644 --- a/tests/ui/suggestions/closure-arg-trailing-semicolon.stderr +++ b/tests/ui/suggestions/closure-arg-trailing-semicolon.stderr @@ -147,7 +147,7 @@ note: required by a bound in `Callable::CALL` LL | trait Callable { | ^^^ required by this bound in `Callable::CALL` LL | const CALL: fn(); - | ---- required by a bound in this associated constant + | error: aborting due to 9 previous errors diff --git a/tests/ui/suggestions/correct-binder-for-arbitrary-bound-sugg.stderr b/tests/ui/suggestions/correct-binder-for-arbitrary-bound-sugg.stderr index 2cd3fba871548..95546191040db 100644 --- a/tests/ui/suggestions/correct-binder-for-arbitrary-bound-sugg.stderr +++ b/tests/ui/suggestions/correct-binder-for-arbitrary-bound-sugg.stderr @@ -8,7 +8,6 @@ note: required by a bound in `Foo` --> $DIR/correct-binder-for-arbitrary-bound-sugg.rs:3:23 | LL | trait Foo - | --- required by a bound in this trait LL | where LL | for<'a> &'a Self: Bar, | ^^^ required by this bound in `Foo` diff --git a/tests/ui/suggestions/fn-trait-notation.stderr b/tests/ui/suggestions/fn-trait-notation.stderr index ef7d5fe362820..dd22fee829f3d 100644 --- a/tests/ui/suggestions/fn-trait-notation.stderr +++ b/tests/ui/suggestions/fn-trait-notation.stderr @@ -65,7 +65,6 @@ note: required by a bound in `e0658` --> $DIR/fn-trait-notation.rs:4:8 | LL | fn e0658(f: F, g: G, h: H) -> i32 - | ----- required by a bound in this function LL | where LL | F: Fn, | ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `e0658` diff --git a/tests/ui/suggestions/imm-ref-trait-object-literal-bound-regions.stderr b/tests/ui/suggestions/imm-ref-trait-object-literal-bound-regions.stderr index e25b9ce38571d..5542c32bac173 100644 --- a/tests/ui/suggestions/imm-ref-trait-object-literal-bound-regions.stderr +++ b/tests/ui/suggestions/imm-ref-trait-object-literal-bound-regions.stderr @@ -16,7 +16,6 @@ note: required by a bound in `foo` --> $DIR/imm-ref-trait-object-literal-bound-regions.rs:11:20 | LL | fn foo(_: X) - | --- required by a bound in this function LL | where LL | for<'b> &'b X: Trait, | ^^^^^ required by this bound in `foo` diff --git a/tests/ui/suggestions/issue-84973.stderr b/tests/ui/suggestions/issue-84973.stderr index c5e1958e030f2..2dec2d5f43527 100644 --- a/tests/ui/suggestions/issue-84973.stderr +++ b/tests/ui/suggestions/issue-84973.stderr @@ -13,7 +13,7 @@ LL | G: SomeTrait, | ^^^^^^^^^ required by this bound in `Other::<'a, G>::new` LL | { LL | pub fn new(g: G) -> Self { - | --- required by a bound in this associated function + | help: consider borrowing here | LL | let o = Other::new(&f); diff --git a/tests/ui/trait-bounds/suggest-maybe-sized-bound.stderr b/tests/ui/trait-bounds/suggest-maybe-sized-bound.stderr index b459ad47e067a..4182e0eee795f 100644 --- a/tests/ui/trait-bounds/suggest-maybe-sized-bound.stderr +++ b/tests/ui/trait-bounds/suggest-maybe-sized-bound.stderr @@ -25,6 +25,7 @@ LL | type P = [u8]; note: required by a bound in `main::Trait::P` --> $DIR/suggest-maybe-sized-bound.rs:13:9 | +LL | trait Trait { LL | type P; | ^^^^^^^^^^ required by this bound in `Trait::P` help: consider relaxing the implicit `Sized` restriction diff --git a/tests/ui/trait-bounds/super-assoc-mismatch.stderr b/tests/ui/trait-bounds/super-assoc-mismatch.stderr index 11d764d111eed..876854415509c 100644 --- a/tests/ui/trait-bounds/super-assoc-mismatch.stderr +++ b/tests/ui/trait-bounds/super-assoc-mismatch.stderr @@ -46,6 +46,7 @@ LL | trait Sub: Super {} note: required by a bound in `BoundOnAssoc::Assoc` --> $DIR/super-assoc-mismatch.rs:18:17 | +LL | trait BoundOnAssoc { LL | type Assoc: Sub; | ^^^ required by this bound in `BoundOnAssoc::Assoc` @@ -97,7 +98,6 @@ note: required by a bound in `MultiAssoc` --> $DIR/super-assoc-mismatch.rs:46:23 | LL | trait MultiAssoc - | ---------- required by a bound in this trait LL | where LL | Self::Assoc1<()>: SubGeneric | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `MultiAssoc` diff --git a/tests/ui/traits/bad-method-typaram-kind.stderr b/tests/ui/traits/bad-method-typaram-kind.stderr index 3b3d6e5f832b6..f97f6c2bb8cb1 100644 --- a/tests/ui/traits/bad-method-typaram-kind.stderr +++ b/tests/ui/traits/bad-method-typaram-kind.stderr @@ -9,6 +9,7 @@ LL | 1.bar::(); note: required by a bound in `Bar::bar` --> $DIR/bad-method-typaram-kind.rs:6:14 | +LL | trait Bar { LL | fn bar(&self); | ^^^^ required by this bound in `Bar::bar` help: consider further restricting type parameter `T` with trait `Send` diff --git a/tests/ui/traits/const-traits/assoc-type.current.stderr b/tests/ui/traits/const-traits/assoc-type.current.stderr index f66e9e03b0754..64e2e58f71944 100644 --- a/tests/ui/traits/const-traits/assoc-type.current.stderr +++ b/tests/ui/traits/const-traits/assoc-type.current.stderr @@ -7,6 +7,7 @@ LL | type Bar = NonConstAdd; note: required by a bound in `Foo::Bar` --> $DIR/assoc-type.rs:31:15 | +LL | const trait Foo { LL | type Bar: [const] Add; | ^^^^^^^^^^^ required by this bound in `Foo::Bar` help: make the `impl` of trait `Add` `const` diff --git a/tests/ui/traits/const-traits/assoc-type.next.stderr b/tests/ui/traits/const-traits/assoc-type.next.stderr index f66e9e03b0754..64e2e58f71944 100644 --- a/tests/ui/traits/const-traits/assoc-type.next.stderr +++ b/tests/ui/traits/const-traits/assoc-type.next.stderr @@ -7,6 +7,7 @@ LL | type Bar = NonConstAdd; note: required by a bound in `Foo::Bar` --> $DIR/assoc-type.rs:31:15 | +LL | const trait Foo { LL | type Bar: [const] Add; | ^^^^^^^^^^^ required by this bound in `Foo::Bar` help: make the `impl` of trait `Add` `const` diff --git a/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr b/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr index 52b62e7aaccc8..4b7231cb34eff 100644 --- a/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr +++ b/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr @@ -311,6 +311,7 @@ LL | type Type = (); note: required by a bound in `NonConstTrait::Type` --> $DIR/conditionally-const-invalid-places.rs:24:34 | +LL | trait NonConstTrait { LL | type Type: [const] Trait; | ^^^^^^^^^^^^^ required by this bound in `NonConstTrait::Type` diff --git a/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr b/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr index 375cb58580490..04034827338ff 100644 --- a/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr +++ b/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr @@ -7,6 +7,7 @@ LL | type Assoc = N note: required by a bound in `Foo::Assoc` --> $DIR/item-bound-entailment-fails.rs:5:20 | +LL | const trait Foo { LL | type Assoc: [const] Bar | ^^^^^^^^^^^ required by this bound in `Foo::Assoc` help: make the `impl` of trait `Bar` `const` @@ -28,6 +29,7 @@ LL | const impl Bar for C where T: [const] Bar {} note: required by a bound in `Foo::Assoc` --> $DIR/item-bound-entailment-fails.rs:5:20 | +LL | const trait Foo { LL | type Assoc: [const] Bar | ^^^^^^^^^^^ required by this bound in `Foo::Assoc` diff --git a/tests/ui/traits/const-traits/trait-where-clause-const.stderr b/tests/ui/traits/const-traits/trait-where-clause-const.stderr index 20dd395b820bf..9aedccc96f5cb 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-const.stderr +++ b/tests/ui/traits/const-traits/trait-where-clause-const.stderr @@ -7,6 +7,8 @@ LL | T::b(); note: required by a bound in `Foo::b` --> $DIR/trait-where-clause-const.rs:13:24 | +LL | const trait Foo { +LL | fn a(); LL | fn b() where Self: [const] Bar; | ^^^^^^^^^^^ required by this bound in `Foo::b` @@ -19,6 +21,8 @@ LL | T::c::(); note: required by a bound in `Foo::c` --> $DIR/trait-where-clause-const.rs:14:13 | +LL | const trait Foo { +... LL | fn c(); | ^^^^^^^^^^^ required by this bound in `Foo::c` diff --git a/tests/ui/traits/const-traits/trait-where-clause.stderr b/tests/ui/traits/const-traits/trait-where-clause.stderr index 57d87f74565e2..38b873abeda48 100644 --- a/tests/ui/traits/const-traits/trait-where-clause.stderr +++ b/tests/ui/traits/const-traits/trait-where-clause.stderr @@ -31,6 +31,8 @@ LL | T::b(); note: required by a bound in `Foo::b` --> $DIR/trait-where-clause.rs:7:24 | +LL | trait Foo { +LL | fn a(); LL | fn b() where Self: [const] Bar; | ^^^^^^^^^^^ required by this bound in `Foo::b` help: consider further restricting type parameter `T` with trait `Bar` @@ -47,6 +49,8 @@ LL | T::c::(); note: required by a bound in `Foo::c` --> $DIR/trait-where-clause.rs:9:13 | +LL | trait Foo { +... LL | fn c(); | ^^^^^^^^^^^ required by this bound in `Foo::c` help: consider further restricting type parameter `T` with trait `Bar` diff --git a/tests/ui/traits/cross-fn-cache-hole.stderr b/tests/ui/traits/cross-fn-cache-hole.stderr index ca43119dde7f6..ed66f4c8ffb9d 100644 --- a/tests/ui/traits/cross-fn-cache-hole.stderr +++ b/tests/ui/traits/cross-fn-cache-hole.stderr @@ -29,7 +29,6 @@ note: required by a bound in `require` --> $DIR/cross-fn-cache-hole.rs:25:14 | LL | fn require() - | ------- required by a bound in this function LL | where A: Bar | ^^^^^^ required by this bound in `require` diff --git a/tests/ui/traits/cycle-cache-err-60010.stderr b/tests/ui/traits/cycle-cache-err-60010.stderr index 9665d5badf599..760a911f46161 100644 --- a/tests/ui/traits/cycle-cache-err-60010.stderr +++ b/tests/ui/traits/cycle-cache-err-60010.stderr @@ -83,6 +83,7 @@ LL | struct SalsaStorage { note: required by a bound in `Database::Storage` --> $DIR/cycle-cache-err-60010.rs:7:5 | +LL | trait Database { LL | type Storage; | ^^^^^^^^^^^^^ required by this bound in `Database::Storage` help: consider relaxing the implicit `Sized` restriction diff --git a/tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.stderr b/tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.stderr index ab62ab81b213b..9ddcec5a409d5 100644 --- a/tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.stderr +++ b/tests/ui/traits/default_auto_traits/maybe-bounds-in-traits.stderr @@ -29,6 +29,8 @@ LL | struct NonLeakS; note: required by a bound in `Test1::Leak2` --> $DIR/maybe-bounds-in-traits.rs:58:9 | +LL | trait Test1 { +LL | type Leak1 = LeakS; LL | type Leak2 = NonLeakS; | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Test1::Leak2` diff --git a/tests/ui/traits/explicit-reference-cast-hrtb.stderr b/tests/ui/traits/explicit-reference-cast-hrtb.stderr index 4921a87900051..1f3f2eeae022c 100644 --- a/tests/ui/traits/explicit-reference-cast-hrtb.stderr +++ b/tests/ui/traits/explicit-reference-cast-hrtb.stderr @@ -13,7 +13,6 @@ note: required by a bound in `f` --> $DIR/explicit-reference-cast-hrtb.rs:7:18 | LL | fn f() - | - required by a bound in this function LL | where LL | for<'a> Foo: From<&'a String>, | ^^^^^^^^^^^^^^^^ required by this bound in `f` diff --git a/tests/ui/traits/explicit-reference-cast-unrelated-leaf.stderr b/tests/ui/traits/explicit-reference-cast-unrelated-leaf.stderr index 1e4cb7f1cd18b..75ec60c9ec52e 100644 --- a/tests/ui/traits/explicit-reference-cast-unrelated-leaf.stderr +++ b/tests/ui/traits/explicit-reference-cast-unrelated-leaf.stderr @@ -16,7 +16,6 @@ note: required by a bound in `Wrapper::do_something_wrapper` --> $DIR/explicit-reference-cast-unrelated-leaf.rs:10:20 | LL | fn do_something_wrapper(self, _: F) - | -------------------- required by a bound in this associated function LL | where LL | for<'a> F: Output<'a>, | ^^^^^^^^^^ required by this bound in `Wrapper::do_something_wrapper` @@ -37,7 +36,6 @@ note: required by a bound in `Wrapper::do_something_wrapper` --> $DIR/explicit-reference-cast-unrelated-leaf.rs:11:20 | LL | fn do_something_wrapper(self, _: F) - | -------------------- required by a bound in this associated function ... LL | for<'a> O: From<>::Type>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Wrapper::do_something_wrapper` diff --git a/tests/ui/traits/fn-pointer/suggest-wrap-parens-method.stderr b/tests/ui/traits/fn-pointer/suggest-wrap-parens-method.stderr index 2fc1523a19373..0288de2ef7be6 100644 --- a/tests/ui/traits/fn-pointer/suggest-wrap-parens-method.stderr +++ b/tests/ui/traits/fn-pointer/suggest-wrap-parens-method.stderr @@ -7,6 +7,7 @@ LL | main.do_stuff(); note: required by a bound in `Bar::do_stuff` --> $DIR/suggest-wrap-parens-method.rs:8:36 | +LL | trait Bar { LL | fn do_stuff(&self) where Self: Foo {} | ^^^ required by this bound in `Bar::do_stuff` help: the trait `Foo` is implemented for fn pointer `fn()`, try casting using `as` diff --git a/tests/ui/traits/inductive-overflow/two-traits.stderr b/tests/ui/traits/inductive-overflow/two-traits.stderr index 1816e029f1844..7c80726582336 100644 --- a/tests/ui/traits/inductive-overflow/two-traits.stderr +++ b/tests/ui/traits/inductive-overflow/two-traits.stderr @@ -7,6 +7,7 @@ LL | type X = Self; note: required by a bound in `Magic::X` --> $DIR/two-traits.rs:8:13 | +LL | pub trait Magic { LL | type X: Trait; | ^^^^^ required by this bound in `Magic::X` help: consider further restricting type parameter `T` with trait `Sync` diff --git a/tests/ui/traits/multidispatch-convert-ambig-dest.stderr b/tests/ui/traits/multidispatch-convert-ambig-dest.stderr index 12984c7936c9a..99135c790640a 100644 --- a/tests/ui/traits/multidispatch-convert-ambig-dest.stderr +++ b/tests/ui/traits/multidispatch-convert-ambig-dest.stderr @@ -18,7 +18,6 @@ note: required by a bound in `test` --> $DIR/multidispatch-convert-ambig-dest.rs:21:11 | LL | fn test(_: T, _: U) - | ---- required by a bound in this function LL | where T : Convert | ^^^^^^^^^^ required by this bound in `test` help: consider specifying the generic arguments diff --git a/tests/ui/traits/next-solver/diagnostics/dont-suppress-independent-projection-error.current.stderr b/tests/ui/traits/next-solver/diagnostics/dont-suppress-independent-projection-error.current.stderr index 546a069bb93ab..3f2b788d9c071 100644 --- a/tests/ui/traits/next-solver/diagnostics/dont-suppress-independent-projection-error.current.stderr +++ b/tests/ui/traits/next-solver/diagnostics/dont-suppress-independent-projection-error.current.stderr @@ -20,7 +20,6 @@ note: required by a bound in `f` --> $DIR/dont-suppress-independent-projection-error.rs:22:8 | LL | fn f(_: T) - | - required by a bound in this function LL | where LL | T: Sub, | ^^^ required by this bound in `f` @@ -42,7 +41,6 @@ note: required by a bound in `f` --> $DIR/dont-suppress-independent-projection-error.rs:23:14 | LL | fn f(_: T) - | - required by a bound in this function ... LL | T: Super, | ^^^^^^^^^^^ required by this bound in `f` diff --git a/tests/ui/traits/next-solver/diagnostics/dont-suppress-independent-projection-error.next.stderr b/tests/ui/traits/next-solver/diagnostics/dont-suppress-independent-projection-error.next.stderr index 546a069bb93ab..3f2b788d9c071 100644 --- a/tests/ui/traits/next-solver/diagnostics/dont-suppress-independent-projection-error.next.stderr +++ b/tests/ui/traits/next-solver/diagnostics/dont-suppress-independent-projection-error.next.stderr @@ -20,7 +20,6 @@ note: required by a bound in `f` --> $DIR/dont-suppress-independent-projection-error.rs:22:8 | LL | fn f(_: T) - | - required by a bound in this function LL | where LL | T: Sub, | ^^^ required by this bound in `f` @@ -42,7 +41,6 @@ note: required by a bound in `f` --> $DIR/dont-suppress-independent-projection-error.rs:23:14 | LL | fn f(_: T) - | - required by a bound in this function ... LL | T: Super, | ^^^^^^^^^^^ required by this bound in `f` diff --git a/tests/ui/traits/next-solver/diagnostics/iterator-item-suggest-no-ice.stderr b/tests/ui/traits/next-solver/diagnostics/iterator-item-suggest-no-ice.stderr index 7f160b1b7e951..59788287ddf7c 100644 --- a/tests/ui/traits/next-solver/diagnostics/iterator-item-suggest-no-ice.stderr +++ b/tests/ui/traits/next-solver/diagnostics/iterator-item-suggest-no-ice.stderr @@ -34,8 +34,8 @@ LL | self.bar(collection); note: required by a bound in `FooMut::bar` --> $DIR/iterator-item-suggest-no-ice.rs:7:24 | +LL | trait FooMut { LL | fn bar(&self, _: I) - | --- required by a bound in this associated function LL | where LL | for<'b> &'b I: Iterator; | ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `FooMut::bar` diff --git a/tests/ui/traits/next-solver/diagnostics/rpitit-fulfillment-error.stderr b/tests/ui/traits/next-solver/diagnostics/rpitit-fulfillment-error.stderr index 49bfbf237b4e2..294938f28c013 100644 --- a/tests/ui/traits/next-solver/diagnostics/rpitit-fulfillment-error.stderr +++ b/tests/ui/traits/next-solver/diagnostics/rpitit-fulfillment-error.stderr @@ -10,6 +10,7 @@ LL | self.build(further_commands) note: required by a bound in `Crash::build` --> $DIR/rpitit-fulfillment-error.rs:5:44 | +LL | trait Crash { LL | fn build<'a>(&mut self, commands: impl Iterator + 'a) -> impl Iterator + 'a { | ^^^^^^^^ required by this bound in `Crash::build` help: consider further restricting `Self` diff --git a/tests/ui/traits/next-solver/more-object-bound.stderr b/tests/ui/traits/next-solver/more-object-bound.stderr index ccbf19ae4d96c..41c2c615b8647 100644 --- a/tests/ui/traits/next-solver/more-object-bound.stderr +++ b/tests/ui/traits/next-solver/more-object-bound.stderr @@ -17,7 +17,6 @@ note: required by a bound in `foo` --> $DIR/more-object-bound.rs:18:8 | LL | fn foo(x: T::A) -> B - | --- required by a bound in this function LL | where LL | T: Trait, | ^^^^^^^^^^^^ required by this bound in `foo` diff --git a/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr b/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr index f5ff41fc17aae..3ff67da114462 100644 --- a/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr +++ b/tests/ui/traits/next-solver/normalize/normalize-param-env-2.stderr @@ -35,8 +35,9 @@ LL | impl A for () { note: required by a bound in `A::f` --> $DIR/normalize-param-env-2.rs:14:22 | +LL | trait A { +... LL | fn f() - | - required by a bound in this associated function LL | where LL | Self::Assoc: A, | ^^^^ required by this bound in `A::f` diff --git a/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.current.stderr b/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.current.stderr index 955d5b4970d34..1189f62601759 100644 --- a/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.current.stderr +++ b/tests/ui/traits/next-solver/opaques/implied-bounds-opaque-hidden-in-closure-sig.current.stderr @@ -15,7 +15,6 @@ note: required by a bound in `RequiresWf` --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:31:16 | LL | struct RequiresWf(F) - | ---------- required by a bound in this tuple struct ... LL | F::Output: Trait, | ^^^^^ required by this bound in `RequiresWf` @@ -35,7 +34,6 @@ note: required by a bound in `RequiresWf` --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:31:16 | LL | struct RequiresWf(F) - | ---------- required by a bound in this struct ... LL | F::Output: Trait, | ^^^^^ required by this bound in `RequiresWf` @@ -55,7 +53,6 @@ note: required by a bound in `RequiresWf` --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:31:16 | LL | struct RequiresWf(F) - | ---------- required by a bound in this struct ... LL | F::Output: Trait, | ^^^^^ required by this bound in `RequiresWf` @@ -75,7 +72,6 @@ note: required by a bound in `RequiresWf` --> $DIR/implied-bounds-opaque-hidden-in-closure-sig.rs:31:16 | LL | struct RequiresWf(F) - | ---------- required by a bound in this struct ... LL | F::Output: Trait, | ^^^^^ required by this bound in `RequiresWf` diff --git a/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.stderr b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.stderr index 80f1a9328d5e0..e711e1eb00a88 100644 --- a/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.stderr +++ b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.stderr @@ -13,7 +13,6 @@ note: required by a bound in `Z` --> $DIR/outlives-goal-error-due-to-normalization-failure-no-ice.rs:7:8 | LL | trait Z<'a, T: ?Sized> - | - required by a bound in this trait LL | where LL | T: Z<'a, ()>, | ^^^^^^^^^ required by this bound in `Z` diff --git a/tests/ui/traits/next-solver/overflow/dont-drop-obligations-on-overflow-2.stderr b/tests/ui/traits/next-solver/overflow/dont-drop-obligations-on-overflow-2.stderr index c8d3b877657f3..684ad98bc3f38 100644 --- a/tests/ui/traits/next-solver/overflow/dont-drop-obligations-on-overflow-2.stderr +++ b/tests/ui/traits/next-solver/overflow/dont-drop-obligations-on-overflow-2.stderr @@ -9,7 +9,6 @@ note: required by a bound in `prove` --> $DIR/dont-drop-obligations-on-overflow-2.rs:18:23 | LL | fn prove() - | ----- required by a bound in this function LL | where LL | for<'a> Tait<'a>: Sized, | ^^^^^ required by this bound in `prove` diff --git a/tests/ui/traits/next-solver/transmute-from-unconstrained.stderr b/tests/ui/traits/next-solver/transmute-from-unconstrained.stderr index a3a1cee105d59..e6fc0e297a512 100644 --- a/tests/ui/traits/next-solver/transmute-from-unconstrained.stderr +++ b/tests/ui/traits/next-solver/transmute-from-unconstrained.stderr @@ -9,7 +9,6 @@ note: required by a bound in `assert_transmutable` --> $DIR/transmute-from-unconstrained.rs:13:9 | LL | fn assert_transmutable() - | ------------------- required by a bound in this function LL | where LL | (): std::mem::TransmuteFrom, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `assert_transmutable` diff --git a/tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr b/tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr index 0b3aa5c904f9c..7e4b5cf68aedc 100644 --- a/tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr +++ b/tests/ui/traits/non_lifetime_binders/bad-sized-cond.stderr @@ -9,7 +9,6 @@ note: required by a bound in `foo` --> $DIR/bad-sized-cond.rs:5:15 | LL | pub fn foo() - | --- required by a bound in this function LL | where LL | for V: Sized, | ^^^^^ required by this bound in `foo` @@ -26,7 +25,6 @@ note: required by a bound in `bar` --> $DIR/bad-sized-cond.rs:11:15 | LL | pub fn bar() - | --- required by a bound in this function LL | where LL | for V: IntoIterator, | ^^^^^^^^^^^^ required by this bound in `bar` @@ -43,7 +41,6 @@ note: required by a bound in `bar` --> $DIR/bad-sized-cond.rs:11:15 | LL | pub fn bar() - | --- required by a bound in this function LL | where LL | for V: IntoIterator, | ^^^^^^^^^^^^ required by this bound in `bar` diff --git a/tests/ui/traits/non_lifetime_binders/fail.stderr b/tests/ui/traits/non_lifetime_binders/fail.stderr index 38a0eabddd3bb..3cc6d79717268 100644 --- a/tests/ui/traits/non_lifetime_binders/fail.stderr +++ b/tests/ui/traits/non_lifetime_binders/fail.stderr @@ -13,7 +13,6 @@ note: required by a bound in `fail` --> $DIR/fail.rs:9:15 | LL | fn fail() - | ---- required by a bound in this function LL | where LL | for T: Trait, | ^^^^^ required by this bound in `fail` @@ -29,7 +28,6 @@ note: required by a bound in `auto_trait` --> $DIR/fail.rs:14:15 | LL | fn auto_trait() - | ---------- required by a bound in this function LL | where LL | for T: Send, | ^^^^ required by this bound in `auto_trait` diff --git a/tests/ui/traits/non_lifetime_binders/foreach-partial-eq-next-solver.stderr b/tests/ui/traits/non_lifetime_binders/foreach-partial-eq-next-solver.stderr index 19921e3e06eed..84cf075f34b45 100644 --- a/tests/ui/traits/non_lifetime_binders/foreach-partial-eq-next-solver.stderr +++ b/tests/ui/traits/non_lifetime_binders/foreach-partial-eq-next-solver.stderr @@ -9,7 +9,6 @@ note: required by a bound in `auto_trait` --> $DIR/foreach-partial-eq-next-solver.rs:17:27 | LL | fn auto_trait() - | ---------- required by a bound in this function LL | where LL | for T: PartialEq + PartialOrd, | ^^^^^^^^^^ required by this bound in `auto_trait` diff --git a/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.stderr b/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.stderr index b621f5c612dee..436ff8f0b3820 100644 --- a/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.stderr +++ b/tests/ui/traits/non_lifetime_binders/foreach-partial-eq.stderr @@ -9,7 +9,6 @@ note: required by a bound in `auto_trait` --> $DIR/foreach-partial-eq.rs:5:27 | LL | fn auto_trait() - | ---------- required by a bound in this function LL | where LL | for T: PartialEq + PartialOrd, | ^^^^^^^^^^ required by this bound in `auto_trait` diff --git a/tests/ui/traits/non_lifetime_binders/universe-error-host-effect.stderr b/tests/ui/traits/non_lifetime_binders/universe-error-host-effect.stderr index a634c86afa534..f1bd591086722 100644 --- a/tests/ui/traits/non_lifetime_binders/universe-error-host-effect.stderr +++ b/tests/ui/traits/non_lifetime_binders/universe-error-host-effect.stderr @@ -34,7 +34,6 @@ note: required by a bound in `foo` --> $DIR/universe-error-host-effect.rs:19:15 | LL | fn foo() - | --- required by a bound in this function LL | where LL | for T: const Other, | ^^^^^^^^^^^^^^^^^ required by this bound in `foo` diff --git a/tests/ui/traits/non_lifetime_binders/universe-error1.current.stderr b/tests/ui/traits/non_lifetime_binders/universe-error1.current.stderr index 1ef4cc1034bc3..388fb181fe81a 100644 --- a/tests/ui/traits/non_lifetime_binders/universe-error1.current.stderr +++ b/tests/ui/traits/non_lifetime_binders/universe-error1.current.stderr @@ -8,7 +8,6 @@ note: required by a bound in `foo` --> $DIR/universe-error1.rs:17:15 | LL | fn foo() - | --- required by a bound in this function LL | where LL | for T: Other {} | ^^^^^^^^ required by this bound in `foo` diff --git a/tests/ui/traits/non_lifetime_binders/universe-error1.next.stderr b/tests/ui/traits/non_lifetime_binders/universe-error1.next.stderr index 1ef4cc1034bc3..388fb181fe81a 100644 --- a/tests/ui/traits/non_lifetime_binders/universe-error1.next.stderr +++ b/tests/ui/traits/non_lifetime_binders/universe-error1.next.stderr @@ -8,7 +8,6 @@ note: required by a bound in `foo` --> $DIR/universe-error1.rs:17:15 | LL | fn foo() - | --- required by a bound in this function LL | where LL | for T: Other {} | ^^^^^^^^ required by this bound in `foo` diff --git a/tests/ui/traits/normalize/unconstrained-projection-normalization-2.current.stderr b/tests/ui/traits/normalize/unconstrained-projection-normalization-2.current.stderr index e8742e7f09902..3d249c3949f28 100644 --- a/tests/ui/traits/normalize/unconstrained-projection-normalization-2.current.stderr +++ b/tests/ui/traits/normalize/unconstrained-projection-normalization-2.current.stderr @@ -25,6 +25,7 @@ LL | type Assoc = T; note: required by a bound in `Every::Assoc` --> $DIR/unconstrained-projection-normalization-2.rs:12:5 | +LL | pub trait Every { LL | type Assoc; | ^^^^^^^^^^^ required by this bound in `Every::Assoc` help: consider removing the `?Sized` bound to make the type parameter `Sized` diff --git a/tests/ui/traits/normalize/unconstrained-projection-normalization-2.next.stderr b/tests/ui/traits/normalize/unconstrained-projection-normalization-2.next.stderr index e8742e7f09902..3d249c3949f28 100644 --- a/tests/ui/traits/normalize/unconstrained-projection-normalization-2.next.stderr +++ b/tests/ui/traits/normalize/unconstrained-projection-normalization-2.next.stderr @@ -25,6 +25,7 @@ LL | type Assoc = T; note: required by a bound in `Every::Assoc` --> $DIR/unconstrained-projection-normalization-2.rs:12:5 | +LL | pub trait Every { LL | type Assoc; | ^^^^^^^^^^^ required by this bound in `Every::Assoc` help: consider removing the `?Sized` bound to make the type parameter `Sized` diff --git a/tests/ui/traits/normalize/unconstrained-projection-normalization.current.stderr b/tests/ui/traits/normalize/unconstrained-projection-normalization.current.stderr index 6e908df0aba2d..598430b62d001 100644 --- a/tests/ui/traits/normalize/unconstrained-projection-normalization.current.stderr +++ b/tests/ui/traits/normalize/unconstrained-projection-normalization.current.stderr @@ -25,6 +25,7 @@ LL | type Assoc = T; note: required by a bound in `Every::Assoc` --> $DIR/unconstrained-projection-normalization.rs:11:5 | +LL | pub trait Every { LL | type Assoc; | ^^^^^^^^^^^ required by this bound in `Every::Assoc` help: consider removing the `?Sized` bound to make the type parameter `Sized` diff --git a/tests/ui/traits/normalize/unconstrained-projection-normalization.next.stderr b/tests/ui/traits/normalize/unconstrained-projection-normalization.next.stderr index 6e908df0aba2d..598430b62d001 100644 --- a/tests/ui/traits/normalize/unconstrained-projection-normalization.next.stderr +++ b/tests/ui/traits/normalize/unconstrained-projection-normalization.next.stderr @@ -25,6 +25,7 @@ LL | type Assoc = T; note: required by a bound in `Every::Assoc` --> $DIR/unconstrained-projection-normalization.rs:11:5 | +LL | pub trait Every { LL | type Assoc; | ^^^^^^^^^^^ required by this bound in `Every::Assoc` help: consider removing the `?Sized` bound to make the type parameter `Sized` diff --git a/tests/ui/traits/object/enforce-supertrait-projection.stderr b/tests/ui/traits/object/enforce-supertrait-projection.stderr index 198a185dd4840..8c8a46ff82af6 100644 --- a/tests/ui/traits/object/enforce-supertrait-projection.stderr +++ b/tests/ui/traits/object/enforce-supertrait-projection.stderr @@ -16,7 +16,6 @@ note: required by a bound in `foo` --> $DIR/enforce-supertrait-projection.rs:15:8 | LL | fn foo(x: T::A) -> B - | --- required by a bound in this function LL | where LL | T: Trait, | ^^^^^^^^^^^^ required by this bound in `foo` diff --git a/tests/ui/traits/projection-no-progress-cycle-issue-157516.stderr b/tests/ui/traits/projection-no-progress-cycle-issue-157516.stderr index a6960fc18493f..7a274fc12b9f3 100644 --- a/tests/ui/traits/projection-no-progress-cycle-issue-157516.stderr +++ b/tests/ui/traits/projection-no-progress-cycle-issue-157516.stderr @@ -9,6 +9,7 @@ LL | T::Object::OPS note: required by a bound in `Driver::Object` --> $DIR/projection-no-progress-cycle-issue-157516.rs:12:22 | +LL | trait Driver { LL | type Object: Alloc; | ^^^^^ required by this bound in `Driver::Object` help: use the fully qualified path to an implementation diff --git a/tests/ui/traits/suggest-dereferences/dont-suggest-unsize-deref.stderr b/tests/ui/traits/suggest-dereferences/dont-suggest-unsize-deref.stderr index 8024ad28d5ae6..6808cef15a173 100644 --- a/tests/ui/traits/suggest-dereferences/dont-suggest-unsize-deref.stderr +++ b/tests/ui/traits/suggest-dereferences/dont-suggest-unsize-deref.stderr @@ -12,7 +12,6 @@ note: required by a bound in `use_iterator` --> $DIR/dont-suggest-unsize-deref.rs:3:8 | LL | fn use_iterator(itr: I) - | ------------ required by a bound in this function LL | where LL | I: IntoIterator, | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `use_iterator` diff --git a/tests/ui/traits/trivial-unsized-projection-2.bad.stderr b/tests/ui/traits/trivial-unsized-projection-2.bad.stderr index bf8d3c40cf653..ba636ad148f11 100644 --- a/tests/ui/traits/trivial-unsized-projection-2.bad.stderr +++ b/tests/ui/traits/trivial-unsized-projection-2.bad.stderr @@ -13,8 +13,8 @@ LL | struct Tail([()]); note: required by a bound in `Bad::Assert` --> $DIR/trivial-unsized-projection-2.rs:14:15 | +LL | trait Bad { LL | type Assert - | ------ required by a bound in this associated type LL | where LL | Self: Sized; | ^^^^^ required by this bound in `Bad::Assert` @@ -38,8 +38,8 @@ LL | struct Tail([()]); note: required by a bound in `Bad::Assert` --> $DIR/trivial-unsized-projection-2.rs:14:15 | +LL | trait Bad { LL | type Assert - | ------ required by a bound in this associated type LL | where LL | Self: Sized; | ^^^^^ required by this bound in `Bad::Assert` diff --git a/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr b/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr index fcac02bc0a049..6c4ace807442f 100644 --- a/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr +++ b/tests/ui/traits/trivial-unsized-projection-2.bad_new.stderr @@ -19,8 +19,8 @@ LL | struct Tail([()]); note: required by a bound in `Bad::Assert` --> $DIR/trivial-unsized-projection-2.rs:14:15 | +LL | trait Bad { LL | type Assert - | ------ required by a bound in this associated type LL | where LL | Self: Sized; | ^^^^^ required by this bound in `Bad::Assert` diff --git a/tests/ui/traits/trivial-unsized-projection.bad.stderr b/tests/ui/traits/trivial-unsized-projection.bad.stderr index 4aea63329b360..bab0a72587320 100644 --- a/tests/ui/traits/trivial-unsized-projection.bad.stderr +++ b/tests/ui/traits/trivial-unsized-projection.bad.stderr @@ -8,8 +8,8 @@ LL | const FOO: <[()] as Bad>::Assert = todo!(); note: required by a bound in `Bad::Assert` --> $DIR/trivial-unsized-projection.rs:14:15 | +LL | trait Bad { LL | type Assert - | ------ required by a bound in this associated type LL | where LL | Self: Sized; | ^^^^^ required by this bound in `Bad::Assert` @@ -28,8 +28,8 @@ LL | const FOO: <[()] as Bad>::Assert = todo!(); note: required by a bound in `Bad::Assert` --> $DIR/trivial-unsized-projection.rs:14:15 | +LL | trait Bad { LL | type Assert - | ------ required by a bound in this associated type LL | where LL | Self: Sized; | ^^^^^ required by this bound in `Bad::Assert` diff --git a/tests/ui/traits/trivial-unsized-projection.bad_new.stderr b/tests/ui/traits/trivial-unsized-projection.bad_new.stderr index 09b51b30460d0..a055181542d4d 100644 --- a/tests/ui/traits/trivial-unsized-projection.bad_new.stderr +++ b/tests/ui/traits/trivial-unsized-projection.bad_new.stderr @@ -14,8 +14,8 @@ LL | const FOO: <[()] as Bad>::Assert = todo!(); note: required by a bound in `Bad::Assert` --> $DIR/trivial-unsized-projection.rs:14:15 | +LL | trait Bad { LL | type Assert - | ------ required by a bound in this associated type LL | where LL | Self: Sized; | ^^^^^ required by this bound in `Bad::Assert` diff --git a/tests/ui/traits/unsize-goal-escaping-bounds.current.stderr b/tests/ui/traits/unsize-goal-escaping-bounds.current.stderr index d2d679243ee7c..ab4bafac01fad 100644 --- a/tests/ui/traits/unsize-goal-escaping-bounds.current.stderr +++ b/tests/ui/traits/unsize-goal-escaping-bounds.current.stderr @@ -9,7 +9,6 @@ note: required by a bound in `foo` --> $DIR/unsize-goal-escaping-bounds.rs:15:17 | LL | fn foo() - | --- required by a bound in this function LL | where LL | for<'a> (): Unsize, | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `foo` diff --git a/tests/ui/traits/vtable-res-trait-param.stderr b/tests/ui/traits/vtable-res-trait-param.stderr index fff602b8d2bed..0868e57a479fe 100644 --- a/tests/ui/traits/vtable-res-trait-param.stderr +++ b/tests/ui/traits/vtable-res-trait-param.stderr @@ -14,6 +14,7 @@ LL | trait TraitA { note: required by a bound in `TraitB::gimme_an_a` --> $DIR/vtable-res-trait-param.rs:6:21 | +LL | trait TraitB { LL | fn gimme_an_a(&self, a: A) -> isize; | ^^^^^^ required by this bound in `TraitB::gimme_an_a` diff --git a/tests/ui/transmutability/alignment/align-fail.stderr b/tests/ui/transmutability/alignment/align-fail.stderr index 164c57a362442..be2f2058db18d 100644 --- a/tests/ui/transmutability/alignment/align-fail.stderr +++ b/tests/ui/transmutability/alignment/align-fail.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_maybe_transmutable` --> $DIR/align-fail.rs:9:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/huge-len.rs:8:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom, | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` @@ -23,7 +22,6 @@ note: required by a bound in `is_maybe_transmutable` --> $DIR/huge-len.rs:8:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom, | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` diff --git a/tests/ui/transmutability/arrays/should_require_well_defined_layout.stderr b/tests/ui/transmutability/arrays/should_require_well_defined_layout.stderr index e9420cd393e9a..a3e9d00eac93e 100644 --- a/tests/ui/transmutability/arrays/should_require_well_defined_layout.stderr +++ b/tests/ui/transmutability/arrays/should_require_well_defined_layout.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:12:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/should_require_well_defined_layout.rs:12:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/should_require_well_defined_layout.rs:12:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/should_require_well_defined_layout.rs:12:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/should_require_well_defined_layout.rs:12:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/should_require_well_defined_layout.rs:12:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/assoc-bound.rs:9:18 | +LL | trait B { LL | type AssocB: std::mem::TransmuteFrom<()>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `B::AssocB` help: consider further restricting the associated type @@ -24,6 +25,7 @@ LL | type AssocB = <&'static i32 as A>::AssocA; note: required by a bound in `B::AssocB` --> $DIR/assoc-bound.rs:9:18 | +LL | trait B { LL | type AssocB: std::mem::TransmuteFrom<()>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `B::AssocB` diff --git a/tests/ui/transmutability/char.stderr b/tests/ui/transmutability/char.stderr index b15d4c83e29b3..19f76878d4049 100644 --- a/tests/ui/transmutability/char.stderr +++ b/tests/ui/transmutability/char.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_transmutable` --> $DIR/char.rs:7:10 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -23,7 +22,6 @@ note: required by a bound in `is_transmutable` --> $DIR/char.rs:7:10 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -38,7 +36,6 @@ note: required by a bound in `is_transmutable` --> $DIR/char.rs:7:10 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` diff --git a/tests/ui/transmutability/dont-assume-err-is-yes-issue-126377.stderr b/tests/ui/transmutability/dont-assume-err-is-yes-issue-126377.stderr index 5c59fb9e175ea..b8f0245486bf3 100644 --- a/tests/ui/transmutability/dont-assume-err-is-yes-issue-126377.stderr +++ b/tests/ui/transmutability/dont-assume-err-is-yes-issue-126377.stderr @@ -14,7 +14,6 @@ note: required by a bound in `is_transmutable` --> $DIR/dont-assume-err-is-yes-issue-126377.rs:8:9 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | (): TransmuteFrom<(), { Assume::SAFETY }>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` diff --git a/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr b/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr index 7e5d0a6d41224..3906777a6a164 100644 --- a/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr +++ b/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/should_pad_variants.rs:13:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/should_respect_endianness.rs:13:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/unknown_dst_field.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -35,7 +34,6 @@ note: required by a bound in `is_transmutable` --> $DIR/unknown_dst_field.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` diff --git a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr index e6bb45a34a1df..c8ea3503c3de2 100644 --- a/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr +++ b/tests/ui/transmutability/malformed-program-gracefulness/unknown_src_field.stderr @@ -20,7 +20,6 @@ note: required by a bound in `is_transmutable` --> $DIR/unknown_src_field.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -35,7 +34,6 @@ note: required by a bound in `is_transmutable` --> $DIR/unknown_src_field.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` diff --git a/tests/ui/transmutability/maybeuninit.stderr b/tests/ui/transmutability/maybeuninit.stderr index 897c2df10a8f5..d60f37cbee753 100644 --- a/tests/ui/transmutability/maybeuninit.stderr +++ b/tests/ui/transmutability/maybeuninit.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_maybe_transmutable` --> $DIR/maybeuninit.rs:12:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` diff --git a/tests/ui/transmutability/primitives/bool-mut.stderr b/tests/ui/transmutability/primitives/bool-mut.stderr index fcf60bc979c2d..da84d8af6af43 100644 --- a/tests/ui/transmutability/primitives/bool-mut.stderr +++ b/tests/ui/transmutability/primitives/bool-mut.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_transmutable` --> $DIR/bool-mut.rs:9:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` diff --git a/tests/ui/transmutability/primitives/bool.current.stderr b/tests/ui/transmutability/primitives/bool.current.stderr index 2945cdaad4062..cdf6e834232cb 100644 --- a/tests/ui/transmutability/primitives/bool.current.stderr +++ b/tests/ui/transmutability/primitives/bool.current.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_transmutable` --> $DIR/bool.rs:11:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` diff --git a/tests/ui/transmutability/primitives/bool.next.stderr b/tests/ui/transmutability/primitives/bool.next.stderr index 2945cdaad4062..cdf6e834232cb 100644 --- a/tests/ui/transmutability/primitives/bool.next.stderr +++ b/tests/ui/transmutability/primitives/bool.next.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_transmutable` --> $DIR/bool.rs:11:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` diff --git a/tests/ui/transmutability/primitives/numbers.current.stderr b/tests/ui/transmutability/primitives/numbers.current.stderr index efb2ce8c77207..4d304b2981f2e 100644 --- a/tests/ui/transmutability/primitives/numbers.current.stderr +++ b/tests/ui/transmutability/primitives/numbers.current.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -23,7 +22,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -38,7 +36,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -53,7 +50,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -68,7 +64,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -83,7 +78,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -98,7 +92,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -113,7 +106,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -128,7 +120,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -143,7 +134,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -158,7 +148,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -173,7 +162,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -188,7 +176,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -203,7 +190,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -218,7 +204,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -233,7 +218,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -248,7 +232,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -263,7 +246,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -278,7 +260,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -293,7 +274,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -308,7 +288,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -323,7 +302,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -338,7 +316,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -353,7 +330,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -368,7 +344,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -383,7 +358,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -398,7 +372,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -413,7 +386,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -428,7 +400,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -443,7 +414,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -458,7 +428,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -473,7 +442,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -488,7 +456,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -503,7 +470,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -518,7 +484,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -533,7 +498,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -548,7 +512,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -563,7 +526,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -578,7 +540,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -593,7 +554,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -608,7 +568,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -623,7 +582,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -638,7 +596,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -653,7 +610,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -668,7 +624,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -683,7 +638,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -698,7 +652,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -713,7 +666,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -728,7 +680,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -743,7 +694,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -758,7 +708,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -773,7 +722,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -788,7 +736,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -803,7 +750,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -818,7 +764,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -833,7 +778,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -848,7 +792,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` diff --git a/tests/ui/transmutability/primitives/numbers.next.stderr b/tests/ui/transmutability/primitives/numbers.next.stderr index efb2ce8c77207..4d304b2981f2e 100644 --- a/tests/ui/transmutability/primitives/numbers.next.stderr +++ b/tests/ui/transmutability/primitives/numbers.next.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -23,7 +22,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -38,7 +36,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -53,7 +50,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -68,7 +64,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -83,7 +78,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -98,7 +92,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -113,7 +106,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -128,7 +120,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -143,7 +134,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -158,7 +148,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -173,7 +162,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -188,7 +176,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -203,7 +190,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -218,7 +204,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -233,7 +218,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -248,7 +232,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -263,7 +246,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -278,7 +260,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -293,7 +274,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -308,7 +288,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -323,7 +302,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -338,7 +316,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -353,7 +330,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -368,7 +344,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -383,7 +358,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -398,7 +372,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -413,7 +386,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -428,7 +400,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -443,7 +414,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -458,7 +428,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -473,7 +442,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -488,7 +456,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -503,7 +470,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -518,7 +484,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -533,7 +498,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -548,7 +512,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -563,7 +526,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -578,7 +540,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -593,7 +554,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -608,7 +568,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -623,7 +582,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -638,7 +596,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -653,7 +610,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -668,7 +624,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -683,7 +638,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -698,7 +652,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -713,7 +666,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -728,7 +680,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -743,7 +694,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -758,7 +708,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -773,7 +722,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -788,7 +736,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -803,7 +750,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -818,7 +764,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -833,7 +778,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -848,7 +792,6 @@ note: required by a bound in `is_transmutable` --> $DIR/numbers.rs:14:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` diff --git a/tests/ui/transmutability/primitives/unit.current.stderr b/tests/ui/transmutability/primitives/unit.current.stderr index 4bfb229832b3f..b18ec1c8d66e8 100644 --- a/tests/ui/transmutability/primitives/unit.current.stderr +++ b/tests/ui/transmutability/primitives/unit.current.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_transmutable` --> $DIR/unit.rs:16:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/unit.rs:16:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/recursive-wrapper-types-bit-compatible-mut.rs:9:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/recursive-wrapper-types-bit-incompatible.rs:9:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/reject_extension.rs:13:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom< | ______________^ diff --git a/tests/ui/transmutability/references/unit-to-u8.stderr b/tests/ui/transmutability/references/unit-to-u8.stderr index 35d1179f451b1..f9fd155320c9f 100644 --- a/tests/ui/transmutability/references/unit-to-u8.stderr +++ b/tests/ui/transmutability/references/unit-to-u8.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_maybe_transmutable` --> $DIR/unit-to-u8.rs:9:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/unsafecell.rs:12:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` @@ -23,7 +22,6 @@ note: required by a bound in `is_maybe_transmutable` --> $DIR/unsafecell.rs:12:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` @@ -38,7 +36,6 @@ note: required by a bound in `is_maybe_transmutable` --> $DIR/unsafecell.rs:12:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` @@ -53,7 +50,6 @@ note: required by a bound in `is_maybe_transmutable` --> $DIR/unsafecell.rs:12:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` diff --git a/tests/ui/transmutability/region-infer.stderr b/tests/ui/transmutability/region-infer.stderr index 09ecf484bc893..026f8a97e49f0 100644 --- a/tests/ui/transmutability/region-infer.stderr +++ b/tests/ui/transmutability/region-infer.stderr @@ -8,7 +8,6 @@ note: required by a bound in `test` --> $DIR/region-infer.rs:10:12 | LL | fn test<'a>() - | ---- required by a bound in this function LL | where LL | W<'a>: TransmuteFrom< | ____________^ diff --git a/tests/ui/transmutability/safety/should_reject_if_dst_has_safety_invariant.stderr b/tests/ui/transmutability/safety/should_reject_if_dst_has_safety_invariant.stderr index 6445b1e146ede..ccf296cda5f41 100644 --- a/tests/ui/transmutability/safety/should_reject_if_dst_has_safety_invariant.stderr +++ b/tests/ui/transmutability/safety/should_reject_if_dst_has_safety_invariant.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_transmutable` --> $DIR/should_reject_if_dst_has_safety_invariant.rs:13:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom // safety is NOT assumed | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` diff --git a/tests/ui/transmutability/safety/should_reject_if_ref_src_has_safety_invariant.stderr b/tests/ui/transmutability/safety/should_reject_if_ref_src_has_safety_invariant.stderr index 38ef829f06438..7ee1b06b115b2 100644 --- a/tests/ui/transmutability/safety/should_reject_if_ref_src_has_safety_invariant.stderr +++ b/tests/ui/transmutability/safety/should_reject_if_ref_src_has_safety_invariant.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_transmutable` --> $DIR/should_reject_if_ref_src_has_safety_invariant.rs:13:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom // safety is NOT assumed | ^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` diff --git a/tests/ui/transmutability/uninhabited.stderr b/tests/ui/transmutability/uninhabited.stderr index ac4b342ca990c..5f66d85446d5e 100644 --- a/tests/ui/transmutability/uninhabited.stderr +++ b/tests/ui/transmutability/uninhabited.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_maybe_transmutable` --> $DIR/uninhabited.rs:10:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/uninhabited.rs:10:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/uninhabited.rs:10:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/uninhabited.rs:10:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/uninhabited.rs:10:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/extension.rs:6:16 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` diff --git a/tests/ui/transmutability/unions/should_pad_variants.stderr b/tests/ui/transmutability/unions/should_pad_variants.stderr index bb26281c2f0ba..018bf4ccc86d8 100644 --- a/tests/ui/transmutability/unions/should_pad_variants.stderr +++ b/tests/ui/transmutability/unions/should_pad_variants.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_transmutable` --> $DIR/should_pad_variants.rs:13:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom $DIR/should_reject_contraction.rs:12:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` diff --git a/tests/ui/transmutability/unions/should_reject_disjoint.stderr b/tests/ui/transmutability/unions/should_reject_disjoint.stderr index d55abbe081776..0283c6caa931a 100644 --- a/tests/ui/transmutability/unions/should_reject_disjoint.stderr +++ b/tests/ui/transmutability/unions/should_reject_disjoint.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_maybe_transmutable` --> $DIR/should_reject_disjoint.rs:12:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` @@ -23,7 +22,6 @@ note: required by a bound in `is_maybe_transmutable` --> $DIR/should_reject_disjoint.rs:12:14 | LL | pub fn is_maybe_transmutable() - | --------------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` diff --git a/tests/ui/transmutability/unions/should_reject_intersecting.stderr b/tests/ui/transmutability/unions/should_reject_intersecting.stderr index 522681d7d1578..cef172054b06c 100644 --- a/tests/ui/transmutability/unions/should_reject_intersecting.stderr +++ b/tests/ui/transmutability/unions/should_reject_intersecting.stderr @@ -8,7 +8,6 @@ note: required by a bound in `is_transmutable` --> $DIR/should_reject_intersecting.rs:13:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` @@ -23,7 +22,6 @@ note: required by a bound in `is_transmutable` --> $DIR/should_reject_intersecting.rs:13:14 | LL | pub fn is_transmutable() - | --------------- required by a bound in this function LL | where LL | Dst: TransmuteFrom | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` diff --git a/tests/ui/type-alias-impl-trait/issue-57961.stderr b/tests/ui/type-alias-impl-trait/issue-57961.stderr index 314296b5bb317..f6e68373b5888 100644 --- a/tests/ui/type-alias-impl-trait/issue-57961.stderr +++ b/tests/ui/type-alias-impl-trait/issue-57961.stderr @@ -12,6 +12,7 @@ LL | type Bar = std::vec::IntoIter; note: required by a bound in `Foo::Bar` --> $DIR/issue-57961.rs:6:24 | +LL | trait Foo { LL | type Bar: Iterator; | ^^^^^^^^ required by this bound in `Foo::Bar` diff --git a/tests/ui/typeck/method-chain-gats.stderr b/tests/ui/typeck/method-chain-gats.stderr index d3a54dbd0f9e2..be734b2800bde 100644 --- a/tests/ui/typeck/method-chain-gats.stderr +++ b/tests/ui/typeck/method-chain-gats.stderr @@ -12,8 +12,8 @@ LL | fn fmap2(input: T, f1: impl Fn(A) -> B, f2: impl Fn(B) -> C) -> note: required by a bound in `Functor::fmap` --> $DIR/method-chain-gats.rs:10:24 | +LL | trait Functor: Base { LL | fn fmap(self, f: impl Fn(A) -> B) -> Self::Base - | ---- required by a bound in this associated function LL | where LL | Self::Base: Functor; | ^^^^^^^^^^ required by this bound in `Functor::fmap` diff --git a/tests/ui/typeck/type-inference-for-associated-types-69683.stderr b/tests/ui/typeck/type-inference-for-associated-types-69683.stderr index 46ddd4556e96f..4e4c4fc1358f6 100644 --- a/tests/ui/typeck/type-inference-for-associated-types-69683.stderr +++ b/tests/ui/typeck/type-inference-for-associated-types-69683.stderr @@ -16,11 +16,13 @@ LL | impl, S> Element<[S; 3]> for T { note: required by a bound in `Foo::foo` --> $DIR/type-inference-for-associated-types-69683.rs:16:9 | +LL | trait Foo +LL | where LL | u8: Element, | ^^^^^^^^^^ required by this bound in `Foo::foo` LL | { LL | fn foo(self, x: >::Array); - | --- required by a bound in this associated function + | help: try using a fully qualified path to specify the expected types | LL - 0u16.foo(b); diff --git a/tests/ui/unboxed-closures/unboxed-closures-infer-fn-once-move-from-projection.stderr b/tests/ui/unboxed-closures/unboxed-closures-infer-fn-once-move-from-projection.stderr index d811cead513c7..ae99932e8eb64 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-infer-fn-once-move-from-projection.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-infer-fn-once-move-from-projection.stderr @@ -14,7 +14,6 @@ note: required by a bound in `foo` --> $DIR/unboxed-closures-infer-fn-once-move-from-projection.rs:5:14 | LL | fn foo(f: F) - | --- required by a bound in this function LL | where F: Fn() | ^^^^ required by this bound in `foo` diff --git a/tests/ui/unstable-feature-bound/unstable-impl-assoc-type.fail.stderr b/tests/ui/unstable-feature-bound/unstable-impl-assoc-type.fail.stderr index db9759b4cc3a5..e69d6f89d967b 100644 --- a/tests/ui/unstable-feature-bound/unstable-impl-assoc-type.fail.stderr +++ b/tests/ui/unstable-feature-bound/unstable-impl-assoc-type.fail.stderr @@ -15,6 +15,7 @@ LL | impl Bar for Foo {} note: required by a bound in `Trait::Assoc` --> $DIR/unstable-impl-assoc-type.rs:13:17 | +LL | trait Trait { LL | type Assoc: Bar; | ^^^ required by this bound in `Trait::Assoc` diff --git a/tests/ui/unstable-feature-bound/unstable_feature_bound_free_fn.fail.stderr b/tests/ui/unstable-feature-bound/unstable_feature_bound_free_fn.fail.stderr index f83542568289a..4dd14a165c67f 100644 --- a/tests/ui/unstable-feature-bound/unstable_feature_bound_free_fn.fail.stderr +++ b/tests/ui/unstable-feature-bound/unstable_feature_bound_free_fn.fail.stderr @@ -11,7 +11,7 @@ note: required by a bound in `bar` LL | #[unstable_feature_bound(feat_bar)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `bar` LL | fn bar() { - | --- required by a bound in this function + | error: aborting due to 1 previous error diff --git a/tests/ui/unstable-feature-bound/unstable_feature_bound_on_trait.fail.stderr b/tests/ui/unstable-feature-bound/unstable_feature_bound_on_trait.fail.stderr index 69be101a40d2a..cd0fdf7e3ed29 100644 --- a/tests/ui/unstable-feature-bound/unstable_feature_bound_on_trait.fail.stderr +++ b/tests/ui/unstable-feature-bound/unstable_feature_bound_on_trait.fail.stderr @@ -10,9 +10,10 @@ note: required by a bound in `Bar::bar` | LL | #[unstable_feature_bound(foo)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Bar::bar` -... +LL | trait Bar { +LL | #[stable(feature = "a", since = "1.1.1" )] LL | fn bar() {} - | --- required by a bound in this associated function + | error: aborting due to 1 previous error diff --git a/tests/ui/wf/return-type-non-wf-no-ice.current.stderr b/tests/ui/wf/return-type-non-wf-no-ice.current.stderr index 888f0893ec7c4..edadc7f4c0839 100644 --- a/tests/ui/wf/return-type-non-wf-no-ice.current.stderr +++ b/tests/ui/wf/return-type-non-wf-no-ice.current.stderr @@ -8,7 +8,6 @@ note: required by a bound in `Foo` --> $DIR/return-type-non-wf-no-ice.rs:10:8 | LL | pub struct Foo(T) - | --- required by a bound in this struct LL | where LL | T: Iterator, | ^^^^^^^^ required by this bound in `Foo` diff --git a/tests/ui/where-clauses/higher-ranked-fn-type.quiet.stderr b/tests/ui/where-clauses/higher-ranked-fn-type.quiet.stderr index 6de4caa76ee0e..47c906175b7a9 100644 --- a/tests/ui/where-clauses/higher-ranked-fn-type.quiet.stderr +++ b/tests/ui/where-clauses/higher-ranked-fn-type.quiet.stderr @@ -13,7 +13,6 @@ note: required by a bound in `called` --> $DIR/higher-ranked-fn-type.rs:12:25 | LL | fn called() - | ------ required by a bound in this function LL | where LL | for<'b> fn(&'b ()): Foo, | ^^^ required by this bound in `called` diff --git a/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr b/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr index 89a91a1f1ad7b..5392c269ee907 100644 --- a/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr +++ b/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr @@ -14,7 +14,6 @@ note: required by a bound in `called` --> $DIR/higher-ranked-fn-type.rs:12:25 | LL | fn called() - | ------ required by a bound in this function LL | where LL | for<'b> fn(&'b ()): Foo, | ^^^ required by this bound in `called` diff --git a/tests/ui/where-clauses/self-in-where-clause-allowed.stderr b/tests/ui/where-clauses/self-in-where-clause-allowed.stderr index 5d23c4bee00f3..4d4036c488d66 100644 --- a/tests/ui/where-clauses/self-in-where-clause-allowed.stderr +++ b/tests/ui/where-clauses/self-in-where-clause-allowed.stderr @@ -7,6 +7,8 @@ LL | trait_object.autotrait_bound(); note: required by a bound in `Trait::autotrait_bound` --> $DIR/self-in-where-clause-allowed.rs:12:43 | +LL | trait Trait { +... LL | fn autotrait_bound(&self) where Self: AutoTrait {} | ^^^^^^^^^ required by this bound in `Trait::autotrait_bound` diff --git a/tests/ui/where-clauses/where-clause-method-substituion.stderr b/tests/ui/where-clauses/where-clause-method-substituion.stderr index 73aac3d54a310..49dc135ca14ad 100644 --- a/tests/ui/where-clauses/where-clause-method-substituion.stderr +++ b/tests/ui/where-clauses/where-clause-method-substituion.stderr @@ -17,6 +17,7 @@ LL | trait Foo { note: required by a bound in `Bar::method` --> $DIR/where-clause-method-substituion.rs:6:34 | +LL | trait Bar { LL | fn method(&self) where A: Foo; | ^^^^^^ required by this bound in `Bar::method` diff --git a/tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr b/tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr index d1de813a2d9f8..d69107aa2307d 100644 --- a/tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr +++ b/tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr @@ -8,7 +8,6 @@ note: required by a bound in `Foo::::equals` --> $DIR/where-clauses-method-unsatisfied.rs:16:12 | LL | fn equals(&self, u: &Foo) -> bool - | ------ required by a bound in this associated function LL | where LL | T: Eq, | ^^ required by this bound in `Foo::::equals` diff --git a/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr b/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr index d1de813a2d9f8..d69107aa2307d 100644 --- a/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr +++ b/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr @@ -8,7 +8,6 @@ note: required by a bound in `Foo::::equals` --> $DIR/where-clauses-method-unsatisfied.rs:16:12 | LL | fn equals(&self, u: &Foo) -> bool - | ------ required by a bound in this associated function LL | where LL | T: Eq, | ^^ required by this bound in `Foo::::equals` diff --git a/tests/ui/where-clauses/where-clauses-unsatisfied.current.stderr b/tests/ui/where-clauses/where-clauses-unsatisfied.current.stderr index 485b9459ddd0e..c04c292fb5dee 100644 --- a/tests/ui/where-clauses/where-clauses-unsatisfied.current.stderr +++ b/tests/ui/where-clauses/where-clauses-unsatisfied.current.stderr @@ -8,7 +8,6 @@ note: required by a bound in `equal` --> $DIR/where-clauses-unsatisfied.rs:7:8 | LL | fn equal(a: &T, b: &T) -> bool - | ----- required by a bound in this function LL | where LL | T: Eq, | ^^ required by this bound in `equal` diff --git a/tests/ui/where-clauses/where-clauses-unsatisfied.next.stderr b/tests/ui/where-clauses/where-clauses-unsatisfied.next.stderr index 485b9459ddd0e..c04c292fb5dee 100644 --- a/tests/ui/where-clauses/where-clauses-unsatisfied.next.stderr +++ b/tests/ui/where-clauses/where-clauses-unsatisfied.next.stderr @@ -8,7 +8,6 @@ note: required by a bound in `equal` --> $DIR/where-clauses-unsatisfied.rs:7:8 | LL | fn equal(a: &T, b: &T) -> bool - | ----- required by a bound in this function LL | where LL | T: Eq, | ^^ required by this bound in `equal` From 13c1957e9c433006a19e314115159e538c3e444a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 20 Sep 2026 20:08:44 +0200 Subject: [PATCH 07/21] Move some rustdoc-html tests into the right folder --- tests/rustdoc-html/{duplicate_impls => deref}/auxiliary/impls.rs | 0 .../sidebar-links-duplicate-impls-33054.rs | 0 .../{ => inline_cross}/intra-doc-crate/auxiliary/self.rs | 0 tests/rustdoc-html/{ => inline_cross}/intra-doc-crate/self.rs | 0 .../failing-expansion-on-wrong-macro.rs | 0 tests/rustdoc-html/{macro => macro-expansion}/macro_expansion.rs | 0 tests/rustdoc-html/macro/macro-doc-comment-23812.rs | 1 - tests/rustdoc-html/primitive/primitive-link.rs | 1 - 8 files changed, 2 deletions(-) rename tests/rustdoc-html/{duplicate_impls => deref}/auxiliary/impls.rs (100%) rename tests/rustdoc-html/{duplicate_impls => deref}/sidebar-links-duplicate-impls-33054.rs (100%) rename tests/rustdoc-html/{ => inline_cross}/intra-doc-crate/auxiliary/self.rs (100%) rename tests/rustdoc-html/{ => inline_cross}/intra-doc-crate/self.rs (100%) rename tests/rustdoc-html/{source-code-pages => macro-expansion}/failing-expansion-on-wrong-macro.rs (100%) rename tests/rustdoc-html/{macro => macro-expansion}/macro_expansion.rs (100%) diff --git a/tests/rustdoc-html/duplicate_impls/auxiliary/impls.rs b/tests/rustdoc-html/deref/auxiliary/impls.rs similarity index 100% rename from tests/rustdoc-html/duplicate_impls/auxiliary/impls.rs rename to tests/rustdoc-html/deref/auxiliary/impls.rs diff --git a/tests/rustdoc-html/duplicate_impls/sidebar-links-duplicate-impls-33054.rs b/tests/rustdoc-html/deref/sidebar-links-duplicate-impls-33054.rs similarity index 100% rename from tests/rustdoc-html/duplicate_impls/sidebar-links-duplicate-impls-33054.rs rename to tests/rustdoc-html/deref/sidebar-links-duplicate-impls-33054.rs diff --git a/tests/rustdoc-html/intra-doc-crate/auxiliary/self.rs b/tests/rustdoc-html/inline_cross/intra-doc-crate/auxiliary/self.rs similarity index 100% rename from tests/rustdoc-html/intra-doc-crate/auxiliary/self.rs rename to tests/rustdoc-html/inline_cross/intra-doc-crate/auxiliary/self.rs diff --git a/tests/rustdoc-html/intra-doc-crate/self.rs b/tests/rustdoc-html/inline_cross/intra-doc-crate/self.rs similarity index 100% rename from tests/rustdoc-html/intra-doc-crate/self.rs rename to tests/rustdoc-html/inline_cross/intra-doc-crate/self.rs diff --git a/tests/rustdoc-html/source-code-pages/failing-expansion-on-wrong-macro.rs b/tests/rustdoc-html/macro-expansion/failing-expansion-on-wrong-macro.rs similarity index 100% rename from tests/rustdoc-html/source-code-pages/failing-expansion-on-wrong-macro.rs rename to tests/rustdoc-html/macro-expansion/failing-expansion-on-wrong-macro.rs diff --git a/tests/rustdoc-html/macro/macro_expansion.rs b/tests/rustdoc-html/macro-expansion/macro_expansion.rs similarity index 100% rename from tests/rustdoc-html/macro/macro_expansion.rs rename to tests/rustdoc-html/macro-expansion/macro_expansion.rs diff --git a/tests/rustdoc-html/macro/macro-doc-comment-23812.rs b/tests/rustdoc-html/macro/macro-doc-comment-23812.rs index 03fda4a25b9f3..bb592f9a4f216 100644 --- a/tests/rustdoc-html/macro/macro-doc-comment-23812.rs +++ b/tests/rustdoc-html/macro/macro-doc-comment-23812.rs @@ -24,7 +24,6 @@ doc! { //@ hasraw - 'Inner comment' //@ !hasraw - '//! Inner comment' - doc! { /** Outer block comment */ mod Bar { diff --git a/tests/rustdoc-html/primitive/primitive-link.rs b/tests/rustdoc-html/primitive/primitive-link.rs index 3fe9cdc3ca702..f824195fac5e5 100644 --- a/tests/rustdoc-html/primitive/primitive-link.rs +++ b/tests/rustdoc-html/primitive/primitive-link.rs @@ -1,6 +1,5 @@ #![crate_name = "foo"] - //@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.u32.html"]' 'u32' //@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i64.html"]' 'i64' //@ has foo/struct.Foo.html '//*[@class="docblock"]/p/a[@href="{{channel}}/std/primitive.i32.html"]' 'std::primitive::i32' From 132e321b8939a7ea02263e11a7e5b7097ced9066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 20 Sep 2026 19:17:59 +0000 Subject: [PATCH 08/21] Point at `impl` start --- .../src/error_reporting/traits/suggestions.rs | 4 ++-- .../generic-associated-types-bad.item.stderr | 2 ++ .../generic-associated-types-bad.local.stderr | 1 + .../unsatisfied-bounds-where-clause-on-assoc-ty.stderr | 1 + tests/ui/const-generics/infer/method-chain.stderr | 2 ++ tests/ui/const-generics/infer/uninferred-consts.stderr | 2 ++ tests/ui/consts/ct-var-in-collect_all_mismatches.stderr | 2 ++ tests/ui/delegation/inherent-impls-enums.stderr | 1 + tests/ui/delegation/inherent-impls-parent-generics.stderr | 4 ++++ tests/ui/delegation/inherent-impls-structs.stderr | 1 + tests/ui/inference/issue-86162-2.stderr | 1 + ...ssue-113264-incorrect-impl-trait-in-path-suggestion.stderr | 1 + tests/ui/methods/filter-relevant-fn-bounds.stderr | 1 + .../ui/self/arbitrary_self_types_generic_over_receiver.stderr | 3 +++ .../ui/sized/unsized-str-in-return-expr-arg-and-local.stderr | 1 + tests/ui/structs/ice-missing-field-fn-sig-method.stderr | 1 + tests/ui/suggestions/closure-arg-trailing-semicolon.stderr | 1 + tests/ui/suggestions/issue-84973.stderr | 2 ++ tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr | 2 ++ .../use-parentheses-to-call-closure-issue-145404.stderr | 1 + tests/ui/trait-bounds/ownership-mismatch-on-arg.stderr | 2 ++ tests/ui/traits/explicit-reference-cast-unrelated-leaf.stderr | 2 ++ tests/ui/type-alias-impl-trait/issue-90400-1.stderr | 2 ++ .../where-clauses-method-unsatisfied.current.stderr | 1 + .../where-clauses-method-unsatisfied.next.stderr | 1 + 25 files changed, 40 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index fe4d14ebb4bdc..87c8f1c95b08b 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -3964,9 +3964,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let sm = tcx.sess.source_map(); if let DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy = tcx.def_kind(item_def_id) - && let Some(ident) = tcx.opt_item_ident(tcx.parent(item_def_id)) { - multispan.push_span_context(ident.span); + let span = tcx.def_span(tcx.parent(item_def_id)).shrink_to_lo(); + multispan.push_span_context(span); } if let Some(ident) = tcx.opt_item_ident(item_def_id) { multispan.push_span_context(ident.span); diff --git a/tests/ui/associated-inherent-types/generic-associated-types-bad.item.stderr b/tests/ui/associated-inherent-types/generic-associated-types-bad.item.stderr index 0620725ca3334..d6b37ae1e94cb 100644 --- a/tests/ui/associated-inherent-types/generic-associated-types-bad.item.stderr +++ b/tests/ui/associated-inherent-types/generic-associated-types-bad.item.stderr @@ -7,6 +7,7 @@ LL | const _: Ty::Pr = String::new(); note: required by a bound in `Ty::Pr` --> $DIR/generic-associated-types-bad.rs:10:16 | +LL | impl Ty { LL | type Pr = T; | ^^^^ required by this bound in `Ty::Pr` @@ -19,6 +20,7 @@ LL | const _: Ty::Pr = String::new(); note: required by a bound in `Ty::Pr` --> $DIR/generic-associated-types-bad.rs:10:16 | +LL | impl Ty { LL | type Pr = T; | ^^^^ required by this bound in `Ty::Pr` diff --git a/tests/ui/associated-inherent-types/generic-associated-types-bad.local.stderr b/tests/ui/associated-inherent-types/generic-associated-types-bad.local.stderr index 5859834053887..69efe563e8e15 100644 --- a/tests/ui/associated-inherent-types/generic-associated-types-bad.local.stderr +++ b/tests/ui/associated-inherent-types/generic-associated-types-bad.local.stderr @@ -7,6 +7,7 @@ LL | let _: Ty::Pr>; note: required by a bound in `Ty::Pr` --> $DIR/generic-associated-types-bad.rs:10:16 | +LL | impl Ty { LL | type Pr = T; | ^^^^ required by this bound in `Ty::Pr` diff --git a/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.stderr b/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.stderr index 047fb90c8d8ae..2edf7faa440e1 100644 --- a/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.stderr +++ b/tests/ui/associated-inherent-types/unsatisfied-bounds-where-clause-on-assoc-ty.stderr @@ -7,6 +7,7 @@ LL | let _: S::::X; note: required by a bound in `S::X` --> $DIR/unsatisfied-bounds-where-clause-on-assoc-ty.rs:9:12 | +LL | impl S { LL | type X = () LL | where LL | T: Copy; diff --git a/tests/ui/const-generics/infer/method-chain.stderr b/tests/ui/const-generics/infer/method-chain.stderr index c4dfa3967ba22..66aa9104779e9 100644 --- a/tests/ui/const-generics/infer/method-chain.stderr +++ b/tests/ui/const-generics/infer/method-chain.stderr @@ -7,6 +7,8 @@ LL | Foo.bar().bar().bar().bar().baz(); note: required by a const generic parameter in `Foo::baz` --> $DIR/method-chain.rs:8:12 | +LL | impl Foo { +... LL | fn baz(self) -> Foo { | ^^^^^^^^^^^^^^ required by this const generic parameter in `Foo::baz` help: consider specifying a const for the const parameter `N` diff --git a/tests/ui/const-generics/infer/uninferred-consts.stderr b/tests/ui/const-generics/infer/uninferred-consts.stderr index 839fb25c4e1e6..2eca003e0c7f5 100644 --- a/tests/ui/const-generics/infer/uninferred-consts.stderr +++ b/tests/ui/const-generics/infer/uninferred-consts.stderr @@ -7,6 +7,7 @@ LL | Foo.foo(); note: required by a const generic parameter in `Foo::foo` --> $DIR/uninferred-consts.rs:6:12 | +LL | impl Foo { LL | fn foo(self) {} | ^^^^^^^^^^^^^^ required by this const generic parameter in `Foo::foo` help: consider specifying the generic arguments @@ -23,6 +24,7 @@ LL | Foo.foo(); note: required by a const generic parameter in `Foo::foo` --> $DIR/uninferred-consts.rs:6:28 | +LL | impl Foo { LL | fn foo(self) {} | ^^^^^^^^^^^^^^ required by this const generic parameter in `Foo::foo` help: consider specifying the generic arguments diff --git a/tests/ui/consts/ct-var-in-collect_all_mismatches.stderr b/tests/ui/consts/ct-var-in-collect_all_mismatches.stderr index b5c8d335e85d6..1a2b43ffe4a44 100644 --- a/tests/ui/consts/ct-var-in-collect_all_mismatches.stderr +++ b/tests/ui/consts/ct-var-in-collect_all_mismatches.stderr @@ -7,6 +7,8 @@ LL | self.unsatisfied() note: required by a bound in `Foo::::unsatisfied` --> $DIR/ct-var-in-collect_all_mismatches.rs:15:12 | +LL | impl Foo { +... LL | fn unsatisfied(self) LL | where LL | T: Bar, diff --git a/tests/ui/delegation/inherent-impls-enums.stderr b/tests/ui/delegation/inherent-impls-enums.stderr index d76aba9517ee4..c27f850dd71cf 100644 --- a/tests/ui/delegation/inherent-impls-enums.stderr +++ b/tests/ui/delegation/inherent-impls-enums.stderr @@ -27,6 +27,7 @@ LL | reuse S::<'static, (), 1>::foo_static::<'static, _, _> as foo_static_4; note: required by a const generic parameter in `S::<'a, A, C>::foo_static` --> $DIR/inherent-impls-enums.rs:9:34 | +LL | impl<'a, 'b, 'c, A: 'a, const C: usize> S<'a, A, C> { LL | fn foo_static<'d: 'd, 'e, T, const B: bool>() {} | ^^^^^^^^^^^^^ required by this const generic parameter in `S::<'a, A, C>::foo_static` diff --git a/tests/ui/delegation/inherent-impls-parent-generics.stderr b/tests/ui/delegation/inherent-impls-parent-generics.stderr index 4e5850338b600..5fe1efbf81c13 100644 --- a/tests/ui/delegation/inherent-impls-parent-generics.stderr +++ b/tests/ui/delegation/inherent-impls-parent-generics.stderr @@ -117,6 +117,7 @@ LL | reuse E::foo_static as e; note: required by a const generic parameter in `E::<'a, A, C>::foo_static` --> $DIR/inherent-impls-parent-generics.rs:10:34 | +LL | impl<'a, 'b, 'c, A: 'a, const C: usize> E<'a, A, C> { LL | fn foo_static<'d: 'd, 'e, T, const B: bool>() {} | ^^^^^^^^^^^^^ required by this const generic parameter in `E::<'a, A, C>::foo_static` help: consider specifying the generic arguments @@ -231,6 +232,7 @@ LL | reuse E::<'_, (), _>::foo_static as e8; note: required by a const generic parameter in `E::<'a, A, C>::foo_static` --> $DIR/inherent-impls-parent-generics.rs:10:34 | +LL | impl<'a, 'b, 'c, A: 'a, const C: usize> E<'a, A, C> { LL | fn foo_static<'d: 'd, 'e, T, const B: bool>() {} | ^^^^^^^^^^^^^ required by this const generic parameter in `E::<'a, A, C>::foo_static` help: consider specifying the generic arguments @@ -299,6 +301,7 @@ LL | reuse S::foo_static as s; note: required by a const generic parameter in `S::::foo_static` --> $DIR/inherent-impls-parent-generics.rs:51:34 | +LL | impl<'a, 'b, 'c, A, const C: usize> S { LL | fn foo_static<'d: 'd, 'e, T, const B: bool>() {} | ^^^^^^^^^^^^^ required by this const generic parameter in `S::::foo_static` help: consider specifying the generic arguments @@ -411,6 +414,7 @@ LL | reuse S::<(), _>::foo_static as s8; note: required by a const generic parameter in `S::::foo_static` --> $DIR/inherent-impls-parent-generics.rs:51:34 | +LL | impl<'a, 'b, 'c, A, const C: usize> S { LL | fn foo_static<'d: 'd, 'e, T, const B: bool>() {} | ^^^^^^^^^^^^^ required by this const generic parameter in `S::::foo_static` help: consider specifying the generic arguments diff --git a/tests/ui/delegation/inherent-impls-structs.stderr b/tests/ui/delegation/inherent-impls-structs.stderr index 29963431b1451..dc993fcfb1c70 100644 --- a/tests/ui/delegation/inherent-impls-structs.stderr +++ b/tests/ui/delegation/inherent-impls-structs.stderr @@ -27,6 +27,7 @@ LL | reuse S::<(), 1>::foo_static::<'static, _, _> as foo_static_4; note: required by a const generic parameter in `S::::foo_static` --> $DIR/inherent-impls-structs.rs:8:34 | +LL | impl<'a, 'b, 'c, A, const C: usize> S { LL | fn foo_static<'d: 'd, 'e, T, const B: bool>() {} | ^^^^^^^^^^^^^ required by this const generic parameter in `S::::foo_static` diff --git a/tests/ui/inference/issue-86162-2.stderr b/tests/ui/inference/issue-86162-2.stderr index 155bce3576360..ad79a32d00613 100644 --- a/tests/ui/inference/issue-86162-2.stderr +++ b/tests/ui/inference/issue-86162-2.stderr @@ -10,6 +10,7 @@ LL | Foo::bar(gen()); //<- Do not suggest `Foo::bar::()`! note: required by a bound in `Foo::bar` --> $DIR/issue-86162-2.rs:8:20 | +LL | impl Foo { LL | fn bar(x: impl Clone) {} | ^^^^^ required by this bound in `Foo::bar` help: consider specifying a concrete type for the type parameter `T` diff --git a/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr index 237015a654211..47cba5e02a4ab 100644 --- a/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr +++ b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr @@ -10,6 +10,7 @@ LL | (S {}).owo(None) note: required by a bound in `S::owo` --> $DIR/issue-113264-incorrect-impl-trait-in-path-suggestion.rs:6:35 | +LL | impl S { LL | fn owo(&self, _: Option<&impl T>) {} | ^ required by this bound in `S::owo` help: consider specifying a concrete type for the type parameter `T` diff --git a/tests/ui/methods/filter-relevant-fn-bounds.stderr b/tests/ui/methods/filter-relevant-fn-bounds.stderr index 69552e8204575..976d39a3714ca 100644 --- a/tests/ui/methods/filter-relevant-fn-bounds.stderr +++ b/tests/ui/methods/filter-relevant-fn-bounds.stderr @@ -29,6 +29,7 @@ LL | trait Output<'a> { note: required by a bound in `Wrapper::do_something_wrapper` --> $DIR/filter-relevant-fn-bounds.rs:11:12 | +LL | impl Wrapper { LL | fn do_something_wrapper(self, _: F) ... LL | F: for<'a> FnOnce(>::Type), diff --git a/tests/ui/self/arbitrary_self_types_generic_over_receiver.stderr b/tests/ui/self/arbitrary_self_types_generic_over_receiver.stderr index 7a3d8b43c2e3a..7e0a50b563124 100644 --- a/tests/ui/self/arbitrary_self_types_generic_over_receiver.stderr +++ b/tests/ui/self/arbitrary_self_types_generic_over_receiver.stderr @@ -26,6 +26,7 @@ LL | foo.a(); note: required by a bound in `Foo::a` --> $DIR/arbitrary_self_types_generic_over_receiver.rs:7:21 | +LL | impl Foo { LL | fn a(self: impl Receiver) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::a` help: consider borrowing here @@ -44,6 +45,8 @@ LL | foo.b(); note: required by a bound in `Foo::b` --> $DIR/arbitrary_self_types_generic_over_receiver.rs:11:21 | +LL | impl Foo { +... LL | fn b(self: impl Deref) -> u32 { | ^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::b` help: consider borrowing here diff --git a/tests/ui/sized/unsized-str-in-return-expr-arg-and-local.stderr b/tests/ui/sized/unsized-str-in-return-expr-arg-and-local.stderr index 29cedf3ecfdd0..cf7c748ae0b5f 100644 --- a/tests/ui/sized/unsized-str-in-return-expr-arg-and-local.stderr +++ b/tests/ui/sized/unsized-str-in-return-expr-arg-and-local.stderr @@ -60,6 +60,7 @@ LL | S.baz(*""); note: required by a bound in `S::baz` --> $DIR/unsized-str-in-return-expr-arg-and-local.rs:10:27 | +LL | impl S { LL | fn baz(&self, _: impl Sized) {} | ^^^^^ required by this bound in `S::baz` help: references are always `Sized`, even if they point to unsized data; consider not dereferencing the expression diff --git a/tests/ui/structs/ice-missing-field-fn-sig-method.stderr b/tests/ui/structs/ice-missing-field-fn-sig-method.stderr index d652dd9537935..69473145d1c38 100644 --- a/tests/ui/structs/ice-missing-field-fn-sig-method.stderr +++ b/tests/ui/structs/ice-missing-field-fn-sig-method.stderr @@ -14,6 +14,7 @@ LL | trait Context {} note: required by a bound in `Foo::take` --> $DIR/ice-missing-field-fn-sig-method.rs:7:16 | +LL | impl Foo { LL | fn take(&self, _: T) {} | ^^^^^^^ required by this bound in `Foo::take` diff --git a/tests/ui/suggestions/closure-arg-trailing-semicolon.stderr b/tests/ui/suggestions/closure-arg-trailing-semicolon.stderr index 0a625e0f25cda..25870c664be78 100644 --- a/tests/ui/suggestions/closure-arg-trailing-semicolon.stderr +++ b/tests/ui/suggestions/closure-arg-trailing-semicolon.stderr @@ -26,6 +26,7 @@ LL | S.run(|| { 5u8; }); note: required by a bound in `S::run` --> $DIR/closure-arg-trailing-semicolon.rs:25:15 | +LL | impl S { LL | fn run(&self, _: impl Fn() -> R) {} | ^^^ required by this bound in `S::run` diff --git a/tests/ui/suggestions/issue-84973.stderr b/tests/ui/suggestions/issue-84973.stderr index 2dec2d5f43527..c42c4af123da4 100644 --- a/tests/ui/suggestions/issue-84973.stderr +++ b/tests/ui/suggestions/issue-84973.stderr @@ -9,6 +9,8 @@ LL | let o = Other::new(f); note: required by a bound in `Other::<'a, G>::new` --> $DIR/issue-84973.rs:25:8 | +LL | impl<'a, G> Other<'a, G> +LL | where LL | G: SomeTrait, | ^^^^^^^^^ required by this bound in `Other::<'a, G>::new` LL | { diff --git a/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr b/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr index f0acf1dbb963c..6afc6267dbdca 100644 --- a/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr +++ b/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr @@ -14,6 +14,8 @@ LL | trader.set_closure(closure); note: required by a bound in `Trader::<'a>::set_closure` --> $DIR/late-bound-in-borrow-closure-sugg.rs:15:50 | +LL | impl<'a> Trader<'a> { +... LL | pub fn set_closure(&mut self, function: impl Fn(&mut Trader) + 'a) { | ^^^^^^^^^^^^^^^ required by this bound in `Trader::<'a>::set_closure` help: consider wrapping the function in a closure diff --git a/tests/ui/suggestions/use-parentheses-to-call-closure-issue-145404.stderr b/tests/ui/suggestions/use-parentheses-to-call-closure-issue-145404.stderr index e32b2d4a30c80..19151a674c7f8 100644 --- a/tests/ui/suggestions/use-parentheses-to-call-closure-issue-145404.stderr +++ b/tests/ui/suggestions/use-parentheses-to-call-closure-issue-145404.stderr @@ -10,6 +10,7 @@ LL | S.call(|| "hello"); note: required by a bound in `S::call` --> $DIR/use-parentheses-to-call-closure-issue-145404.rs:8:28 | +LL | impl S { LL | fn call(&self, _: impl Display) {} | ^^^^^^^ required by this bound in `S::call` help: use parentheses to call this closure diff --git a/tests/ui/trait-bounds/ownership-mismatch-on-arg.stderr b/tests/ui/trait-bounds/ownership-mismatch-on-arg.stderr index 0d1f944dacfe8..a60a260ed1fe7 100644 --- a/tests/ui/trait-bounds/ownership-mismatch-on-arg.stderr +++ b/tests/ui/trait-bounds/ownership-mismatch-on-arg.stderr @@ -30,6 +30,7 @@ LL | impl Tr for Hello {} note: required by a bound in `needs_deref::S::foo` --> $DIR/ownership-mismatch-on-arg.rs:13:39 | +LL | impl S { LL | fn foo(&self, _v: T, _w: T, _k: K) {} | ^^ required by this bound in `S::foo` @@ -84,6 +85,7 @@ LL | impl Tr for &Hello {} note: required by a bound in `needs_borrow::S::foo` --> $DIR/ownership-mismatch-on-arg.rs:36:19 | +LL | impl S { LL | fn foo(&self, _v: T, _w: T, _k: K) {} | ^^ required by this bound in `S::foo` help: consider borrowing these argument diff --git a/tests/ui/traits/explicit-reference-cast-unrelated-leaf.stderr b/tests/ui/traits/explicit-reference-cast-unrelated-leaf.stderr index 75ec60c9ec52e..9f486cd12874f 100644 --- a/tests/ui/traits/explicit-reference-cast-unrelated-leaf.stderr +++ b/tests/ui/traits/explicit-reference-cast-unrelated-leaf.stderr @@ -15,6 +15,7 @@ LL | trait Output<'a> { note: required by a bound in `Wrapper::do_something_wrapper` --> $DIR/explicit-reference-cast-unrelated-leaf.rs:10:20 | +LL | impl Wrapper { LL | fn do_something_wrapper(self, _: F) LL | where LL | for<'a> F: Output<'a>, @@ -35,6 +36,7 @@ LL | trait Output<'a> { note: required by a bound in `Wrapper::do_something_wrapper` --> $DIR/explicit-reference-cast-unrelated-leaf.rs:11:20 | +LL | impl Wrapper { LL | fn do_something_wrapper(self, _: F) ... LL | for<'a> O: From<>::Type>, diff --git a/tests/ui/type-alias-impl-trait/issue-90400-1.stderr b/tests/ui/type-alias-impl-trait/issue-90400-1.stderr index afdccd56a50f4..85700056d47c6 100644 --- a/tests/ui/type-alias-impl-trait/issue-90400-1.stderr +++ b/tests/ui/type-alias-impl-trait/issue-90400-1.stderr @@ -7,6 +7,8 @@ LL | move || bar.bar() note: required by a bound in `::foo` --> $DIR/issue-90400-1.rs:21:15 | +LL | impl Foo for MyFoo { +... LL | fn foo(&self, bar: B) -> Self::FooFn { | ^^^ required by this bound in `::foo` help: consider restricting type parameter `B` with trait `Bar` diff --git a/tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr b/tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr index d69107aa2307d..df03acb8f4185 100644 --- a/tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr +++ b/tests/ui/where-clauses/where-clauses-method-unsatisfied.current.stderr @@ -7,6 +7,7 @@ LL | x.equals(&x); note: required by a bound in `Foo::::equals` --> $DIR/where-clauses-method-unsatisfied.rs:16:12 | +LL | impl Foo { LL | fn equals(&self, u: &Foo) -> bool LL | where LL | T: Eq, diff --git a/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr b/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr index d69107aa2307d..df03acb8f4185 100644 --- a/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr +++ b/tests/ui/where-clauses/where-clauses-method-unsatisfied.next.stderr @@ -7,6 +7,7 @@ LL | x.equals(&x); note: required by a bound in `Foo::::equals` --> $DIR/where-clauses-method-unsatisfied.rs:16:12 | +LL | impl Foo { LL | fn equals(&self, u: &Foo) -> bool LL | where LL | T: Eq, From 22dee8fbba20886cf541ddf33c93db293294b210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 20 Sep 2026 21:57:37 +0000 Subject: [PATCH 09/21] Fix test --- tests/ui-fulldeps/rustc-dev-remap.remap-unremap.stderr | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/ui-fulldeps/rustc-dev-remap.remap-unremap.stderr b/tests/ui-fulldeps/rustc-dev-remap.remap-unremap.stderr index f9bcc4ef4d8a6..009c0d37bf825 100644 --- a/tests/ui-fulldeps/rustc-dev-remap.remap-unremap.stderr +++ b/tests/ui-fulldeps/rustc-dev-remap.remap-unremap.stderr @@ -23,6 +23,8 @@ LL | impl VisitorResult for Result<(), E> { note: required by a bound in `rustc_ast::visit::Visitor::Result` --> $COMPILER_DIR_REAL/rustc_ast/src/visit.rs:LL:COL | +LL | pub trait $Visitor<$($lt)?>: Sized $(${ignore($mut)} + MutVisitorResult)? { +... LL | type Result: VisitorResult = (); | ^^^^^^^^^^^^^ required by this bound in `Visitor::Result` ... From 23ba1fae5fec0b5535c4ea21d23ded2f2d7304a4 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 21 Sep 2026 08:58:45 +1000 Subject: [PATCH 10/21] Convert `create_err(e).emit()` occurrences to `emit_err(e)` --- compiler/rustc_ast_lowering/src/item.rs | 10 ++-- compiler/rustc_builtin_macros/src/asm.rs | 10 ++-- .../src/proc_macro_harness.rs | 10 ++-- .../rustc_codegen_ssa/src/codegen_attrs.rs | 12 ++--- .../rustc_hir_analysis/src/collect/type_of.rs | 6 +-- .../src/hir_ty_lowering/mod.rs | 13 ++---- compiler/rustc_hir_analysis/src/lib.rs | 10 ++-- compiler/rustc_middle/src/ty/opaque_types.rs | 12 ++--- compiler/rustc_parse/src/parser/expr.rs | 46 ++++++++----------- compiler/rustc_parse/src/parser/pat.rs | 20 ++++---- compiler/rustc_resolve/src/imports.rs | 17 +++---- .../rustc_resolve/src/late/diagnostics.rs | 44 ++++++++---------- 12 files changed, 85 insertions(+), 125 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 1073706499919..f8106bd68d82c 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1759,12 +1759,10 @@ impl<'hir> LoweringContext<'_, 'hir> { if !self.tcx.is_descendant_of(parent_module, did) { // If the restriction path is not an ancestor of the item, // emit an error and recover by lowering the restriction to `Unrestricted`. - self.dcx() - .create_err(RestrictionAncestorOnly { - span: path.span, - kind: resolving_kind, - }) - .emit(); + self.dcx().emit_err(RestrictionAncestorOnly { + span: path.span, + kind: resolving_kind, + }); hir::RestrictionKind::Unrestricted } else { hir::RestrictionKind::Restricted(self.arena.alloc(hir::Path { diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index 5039d27a46fb4..12132b797bd56 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -481,12 +481,10 @@ fn expand_preparsed_asm( Some(&idx) => Some(idx), None => { let span = arg.position_span; - ecx.dcx() - .create_err(diagnostics::AsmNoMatchedArgumentName { - name: name.to_owned(), - span: span_in_template(span), - }) - .emit(); + ecx.dcx().emit_err(diagnostics::AsmNoMatchedArgumentName { + name: name.to_owned(), + span: span_in_template(span), + }); None } } diff --git a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs index c35e56a8e850b..2fbce3638e021 100644 --- a/compiler/rustc_builtin_macros/src/proc_macro_harness.rs +++ b/compiler/rustc_builtin_macros/src/proc_macro_harness.rs @@ -231,12 +231,10 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> { if !self.is_proc_macro_crate { let path = &attr.get_normal_item().path; - self.dcx - .create_err(diagnostics::AttributeOnlyUsableWithCrateType { - span: path.span, - path: &pprust::path_to_string(&attr.get_normal_item().path), - }) - .emit(); + self.dcx.emit_err(diagnostics::AttributeOnlyUsableWithCrateType { + span: path.span, + path: &pprust::path_to_string(&attr.get_normal_item().path), + }); return; } diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index 496e1ca3ce17e..008b10c784d87 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -497,13 +497,11 @@ fn check_result( let span = find_attr!(tcx, did, TargetFeature{attr_span: span, ..} => *span) .unwrap_or_else(|| tcx.def_span(did)); - tcx.dcx() - .create_err(diagnostics::TargetFeatureDisableOrEnable { - features, - span: Some(span), - missing_features: Some(diagnostics::MissingFeatures), - }) - .emit(); + tcx.dcx().emit_err(diagnostics::TargetFeatureDisableOrEnable { + features, + span: Some(span), + missing_features: Some(diagnostics::MissingFeatures), + }); } } diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 4c7b307c4e146..dc86f2837da8e 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -256,10 +256,8 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_ GenericParamKind::Const { ty, .. } => { let lowered_ty = icx.lower_ty(ty); if !tcx.features().generic_const_parameter_types() && lowered_ty.has_param() { - let guar = tcx - .dcx() - .create_err(ParamInTyOfConstParam { span: ty.span, ty: lowered_ty }) - .emit(); + let guar = + tcx.dcx().emit_err(ParamInTyOfConstParam { span: ty.span, ty: lowered_ty }); Ty::new_error(tcx, guar) } else { lowered_ty diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index 309757aa66021..c66416802f0ea 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -3512,9 +3512,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { { res } else { - let err = dcx - .create_err(NoVariantNamed { span: variant.span, ident: variant, ty }) - .emit(); + let err = + dcx.emit_err(NoVariantNamed { span: variant.span, ident: variant, ty }); return Ty::new_error(tcx, err); } } else { @@ -3552,8 +3551,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { } Ty::new_field_representing_type(tcx, ty, variant_idx, field_idx) } else { - let err = - dcx.create_err(NoFieldOnType { span: ident.span, field: ident, ty }).emit(); + let err = dcx.emit_err(NoFieldOnType { span: ident.span, field: ident, ty }); Ty::new_error(tcx, err) } } @@ -3561,8 +3559,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { let index = match field.as_str().parse::() { Ok(idx) => idx, Err(_) => { - let err = - dcx.create_err(NoFieldOnType { span: field.span, field, ty }).emit(); + let err = dcx.emit_err(NoFieldOnType { span: field.span, field, ty }); return Ty::new_error(tcx, err); } }; @@ -3572,7 +3569,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { if tys.get(index).is_some() { Ty::new_field_representing_type(tcx, ty, FIRST_VARIANT, index.into()) } else { - let err = dcx.create_err(NoFieldOnType { span: field.span, field, ty }).emit(); + let err = dcx.emit_err(NoFieldOnType { span: field.span, field, ty }); Ty::new_error(tcx, err) } } diff --git a/compiler/rustc_hir_analysis/src/lib.rs b/compiler/rustc_hir_analysis/src/lib.rs index a01ea8271570f..dbbf068185c23 100644 --- a/compiler/rustc_hir_analysis/src/lib.rs +++ b/compiler/rustc_hir_analysis/src/lib.rs @@ -104,12 +104,10 @@ fn check_c_variadic_abi(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: ExternAbi, match abi.supports_c_variadic() { CVariadicStatus::Stable => {} CVariadicStatus::NotSupported => { - tcx.dcx() - .create_err(diagnostics::VariadicFunctionCompatibleConvention { - span, - convention: &format!("{abi}"), - }) - .emit(); + tcx.dcx().emit_err(diagnostics::VariadicFunctionCompatibleConvention { + span, + convention: &format!("{abi}"), + }); } CVariadicStatus::Unstable { feature } => { if !tcx.features().enabled(feature) { diff --git a/compiler/rustc_middle/src/ty/opaque_types.rs b/compiler/rustc_middle/src/ty/opaque_types.rs index f4a3c708e0e68..63146ff7ed765 100644 --- a/compiler/rustc_middle/src/ty/opaque_types.rs +++ b/compiler/rustc_middle/src/ty/opaque_types.rs @@ -201,14 +201,10 @@ impl<'tcx> TypeFolder> for ReverseMapper<'tcx> { Some(GenericArgKind::Const(c1)) => c1, Some(u) => panic!("const mapped to unexpected kind: {u:?}"), None => { - let guar = self - .tcx - .dcx() - .create_err(ConstNotUsedTraitAlias { - ct: ct.to_string(), - span: self.span, - }) - .emit(); + let guar = self.tcx.dcx().emit_err(ConstNotUsedTraitAlias { + ct: ct.to_string(), + span: self.span, + }); ty::Const::new_error(self.tcx, guar) } } diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 6bc42a0a40734..31e2d15a5ebb3 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1178,23 +1178,21 @@ impl<'a> Parser<'a> { { err.cancel(); let type_str = pprust::path_to_string(&path); - self.dcx() - .create_err(crate::diagnostics::ParenthesesWithStructFields { - span, - braces_for_struct: crate::diagnostics::BracesForStructLiteral { - first: open_paren, - second: close_paren, - r#type: type_str.clone(), - }, - no_fields_for_fn: crate::diagnostics::NoFieldsForFnCall { - r#type: type_str, - fields: fields - .into_iter() - .map(|field| field.span.until(field.expr.span)) - .collect(), - }, - }) - .emit() + self.dcx().emit_err(crate::diagnostics::ParenthesesWithStructFields { + span, + braces_for_struct: crate::diagnostics::BracesForStructLiteral { + first: open_paren, + second: close_paren, + r#type: type_str.clone(), + }, + no_fields_for_fn: crate::diagnostics::NoFieldsForFnCall { + r#type: type_str, + fields: fields + .into_iter() + .map(|field| field.span.until(field.expr.span)) + .collect(), + }, + }) } else { err.emit() }; @@ -3654,16 +3652,12 @@ impl<'a> Parser<'a> { )?; let guar = if is_underscore_entry_point { - self.dcx() - .create_err(crate::diagnostics::StructLiteralPlaceholderPath { span }) - .emit() + self.dcx().emit_err(crate::diagnostics::StructLiteralPlaceholderPath { span }) } else { - self.dcx() - .create_err(crate::diagnostics::StructLiteralWithoutPathLate { - span: expr.span, - suggestion_span: expr.span.shrink_to_lo(), - }) - .emit() + self.dcx().emit_err(crate::diagnostics::StructLiteralWithoutPathLate { + span: expr.span, + suggestion_span: expr.span.shrink_to_lo(), + }) }; Ok(Some(self.mk_expr_err(expr.span, guar))) diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs index 64cc8ad9812f2..8508941f459f2 100644 --- a/compiler/rustc_parse/src/parser/pat.rs +++ b/compiler/rustc_parse/src/parser/pat.rs @@ -1936,17 +1936,15 @@ impl<'a> Parser<'a> { let subpat = if let Some(box_span) = is_box { let prefix_span = box_span.until(boxed_span); - self.dcx() - .create_err(diagnostics::BoxPatsRemoved { - span: box_span, - sugg_deref_macro_call: diagnostics::UseDerefMacro { - field: Some((prefix_span, fieldname)), - before: boxed_span.shrink_to_lo(), - after: hi.shrink_to_hi(), - }, - sugg_removal: prefix_span, - }) - .emit(); + self.dcx().emit_err(diagnostics::BoxPatsRemoved { + span: box_span, + sugg_deref_macro_call: diagnostics::UseDerefMacro { + field: Some((prefix_span, fieldname)), + before: boxed_span.shrink_to_lo(), + after: hi.shrink_to_hi(), + }, + sugg_removal: prefix_span, + }); self.mk_pat(lo.to(hi), PatKind::Deref(Box::new(fieldpat))) } else { diff --git a/compiler/rustc_resolve/src/imports.rs b/compiler/rustc_resolve/src/imports.rs index 38ad390c23b88..a19207d6fbacc 100644 --- a/compiler/rustc_resolve/src/imports.rs +++ b/compiler/rustc_resolve/src/imports.rs @@ -1225,9 +1225,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { span_bug!(import.span, "inconsistent resolution for an import"); } } else if self.privacy_errors.is_empty() { - self.dcx() - .create_err(CannotDetermineImportResolution { span: import.span }) - .emit(); + self.dcx().emit_err(CannotDetermineImportResolution { span: import.span }); } module @@ -1459,9 +1457,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { span_bug!(import.span, "inconsistent resolution for an import"); } } else if this.privacy_errors.is_empty() { - this.dcx() - .create_err(CannotDetermineImportResolution { span: import.span }) - .emit(); + this.dcx().emit_err(CannotDetermineImportResolution { span: import.span }); } } Err(..) => { @@ -1681,12 +1677,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { diagnostic: diagnostic.into(), }); } else if ns == TypeNS { - let err = if crate_private_reexport { - self.dcx().create_err(CannotBeReexportedCratePublicNS { span: import.span, ident }) + if crate_private_reexport { + self.dcx().emit_err(CannotBeReexportedCratePublicNS { span: import.span, ident }); } else { - self.dcx().create_err(CannotBeReexportedPrivateNS { span: import.span, ident }) - }; - err.emit(); + self.dcx().emit_err(CannotBeReexportedPrivateNS { span: import.span, ident }); + } } else { let mut err = if crate_private_reexport { self.dcx().create_err(CannotBeReexportedCratePublic { span: import.span, ident }) diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 4a6846d09a8c4..611e7147757fe 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -4132,13 +4132,10 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { &self, lifetime_ref: &ast::Lifetime, ) -> ErrorGuaranteed { - self.r - .dcx() - .create_err(diagnostics::ParamInTyOfConstParam { - span: lifetime_ref.ident.span, - name: lifetime_ref.ident.name, - }) - .emit() + self.r.dcx().emit_err(diagnostics::ParamInTyOfConstParam { + span: lifetime_ref.ident.span, + name: lifetime_ref.ident.name, + }) } /// Non-static lifetimes are prohibited in anonymous constants under `min_const_generics`. @@ -4150,31 +4147,26 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> { lifetime_ref: &ast::Lifetime, ) -> ErrorGuaranteed { match cause { - NoConstantGenericsReason::IsEnumDiscriminant => self - .r - .dcx() - .create_err(diagnostics::ParamInEnumDiscriminant { + NoConstantGenericsReason::IsEnumDiscriminant => { + self.r.dcx().emit_err(diagnostics::ParamInEnumDiscriminant { span: lifetime_ref.ident.span, name: lifetime_ref.ident.name, param_kind: diagnostics::ParamKindInEnumDiscriminant::Lifetime, }) - .emit(), + } NoConstantGenericsReason::NonTrivialConstArg => { assert!(!self.r.features.generic_const_exprs()); - self.r - .dcx() - .create_err(diagnostics::ParamInNonTrivialAnonConst { - span: lifetime_ref.ident.span, - name: lifetime_ref.ident.name, - param_kind: diagnostics::ParamKindInNonTrivialAnonConst::Lifetime, - help: self.r.tcx.sess.is_nightly_build() - && !self.r.features.min_generic_const_args(), - is_gca: self.r.features.generic_const_args(), - help_gca: self.r.features.generic_const_args(), - help_suggest_gca: self.r.tcx.sess.is_nightly_build() - && !self.r.features.generic_const_args(), - }) - .emit() + self.r.dcx().emit_err(diagnostics::ParamInNonTrivialAnonConst { + span: lifetime_ref.ident.span, + name: lifetime_ref.ident.name, + param_kind: diagnostics::ParamKindInNonTrivialAnonConst::Lifetime, + help: self.r.tcx.sess.is_nightly_build() + && !self.r.features.min_generic_const_args(), + is_gca: self.r.features.generic_const_args(), + help_gca: self.r.features.generic_const_args(), + help_suggest_gca: self.r.tcx.sess.is_nightly_build() + && !self.r.features.generic_const_args(), + }) } } } From 30b8dfc3533d8104fff5c9db8adc838b4e4bf471 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Fri, 11 Sep 2026 07:33:25 +1000 Subject: [PATCH 11/21] Remove `G` generic param from `Diag<'_, G>` It encodes the `emit` behaviour, one of: - `BugAbort`: Abort as a bug. - `FatalAbort`: Abort as a fatal error. - `ErrorGuaranteed`: Return an `ErrorGuaranteed` (the default). - `()`: return `()`. This is useful but `Diag` is very widely used and it's arguably not useful enough to be worth the generic parameter. This commit removes it. Benefits: - Many fewer generic parameters, including many functions where the genericity is entirely uninteresting. This includes every `Diagnostic::into_diag` and `Subdiagnostic::add_to_diag`. Removes the need for the comment about `` on `trait Diagnostic`. - No `PhantomData` in `Diag`. - Makes bootstrapping a bit faster. The downside is there is no longer a single `emit` method. - Getting a `!` return type requires calling `emit_bug` or `emit_fatal`. This only affects a few call sites. - Getting an `ErrorGuaranteed` return type requires calling `emit_err`. This affects a lot of call sites. (It arguably makes call sites more self-documenting.) - Using the wrong `emit_*` on a diagnostic causes a runtime abort, which previously couldn't occur. Seems unlikely, but it's not impossible. - Note: If no particular return type is needed, `emit` can be used for any diagnostic. (Bug/fatal diagnostics will still trigger abort.) --- compiler/rustc_abi/src/lib.rs | 4 +- compiler/rustc_ast_lowering/src/lib.rs | 2 +- compiler/rustc_ast_passes/src/diagnostics.rs | 2 +- .../src/attributes/cfg_select.rs | 12 +- compiler/rustc_attr_parsing/src/context.rs | 10 +- .../rustc_attr_parsing/src/diagnostics.rs | 14 +- compiler/rustc_attr_parsing/src/interface.rs | 2 +- compiler/rustc_attr_parsing/src/parser.rs | 2 +- .../src/diagnostics/explain_borrow.rs | 16 +- .../rustc_borrowck/src/diagnostics/mod.rs | 8 +- .../src/diagnostics/opaque_types.rs | 2 +- .../src/diagnostics/region_name.rs | 2 +- .../rustc_borrowck/src/region_infer/mod.rs | 2 +- .../src/region_infer/opaque_types/mod.rs | 2 +- .../rustc_borrowck/src/session_diagnostics.rs | 6 +- .../rustc_borrowck/src/universal_regions.rs | 2 +- compiler/rustc_builtin_macros/src/asm.rs | 10 +- compiler/rustc_builtin_macros/src/assert.rs | 2 +- compiler/rustc_builtin_macros/src/cfg.rs | 2 +- .../rustc_builtin_macros/src/diagnostics.rs | 10 +- compiler/rustc_builtin_macros/src/format.rs | 4 +- compiler/rustc_builtin_macros/src/iter.rs | 2 +- .../rustc_builtin_macros/src/pattern_type.rs | 2 +- .../rustc_builtin_macros/src/source_util.rs | 8 +- compiler/rustc_builtin_macros/src/test.rs | 2 +- .../src/test_binder_constraints.rs | 2 +- compiler/rustc_builtin_macros/src/util.rs | 6 +- .../rustc_builtin_macros/src/view_type.rs | 2 +- .../rustc_codegen_llvm/src/diagnostics.rs | 10 +- compiler/rustc_codegen_ssa/src/back/write.rs | 2 +- compiler/rustc_codegen_ssa/src/diagnostics.rs | 16 +- .../src/check_consts/check.rs | 6 +- .../rustc_const_eval/src/const_eval/error.rs | 8 +- compiler/rustc_const_eval/src/diagnostics.rs | 2 +- compiler/rustc_errors/src/decorate_diag.rs | 8 +- compiler/rustc_errors/src/diagnostic.rs | 216 +++++++----------- compiler/rustc_errors/src/diagnostic_impls.rs | 2 +- compiler/rustc_errors/src/lib.rs | 99 ++++---- compiler/rustc_expand/src/expand.rs | 4 +- compiler/rustc_expand/src/mbe/diagnostics.rs | 4 +- compiler/rustc_expand/src/mbe/macro_parser.rs | 6 +- compiler/rustc_expand/src/mbe/macro_rules.rs | 18 +- compiler/rustc_expand/src/module.rs | 2 +- .../rustc_expand/src/proc_macro_server.rs | 3 +- compiler/rustc_hir/src/lints.rs | 2 +- .../src/check/always_applicable.rs | 8 +- .../rustc_hir_analysis/src/check/check.rs | 12 +- .../src/check/compare_eii.rs | 8 +- .../src/check/compare_impl_item.rs | 32 +-- compiler/rustc_hir_analysis/src/check/mod.rs | 2 +- .../rustc_hir_analysis/src/check/wfcheck.rs | 14 +- .../rustc_hir_analysis/src/check_unused.rs | 4 +- .../src/coherence/builtin.rs | 2 +- .../src/coherence/inherent_impls_overlap.rs | 4 +- .../rustc_hir_analysis/src/coherence/mod.rs | 6 +- .../src/coherence/orphan.rs | 2 +- .../src/coherence/unsafety.rs | 6 +- compiler/rustc_hir_analysis/src/collect.rs | 10 +- .../rustc_hir_analysis/src/collect/dump.rs | 2 +- .../src/collect/generics_of.rs | 4 +- .../src/collect/resolve_bound_vars.rs | 2 +- .../rustc_hir_analysis/src/collect/type_of.rs | 2 +- .../src/collect/type_of/opaque.rs | 2 +- .../rustc_hir_analysis/src/diagnostics.rs | 8 +- .../wrong_number_of_generic_args.rs | 34 +-- .../src/hir_ty_lowering/bounds.rs | 2 +- .../src/hir_ty_lowering/dyn_trait.rs | 12 +- .../src/hir_ty_lowering/errors.rs | 30 +-- .../src/hir_ty_lowering/generics.rs | 10 +- .../src/hir_ty_lowering/mod.rs | 12 +- .../rustc_hir_analysis/src/impl_wf_check.rs | 4 +- .../src/impl_wf_check/min_specialization.rs | 8 +- compiler/rustc_hir_typeck/src/callee.rs | 4 +- compiler/rustc_hir_typeck/src/cast.rs | 2 +- compiler/rustc_hir_typeck/src/closure.rs | 2 +- compiler/rustc_hir_typeck/src/coercion.rs | 4 +- compiler/rustc_hir_typeck/src/diagnostics.rs | 16 +- compiler/rustc_hir_typeck/src/expr.rs | 24 +- .../rustc_hir_typeck/src/fn_ctxt/_impl.rs | 12 +- .../rustc_hir_typeck/src/fn_ctxt/checks.rs | 20 +- compiler/rustc_hir_typeck/src/inline_asm.rs | 4 +- compiler/rustc_hir_typeck/src/intrinsicck.rs | 34 +-- compiler/rustc_hir_typeck/src/lib.rs | 4 +- .../src/method/prelude_edition_lints.rs | 12 +- compiler/rustc_hir_typeck/src/method/probe.rs | 6 +- .../rustc_hir_typeck/src/method/suggest.rs | 12 +- compiler/rustc_hir_typeck/src/op.rs | 4 +- compiler/rustc_hir_typeck/src/opaque_types.rs | 2 +- compiler/rustc_hir_typeck/src/pat.rs | 32 +-- compiler/rustc_hir_typeck/src/place_op.rs | 4 +- compiler/rustc_hir_typeck/src/upvar.rs | 4 +- compiler/rustc_hir_typeck/src/writeback.rs | 6 +- compiler/rustc_interface/src/interface.rs | 4 +- compiler/rustc_interface/src/passes.rs | 8 +- compiler/rustc_interface/src/util.rs | 4 +- compiler/rustc_lint/src/builtin.rs | 2 +- compiler/rustc_lint/src/context.rs | 8 +- .../src/default_could_be_derived.rs | 4 +- compiler/rustc_lint/src/diagnostics.rs | 60 ++--- compiler/rustc_lint/src/early/diagnostics.rs | 6 +- compiler/rustc_lint/src/if_let_rescope.rs | 2 +- .../rustc_lint/src/impl_trait_overcaptures.rs | 4 +- compiler/rustc_lint/src/levels.rs | 14 +- compiler/rustc_lint/src/non_fmt_panic.rs | 4 +- compiler/rustc_lint/src/nonstandard_style.rs | 4 +- .../src/diagnostics/diagnostic.rs | 4 +- .../src/diagnostics/subdiagnostic.rs | 5 +- compiler/rustc_metadata/src/diagnostics.rs | 12 +- compiler/rustc_middle/src/lint.rs | 8 +- compiler/rustc_middle/src/middle/stability.rs | 4 +- compiler/rustc_middle/src/traits/mod.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 8 +- compiler/rustc_middle/src/ty/layout.rs | 4 +- compiler/rustc_middle/src/ty/opaque_types.rs | 8 +- .../rustc_mir_build/src/check_tail_calls.rs | 76 +++--- compiler/rustc_mir_build/src/diagnostics.rs | 12 +- .../src/thir/pattern/check_match.rs | 2 +- .../src/thir/pattern/const_to_pat.rs | 2 +- .../src/thir/pattern/migration.rs | 2 +- .../rustc_mir_transform/src/diagnostics.rs | 12 +- .../src/lint_tail_expr_drop_order.rs | 2 +- .../rustc_mir_transform/src/pass_manager.rs | 2 +- compiler/rustc_parse/src/diagnostics.rs | 16 +- compiler/rustc_parse/src/lexer/mod.rs | 6 +- .../src/lexer/unescape_error_reporting.rs | 6 +- compiler/rustc_parse/src/lib.rs | 6 +- .../rustc_parse/src/parser/diagnostics.rs | 24 +- compiler/rustc_parse/src/parser/expr.rs | 12 +- compiler/rustc_parse/src/parser/function.rs | 6 +- compiler/rustc_parse/src/parser/generics.rs | 2 +- compiler/rustc_parse/src/parser/item.rs | 4 +- compiler/rustc_parse/src/parser/mod.rs | 4 +- compiler/rustc_parse/src/parser/pat.rs | 2 +- compiler/rustc_parse/src/parser/path.rs | 2 +- compiler/rustc_parse/src/parser/stmt.rs | 4 +- compiler/rustc_parse/src/parser/ty.rs | 6 +- compiler/rustc_passes/src/diagnostics.rs | 8 +- .../src/handle_cycle_error.rs | 6 +- .../rustc_resolve/src/diagnostics/impls.rs | 6 +- compiler/rustc_resolve/src/diagnostics/mod.rs | 6 +- compiler/rustc_resolve/src/late.rs | 6 +- .../rustc_resolve/src/late/diagnostics.rs | 6 +- compiler/rustc_session/src/config.rs | 4 +- compiler/rustc_session/src/config/externs.rs | 6 +- .../rustc_session/src/config/print_request.rs | 2 +- compiler/rustc_session/src/diagnostics.rs | 12 +- compiler/rustc_session/src/parse.rs | 4 +- compiler/rustc_session/src/session.rs | 7 +- .../rustc_trait_selection/src/diagnostics.rs | 24 +- .../src/diagnostics/note_and_explain.rs | 2 +- .../infer/nice_region_error/mod.rs | 2 +- .../nice_region_error/static_impl_trait.rs | 4 +- .../trait_impl_difference.rs | 2 +- .../src/error_reporting/infer/region.rs | 22 +- .../src/error_reporting/traits/ambiguity.rs | 4 +- .../traits/fulfillment_errors.rs | 22 +- .../src/error_reporting/traits/mod.rs | 6 +- .../src/error_reporting/traits/overflow.rs | 6 +- .../src/error_reporting/traits/suggestions.rs | 54 ++--- .../rustc_trait_selection/src/opaque_types.rs | 4 +- .../src/traits/coherence.rs | 6 +- .../src/traits/const_evaluatable.rs | 2 +- .../src/traits/project.rs | 2 +- .../src/traits/select/mod.rs | 2 +- .../src/traits/specialize/mod.rs | 8 +- .../src/diagnostics/diagnostic-structs.md | 4 +- src/librustdoc/config.rs | 4 +- src/librustdoc/html/markdown.rs | 2 +- .../passes/collect_intra_doc_links.rs | 8 +- .../passes/lint/check_code_block_syntax.rs | 4 +- .../passes/lint/redundant_explicit_links.rs | 12 +- .../passes/lint/unescaped_backticks.rs | 2 +- src/tools/clippy/clippy_config/src/types.rs | 2 +- .../src/casts/cast_possible_truncation.rs | 2 +- .../clippy_lints/src/empty_line_after.rs | 2 +- .../clippy_lints/src/functions/result.rs | 2 +- .../clippy/clippy_lints/src/if_let_mutex.rs | 2 +- .../clippy_lints/src/implicit_hasher.rs | 2 +- .../clippy_lints/src/large_stack_frames.rs | 2 +- .../clippy/clippy_lints/src/manual_clamp.rs | 2 +- .../matches/significant_drop_in_scrutinee.rs | 2 +- .../clippy_lints/src/matches/single_match.rs | 2 +- .../methods/suspicious_command_arg_space.rs | 2 +- .../src/methods/swap_with_temporary.rs | 2 +- .../src/methods/unnecessary_fold.rs | 2 +- .../src/missing_asserts_for_indexing.rs | 2 +- .../clippy/clippy_lints/src/mutex_atomic.rs | 2 +- .../src/needless_pass_by_value.rs | 2 +- .../src/pointers_in_nomem_asm_block.rs | 2 +- .../clippy/clippy_utils/src/diagnostics.rs | 16 +- src/tools/clippy/clippy_utils/src/sugg.rs | 2 +- src/tools/miri/src/diagnostics.rs | 2 +- .../diagnostic-derive-doc-comment-field.rs | 2 +- ...diagnostic-derive-doc-comment-field.stderr | 2 +- 194 files changed, 840 insertions(+), 886 deletions(-) diff --git a/compiler/rustc_abi/src/lib.rs b/compiler/rustc_abi/src/lib.rs index b056fdc73d40b..f971ee3c563b8 100644 --- a/compiler/rustc_abi/src/lib.rs +++ b/compiler/rustc_abi/src/lib.rs @@ -399,8 +399,8 @@ pub enum TargetDataLayoutError<'a> { } #[cfg(feature = "nightly")] -impl Diagnostic<'_, G> for TargetDataLayoutError<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { +impl Diagnostic<'_> for TargetDataLayoutError<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { match self { TargetDataLayoutError::InvalidAddressSpace { addr_space, err, cause } => { Diag::new(dcx, level, msg!("invalid address space `{$addr_space}` for `{$cause}` in \"data-layout\": {$err}")) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 410823919c523..7ff6a2538c1e7 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1751,7 +1751,7 @@ impl<'hir> LoweringContext<'_, 'hir> { }, feature, ) - .emit(); + .emit_err(); hir::TyKind::Err(guar) } ImplTraitContext::Disallowed(position) => { diff --git a/compiler/rustc_ast_passes/src/diagnostics.rs b/compiler/rustc_ast_passes/src/diagnostics.rs index 4771a87335954..a3cffab3fc4dc 100644 --- a/compiler/rustc_ast_passes/src/diagnostics.rs +++ b/compiler/rustc_ast_passes/src/diagnostics.rs @@ -663,7 +663,7 @@ pub(crate) struct EmptyLabelManySpans(pub Vec); // The derive for `Vec` does multiple calls to `span_label`, adding commas between each impl Subdiagnostic for EmptyLabelManySpans { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { diag.span_labels(self.0, ""); } } diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs b/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs index 53d7044521e5a..6c6793b29f586 100644 --- a/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs +++ b/compiler/rustc_attr_parsing/src/attributes/cfg_select.rs @@ -89,13 +89,13 @@ pub fn parse_cfg_select( let mut branches = CfgSelectBranches::default(); while p.token != token::Eof { - p.recover_from_outer_attributes("`cfg_select` branches").map_err(|e| e.emit())?; + p.recover_from_outer_attributes("`cfg_select` branches").map_err(|e| e.emit_err())?; if p.eat_keyword(exp!(Underscore)) { let underscore = p.prev_token; - p.expect(exp!(FatArrow)).map_err(|e| e.emit())?; + p.expect(exp!(FatArrow)).map_err(|e| e.emit_err())?; - let tts = p.parse_cfg_select_branch_rhs().map_err(|e| e.emit())?; + let tts = p.parse_cfg_select_branch_rhs().map_err(|e| e.emit_err())?; let span = underscore.span.to(p.token.span); match branches.wildcard { @@ -110,7 +110,7 @@ pub fn parse_cfg_select( ShouldEmit::ErrorsAndLints { recovery: Recovery::Allowed }, AllowExprMetavar::Yes, ) - .map_err(|diag| diag.emit())?; + .map_err(|diag| diag.emit_err())?; let cfg_span = meta.span(); let cfg = AttributeParser::parse_single_args( sess, @@ -132,9 +132,9 @@ pub fn parse_cfg_select( &AttributeTemplate::default(), )?; - p.expect(exp!(FatArrow)).map_err(|e| e.emit())?; + p.expect(exp!(FatArrow)).map_err(|e| e.emit_err())?; - let tts = p.parse_cfg_select_branch_rhs().map_err(|e| e.emit())?; + let tts = p.parse_cfg_select_branch_rhs().map_err(|e| e.emit_err())?; let span = cfg_span.to(p.token.span); match branches.wildcard { diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index f936f5aab8265..22a4a069b75c7 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -418,7 +418,7 @@ impl<'f, 'sess: 'f> SharedContext<'f, 'sess> { pub(crate) fn emit_lint( &mut self, lint: &'static Lint, - diagnostic: impl for<'x> Diagnostic<'x, ()> + DynSend + DynSync + 'static, + diagnostic: impl for<'x> Diagnostic<'x> + DynSend + DynSync + 'static, span: impl Into, ) { self.emit_lint_inner( @@ -429,7 +429,7 @@ impl<'f, 'sess: 'f> SharedContext<'f, 'sess> { } pub(crate) fn emit_lint_with_sess< - F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &Session) -> Diag<'a, ()> + F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &Session) -> Diag<'a> + DynSend + DynSync + 'static, @@ -895,9 +895,9 @@ pub enum ShouldEmit { impl ShouldEmit { pub(crate) fn emit_err(self, diag: Diag<'_>) -> ErrorGuaranteed { match self { - ShouldEmit::EarlyFatal { .. } if diag.level() == Level::DelayedBug => diag.emit(), - ShouldEmit::EarlyFatal { .. } => diag.upgrade_to_fatal().emit(), - ShouldEmit::ErrorsAndLints { .. } => diag.emit(), + ShouldEmit::EarlyFatal { .. } if diag.level() == Level::DelayedBug => diag.emit_err(), + ShouldEmit::EarlyFatal { .. } => diag.upgrade_to_fatal().emit_fatal(), + ShouldEmit::ErrorsAndLints { .. } => diag.emit_err(), ShouldEmit::Nothing => diag.delay_as_bug(), } } diff --git a/compiler/rustc_attr_parsing/src/diagnostics.rs b/compiler/rustc_attr_parsing/src/diagnostics.rs index e5f49690f71dc..2c0b85d57c208 100644 --- a/compiler/rustc_attr_parsing/src/diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/diagnostics.rs @@ -1476,9 +1476,9 @@ pub(crate) enum AttributeParseErrorSuggestions { } impl<'a> AttributeParseError<'a> { - fn render_expected_specific_argument( + fn render_expected_specific_argument( &self, - diag: &mut Diag<'_, G>, + diag: &mut Diag<'_>, possibilities: &[Symbol], strings: bool, ) { @@ -1509,9 +1509,9 @@ impl<'a> AttributeParseError<'a> { } } - fn render_expected_specific_argument_list( + fn render_expected_specific_argument_list( &self, - diag: &mut Diag<'_, G>, + diag: &mut Diag<'_>, possibilities: &[Symbol], strings: bool, ) { @@ -1543,7 +1543,7 @@ impl<'a> AttributeParseError<'a> { } } - fn render_suggestions(&self, diag: &mut Diag<'_, G>) { + fn render_suggestions(&self, diag: &mut Diag<'_>) { let description = self.description(); match &self.suggestions { @@ -1592,8 +1592,8 @@ impl AttributeParseErrorSuggestions { } } -impl<'a, G> Diagnostic<'a, G> for AttributeParseError<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { +impl<'a> Diagnostic<'a> for AttributeParseError<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let name = self.path.to_string(); let description = self.description(); diff --git a/compiler/rustc_attr_parsing/src/interface.rs b/compiler/rustc_attr_parsing/src/interface.rs index 1cecce8fd43ef..48083683b6a7a 100644 --- a/compiler/rustc_attr_parsing/src/interface.rs +++ b/compiler/rustc_attr_parsing/src/interface.rs @@ -27,7 +27,7 @@ use crate::{AttributeTemplate, ShouldEmit}; pub struct EmitAttribute( pub Box< - dyn for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &Session) -> Diag<'a, ()> + dyn for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &Session) -> Diag<'a> + DynSend + DynSync + 'static, diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs index 8efe5bf4f1f90..c85b1f8fee967 100644 --- a/compiler/rustc_attr_parsing/src/parser.rs +++ b/compiler/rustc_attr_parsing/src/parser.rs @@ -434,7 +434,7 @@ fn expr_to_lit<'sess>( let lit = MetaItemLit { symbol: token_lit.symbol, suffix: token_lit.suffix, - kind: LitKind::Err(err.emit()), + kind: LitKind::Err(err.emit_err()), span: expr.span, }; Ok(Some(lit)) diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index 429eb85ed9e11..f431374de37ba 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -55,10 +55,10 @@ impl<'tcx> BorrowExplanation<'tcx> { pub(crate) fn is_explained(&self) -> bool { !matches!(self, BorrowExplanation::Unexplained) } - pub(crate) fn add_explanation_to_diagnostic( + pub(crate) fn add_explanation_to_diagnostic( &self, cx: &MirBorrowckCtxt<'_, '_, 'tcx>, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, borrow_desc: &str, borrow_span: Option, multiple_borrow_span: Option<(Span, Span)>, @@ -437,10 +437,10 @@ impl<'tcx> BorrowExplanation<'tcx> { } } - fn add_object_lifetime_default_note( + fn add_object_lifetime_default_note( &self, tcx: TyCtxt<'tcx>, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, unsize_ty: Ty<'tcx>, ) { if let ty::Adt(def, args) = unsize_ty.kind() { @@ -494,9 +494,9 @@ impl<'tcx> BorrowExplanation<'tcx> { } } - fn add_lifetime_bound_suggestion_to_diagnostic( + fn add_lifetime_bound_suggestion_to_diagnostic( &self, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, category: &ConstraintCategory<'tcx>, span: Span, region_name: &RegionName, @@ -523,14 +523,14 @@ impl<'tcx> BorrowExplanation<'tcx> { } } -fn suggest_rewrite_if_let( +fn suggest_rewrite_if_let( tcx: TyCtxt<'_>, expr: &hir::Expr<'_>, pat: &str, init: &hir::Expr<'_>, conseq: &hir::Expr<'_>, alt: Option<&hir::Expr<'_>>, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, ) { let source_map = tcx.sess.source_map(); err.span_note( diff --git a/compiler/rustc_borrowck/src/diagnostics/mod.rs b/compiler/rustc_borrowck/src/diagnostics/mod.rs index 5ebf950358c4f..fadcf92b6ea7a 100644 --- a/compiler/rustc_borrowck/src/diagnostics/mod.rs +++ b/compiler/rustc_borrowck/src/diagnostics/mod.rs @@ -642,9 +642,9 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { /// /// This is very similar to `fn suggest_static_lifetime_for_gat_from_hrtb` which handles this /// note for failed type tests instead of outlives errors. - fn add_placeholder_from_predicate_note( + fn add_placeholder_from_predicate_note( &self, - diag: &mut Diag<'_, G>, + diag: &mut Diag<'_>, path: &[OutlivesConstraint<'tcx>], ) { let tcx = self.infcx.tcx; @@ -704,9 +704,9 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> { /// Add a label to region errors and borrow explanations when outlives constraints arise from /// proving a type implements `Sized` or `Copy`. - fn add_sized_or_copy_bound_info( + fn add_sized_or_copy_bound_info( &self, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, blamed_category: ConstraintCategory<'tcx>, path: &[OutlivesConstraint<'tcx>], ) { diff --git a/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs b/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs index 009dff77efd0f..9bfae5582d9fe 100644 --- a/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs +++ b/compiler/rustc_borrowck/src/diagnostics/opaque_types.rs @@ -61,7 +61,7 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> { { last_unexpected_hidden_region = Some((hidden_type.span, named_ty, named_key)); - diag.emit() + diag.emit_err() } else { diag.delay_as_bug() } diff --git a/compiler/rustc_borrowck/src/diagnostics/region_name.rs b/compiler/rustc_borrowck/src/diagnostics/region_name.rs index 0e98e0c0bb604..9436d31ba19e8 100644 --- a/compiler/rustc_borrowck/src/diagnostics/region_name.rs +++ b/compiler/rustc_borrowck/src/diagnostics/region_name.rs @@ -104,7 +104,7 @@ impl RegionName { } } - pub(crate) fn highlight_region_name(&self, diag: &mut Diag<'_, G>) { + pub(crate) fn highlight_region_name(&self, diag: &mut Diag<'_>) { match &self.source { RegionNameSource::NamedLateParamRegion(span) | RegionNameSource::NamedEarlyParamRegion(span) => { diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs index 76af4e2dd5530..75ee675b71232 100644 --- a/compiler/rustc_borrowck/src/region_infer/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs @@ -430,7 +430,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { } /// Adds annotations for `#[rustc_regions]`; see `UniversalRegions::annotate`. - pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diag<'_, ()>) { + pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diag<'_>) { self.universal_regions().annotate(tcx, err) } diff --git a/compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs b/compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs index ad15c5750b092..9a08218fba8a7 100644 --- a/compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs +++ b/compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs @@ -171,7 +171,7 @@ fn add_hidden_type<'tcx>( prev.span = prev.span.substitute_dummy(hidden_ty.span); } else { let (Ok(guar) | Err(guar)) = - prev.build_mismatch_error(&hidden_ty, tcx).map(|d| d.emit()); + prev.build_mismatch_error(&hidden_ty, tcx).map(|d| d.emit_err()); *prev = ty::DefinitionSiteHiddenType::new_error(tcx, guar); } } else { diff --git a/compiler/rustc_borrowck/src/session_diagnostics.rs b/compiler/rustc_borrowck/src/session_diagnostics.rs index a0f347679b05a..8935aed1e7e00 100644 --- a/compiler/rustc_borrowck/src/session_diagnostics.rs +++ b/compiler/rustc_borrowck/src/session_diagnostics.rs @@ -659,13 +659,13 @@ pub(crate) struct SimdIntrinsicArgConst { pub intrinsic: String, } -pub(crate) struct TailExprDropOrder)> { +pub(crate) struct TailExprDropOrder)> { pub borrowed: Span, pub callback: F, } -impl<'a, F: FnOnce(&mut Diag<'_, ()>)> Diagnostic<'a, ()> for TailExprDropOrder { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a, F: FnOnce(&mut Diag<'_>)> Diagnostic<'a> for TailExprDropOrder { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { borrowed, callback } = self; let mut diag = Diag::new(dcx, level, "relative drop order changing in Rust 2024") .with_span_label( diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs index e494f363879cb..1d55c8f940b83 100644 --- a/compiler/rustc_borrowck/src/universal_regions.rs +++ b/compiler/rustc_borrowck/src/universal_regions.rs @@ -614,7 +614,7 @@ impl<'tcx> UniversalRegions<'tcx> { /// that this region imposes on others. The methods in this file /// handle the part about dumping the inference context internal /// state. - pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diag<'_, ()>) { + pub(crate) fn annotate(&self, tcx: TyCtxt<'tcx>, err: &mut Diag<'_>) { match self.defining_ty { DefiningTy::Closure(def_id, args) => { let v = with_no_trimmed_paths!( diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index 12132b797bd56..975b2c49b292d 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -314,7 +314,7 @@ fn expand_preparsed_asm( Ok(template_part) => template_part, Err(err) => { return ExpandResult::Ready(Err(match err { - Ok((err, _)) => err.emit(), + Ok((err, _)) => err.emit_err(), Err(guar) => guar, })); } @@ -407,7 +407,7 @@ fn expand_preparsed_asm( if let Some((label, span)) = err.secondary_label { e.span_label(span_in_template(span), label); } - let guar = e.emit(); + let guar = e.emit_err(); return ExpandResult::Ready(Err(guar)); } @@ -600,7 +600,7 @@ pub(super) fn expand_asm<'cx>( MacEager::expr(expr) } Err(err) => { - let guar = err.emit(); + let guar = err.emit_err(); DummyResult::any(sp, guar) } }) @@ -630,7 +630,7 @@ pub(super) fn expand_naked_asm<'cx>( MacEager::expr(expr) } Err(err) => { - let guar = err.emit(); + let guar = err.emit_err(); DummyResult::any(sp, guar) } }) @@ -663,7 +663,7 @@ pub(super) fn expand_global_asm<'cx>( } } Err(err) => { - let guar = err.emit(); + let guar = err.emit_err(); DummyResult::any(sp, guar) } }) diff --git a/compiler/rustc_builtin_macros/src/assert.rs b/compiler/rustc_builtin_macros/src/assert.rs index 106b67d1c8ec7..5f71e02d1350b 100644 --- a/compiler/rustc_builtin_macros/src/assert.rs +++ b/compiler/rustc_builtin_macros/src/assert.rs @@ -22,7 +22,7 @@ pub(crate) fn expand_assert<'cx>( let Assert { cond_expr, custom_message } = match parse_assert(cx, span, tts) { Ok(assert) => assert, Err(err) => { - let guar = err.emit(); + let guar = err.emit_err(); return ExpandResult::Ready(DummyResult::any(span, guar)); } }; diff --git a/compiler/rustc_builtin_macros/src/cfg.rs b/compiler/rustc_builtin_macros/src/cfg.rs index b34d928146efd..ae3781380b90e 100644 --- a/compiler/rustc_builtin_macros/src/cfg.rs +++ b/compiler/rustc_builtin_macros/src/cfg.rs @@ -46,7 +46,7 @@ fn parse_cfg(cx: &ExtCtxt<'_>, span: Span, tts: TokenStream) -> Result Diagnostic<'a, G> for EnvNotDefinedWithUserMessage { +impl<'a> Diagnostic<'a> for EnvNotDefinedWithUserMessage { #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new(dcx, level, self.msg_from_user.to_string()); diag.span(self.span); diag @@ -773,7 +773,7 @@ pub(crate) struct FormatUnusedArg { // Allow the singular form to be a subdiagnostic of the multiple-unused // form of diagnostic. impl Subdiagnostic for FormatUnusedArg { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { diag.span_label( self.span, msg!( @@ -957,8 +957,8 @@ pub(crate) struct AsmClobberNoReg { pub(crate) clobbers: Vec, } -impl<'a, G> Diagnostic<'a, G> for AsmClobberNoReg { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { +impl<'a> Diagnostic<'a> for AsmClobberNoReg { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { Diag::new( dcx, level, diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs index f501110fc97d5..e23c057f8a651 100644 --- a/compiler/rustc_builtin_macros/src/format.rs +++ b/compiler/rustc_builtin_macros/src/format.rs @@ -265,7 +265,7 @@ fn make_format_args( } } } - err.emit() + err.emit_err() } Err(guar) => guar, }; @@ -1156,7 +1156,7 @@ fn expand_format_args_impl<'cx>( } } Err(err) => { - let guar = err.emit(); + let guar = err.emit_err(); DummyResult::any(sp, guar) } }) diff --git a/compiler/rustc_builtin_macros/src/iter.rs b/compiler/rustc_builtin_macros/src/iter.rs index 86bf347cd9848..59fabe966b7e1 100644 --- a/compiler/rustc_builtin_macros/src/iter.rs +++ b/compiler/rustc_builtin_macros/src/iter.rs @@ -12,7 +12,7 @@ pub(crate) fn expand<'cx>( let closure = match parse_closure(cx, sp, tts) { Ok(parsed) => parsed, Err(err) => { - return ExpandResult::Ready(DummyResult::any(sp, err.emit())); + return ExpandResult::Ready(DummyResult::any(sp, err.emit_err())); } }; diff --git a/compiler/rustc_builtin_macros/src/pattern_type.rs b/compiler/rustc_builtin_macros/src/pattern_type.rs index 215baf099416b..4d34ba963e4e8 100644 --- a/compiler/rustc_builtin_macros/src/pattern_type.rs +++ b/compiler/rustc_builtin_macros/src/pattern_type.rs @@ -14,7 +14,7 @@ pub(crate) fn expand<'cx>( let (ty, pat) = match parse_pat_ty(cx, tts) { Ok(parsed) => parsed, Err(err) => { - return ExpandResult::Ready(DummyResult::any(sp, err.emit())); + return ExpandResult::Ready(DummyResult::any(sp, err.emit_err())); } }; diff --git a/compiler/rustc_builtin_macros/src/source_util.rs b/compiler/rustc_builtin_macros/src/source_util.rs index 37b2f49c3596d..61fa31b5de254 100644 --- a/compiler/rustc_builtin_macros/src/source_util.rs +++ b/compiler/rustc_builtin_macros/src/source_util.rs @@ -120,7 +120,7 @@ pub(crate) fn expand_include<'cx>( let path = match cx.sess.resolve_path(path.as_str(), sp) { Ok(path) => path, Err(err) => { - let guar = err.emit(); + let guar = err.emit_err(); return ExpandResult::Ready(DummyResult::any(sp, guar)); } }; @@ -225,7 +225,7 @@ pub(crate) fn expand_include_str( Err(utf8err) => { let mut err = cx.dcx().struct_span_err(sp, format!("`{path}` wasn't a utf-8 file")); utf8_error(cx.source_map(), path.as_str(), None, &mut err, utf8err, &bytes[..]); - DummyResult::any(sp, err.emit()) + DummyResult::any(sp, err.emit_err()) } }, Err(dummy) => dummy, @@ -270,7 +270,7 @@ fn load_binary_file( let resolved_path = match cx.sess.resolve_path(original_path, macro_span) { Ok(path) => path, Err(err) => { - let guar = err.emit(); + let guar = err.emit_err(); return Err(DummyResult::any(macro_span, guar)); } }; @@ -306,7 +306,7 @@ fn load_binary_file( ); } } - let guar = err.emit(); + let guar = err.emit_err(); Err(DummyResult::any(macro_span, guar)) } } diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 857d0b774879d..42dbc801bfb5a 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -414,7 +414,7 @@ fn not_testable_error(cx: &ExtCtxt<'_>, is_bench: bool, attr_sp: Span, item: Opt Some(ast::ItemKind::MacCall(_)) => Level::Warning, _ => Level::Error, }; - let mut err = Diag::<()>::new(dcx, level, msg); + let mut err = Diag::new(dcx, level, msg); err.span(attr_sp); if let Some(item) = item { err.span_label( diff --git a/compiler/rustc_builtin_macros/src/test_binder_constraints.rs b/compiler/rustc_builtin_macros/src/test_binder_constraints.rs index 0c7482672df46..d6a3649500c29 100644 --- a/compiler/rustc_builtin_macros/src/test_binder_constraints.rs +++ b/compiler/rustc_builtin_macros/src/test_binder_constraints.rs @@ -19,7 +19,7 @@ pub(crate) fn expand<'cx>( let item = match p.parse_test_binder_constraints() { Ok(expr) => expr, Err(diag) => { - let guar = diag.emit(); + let guar = diag.emit_err(); return ExpandResult::Ready(DummyResult::any(span, guar)); } }; diff --git a/compiler/rustc_builtin_macros/src/util.rs b/compiler/rustc_builtin_macros/src/util.rs index 80fa3e3b8ac8d..0c95c30095d5a 100644 --- a/compiler/rustc_builtin_macros/src/util.rs +++ b/compiler/rustc_builtin_macros/src/util.rs @@ -136,7 +136,7 @@ pub(crate) fn expr_to_string( ) -> ExpandResult, ()> { expr_to_spanned_string(cx, expr, err_msg).map(|res| { res.map_err(|err| match err { - Ok((err, _)) => err.emit(), + Ok((err, _)) => err.emit_err(), Err(guar) => guar, }) .map(|ExprToSpannedString { symbol, style, .. }| (symbol, style)) @@ -157,7 +157,7 @@ pub(crate) fn check_zero_tts(cx: &ExtCtxt<'_>, span: Span, tts: TokenStream, nam pub(crate) fn parse_expr(p: &mut parser::Parser<'_>) -> Result, ErrorGuaranteed> { let guar = match p.parse_expr() { Ok(expr) => return Ok(expr), - Err(err) => err.emit(), + Err(err) => err.emit_err(), }; while p.token != token::Eof { p.bump(); @@ -191,7 +191,7 @@ pub(crate) fn get_single_str_spanned_from_tts( }; expr_to_spanned_string(cx, ret, "argument must be a string literal").map(|res| { res.map_err(|err| match err { - Ok((err, _)) => err.emit(), + Ok((err, _)) => err.emit_err(), Err(guar) => guar, }) .map(|ExprToSpannedString { symbol, span, .. }| (symbol, span)) diff --git a/compiler/rustc_builtin_macros/src/view_type.rs b/compiler/rustc_builtin_macros/src/view_type.rs index 090603f4f1253..69bd8f2727fc3 100644 --- a/compiler/rustc_builtin_macros/src/view_type.rs +++ b/compiler/rustc_builtin_macros/src/view_type.rs @@ -15,7 +15,7 @@ pub(crate) fn expand<'cx>( let (ty, pat) = match parse_view_ty(cx, tts) { Ok(parsed) => parsed, Err(err) => { - return ExpandResult::Ready(DummyResult::any(sp, err.emit())); + return ExpandResult::Ready(DummyResult::any(sp, err.emit_err())); } }; diff --git a/compiler/rustc_codegen_llvm/src/diagnostics.rs b/compiler/rustc_codegen_llvm/src/diagnostics.rs index 78e502f13af75..6c5c23203aa79 100644 --- a/compiler/rustc_codegen_llvm/src/diagnostics.rs +++ b/compiler/rustc_codegen_llvm/src/diagnostics.rs @@ -20,10 +20,10 @@ pub(crate) struct SanitizerMemtagRequiresMte; pub(crate) struct ParseTargetMachineConfig<'a>(pub LlvmError<'a>); -impl Diagnostic<'_, G> for ParseTargetMachineConfig<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { +impl Diagnostic<'_> for ParseTargetMachineConfig<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { // Reuse the formatted primary message from `LlvmError` without emitting it. - let diag: Diag<'_, ()> = self.0.into_diag(dcx, level); + let diag = self.0.into_diag(dcx, level); let (message, _) = diag.messages.first().expect("`LlvmError` with no message"); let message = format_diag_message(message, &diag.args).into_owned(); diag.cancel(); @@ -141,8 +141,8 @@ pub(crate) enum LlvmError<'a> { pub(crate) struct WithLlvmError<'a>(pub LlvmError<'a>, pub String); -impl Diagnostic<'_, G> for WithLlvmError<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { +impl Diagnostic<'_> for WithLlvmError<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { use LlvmError::*; let msg_with_llvm_err = match &self.0 { WriteOutput { .. } => msg!("could not write output to {$path}: {$llvm_err}"), diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index c93aa87b25077..ef22ab51ef994 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -2060,7 +2060,7 @@ impl SharedEmitterMain { } Ok(SharedEmitterMessage::InlineAsmError(inner)) => { assert_matches!(inner.level, Level::Error | Level::Warning | Level::Note); - let mut err = Diag::<()>::new(sess.dcx(), inner.level, inner.msg); + let mut err = Diag::new(sess.dcx(), inner.level, inner.msg); if !inner.span.is_dummy() { err.span(inner.span.span()); } diff --git a/compiler/rustc_codegen_ssa/src/diagnostics.rs b/compiler/rustc_codegen_ssa/src/diagnostics.rs index 8aa2da904bd07..8c72f294235a9 100644 --- a/compiler/rustc_codegen_ssa/src/diagnostics.rs +++ b/compiler/rustc_codegen_ssa/src/diagnostics.rs @@ -202,8 +202,8 @@ pub enum LinkRlibError { pub(crate) struct ThorinErrorWrapper(pub thorin::Error); -impl Diagnostic<'_, G> for ThorinErrorWrapper { - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { +impl Diagnostic<'_> for ThorinErrorWrapper { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { let build = |msg| Diag::new(dcx, level, msg); match self.0 { thorin::Error::ReadInput(_) => build(msg!("failed to read input file")), @@ -334,8 +334,8 @@ pub(crate) struct LinkingFailed<'a> { pub sysroot_dir: PathBuf, } -impl Diagnostic<'_, G> for LinkingFailed<'_> { - fn into_diag(mut self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { +impl Diagnostic<'_> for LinkingFailed<'_> { + fn into_diag(mut self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { let mut diag = Diag::new(dcx, level, msg!("linking with `{$linker_path}` failed: {$exit_status}")); diag.arg("linker_path", format!("{}", self.linker_path.display())); @@ -463,8 +463,8 @@ pub(crate) struct LinkExeUnexpectedError; pub(crate) struct LinkExeStatusStackBufferOverrun; -impl<'a, G> Diagnostic<'a, G> for LinkExeStatusStackBufferOverrun { - fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { +impl<'a> Diagnostic<'a> for LinkExeStatusStackBufferOverrun { + fn into_diag(self, dcx: rustc_errors::DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new(dcx, level, msg!("0xc0000409 is `STATUS_STACK_BUFFER_OVERRUN`")); diag.note(msg!( "this may have been caused by a program abort and not a stack buffer overrun" @@ -1265,8 +1265,8 @@ pub(crate) struct TargetFeatureDisableOrEnable<'a> { #[help("add the missing features in a `target_feature` attribute")] pub(crate) struct MissingFeatures; -impl Diagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { +impl Diagnostic<'_> for TargetFeatureDisableOrEnable<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { let mut diag = Diag::new( dcx, level, diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs index 4d268c8a1f8cd..c9217856252d8 100644 --- a/compiler/rustc_const_eval/src/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/check_consts/check.rs @@ -175,7 +175,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { let secondary_errors = mem::take(&mut self.secondary_errors); if self.error_emitted.is_none() { for error in secondary_errors { - self.error_emitted = Some(error.emit()); + self.error_emitted = Some(error.emit_err()); } } else { assert!(self.tcx.dcx().has_errors().is_some()); @@ -276,8 +276,8 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> { match op.importance() { ops::DiagImportance::Primary => { - let reported = err.emit(); - self.error_emitted = Some(reported); + let guar = err.emit_err(); + self.error_emitted = Some(guar); } ops::DiagImportance::Secondary => { diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index f06ef0dbcf575..8532cad91b808 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -223,11 +223,11 @@ pub(super) fn report<'tcx>( ); mk(&mut err, span, frames); - let g = err.emit(); + let guar = err.emit_err(); let reported = if allowed_in_infallible { - ReportedErrorInfo::allowed_in_infallible(g) + ReportedErrorInfo::allowed_in_infallible(guar) } else { - ReportedErrorInfo::const_eval_error(g) + ReportedErrorInfo::const_eval_error(guar) }; ErrorHandled::Reported(reported, span) } @@ -243,7 +243,7 @@ pub(super) fn lint<'tcx, L>( lint: &'static rustc_lint_defs::Lint, decorator: impl FnOnce(Vec) -> L, ) where - L: for<'a> rustc_errors::Diagnostic<'a, ()>, + L: for<'a> rustc_errors::Diagnostic<'a>, { let (span, frames) = get_span_and_frames(tcx, &machine.stack); diff --git a/compiler/rustc_const_eval/src/diagnostics.rs b/compiler/rustc_const_eval/src/diagnostics.rs index 2d8568f7f909b..995356fd3b488 100644 --- a/compiler/rustc_const_eval/src/diagnostics.rs +++ b/compiler/rustc_const_eval/src/diagnostics.rs @@ -317,7 +317,7 @@ pub(crate) struct FrameNote { } impl Subdiagnostic for FrameNote { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { let mut span: MultiSpan = self.span.into(); if self.has_label && !self.span.is_dummy() { span.push_span_label(self.span, msg!("the failure occurred here")); diff --git a/compiler/rustc_errors/src/decorate_diag.rs b/compiler/rustc_errors/src/decorate_diag.rs index 3a222fd8a10cf..382a3b2758407 100644 --- a/compiler/rustc_errors/src/decorate_diag.rs +++ b/compiler/rustc_errors/src/decorate_diag.rs @@ -13,7 +13,7 @@ pub struct DecorateDiagCompat( /// The third argument of the closure is a `Session`. However, due to the dependency tree, /// we don't have access to `rustc_session` here, so we downcast it when needed. pub Box< - dyn for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &dyn Any) -> Diag<'a, ()> + dyn for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &dyn Any) -> Diag<'a> + DynSync + DynSend + 'static, @@ -26,7 +26,7 @@ impl std::fmt::Debug for DecorateDiagCompat { } } -impl Diagnostic<'a, ()> + DynSync + DynSend + 'static> From for DecorateDiagCompat { +impl Diagnostic<'a> + DynSync + DynSend + 'static> From for DecorateDiagCompat { #[inline] fn from(d: D) -> Self { Self(Box::new(|dcx, level, _| d.into_diag(dcx, level))) @@ -82,7 +82,7 @@ impl LintBuffer { } pub fn dyn_buffer_lint< - F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level) -> Diag<'a, ()> + DynSync + DynSend + 'static, + F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level) -> Diag<'a> + DynSync + DynSend + 'static, >( &mut self, lint: &'static Lint, @@ -99,7 +99,7 @@ impl LintBuffer { } pub fn dyn_buffer_lint_any< - F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &dyn Any) -> Diag<'a, ()> + F: for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &dyn Any) -> Diag<'a> + DynSend + DynSync + 'static, diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 888636365dc0c..9a12d6d53b6e6 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -1,7 +1,6 @@ use std::borrow::Cow; use std::fmt::{self, Debug}; use std::hash::{Hash, Hasher}; -use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; use std::panic; use std::path::PathBuf; @@ -20,58 +19,29 @@ use crate::{ Suggestions, }; -/// Marker type which enables implementation of `create_bug` and `emit_bug` functions for -/// bug diagnostics. -#[derive(Copy, Clone)] -pub struct BugAbort; - -/// Marker type which enables implementation of `create_fatal` and `emit_fatal` functions for -/// fatal diagnostics. -#[derive(Copy, Clone)] -pub struct FatalAbort; - /// Trait implemented by error types. This is rarely implemented manually. Instead, use /// `#[derive(Diagnostic)]` -- see [rustc_macros::Diagnostic]. -/// -/// When implemented manually, it should be generic over the emission -/// guarantee, i.e.: -/// ```ignore (fragment) -/// impl<'a, G> Diagnostic<'a, G> for Foo { ... } -/// ``` -/// rather than being specific: -/// ```ignore (fragment) -/// impl<'a> Diagnostic<'a> for Bar { ... } // the default type param is `ErrorGuaranteed` -/// impl<'a> Diagnostic<'a, ()> for Baz { ... } -/// ``` -/// There are two reasons for this. -/// - A diagnostic like `Foo` *could* be emitted at any level -- `level` is -/// passed in to `into_diag` from outside. Even if in practice it is -/// always emitted at a single level, we let the diagnostic creation/emission -/// site determine the level (by using `create_err`, `emit_warn`, etc.) -/// rather than the `Diagnostic` impl. -/// - Derived impls are always generic, and it's good for the hand-written -/// impls to be consistent with them. -pub trait Diagnostic<'a, G = ErrorGuaranteed> { +pub trait Diagnostic<'a> { /// Write out as a diagnostic out of `DiagCtxt`. #[must_use] #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G>; + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a>; } -impl<'a, T, G> Diagnostic<'a, G> for Spanned +impl<'a, T> Diagnostic<'a> for Spanned where - T: Diagnostic<'a, G>, + T: Diagnostic<'a>, { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { self.node.into_diag(dcx, level).with_span(self.span) } } /// Type used to emit diagnostic through a closure instead of implementing the `Diagnostic` trait. -pub struct DiagDecorator)>(pub F); +pub struct DiagDecorator)>(pub F); -impl<'a, F: FnOnce(&mut Diag<'_, ()>)> Diagnostic<'a, ()> for DiagDecorator { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a, F: FnOnce(&mut Diag<'_>)> Diagnostic<'a> for DiagDecorator { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new(dcx, level, ""); (self.0)(&mut diag); diag @@ -82,7 +52,7 @@ impl<'a, F: FnOnce(&mut Diag<'_, ()>)> Diagnostic<'a, ()> for DiagDecorator { /// `#[derive(Subdiagnostic)]` -- see [rustc_macros::Subdiagnostic]. pub trait Subdiagnostic { /// Add a subdiagnostic to an existing diagnostic. - fn add_to_diag(self, diag: &mut Diag<'_, G>); + fn add_to_diag(self, diag: &mut Diag<'_>); } #[derive(Clone, Debug, Encodable, Decodable)] @@ -391,16 +361,16 @@ pub struct Subdiag { /// Wraps a `DiagInner`, adding some useful things. /// - The `dcx` field, allowing it to (a) emit itself, and (b) do a drop check /// that it has been emitted or cancelled. -/// - `G`, which determines the type returned from `emit`. /// -/// Each constructed `Diag` must be consumed by a function such as `emit`, -/// `cancel`, or `delay_as_bug`. A panic occurs if a `Diag` is dropped without -/// being consumed by one of these functions. +/// Each constructed `Diag` must be consumed by a function such as +/// `emit_bug`/`emit_fatal`/`emit_err`/`emit`, `cancel`, or `delay_as_bug`. A +/// panic occurs if a `Diag` is dropped without being consumed by one of these +/// functions. /// /// If there is some state in a downstream crate you would like to access in /// the methods of `Diag` here, consider extending `DiagCtxtFlags`. #[must_use] -pub struct Diag<'a, G = ErrorGuaranteed> { +pub struct Diag<'a> { pub dcx: DiagCtxtHandle<'a>, /// Why the `Option`? It is always `Some` until the `Diag` is consumed via @@ -413,17 +383,15 @@ pub struct Diag<'a, G = ErrorGuaranteed> { /// theory, return value optimization (RVO) should avoid unnecessary /// copying. In practice, it does not (at the time of writing). diag: Option>, - - _marker: PhantomData, } // Cloning a `Diag` is a recipe for a diagnostic being emitted twice, which // would be bad. -impl !Clone for Diag<'_, G> {} +impl !Clone for Diag<'_> {} -rustc_data_structures::static_assert_size!(Diag<'_, ()>, 3 * size_of::()); +rustc_data_structures::static_assert_size!(Diag<'_>, 3 * size_of::()); -impl Deref for Diag<'_, G> { +impl Deref for Diag<'_> { type Target = DiagInner; fn deref(&self) -> &DiagInner { @@ -431,80 +399,18 @@ impl Deref for Diag<'_, G> { } } -impl DerefMut for Diag<'_, G> { +impl DerefMut for Diag<'_> { fn deref_mut(&mut self) -> &mut DiagInner { self.diag.as_mut().unwrap() } } -impl Debug for Diag<'_, G> { +impl Debug for Diag<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.diag.fmt(f) } } -impl Diag<'_, BugAbort> { - #[track_caller] - pub fn emit(self) -> ! { - assert_eq!(self.level, Level::Bug); - self.emit_producing_nothing(); - panic::panic_any(ExplicitBug); - } -} - -impl Diag<'_, FatalAbort> { - #[track_caller] - pub fn emit(self) -> ! { - assert_eq!(self.level, Level::Fatal); - self.emit_producing_nothing(); - crate::FatalError.raise() - } -} - -impl Diag<'_, ErrorGuaranteed> { - #[track_caller] - pub fn emit(self) -> ErrorGuaranteed { - self.emit_producing_error_guaranteed() - } - - /// Emit the diagnostic unless `delay` is true, - /// in which case the emission will be delayed as a bug. - /// - /// See `emit` and `delay_as_bug` for details. - #[track_caller] - pub fn emit_unless_delay(mut self, delay: bool) -> ErrorGuaranteed { - if delay { - self.downgrade_to_delayed_bug(); - } - self.emit() - } - - /// Delay emission of this diagnostic as a bug. - /// - /// This can be useful in contexts where an error indicates a bug but - /// typically this only happens when other compilation errors have already - /// happened. In those cases this can be used to defer emission of this - /// diagnostic as a bug in the compiler only if no other errors have been - /// emitted. - /// - /// In the meantime, though, callsites are required to deal with the "bug" - /// locally in whichever way makes the most sense. - #[track_caller] - pub fn delay_as_bug(mut self) -> ErrorGuaranteed { - self.downgrade_to_delayed_bug(); - self.emit() - } -} - -impl Diag<'_, ()> { - #[track_caller] - pub fn emit(self) { - assert_ne!(self.level, Level::Bug); - assert_ne!(self.level, Level::Fatal); - self.emit_producing_nothing(); - } -} - /// `Diag` impls many `&mut self -> &mut Self` methods. Each one modifies an /// existing diagnostic, either in a standalone fashion, e.g. /// `err.code(code);`, or in a chained fashion to make multiple modifications, @@ -548,22 +454,22 @@ macro_rules! with_fn { }; } -impl<'a, G> Diag<'a, G> { +impl<'a> Diag<'a> { #[track_caller] pub fn new(dcx: DiagCtxtHandle<'a>, level: Level, message: impl Into) -> Self { Self::new_diagnostic(dcx, DiagInner::new(level, message)) } /// Allow moving diagnostics between different error tainting contexts - pub fn with_dcx(mut self, dcx: DiagCtxtHandle<'_>) -> Diag<'_, G> { - Diag { dcx, diag: self.diag.take(), _marker: PhantomData } + pub fn with_dcx(mut self, dcx: DiagCtxtHandle<'_>) -> Diag<'_> { + Diag { dcx, diag: self.diag.take() } } /// Creates a new `Diag` with an already constructed diagnostic. #[track_caller] pub(crate) fn new_diagnostic(dcx: DiagCtxtHandle<'a>, diag: DiagInner) -> Self { debug!("Created new diagnostic"); - Self { dcx, diag: Some(Box::new(diag)), _marker: PhantomData } + Self { dcx, diag: Some(Box::new(diag)) } } /// Delay emission of this diagnostic as a bug. @@ -588,7 +494,7 @@ impl<'a, G> Diag<'a, G> { /// Make emitting this diagnostic fatal. #[track_caller] - pub fn upgrade_to_fatal(mut self) -> Diag<'a, FatalAbort> { + pub fn upgrade_to_fatal(mut self) -> Diag<'a> { assert!( matches!(self.level, Level::Error), "upgrade_to_fatal: cannot upgrade {:?} to Fatal: not an error", @@ -599,7 +505,7 @@ impl<'a, G> Diag<'a, G> { // Take is okay since we immediately rewrap it in another diagnostic. // i.e. we do emit it despite defusing the original diagnostic's drop bomb. let diag = self.diag.take(); - Diag { dcx: self.dcx, diag, _marker: PhantomData } + Diag { dcx: self.dcx, diag } } with_fn! { with_span_label, @@ -1302,21 +1208,45 @@ impl<'a, G> Diag<'a, G> { self } - /// Most `emit` methods use this as a starting point. - fn emit_producing_nothing(mut self) { + /// Emit the diagnostic. Will also abort appropriately if the level is `Bug` or `Fatal`. + #[track_caller] + pub fn emit(mut self) { + let level = self.level; // get level before taking the inner diag let diag = self.take_diag(); self.dcx.emit_diagnostic(diag); + + match level { + Level::Bug => panic::panic_any(ExplicitBug), + Level::Fatal => crate::FatalError.raise(), + _ => {} + } } - /// `Diag<'_, ErrorGuaranteed>::emit` uses this. - fn emit_producing_error_guaranteed(mut self) -> ErrorGuaranteed { + /// Use this on a `Bug` diagnostic if you need the `!` return type. Otherwise `emit` suffices. + /// Aborts if used on a non-`Bug` diagnostic. + #[track_caller] + pub fn emit_bug(self) -> ! { + assert_eq!(self.level, Level::Bug); + self.emit(); + unreachable!(); // `emit` will have aborted + } + + /// Use this on a `Fatal` diagnostic if you need the `!` return type. Otherwise `emit` + /// suffices. Aborts if used on a non-`Fatal` diagnostic. + #[track_caller] + pub fn emit_fatal(self) -> ! { + assert_eq!(self.level, Level::Fatal); + self.emit(); + unreachable!(); // `emit` will have aborted + } + + /// Use this on an `Error`/`DelayedBug` diagnostic if you need the `ErrorGuaranteed` return + /// type. Otherwise `emit` suffices. Aborts if used on a non-`Error`/`DelayedBug` diagnostic. + #[track_caller] + pub fn emit_err(mut self) -> ErrorGuaranteed { let diag = self.take_diag(); - // The only error levels that produce `ErrorGuaranteed` are - // `Error` and `DelayedBug`. But `DelayedBug` should never occur here - // because delayed bugs have their level changed to `Bug` when they are - // actually printed, so they produce an ICE. - // + // The only error levels that should reach here are `Error` and `DelayedBug`. // (Also, even though `level` isn't `pub`, the whole `DiagInner` could // be overwritten with a new one thanks to `DerefMut`. So this assert // protects against that, too.) @@ -1330,6 +1260,18 @@ impl<'a, G> Diag<'a, G> { guar.unwrap() } + /// Emit the diagnostic unless `delay` is true, + /// in which case the emission will be delayed as a bug. + /// + /// See `emit` and `delay_as_bug` for details. + #[track_caller] + pub fn emit_err_unless_delay(mut self, delay: bool) -> ErrorGuaranteed { + if delay { + self.downgrade_to_delayed_bug(); + } + self.emit_err() + } + /// Cancel and consume the diagnostic. (A diagnostic must either be emitted or /// cancelled or it will panic when dropped). pub fn cancel(mut self) { @@ -1349,11 +1291,27 @@ impl<'a, G> Diag<'a, G> { let diag = self.take_diag(); self.dcx.stash_diagnostic(span, key, diag) } + + /// Delay emission of this diagnostic as a bug. + /// + /// This can be useful in contexts where an error indicates a bug but + /// typically this only happens when other compilation errors have already + /// happened. In those cases this can be used to defer emission of this + /// diagnostic as a bug in the compiler only if no other errors have been + /// emitted. + /// + /// In the meantime, though, callsites are required to deal with the "bug" + /// locally in whichever way makes the most sense. + #[track_caller] + pub fn delay_as_bug(mut self) -> ErrorGuaranteed { + self.downgrade_to_delayed_bug(); + self.emit_err() + } } /// Destructor bomb: every `Diag` must be consumed (emitted, cancelled, etc.) /// or we emit a bug. -impl Drop for Diag<'_, G> { +impl Drop for Diag<'_> { fn drop(&mut self) { match self.diag.take() { Some(diag) if !panicking() => { diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index b002b8932a239..fa9e3544f12ae 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -42,7 +42,7 @@ pub struct SingleLabelManySpans { pub label: &'static str, } impl Subdiagnostic for SingleLabelManySpans { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { diag.span_labels(self.spans, self.label); } } diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 89209b64e0108..30791a51f7644 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -32,8 +32,8 @@ pub use anstyle::{ pub use codes::*; pub use decorate_diag::{BufferedEarlyLint, DecorateDiagCompat, LintBuffer}; pub use diagnostic::{ - BugAbort, Diag, DiagDecorator, DiagInner, DiagLocation, DiagStyledString, Diagnostic, - FatalAbort, StringPart, Subdiag, Subdiagnostic, + Diag, DiagDecorator, DiagInner, DiagLocation, DiagStyledString, Diagnostic, StringPart, + Subdiag, Subdiagnostic, }; pub use diagnostic_impls::{ DiagSymbolList, ElidedLifetimeInPathSubdiag, ExpectedLifetimeParameter, @@ -632,7 +632,7 @@ impl<'a> DiagCtxtHandle<'a> { /// Steal a previously stashed non-error diagnostic with the given `Span` /// and [`StashKey`] as the key. Panics if the found diagnostic is an /// error. - pub fn steal_non_err(self, span: Span, key: StashKey) -> Option> { + pub fn steal_non_err(self, span: Span, key: StashKey) -> Option> { // FIXME(#120456) - is `swap_remove` correct? let (diag, guar, _) = self.dcx.inner.borrow_mut().stashed_diagnostics.get_mut(&key).and_then( @@ -661,13 +661,12 @@ impl<'a> DiagCtxtHandle<'a> { |stashed_diagnostics| stashed_diagnostics.swap_remove(&span.with_parent(None)), ); err.map(|(err, guar, _)| { - // The use of `::` is safe because level is `Level::Error`. assert_eq!(err.level, Error); assert!(guar.is_some()); - let mut err = Diag::::new_diagnostic(self, err); + let mut err = Diag::new_diagnostic(self, err); modify_err(&mut err); assert_eq!(err.level, Error); - err.emit() + err.emit_err() }) } @@ -690,11 +689,11 @@ impl<'a> DiagCtxtHandle<'a> { assert!(guar.is_some()); // Because `old_err` has already been counted, it can only be // safely cancelled because the `new_err` supplants it. - Diag::::new_diagnostic(self, old_err).cancel(); + Diag::new_diagnostic(self, old_err).cancel(); } None => {} }; - new_err.emit() + new_err.emit_err() } pub fn has_stashed_diagnostic(&self, span: Span, key: StashKey) -> bool { @@ -952,13 +951,13 @@ impl<'a> DiagCtxtHandle<'a> { // functions create and emit a diagnostic all in one go. impl<'a> DiagCtxtHandle<'a> { #[track_caller] - pub fn struct_bug(self, msg: impl Into>) -> Diag<'a, BugAbort> { + pub fn struct_bug(self, msg: impl Into>) -> Diag<'a> { Diag::new(self, Bug, msg.into()) } #[track_caller] pub fn bug(self, msg: impl Into>) -> ! { - self.struct_bug(msg).emit() + self.struct_bug(msg).emit_bug() } #[track_caller] @@ -966,33 +965,33 @@ impl<'a> DiagCtxtHandle<'a> { self, span: impl Into, msg: impl Into>, - ) -> Diag<'a, BugAbort> { + ) -> Diag<'a> { self.struct_bug(msg).with_span(span) } #[track_caller] pub fn span_bug(self, span: impl Into, msg: impl Into>) -> ! { - self.struct_span_bug(span, msg.into()).emit() + self.struct_span_bug(span, msg.into()).emit_bug() } #[track_caller] - pub fn create_bug(self, bug: impl Diagnostic<'a, BugAbort>) -> Diag<'a, BugAbort> { + pub fn create_bug(self, bug: impl Diagnostic<'a>) -> Diag<'a> { bug.into_diag(self, Bug) } #[track_caller] - pub fn emit_bug(self, bug: impl Diagnostic<'a, BugAbort>) -> ! { - self.create_bug(bug).emit() + pub fn emit_bug(self, bug: impl Diagnostic<'a>) -> ! { + self.create_bug(bug).emit_bug() } #[track_caller] - pub fn struct_fatal(self, msg: impl Into) -> Diag<'a, FatalAbort> { + pub fn struct_fatal(self, msg: impl Into) -> Diag<'a> { Diag::new(self, Fatal, msg) } #[track_caller] pub fn fatal(self, msg: impl Into) -> ! { - self.struct_fatal(msg).emit() + self.struct_fatal(msg).emit_fatal() } #[track_caller] @@ -1000,23 +999,23 @@ impl<'a> DiagCtxtHandle<'a> { self, span: impl Into, msg: impl Into, - ) -> Diag<'a, FatalAbort> { + ) -> Diag<'a> { self.struct_fatal(msg).with_span(span) } #[track_caller] pub fn span_fatal(self, span: impl Into, msg: impl Into) -> ! { - self.struct_span_fatal(span, msg).emit() + self.struct_span_fatal(span, msg).emit_fatal() } #[track_caller] - pub fn create_fatal(self, fatal: impl Diagnostic<'a, FatalAbort>) -> Diag<'a, FatalAbort> { + pub fn create_fatal(self, fatal: impl Diagnostic<'a>) -> Diag<'a> { fatal.into_diag(self, Fatal) } #[track_caller] - pub fn emit_fatal(self, fatal: impl Diagnostic<'a, FatalAbort>) -> ! { - self.create_fatal(fatal).emit() + pub fn emit_fatal(self, fatal: impl Diagnostic<'a>) -> ! { + self.create_fatal(fatal).emit_fatal() } // FIXME: This method should be removed (every error should have an associated error code). @@ -1027,7 +1026,7 @@ impl<'a> DiagCtxtHandle<'a> { #[track_caller] pub fn err(self, msg: impl Into) -> ErrorGuaranteed { - self.struct_err(msg).emit() + self.struct_err(msg).emit_err() } #[track_caller] @@ -1045,7 +1044,7 @@ impl<'a> DiagCtxtHandle<'a> { span: impl Into, msg: impl Into, ) -> ErrorGuaranteed { - self.struct_span_err(span, msg).emit() + self.struct_span_err(span, msg).emit_err() } #[track_caller] @@ -1055,13 +1054,13 @@ impl<'a> DiagCtxtHandle<'a> { #[track_caller] pub fn emit_err(self, err: impl Diagnostic<'a>) -> ErrorGuaranteed { - self.create_err(err).emit() + self.create_err(err).emit_err() } /// Ensures that an error is printed. See [`Level::DelayedBug`]. #[track_caller] pub fn delayed_bug(self, msg: impl Into>) -> ErrorGuaranteed { - Diag::::new(self, DelayedBug, msg.into()).emit() + Diag::new(self, DelayedBug, msg.into()).emit_err() } /// Ensures that an error is printed. See [`Level::DelayedBug`]. @@ -1074,11 +1073,11 @@ impl<'a> DiagCtxtHandle<'a> { sp: impl Into, msg: impl Into>, ) -> ErrorGuaranteed { - Diag::::new(self, DelayedBug, msg.into()).with_span(sp).emit() + Diag::new(self, DelayedBug, msg.into()).with_span(sp).emit_err() } #[track_caller] - pub fn struct_warn(self, msg: impl Into) -> Diag<'a, ()> { + pub fn struct_warn(self, msg: impl Into) -> Diag<'a> { Diag::new(self, Warning, msg) } @@ -1092,7 +1091,7 @@ impl<'a> DiagCtxtHandle<'a> { self, span: impl Into, msg: impl Into, - ) -> Diag<'a, ()> { + ) -> Diag<'a> { self.struct_warn(msg).with_span(span) } @@ -1102,17 +1101,17 @@ impl<'a> DiagCtxtHandle<'a> { } #[track_caller] - pub fn create_warn(self, warning: impl Diagnostic<'a, ()>) -> Diag<'a, ()> { + pub fn create_warn(self, warning: impl Diagnostic<'a>) -> Diag<'a> { warning.into_diag(self, Warning) } #[track_caller] - pub fn emit_warn(self, warning: impl Diagnostic<'a, ()>) { + pub fn emit_warn(self, warning: impl Diagnostic<'a>) { self.create_warn(warning).emit() } #[track_caller] - pub fn struct_note(self, msg: impl Into) -> Diag<'a, ()> { + pub fn struct_note(self, msg: impl Into) -> Diag<'a> { Diag::new(self, Note, msg) } @@ -1126,7 +1125,7 @@ impl<'a> DiagCtxtHandle<'a> { self, span: impl Into, msg: impl Into, - ) -> Diag<'a, ()> { + ) -> Diag<'a> { self.struct_note(msg).with_span(span) } @@ -1136,22 +1135,22 @@ impl<'a> DiagCtxtHandle<'a> { } #[track_caller] - pub fn create_note(self, note: impl Diagnostic<'a, ()>) -> Diag<'a, ()> { + pub fn create_note(self, note: impl Diagnostic<'a>) -> Diag<'a> { note.into_diag(self, Note) } #[track_caller] - pub fn emit_note(self, note: impl Diagnostic<'a, ()>) { + pub fn emit_note(self, note: impl Diagnostic<'a>) { self.create_note(note).emit() } #[track_caller] - pub fn struct_allow(self, msg: impl Into) -> Diag<'a, ()> { + pub fn struct_allow(self, msg: impl Into) -> Diag<'a> { Diag::new(self, Allow, msg) } #[track_caller] - pub fn struct_expect(self, msg: impl Into, id: LintExpectationId) -> Diag<'a, ()> { + pub fn struct_expect(self, msg: impl Into, id: LintExpectationId) -> Diag<'a> { Diag::new(self, Expect, msg).with_lint_id(id) } } @@ -1550,19 +1549,19 @@ impl DelayedDiagInner { } } -/// | Level | is_error | emit return type | Top-level | Used in lints? -/// | ----- | -------- | ---------------- | --------- | -------------- -/// | Bug | yes | BugAbort | yes | - -/// | Fatal | yes | FatalAbort | yes | - -/// | Error | yes | ErrorGuaranteed | yes | yes -/// | DelayedBug | yes | ErrorGuaranteed | yes | - -/// | ForceWarning | - | () | yes | lint-only -/// | Warning | - | () | yes | yes -/// | Note | - | () | rare | - -/// | Help | - | () | don't use | - -/// | FailureNote | - | () | rare | - -/// | Allow | - | () | yes | lint-only -/// | Expect | - | () | yes | lint-only +/// | Level | is_error | usable emit fns | Top-level | Used in lints? +/// | ----- | -------- | --------------- | --------- | -------------- +/// | Bug | yes | emit, emit_bug | yes | - +/// | Fatal | yes | emit, emit_fatal | yes | - +/// | Error | yes | emit, emit_err | yes | yes +/// | DelayedBug | yes | emit, emit_err | yes | - +/// | ForceWarning | - | emit | yes | lint-only +/// | Warning | - | emit | yes | yes +/// | Note | - | emit | rare | - +/// | Help | - | emit | don't use | - +/// | FailureNote | - | emit | rare | - +/// | Allow | - | emit | yes | lint-only +/// | Expect | - | emit | yes | lint-only /// #[derive(Copy, PartialEq, Eq, Clone, Hash, Debug, Encodable, Decodable)] pub enum Level { diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 51c517ee24a66..5a2442fbccf35 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -898,7 +898,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { } } Err(err) => { - let _guar = err.emit(); + err.emit(); fragment_kind.expect_from_annotatables(iter::once(item)) } } @@ -1068,7 +1068,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { err.span(span); } annotate_err_with_kind(&mut err, kind, span); - let guar = err.emit(); + let guar = err.emit_err(); self.cx.macro_error_and_trace_macros_diag(); kind.dummy(span, guar) } diff --git a/compiler/rustc_expand/src/mbe/diagnostics.rs b/compiler/rustc_expand/src/mbe/diagnostics.rs index 0e79dadb3503e..f7603f25bb137 100644 --- a/compiler/rustc_expand/src/mbe/diagnostics.rs +++ b/compiler/rustc_expand/src/mbe/diagnostics.rs @@ -140,7 +140,7 @@ pub(super) fn failed_to_match_macro( } } } - let guar = err.emit(); + let guar = err.emit_err(); (sp, guar) } @@ -497,7 +497,7 @@ pub(super) fn emit_frag_parse_err( } } } - e.emit() + e.emit_err() } pub(crate) fn annotate_err_with_kind(err: &mut Diag<'_>, kind: AstFragmentKind, span: Span) { diff --git a/compiler/rustc_expand/src/mbe/macro_parser.rs b/compiler/rustc_expand/src/mbe/macro_parser.rs index 3e94e0ca34773..4505bcf394ace 100644 --- a/compiler/rustc_expand/src/mbe/macro_parser.rs +++ b/compiler/rustc_expand/src/mbe/macro_parser.rs @@ -713,13 +713,13 @@ impl TtParser { fn nt_parsing_error(&self, loc: &MatcherLoc, err: Diag<'_>) -> ParseResult { let &MatcherLoc::MetaVarDecl { span, kind, .. } = loc else { unreachable!() }; - let guarantee = err + let guar = err .with_span_label( span, format!("while parsing argument for this `{kind}` macro fragment"), ) - .emit(); - ErrorReported(guarantee) + .emit_err(); + ErrorReported(guar) } fn nameize>( diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index 2212724c68bc1..5ace9b36d0b6f 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -255,7 +255,7 @@ impl MacroRulesMacroExpander { let id = cx.current_expansion.id; let tts = transcribe(psess, &named_matches, rhs, *rhs_span, self.transparency, id) - .map_err(|e| e.emit())?; + .map_err(|e| e.emit_err())?; if cx.trace_macros() { let msg = format!("to `{}`", pprust::tts_to_string(&tts)); @@ -464,7 +464,7 @@ fn expand_macro<'cx, 'a: 'cx>( let tts = match transcribe(psess, &named_matches, rhs, *rhs_span, transparency, id) { Ok(tts) => tts, Err(err) => { - let guar = err.emit(); + let guar = err.emit_err(); return DummyResult::any(arm_span, guar); } }; @@ -562,7 +562,7 @@ fn expand_macro_attr( let id = cx.current_expansion.id; let tts = transcribe(psess, &named_matches, rhs, *rhs_span, transparency, id) - .map_err(|e| e.emit())?; + .map_err(|e| e.emit_err())?; if cx.trace_macros() { let msg = format!("to `{}`", pprust::tts_to_string(&tts)); @@ -858,7 +858,7 @@ pub fn compile_declarative_macro( if args_not_empty { err.span_label(derive_keyword_span, "need `()` after this `derive`"); } - return dummy_syn_ext(err.emit()); + return dummy_syn_ext(err.emit_err()); } (None, true) } else { @@ -873,7 +873,7 @@ pub fn compile_declarative_macro( let lhs_tt = parse_one_tt(lhs_tt, RulePart::Pattern, sess, node_id, features, edition); check_emission(check_lhs(sess, features, node_id, &lhs_tt)); if let Err(e) = p.expect(exp!(FatArrow)) { - return dummy_syn_ext(e.emit()); + return dummy_syn_ext(e.emit_err()); } if let Some(guar) = check_no_eof(sess, &p, "expected right-hand side of macro rule") { return dummy_syn_ext(guar); @@ -906,7 +906,7 @@ pub fn compile_declarative_macro( break; } if let Err(e) = p.expect(exp_sep) { - return dummy_syn_ext(e.emit()); + return dummy_syn_ext(e.emit_err()); } } @@ -952,7 +952,7 @@ fn check_no_eof(sess: &Session, p: &Parser<'_>, msg: &'static str) -> Option Result<(), let mut err = sess.dcx().struct_span_err(sp, "repetition matches empty token tree"); check_redundant_vis_repetition(&mut err, sess, seq, span); - return Err(err.emit()); + return Err(err.emit_err()); } check_lhs_no_empty_seq(sess, &seq.tts)? } @@ -1660,7 +1660,7 @@ fn check_matcher_core<'tt>( )); } } - errored = Err(err.emit()); + errored = Err(err.emit_err()); } } } diff --git a/compiler/rustc_expand/src/module.rs b/compiler/rustc_expand/src/module.rs index d49eae9830b3f..8e1641c8fb60c 100644 --- a/compiler/rustc_expand/src/module.rs +++ b/compiler/rustc_expand/src/module.rs @@ -300,7 +300,7 @@ impl ModError<'_> { secondary_path: secondary_path.display().to_string(), }) } - ModError::ParserError(err) => err.emit(), + ModError::ParserError(err) => err.emit_err(), } } } diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs index c0a9a43c64cdf..1990917c09f17 100644 --- a/compiler/rustc_expand/src/proc_macro_server.rs +++ b/compiler/rustc_expand/src/proc_macro_server.rs @@ -559,8 +559,7 @@ impl server::Server for Rustc<'_, '_> { fn emit_diagnostic(&mut self, diagnostic: Diagnostic) { let message = rustc_errors::DiagMessage::from(diagnostic.message); - let mut diag: Diag<'_, ()> = - Diag::new(self.psess().dcx(), diagnostic.level.to_internal(), message); + let mut diag = Diag::new(self.psess().dcx(), diagnostic.level.to_internal(), message); diag.span(MultiSpan::from_spans(diagnostic.spans)); for child in diagnostic.children { diag.sub(child.level.to_internal(), child.message, MultiSpan::from_spans(child.spans)); diff --git a/compiler/rustc_hir/src/lints.rs b/compiler/rustc_hir/src/lints.rs index 200f1af2142a7..926c9c91ecb61 100644 --- a/compiler/rustc_hir/src/lints.rs +++ b/compiler/rustc_hir/src/lints.rs @@ -17,7 +17,7 @@ pub struct DelayedLint { pub id: HirId, pub span: MultiSpan, pub callback: Box< - dyn for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &dyn std::any::Any) -> Diag<'a, ()> + dyn for<'a> FnOnce(DiagCtxtHandle<'a>, Level, &dyn std::any::Any) -> Diag<'a> + DynSend + DynSync + 'static, diff --git a/compiler/rustc_hir_analysis/src/check/always_applicable.rs b/compiler/rustc_hir_analysis/src/check/always_applicable.rs index 11960d57016f6..b098a6c186457 100644 --- a/compiler/rustc_hir_analysis/src/check/always_applicable.rs +++ b/compiler/rustc_hir_analysis/src/check/always_applicable.rs @@ -211,7 +211,7 @@ fn ensure_impl_params_and_item_params_correspond<'tcx>( as the {self_descr} definition", ), ); - Err(err.emit()) + Err(err.emit_err()) } fn ensure_all_fields_are_const_destruct<'tcx>( @@ -278,7 +278,7 @@ fn ensure_all_fields_are_const_destruct<'tcx>( None, ); } - Err(diag.emit()) + Err(diag.emit_err()) }) .collect() } @@ -362,7 +362,7 @@ fn ensure_impl_predicates_are_implied_by_item_defn<'tcx>( but the {self_descr} it is implemented for does not", ) .with_span_note(item_span, "the implementor must specify the same requirement") - .emit(), + .emit_err(), ); } } @@ -395,7 +395,7 @@ fn ensure_impl_predicates_are_implied_by_item_defn<'tcx>( but the {self_descr} it is implemented for does not", ) .with_span_note(item_span, "the implementor must specify the same requirement") - .emit(), + .emit_err(), ); } return Err(guar.unwrap()); diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 52b69e6050a32..3602c9507624c 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -43,7 +43,7 @@ use crate::check::wfcheck::{ use crate::collect::ItemCtxt; use crate::diagnostics; -fn add_abi_diag_help(abi: ExternAbi, diag: &mut Diag<'_, G>) { +fn add_abi_diag_help(abi: ExternAbi, diag: &mut Diag<'_>) { if let ExternAbi::Cdecl { unwind } = abi { let c_abi = ExternAbi::C { unwind }; diag.help(format!("use `extern {c_abi}` instead",)); @@ -62,8 +62,8 @@ pub fn check_abi(tcx: TyCtxt<'_>, hir_id: hir::HirId, span: Span, abi: ExternAbi abi: ExternAbi, } - impl<'a> Diagnostic<'a, ()> for UnsupportedCallingConventions { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a> Diagnostic<'a> for UnsupportedCallingConventions { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { abi } = self; let mut lint = Diag::new( dcx, @@ -557,7 +557,7 @@ fn sanity_check_found_hidden_type<'tcx>( } else { let span = tcx.def_span(key.def_id); let other = ty::ProvisionalHiddenType { ty: hidden_ty, span }; - Err(ty.build_mismatch_error(&other, tcx)?.emit()) + Err(ty.build_mismatch_error(&other, tcx)?.emit_err()) } } @@ -2060,7 +2060,7 @@ fn detect_discriminant_duplicate<'tcx>(tcx: TyCtxt<'tcx>, adt: ty::AdtDef<'tcx>) let mut i = 0; while i < discrs.len() { let var_i_idx = discrs[i].0; - let mut error: Option> = None; + let mut error: Option> = None; let mut o = i + 1; while o < discrs.len() { @@ -2304,7 +2304,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'_>, opaque_def_id: LocalDefId) -> ErrorG if !label { err.span_label(span, "cannot resolve opaque type"); } - err.emit() + err.emit_err() } pub(super) fn check_coroutine_obligations( diff --git a/compiler/rustc_hir_analysis/src/check/compare_eii.rs b/compiler/rustc_hir_analysis/src/check/compare_eii.rs index aefe53f2f4399..c9fd3da24fe07 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_eii.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_eii.rs @@ -201,7 +201,7 @@ pub(crate) fn compare_eii_statics<'tcx>( ); diag.span_note(eii_attr_span, "expected this because of this attribute"); - return Err(diag.emit()); + return Err(diag.emit_err()); } // Check that all obligations are satisfied by the implementation's @@ -349,7 +349,7 @@ fn check_early_region_bounds<'tcx>( }); diag.span_label(eii_attr_span, format!("required because of this attribute")); - return Err(diag.emit()); + return Err(diag.emit_err()); } fn check_number_of_arguments<'tcx>( @@ -447,7 +447,7 @@ fn report_number_of_arguments_mismatch<'tcx>( err.span_label(eii_attr_span, format!("required because of this attribute")); - err.emit() + err.emit_err() } fn report_eii_mismatch<'tcx>( @@ -521,7 +521,7 @@ fn report_eii_mismatch<'tcx>( None, ); - diag.emit() + diag.emit_err() } #[instrument(level = "debug", skip(infcx))] diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs index 4061d247f59f1..f459628ab8d29 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs @@ -638,7 +638,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>( false, None, ); - return Err(diag.emit()); + return Err(diag.emit_err()); } } @@ -950,7 +950,7 @@ impl<'tcx> ty::FallibleTypeFolder> for RemapHiddenTyRegions<'tcx> { "hidden type must only reference lifetimes captured by this impl trait", ) .with_note(format!("hidden type inferred to be `{}`", self.ty)) - .emit() + .emit_err() } None => { // This code path is not reached in any tests, but may be @@ -1091,7 +1091,7 @@ fn report_trait_method_mismatch<'tcx>( None, ); - diag.emit() + diag.emit_err() } fn check_region_bounds_on_impl_item<'tcx>( @@ -1134,7 +1134,7 @@ fn check_region_bounds_on_impl_item<'tcx>( bounds_span, where_span, }) - .emit_unless_delay(delay); + .emit_err_unless_delay(delay); Err(reported) } @@ -1435,7 +1435,7 @@ fn check_region_late_boundedness<'tcx>( } } - Some(diag.emit()) + Some(diag.emit_err()) } fn find_region_in_clauses<'tcx>( @@ -1538,7 +1538,7 @@ fn compare_self_type<'tcx>( } else { err.note_trait_signature(trait_m.name(), trait_m.signature(tcx)); } - return Err(err.emit_unless_delay(delay)); + return Err(err.emit_err_unless_delay(delay)); } (true, false) => { @@ -1559,7 +1559,7 @@ fn compare_self_type<'tcx>( err.note_trait_signature(trait_m.name(), trait_m.signature(tcx)); } - return Err(err.emit_unless_delay(delay)); + return Err(err.emit_err_unless_delay(delay)); } } @@ -1719,8 +1719,8 @@ fn compare_number_of_generics<'tcx>( err.span_label(*span, "`impl Trait` introduces an implicit type parameter"); } - let reported = err.emit_unless_delay(delay); - err_occurred = Some(reported); + let guar = err.emit_err_unless_delay(delay); + err_occurred = Some(guar); } } @@ -1901,7 +1901,7 @@ fn compare_number_of_method_arguments<'tcx>( } } - return Err(err.emit_unless_delay(delay)); + return Err(err.emit_err_unless_delay(delay)); } Ok(()) @@ -2028,7 +2028,7 @@ fn compare_synthetic_generics<'tcx>( ); }; } - error_found = Some(err.emit_unless_delay(delay)); + error_found = Some(err.emit_err_unless_delay(delay)); } } if let Some(reported) = error_found { Err(reported) } else { Ok(()) } @@ -2130,8 +2130,8 @@ fn compare_generic_param_kinds<'tcx>( err.span_context(impl_header_span); err.span_label(param_impl_span, make_param_message("found", param_impl)); - let reported = err.emit_unless_delay(delay); - return Err(reported); + let guar = err.emit_err_unless_delay(delay); + return Err(guar); } } @@ -2177,7 +2177,7 @@ pub(super) fn compare_const_directness<'tcx>( tcx.def_span(trait_const_item.def_id), "trait declaration of const is marked as `#[rustc_always_gca]`", ) - .emit() + .emit_err() } else { tcx.dcx() .struct_span_err( @@ -2188,7 +2188,7 @@ pub(super) fn compare_const_directness<'tcx>( tcx.def_span(trait_const_item.def_id), "trait declaration of const is not marked as `#[rustc_always_gca]`", ) - .emit() + .emit_err() }; Err(guar) } @@ -2303,7 +2303,7 @@ fn compare_const_clause_entailment<'tcx>( false, None, ); - return Err(diag.emit()); + return Err(diag.emit_err()); }; // Check that all obligations are satisfied by the implementation's diff --git a/compiler/rustc_hir_analysis/src/check/mod.rs b/compiler/rustc_hir_analysis/src/check/mod.rs index 8d936b2cd3498..fa2b3e9f25342 100644 --- a/compiler/rustc_hir_analysis/src/check/mod.rs +++ b/compiler/rustc_hir_analysis/src/check/mod.rs @@ -724,7 +724,7 @@ pub fn check_function_signature<'tcx>( false, None, ); - return Err(diag.emit()); + return Err(diag.emit_err()); } } diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 30947ce0f4f98..bde17c39e2bc4 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -292,7 +292,7 @@ pub(super) fn check_item<'tcx>( .struct_span_err(sp, "impls of auto traits cannot be default") .with_span_labels(of_trait.defaultness_span, "default because of this") .with_span_label(sp, "auto trait") - .emit()); + .emit_err()); } match header.polarity { ty::ImplPolarity::Positive => { @@ -312,7 +312,7 @@ pub(super) fn check_item<'tcx>( E0750, "negative impls cannot be default impls" ) - .emit()); + .emit_err()); } } } @@ -905,7 +905,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &ty::GenericParamDef) -> Result<(), Er tcx.disabled_nightly_features(&mut diag, features); } - Err(diag.emit()) + Err(diag.emit_err()) } } } @@ -1780,7 +1780,7 @@ fn check_method_receiver<'tcx>( ), ) .with_help(msg!("consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box`, `self: Rc`, or `self: Arc`")) - .emit() + .emit_err() } None | Some(ArbitrarySelfTypesLevel::Basic) if receiver_is_valid( @@ -1804,7 +1804,7 @@ fn check_method_receiver<'tcx>( ), ) .with_help(msg!("consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box`, `self: Rc`, or `self: Arc`")) - .emit() + .emit_err() } _ => // Report error; would not have worked with `arbitrary_self_types[_pointers]`. @@ -2213,7 +2213,7 @@ fn report_bivariance<'tcx>( // Silence potentially redundant error, as the item had a parse error. diag.delay_as_bug() } else { - diag.emit() + diag.emit_err() } } @@ -2403,7 +2403,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> { ); err.note(format!("it is a {ty}")); err.note(format!("and here it is `Debug`ged :3 {ty:?}")); - r = Err(err.emit()); + r = Err(err.emit_err()); } } } diff --git a/compiler/rustc_hir_analysis/src/check_unused.rs b/compiler/rustc_hir_analysis/src/check_unused.rs index 3c8bd2af9b4c1..f6be7a27cc8cf 100644 --- a/compiler/rustc_hir_analysis/src/check_unused.rs +++ b/compiler/rustc_hir_analysis/src/check_unused.rs @@ -12,8 +12,8 @@ struct UnusedImport<'tcx> { span: Span, } -impl<'a, 'tcx> Diagnostic<'a, ()> for UnusedImport<'tcx> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a, 'tcx> Diagnostic<'a> for UnusedImport<'tcx> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { tcx, span } = self; if let Ok(snippet) = tcx.sess.source_map().span_to_snippet(span) { Diag::new(dcx, level, format!("unused import: `{snippet}`")) diff --git a/compiler/rustc_hir_analysis/src/coherence/builtin.rs b/compiler/rustc_hir_analysis/src/coherence/builtin.rs index f7faefa240abe..e9adabc7ca4bb 100644 --- a/compiler/rustc_hir_analysis/src/coherence/builtin.rs +++ b/compiler/rustc_hir_analysis/src/coherence/builtin.rs @@ -1003,7 +1003,7 @@ fn infringing_fields_error<'tcx>( None, ); - err.emit() + err.emit_err() } fn visit_implementation_of_coerce_pointee_validity( diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs index 9052f11e109b6..05ceb049e0dba 100644 --- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs +++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs @@ -91,7 +91,7 @@ impl<'tcx> InherentOverlapChecker<'tcx> { ) .with_span_label(span, format!("duplicate definitions for `{ident}`")) .with_span_label(*former, format!("other definition for `{ident}`")) - .emit()); + .emit_err()); } IndexEntry::Vacant(entry) => { entry.insert(span); @@ -142,7 +142,7 @@ impl<'tcx> InherentOverlapChecker<'tcx> { traits::add_placeholder_note(&mut err); } - res = Err(err.emit()); + res = Err(err.emit_err()); } } res diff --git a/compiler/rustc_hir_analysis/src/coherence/mod.rs b/compiler/rustc_hir_analysis/src/coherence/mod.rs index 894cd584ae41d..e3f4f8d0507d3 100644 --- a/compiler/rustc_hir_analysis/src/coherence/mod.rs +++ b/compiler/rustc_hir_analysis/src/coherence/mod.rs @@ -87,7 +87,7 @@ fn enforce_trait_manually_implementable( err.code(E0328); } - return Err(err.emit()); + return Err(err.emit_err()); } if let ty::trait_def::TraitSpecializationKind::AlwaysApplicable = trait_def.specialization_kind @@ -135,7 +135,7 @@ fn enforce_empty_impls_for_marker_traits( E0715, "impls for marker traits cannot contain items" ) - .emit()) + .emit_err()) } /// Adds query implementations to the [Providers] vtable, see [`rustc_middle::query`]. @@ -239,7 +239,7 @@ fn check_object_overlap<'tcx>( tcx.def_path_str(trait_def_id) ), ) - .emit()); + .emit_err()); } } } diff --git a/compiler/rustc_hir_analysis/src/coherence/orphan.rs b/compiler/rustc_hir_analysis/src/coherence/orphan.rs index 44a1211687c29..496994096d69b 100644 --- a/compiler/rustc_hir_analysis/src/coherence/orphan.rs +++ b/compiler/rustc_hir_analysis/src/coherence/orphan.rs @@ -487,7 +487,7 @@ fn emit_orphan_check_error<'tcx>( } } - diag.emit() + diag.emit_err() } traits::OrphanCheckErr::UncoveredTyParams(UncoveredTyParams { uncovered, local_ty }) => { let mut guar = None; diff --git a/compiler/rustc_hir_analysis/src/coherence/unsafety.rs b/compiler/rustc_hir_analysis/src/coherence/unsafety.rs index ce0171a4d2d7d..18ba46ff08913 100644 --- a/compiler/rustc_hir_analysis/src/coherence/unsafety.rs +++ b/compiler/rustc_hir_analysis/src/coherence/unsafety.rs @@ -49,7 +49,7 @@ pub(super) fn check_item( "", rustc_errors::Applicability::MachineApplicable, ) - .emit()); + .emit_err()); } (Safety::Unsafe, _, Safety::Safe, Positive) => { @@ -83,7 +83,7 @@ pub(super) fn check_item( "unsafe ", rustc_errors::Applicability::MaybeIncorrect, ) - .emit()); + .emit_err()); } (Safety::Safe, Some(attr_name), Safety::Safe, Positive) => { @@ -107,7 +107,7 @@ pub(super) fn check_item( "unsafe ", rustc_errors::Applicability::MaybeIncorrect, ) - .emit()); + .emit_err()); } (_, _, Safety::Unsafe, Negative) => { diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs index f1c330aaeed57..02a7fa6f98791 100644 --- a/compiler/rustc_hir_analysis/src/collect.rs +++ b/compiler/rustc_hir_analysis/src/collect.rs @@ -319,7 +319,7 @@ impl<'tcx> ItemCtxt<'tcx> { ); } - diag.emit() + diag.emit_err() } #[instrument(level = "debug", skip(self), ret)] @@ -519,7 +519,7 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> { " + /* 'a */", Applicability::HasPlaceholders, ) - .emit(); + .emit_err(); ty::Region::new_error(self.tcx(), guar) } else { // If we found elided lifetime during lowering of delegation parent or child @@ -812,8 +812,8 @@ pub(super) fn check_enum_variant_types(tcx: TyCtxt<'_>, def_id: LocalDefId) { msg: &'static str, } - impl<'a> Diagnostic<'a, ()> for ReprCIssue { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a> Diagnostic<'a> for ReprCIssue { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { msg } = self; Diag::new(dcx, level, msg) .with_note("`repr(C)` enums with big discriminants are non-portable, and their size in Rust might not match their size in C") @@ -1417,7 +1417,7 @@ fn recover_infer_ret_ty<'tcx>( https://doc.rust-lang.org/book/ch13-01-closures.html", ); } - let guar = diag.emit(); + let guar = diag.emit_err(); // If we return a dummy binder here, we can ICE later in borrowck when it encounters // `ReLateParam` regions (e.g. in a local type annotation) which weren't registered via the diff --git a/compiler/rustc_hir_analysis/src/collect/dump.rs b/compiler/rustc_hir_analysis/src/collect/dump.rs index 772bbe4a6b579..af6e689c33e13 100644 --- a/compiler/rustc_hir_analysis/src/collect/dump.rs +++ b/compiler/rustc_hir_analysis/src/collect/dump.rs @@ -103,7 +103,7 @@ pub(crate) fn clauses_and_item_bounds(tcx: TyCtxt<'_>) { for bound in bounds { diag.note(format!("{bound:?}")); } - diag.emit() + diag.emit_err() } kind => tcx.dcx().span_delayed_bug( tcx.def_span(id), diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index c9deedb33ffc7..ee4e7471ee434 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -21,8 +21,8 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { msg: &'static str, } - impl<'a> Diagnostic<'a, ()> for GenericParametersForbiddenHere { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a> Diagnostic<'a> for GenericParametersForbiddenHere { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { msg } = self; Diag::new(dcx, level, msg) } diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index 1f35c302cc9f1..a6cc61d2f7bfe 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -2827,7 +2827,7 @@ fn deny_non_region_late_bound( format!("late-bound {what} parameter not allowed on {where_}"), ); - let guar = diag.emit_unless_delay(!tcx.features().non_lifetime_binders() || !first); + let guar = diag.emit_err_unless_delay(!tcx.features().non_lifetime_binders() || !first); first = false; *arg = ResolvedArg::Error(guar); diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index dc86f2837da8e..8754430aaa99e 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -541,7 +541,7 @@ fn infer_placeholder_type<'tcx>( } } - diag.emit() + diag.emit_err() }); Ty::new_error(tcx, guar) } diff --git a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs index 66167e0042982..5ffbe693180f0 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs @@ -119,7 +119,7 @@ impl<'tcx> TaitConstraintLocator<'tcx> { if let Some(prev) = &mut self.found { if hidden_ty.ty != prev.ty { let (Ok(guar) | Err(guar)) = - prev.build_mismatch_error(&hidden_ty, self.tcx).map(|d| d.emit()); + prev.build_mismatch_error(&hidden_ty, self.tcx).map(|d| d.emit_err()); *prev = ty::DefinitionSiteHiddenType::new_error(self.tcx, guar); } } else { diff --git a/compiler/rustc_hir_analysis/src/diagnostics.rs b/compiler/rustc_hir_analysis/src/diagnostics.rs index 1f0c493b881f1..ff5f7dbb119f1 100644 --- a/compiler/rustc_hir_analysis/src/diagnostics.rs +++ b/compiler/rustc_hir_analysis/src/diagnostics.rs @@ -467,9 +467,9 @@ pub(crate) struct MissingGenericParams { } // FIXME: This doesn't need to be a manual impl! -impl<'a, G> Diagnostic<'a, G> for MissingGenericParams { +impl<'a> Diagnostic<'a> for MissingGenericParams { #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut err = Diag::new( dcx, level, @@ -2069,8 +2069,8 @@ pub(crate) struct UncoveredTyParam<'tcx> { pub(crate) local_ty: Option>, } -impl Diagnostic<'_, G> for UncoveredTyParam<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { +impl Diagnostic<'_> for UncoveredTyParam<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { let Self { param, local_ty } = self; let mut diag = Diag::new(dcx, level, "") diff --git a/compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs b/compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs index e995d4fdf697b..fb1239e0e6ad0 100644 --- a/compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs +++ b/compiler/rustc_hir_analysis/src/diagnostics/wrong_number_of_generic_args.rs @@ -543,7 +543,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } /// Builds the `expected 1 type argument / supplied 2 type arguments` message. - fn notify(&self, err: &mut Diag<'_, G>) { + fn notify(&self, err: &mut Diag<'_>) { let (quantifier, bound) = self.get_quantifier_and_bound(); let provided_args = self.num_provided_args(); @@ -595,7 +595,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } } - fn suggest(&self, err: &mut Diag<'_, G>) { + fn suggest(&self, err: &mut Diag<'_>) { debug!( "suggest(self.provided {:?}, self.gen_args.span(): {:?})", self.num_provided_args(), @@ -623,7 +623,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { /// ```text /// type Map = HashMap; /// ``` - fn suggest_adding_args(&self, err: &mut Diag<'_, G>) { + fn suggest_adding_args(&self, err: &mut Diag<'_>) { if self.gen_args.parenthesized != hir::GenericArgsParentheses::No { return; } @@ -650,7 +650,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } } - fn suggest_adding_lifetime_args(&self, err: &mut Diag<'_, G>) { + fn suggest_adding_lifetime_args(&self, err: &mut Diag<'_>) { debug!("suggest_adding_lifetime_args(path_segment: {:?})", self.path_segment); let num_missing_args = self.num_missing_lifetime_args(); let num_params_to_take = num_missing_args; @@ -704,7 +704,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } } - fn suggest_adding_type_and_const_args(&self, err: &mut Diag<'_, G>) { + fn suggest_adding_type_and_const_args(&self, err: &mut Diag<'_>) { let num_missing_args = self.num_missing_type_or_const_args(); let msg = format!("add missing {} argument{}", self.kind(), pluralize!(num_missing_args)); @@ -764,7 +764,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { /// ```compile_fail /// Into::into::>(42) // suggests considering `Into::>::into(42)` /// ``` - fn suggest_moving_args_from_assoc_fn_to_trait(&self, err: &mut Diag<'_, G>) { + fn suggest_moving_args_from_assoc_fn_to_trait(&self, err: &mut Diag<'_>) { let Some(trait_) = self.tcx.trait_of_assoc(self.def_id) else { return; }; @@ -817,9 +817,9 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } } - fn suggest_moving_args_from_assoc_fn_to_trait_for_qualified_path( + fn suggest_moving_args_from_assoc_fn_to_trait_for_qualified_path( &self, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, qpath: &'tcx hir::QPath<'tcx>, msg: String, num_assoc_fn_excess_args: usize, @@ -848,9 +848,9 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } } - fn suggest_moving_args_from_assoc_fn_to_trait_for_method_call( + fn suggest_moving_args_from_assoc_fn_to_trait_for_method_call( &self, - err: &mut Diag<'_, G>, + err: &mut Diag<'_>, trait_def_id: DefId, expr: &'tcx hir::Expr<'tcx>, msg: String, @@ -904,7 +904,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { /// ```text /// type Map = HashMap; /// ``` - fn suggest_removing_args_or_generics(&self, err: &mut Diag<'_, G>) { + fn suggest_removing_args_or_generics(&self, err: &mut Diag<'_>) { let num_provided_lt_args = self.num_provided_lifetime_args(); let num_provided_type_const_args = self.num_provided_type_or_const_args(); let unbound_assoc_items = self.get_unbound_associated_item(); @@ -920,7 +920,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { let remove_entire_generics = num_redundant_args >= self.gen_args.args.len(); - let remove_lifetime_args = |err: &mut Diag<'_, _>| { + let remove_lifetime_args = |err: &mut Diag<'_>| { let mut lt_arg_spans = Vec::new(); let mut found_redundant = false; for arg in self.gen_args.args { @@ -963,7 +963,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { ); }; - let remove_type_or_const_args = |err: &mut Diag<'_, _>| { + let remove_type_or_const_args = |err: &mut Diag<'_>| { let mut gen_arg_spans = Vec::new(); let mut found_redundant = false; for arg in self.gen_args.args { @@ -1096,7 +1096,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } /// Builds the `type defined here` message. - fn show_definition(&self, err: &mut Diag<'_, G>) { + fn show_definition(&self, err: &mut Diag<'_>) { let Some(def_span) = self.tcx.def_ident_span(self.def_id) else { return }; if !self.tcx.sess.source_map().is_span_accessible(def_span) { return; @@ -1143,7 +1143,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } /// Add note if `impl Trait` is explicitly specified. - fn note_synth_provided(&self, err: &mut Diag<'_, G>) { + fn note_synth_provided(&self, err: &mut Diag<'_>) { if !self.is_synth_provided() { return; } @@ -1152,12 +1152,12 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { } } -impl<'a, G> Diagnostic<'a, G> for WrongNumberOfGenericArgs<'_, '_> { +impl<'a> Diagnostic<'a> for WrongNumberOfGenericArgs<'_, '_> { fn into_diag( self, dcx: rustc_errors::DiagCtxtHandle<'a>, level: rustc_errors::Level, - ) -> Diag<'a, G> { + ) -> Diag<'a> { let msg = self.create_error_message(); let mut err = Diag::new(dcx, level, msg); err.code(E0107); diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs index 7f0c6910cc425..011ca64b7f32a 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs @@ -564,7 +564,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { constraint.span, "use of trait associated const not defined as `#[rustc_always_gca]`", ); - return Err(err.emit()); + return Err(err.emit_err()); } else { let err = self.dcx().span_delayed_bug( constraint.span, diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs index beacb3f188cd9..c8ed17d169577 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_trait.rs @@ -138,7 +138,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { trait_pred.def_id(), &violations, ) - .emit(); + .emit_err(); return Ty::new_error(tcx, reported); } } @@ -578,8 +578,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { this: &'a dyn HirTyLowerer<'tcx>, } - impl<'a, 'b, 'tcx> Diagnostic<'a, ()> for TraitObjectWithoutDyn<'b, 'tcx> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a, 'b, 'tcx> Diagnostic<'a> for TraitObjectWithoutDyn<'b, 'tcx> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { span, hir_id, sugg, this } = self; let mut lint = Diag::new(dcx, level, "trait objects without an explicit `dyn` are deprecated"); @@ -665,7 +665,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { s1.append(s2); sugg.cancel(); } - Some(diag.emit()) + Some(diag.emit_err()) } else { tcx.emit_node_span_lint( BARE_TRAIT_OBJECTS, @@ -739,11 +739,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { } /// Make sure that we are in the condition to suggest the blanket implementation. - fn maybe_suggest_blanket_trait_impl( + fn maybe_suggest_blanket_trait_impl( &self, span: Span, hir_id: hir::HirId, - diag: &mut Diag<'_, G>, + diag: &mut Diag<'_>, ) { let tcx = self.tcx(); let parent_id = tcx.hir_get_parent_item(hir_id).def_id; diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs index 5d4770e1fc7de..f2cf4743d76b6 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs @@ -314,7 +314,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { Applicability::MaybeIncorrect, ); } - return err.emit(); + return err.emit_err(); } } return self.dcx().emit_err(err); @@ -534,7 +534,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { where_bounds.join(",\n"), )); } - err.emit() + err.emit_err() } pub(crate) fn report_missing_self_ty_for_resolved_path( @@ -681,7 +681,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { err.span_label(sp, format!("variant `{ident}` not found here")); } - err.emit() + err.emit_err() } else if let Err(reported) = self_ty.error_reported() { reported } else { @@ -813,7 +813,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { } } } - err.emit() + err.emit_err() } pub(crate) fn report_ambiguous_inherent_assoc_item( @@ -830,7 +830,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { ); err.span_label(name.span, format!("multiple `{name}` found")); self.note_ambiguous_inherent_assoc_item(&mut err, candidates, span); - err.emit() + err.emit_err() } // FIXME(fmease): Heavily adapted from `rustc_hir_typeck::method::suggest`. Deduplicate. @@ -940,7 +940,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { "the associated {assoc_tag_str} was found for\n{type_candidates}{additional_types}", )); add_def_label(&mut err); - return err.emit(); + return err.emit_err(); } let mut bound_spans: SortedMap> = Default::default(); @@ -1048,7 +1048,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { err.span_label(span, msg); } add_def_label(&mut err); - err.emit() + err.emit_err() } /// If there are any missing associated items, emit an error instructing the user to provide @@ -1100,7 +1100,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { trait_ref.def_id(), &violations, ) - .emit()); + .emit_err()); } names.entry(trait_ref).or_default().push(assoc_item.name()); @@ -1340,7 +1340,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { } } - Err(err.emit()) + Err(err.emit_err()) } /// On ambiguous associated type, look for an associated function whose name matches the @@ -1392,7 +1392,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { name, Applicability::MaybeIncorrect, ) - .emit()) + .emit_err()) } else { Ok(()) } @@ -1477,7 +1477,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { err.span_label(span, format!("not allowed on {what}")); } generics_args_err_extend(self.tcx(), segments.into_iter(), &mut err, err_extend); - err.emit() + err.emit_err() } pub fn report_trait_object_addition_traits( @@ -1520,7 +1520,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { for more information on them, visit \ ", ); - err.emit() + err.emit_err() } pub fn report_trait_object_with_no_traits( @@ -1715,7 +1715,7 @@ pub fn prohibit_assoc_item_constraint( } } - err.emit() + err.emit_err() } pub(crate) fn fn_trait_to_string( @@ -2004,12 +2004,12 @@ pub(super) struct AmbiguityBetweenVariantAndAssocItem<'tcx> { pub(super) mode: super::LowerTypeRelativePathMode, } -impl<'a, 'tcx> rustc_errors::Diagnostic<'a, ()> for AmbiguityBetweenVariantAndAssocItem<'tcx> { +impl<'a, 'tcx> rustc_errors::Diagnostic<'a> for AmbiguityBetweenVariantAndAssocItem<'tcx> { fn into_diag( self, dcx: rustc_errors::DiagCtxtHandle<'a>, level: rustc_errors::Level, - ) -> Diag<'a, ()> { + ) -> Diag<'a> { let Self { variant_def_id, item_def_id, diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs index 4a35bcb5ef28f..25a17abdbf61c 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/generics.rs @@ -70,7 +70,7 @@ fn generic_arg_mismatch_err( add_braces_suggestion(arg, &mut err); return err .with_primary_message("unresolved item provided when a constant was expected") - .emit(); + .emit_err(); } Res::Def(DefKind::TyParam, src_def_id) => { if let Some(param_local_id) = param.def_id.as_local() { @@ -145,7 +145,7 @@ fn generic_arg_mismatch_err( } } - err.emit() + err.emit_err() } /// Lower generic arguments from the HIR to the [`rustc_middle::ty`] representation. @@ -606,7 +606,7 @@ pub(crate) fn check_generic_arg_count( gen_args, def_id, )) - .emit_unless_delay(all_params_are_binded || has_invalid_bound) + .emit_err_unless_delay(all_params_are_binded || has_invalid_bound) }); Err(reported) @@ -655,8 +655,8 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes( msg: &'static str, } - impl<'a> Diagnostic<'a, ()> for LifetimeArgsIssue { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a> Diagnostic<'a> for LifetimeArgsIssue { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { msg } = self; Diag::new(dcx, level, msg) } diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs index c66416802f0ea..6bb1c4d04e065 100644 --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs @@ -452,7 +452,7 @@ impl<'tcx> ForbidParamUsesFolder<'tcx> { diag.help("alternatively, you can use `#![feature(generic_const_args)]` and extract the expression into a `type const` item"); } } - diag.emit() + diag.emit_err() } } @@ -1718,7 +1718,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { span, "inherent associated types are unstable", ) - .emit()); + .emit_err()); } ty::AssocTag::Fn => unreachable!(), } @@ -2767,7 +2767,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { format!("`{}` does not have this field", variant_def.name), ); } - return ty::Const::new_error(tcx, err.emit()); + return ty::Const::new_error(tcx, err.emit_err()); } } @@ -2977,7 +2977,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { let guar = self .dcx() .struct_span_err(span, "function items cannot be used as const args") - .emit(); + .emit_err(); Const::new_error(tcx, guar) } // Exhaustive match to be clear about what exactly we're considering to be @@ -3168,7 +3168,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { "only consts with a `direct_const_arg!` right-hand side may be used in types", ); } - Err(err.emit()) + Err(err.emit_err()) } } @@ -3501,7 +3501,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { field.span.shrink_to_lo(), "you might be missing a variant here: `Variant.`", ) - .emit(); + .emit_err(); return Ty::new_error(tcx, err); }; diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check.rs b/compiler/rustc_hir_analysis/src/impl_wf_check.rs index e1a91292abe21..4615f1ae4fe58 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check.rs @@ -179,7 +179,7 @@ pub(crate) fn enforce_impl_lifetime_params_are_constrained( } } suggest_to_remove_or_use_generic(tcx, &mut diag, impl_def_id, param, true); - res = Err(diag.emit()); + res = Err(diag.emit_err()); } } ty::GenericParamDefKind::Type { .. } | ty::GenericParamDefKind::Const { .. } => { @@ -245,7 +245,7 @@ pub(crate) fn enforce_impl_non_lifetime_params_are_constrained( }); diag.code(E0207); suggest_to_remove_or_use_generic(tcx, &mut diag, impl_def_id, ¶m, false); - res = Err(diag.emit()); + res = Err(diag.emit_err()); } } res diff --git a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs index d56c094f9f5c3..fdc6357bb9bbe 100644 --- a/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs +++ b/compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs @@ -281,7 +281,7 @@ fn check_duplicate_params<'tcx>( return Err(tcx .dcx() .struct_span_err(span, format!("specializing impl repeats parameter `{param}`")) - .emit()); + .emit_err()); } Ok(()) } @@ -430,7 +430,7 @@ fn check_specialization_on<'tcx>( tcx.def_path_str(trait_ref.def_id), ), ) - .emit()) + .emit_err()) } } ty::ClauseKind::Projection(ty::ProjectionClause { projection_term, term }) => Err(tcx @@ -439,7 +439,7 @@ fn check_specialization_on<'tcx>( span, format!("cannot specialize on associated type `{projection_term} == {term}`",), ) - .emit()), + .emit_err()), ty::ClauseKind::ConstArgHasType(..) => { // FIXME(min_specialization), FIXME(const_generics): // It probably isn't right to allow _every_ `ConstArgHasType` but I am somewhat unsure @@ -454,7 +454,7 @@ fn check_specialization_on<'tcx>( _ => Err(tcx .dcx() .struct_span_err(span, format!("cannot specialize on predicate `{clause}`")) - .emit()), + .emit_err()), } } diff --git a/compiler/rustc_hir_typeck/src/callee.rs b/compiler/rustc_hir_typeck/src/callee.rs index 8a919ede26605..a539898b8fced 100644 --- a/compiler/rustc_hir_typeck/src/callee.rs +++ b/compiler/rustc_hir_typeck/src/callee.rs @@ -127,7 +127,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty: autoderef.final_ty(), }); err.span_label(callee_expr.span, "you can create scalable vectors using intrinsics"); - Ty::new_error(self.tcx, err.emit()); + Ty::new_error(self.tcx, err.emit_err()); } self.register_predicates(autoderef.into_obligations()); @@ -1069,7 +1069,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { err.span_label(span, label); } } - err.emit() + err.emit_err() } fn confirm_deferred_closure_call( diff --git a/compiler/rustc_hir_typeck/src/cast.rs b/compiler/rustc_hir_typeck/src/cast.rs index a82290d395de3..02e6b8188a876 100644 --- a/compiler/rustc_hir_typeck/src/cast.rs +++ b/compiler/rustc_hir_typeck/src/cast.rs @@ -733,7 +733,7 @@ impl<'a, 'tcx> CastCheck<'tcx> { err.span_help(self.expr_span, "consider using a box or reference as appropriate"); } } - err.emit() + err.emit_err() } fn trivial_cast_lint(&self, fcx: &FnCtxt<'a, 'tcx>) { diff --git a/compiler/rustc_hir_typeck/src/closure.rs b/compiler/rustc_hir_typeck/src/closure.rs index 22349259b32a6..4a494fda7ca80 100644 --- a/compiler/rustc_hir_typeck/src/closure.rs +++ b/compiler/rustc_hir_typeck/src/closure.rs @@ -778,7 +778,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { true, closure_arg_span, ) - .emit(); + .emit_err(); let error_sig = self.error_sig_of_closure(decl, guar); diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index 8a4228ebe3124..c13e68fea210d 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -1913,9 +1913,9 @@ impl<'tcx> CoerceMany<'tcx> { ); } - let reported = err.emit_unless_delay(unsized_return); + let guar = err.emit_err_unless_delay(unsized_return); - self.final_ty = Some(Ty::new_error(fcx.tcx, reported)); + self.final_ty = Some(Ty::new_error(fcx.tcx, guar)); } } } diff --git a/compiler/rustc_hir_typeck/src/diagnostics.rs b/compiler/rustc_hir_typeck/src/diagnostics.rs index 3b7de7790ac02..4885b31ead454 100644 --- a/compiler/rustc_hir_typeck/src/diagnostics.rs +++ b/compiler/rustc_hir_typeck/src/diagnostics.rs @@ -275,7 +275,7 @@ pub(crate) struct SuggestAnnotations { pub suggestions: Vec, } impl Subdiagnostic for SuggestAnnotations { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { if self.suggestions.is_empty() { return; } @@ -338,7 +338,7 @@ pub(crate) struct TypeMismatchFruTypo { } impl Subdiagnostic for TypeMismatchFruTypo { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { diag.arg("expr", self.expr.as_deref().unwrap_or("NONE")); // Only explain that `a ..b` is a range if it's split up @@ -561,7 +561,7 @@ pub(crate) struct RemoveSemiForCoerce { } impl Subdiagnostic for RemoveSemiForCoerce { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { let mut multispan: MultiSpan = self.semi.into(); multispan.push_span_label( self.expr, @@ -704,9 +704,9 @@ pub(crate) struct BreakNonLoop<'a> { pub break_expr_span: Span, } -impl<'a, G> Diagnostic<'_, G> for BreakNonLoop<'a> { +impl<'a> Diagnostic<'_> for BreakNonLoop<'a> { #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { let mut diag = Diag::new(dcx, level, msg!("`break` with value from a `{$kind}` loop")); diag.span(self.span); diag.code(E0571); @@ -906,7 +906,7 @@ pub(crate) enum CastUnknownPointerSub { } impl rustc_errors::Subdiagnostic for CastUnknownPointerSub { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { match self { CastUnknownPointerSub::To(span) => { let msg = msg!("needs more type information"); @@ -1202,9 +1202,9 @@ pub(crate) struct NakedFunctionsAsmBlock { pub non_asms: Vec, } -impl Diagnostic<'_, G> for NakedFunctionsAsmBlock { +impl Diagnostic<'_> for NakedFunctionsAsmBlock { #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { let mut diag = Diag::new( dcx, level, diff --git a/compiler/rustc_hir_typeck/src/expr.rs b/compiler/rustc_hir_typeck/src/expr.rs index 92122c38e4ed3..2935641058b20 100644 --- a/compiler/rustc_hir_typeck/src/expr.rs +++ b/compiler/rustc_hir_typeck/src/expr.rs @@ -439,7 +439,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .may_apply() }) }); - Ty::new_error(tcx, err.emit()) + Ty::new_error(tcx, err.emit_err()) }), hir::UnOp::Not => { let result = self.check_user_unop(expr, oprnd_t, unop, expected_inner); @@ -1399,7 +1399,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // If the assignment expression itself is ill-formed, don't // bother emitting another error - err.emit_unless_delay(lhs_ty.references_error() || rhs_ty.references_error()) + err.emit_err_unless_delay(lhs_ty.references_error() || rhs_ty.references_error()) } pub(super) fn check_expr_let( @@ -1619,7 +1619,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ), ) .with_note("unsafe binders are the only valid output of wrap") - .emit(); + .emit_err(); Ty::new_error(self.tcx, guar) } }; @@ -1657,7 +1657,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ), ) .with_note("only an unsafe binder type can be unwrapped") - .emit(); + .emit_err(); Ty::new_error(self.tcx, guar) } } @@ -2699,7 +2699,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }; } } - err.emit() + err.emit_err() } fn available_field_names( @@ -2929,7 +2929,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); } } - err.emit() + err.emit_err() }; Ty::new_error(self.tcx(), guar) @@ -3040,7 +3040,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { HelpUseLatestEdition::new().add_to_diag(&mut err); } - err.emit() + err.emit_err() } fn ban_private_field_access( @@ -3066,7 +3066,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { None, ); } - err.emit() + err.emit_err() } fn ban_take_value_of_method( @@ -3523,8 +3523,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); } - let reported = err.emit(); - Ty::new_error(self.tcx, reported) + let guar = err.emit_err(); + Ty::new_error(self.tcx, guar) } } } @@ -3834,7 +3834,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.dcx() .create_err(NoVariantNamed { span: ident.span, ident, ty: container }) .with_span_label(field.span, "variant not found") - .emit_unless_delay(container.references_error()); + .emit_err_unless_delay(container.references_error()); break; }; let Some(&subfield) = fields.next() else { @@ -3866,7 +3866,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { enum_span: field.span, field_span: subident.span, }) - .emit_unless_delay(container.references_error()); + .emit_err_unless_delay(container.references_error()); break; }; diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index b9f3e2479a903..15383cd8a2a53 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -57,8 +57,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { custom_note: Option<&'b str>, } - impl<'a, 'b, 'c> Diagnostic<'a, ()> for UnreachableItem<'b, 'c> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a, 'b, 'c> Diagnostic<'a> for UnreachableItem<'b, 'c> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { kind, span, orig_span, custom_note } = self; let msg = format!("unreachable {kind}"); Diag::new(dcx, level, msg.clone()).with_span_label(span, msg).with_span_label( @@ -1301,8 +1301,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } } - let reported = err.emit(); - return (Ty::new_error(tcx, reported), res); + let guar = err.emit_err(); + return (Ty::new_error(tcx, guar), res); } } } else { @@ -1563,7 +1563,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { TypeAnnotationNeeded::E0282, true, ) - .emit() + .emit_err() }); let err = Ty::new_error(self.tcx, guar); self.demand_suptype(sp, err, ty); @@ -1589,7 +1589,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { TypeAnnotationNeeded::E0282, true, ) - .emit() + .emit_err() }); // FIXME: Infer `?ct = {const error}`? ty::Const::new_error(self.tcx, e) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs index 9965a9d071031..789d06722f897 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs @@ -693,7 +693,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { must be a tuple or unit type: {:?}", type_errors, ) - .emit(); + .emit_err(); Ty::new_error(self.tcx, guar) } } else { @@ -758,7 +758,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { "cannot use call notation; the first type parameter \ for the function trait is neither a tuple nor unit" ) - .emit(); + .emit_err(); Some(guar) } else if tuple_arguments.is_splatted() { @@ -789,7 +789,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) .kind(), ) - .emit(); + .emit_err(); Some(guar) } else if formal_input_tys.len() != provided_args.len() { @@ -803,7 +803,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { provided_args.len(), if provided_args.len() == 1 { "was" } else { "were" }, ) - .emit(); + .emit_err(); Some(guar) } else { @@ -978,7 +978,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); } - err.emit() + err.emit_err() } fn suggest_ptr_null_mut( @@ -1123,7 +1123,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty.normalized.sort_string(self.tcx) ) .with_span_label(path_span, "not a struct") - .emit(), + .emit_err(), }) } } @@ -2363,7 +2363,7 @@ impl<'a, 'tcx> FnCallDiagCtxt<'a, 'tcx> { self.tuple_arguments, ); self.suggest_confusable(&mut err); - Some(err.emit()) + Some(err.emit_err()) } else { None } @@ -2384,7 +2384,7 @@ impl<'a, 'tcx> FnCallDiagCtxt<'a, 'tcx> { span: self.call_metadata.error_span, }); self.arg_matching_ctxt.suggest_confusable(&mut err); - return Some(err.emit()); + return Some(err.emit_err()); } } @@ -2440,7 +2440,7 @@ impl<'a, 'tcx> FnCallDiagCtxt<'a, 'tcx> { *e, ); self.arg_matching_ctxt.suggest_confusable(&mut err); - reported = Some(err.emit()); + reported = Some(err.emit_err()); return false; } true @@ -2522,7 +2522,7 @@ impl<'a, 'tcx> FnCallDiagCtxt<'a, 'tcx> { ); self.arg_matching_ctxt.suggest_confusable(&mut err); self.detect_dotdot(&mut err, provided_ty, self.provided_args[provided_idx]); - return Some(err.emit()); + return Some(err.emit_err()); } None diff --git a/compiler/rustc_hir_typeck/src/inline_asm.rs b/compiler/rustc_hir_typeck/src/inline_asm.rs index 2b1d9ed038b87..6470e45b3bb3a 100644 --- a/compiler/rustc_hir_typeck/src/inline_asm.rs +++ b/compiler/rustc_hir_typeck/src/inline_asm.rs @@ -207,8 +207,8 @@ impl<'a, 'tcx> InlineAsmCtxt<'a, 'tcx> { default_size: InlineAsmSize, } - impl<'a, 'b> Diagnostic<'a, ()> for FormattingSubRegisterArg<'b> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a, 'b> Diagnostic<'a> for FormattingSubRegisterArg<'b> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { expr_span, idx, diff --git a/compiler/rustc_hir_typeck/src/intrinsicck.rs b/compiler/rustc_hir_typeck/src/intrinsicck.rs index 2e52517de07d1..d2432a7e39af6 100644 --- a/compiler/rustc_hir_typeck/src/intrinsicck.rs +++ b/compiler/rustc_hir_typeck/src/intrinsicck.rs @@ -126,11 +126,11 @@ fn check_transmute<'tcx>( ); if from == to { err.note(format!("`{from}` does not have a fixed size")); - Err(err.emit()) + Err(err.emit_err()) } else { err.note(format!("source type: `{}` ({})", from, skeleton_string(from, sk_from))); err.note(format!("target type: `{}` ({})", to, skeleton_string(to, sk_to))); - Err(err.emit()) + Err(err.emit_err()) } } @@ -144,15 +144,15 @@ fn check_offload<'tcx>( ) -> Result<(), ErrorGuaranteed> { let span = tcx.hir_span(hir_id); let ty::FnDef(kernel_def_id, kernel_args) = *kernel_ty.kind() else { - let err = tcx + let guar = tcx .sess .dcx() .struct_span_err( span, format!("expected a function item for the offload kernel, found `{}`", kernel_ty), ) - .emit(); - return Err(err); + .emit_err(); + return Err(guar); }; let kernel_sig = @@ -160,19 +160,19 @@ fn check_offload<'tcx>( let kernel_sig = tcx.instantiate_bound_regions_with_erased(kernel_sig); let ty::Tuple(tuple_fields) = *args_ty.kind() else { - let err = tcx + let guar = tcx .sess .dcx() .struct_span_err( span, format!("expected a tuple for the offload arguments, found `{}`", args_ty), ) - .emit(); - return Err(err); + .emit_err(); + return Err(guar); }; if kernel_sig.inputs().len() != tuple_fields.len() { - let err = tcx + let guar = tcx .sess .dcx() .struct_span_err( @@ -183,8 +183,8 @@ fn check_offload<'tcx>( tuple_fields.len() ), ) - .emit(); - return Err(err); + .emit_err(); + return Err(guar); } let normalize = |ty| { @@ -206,7 +206,7 @@ fn check_offload<'tcx>( let norm_input_ty = normalize(input_ty); let norm_arg_ty = normalize(arg_ty); if norm_input_ty != norm_arg_ty { - let err = tcx + let guar = tcx .sess .dcx() .struct_span_err( @@ -216,22 +216,22 @@ fn check_offload<'tcx>( i, norm_input_ty, norm_arg_ty ), ) - .emit(); - result = Err(err); + .emit_err(); + result = Err(guar); } } let norm_kernel_ret = normalize(kernel_sig.output()); let norm_offload_ret = normalize(ret_ty); if norm_kernel_ret != norm_offload_ret { - let err = tcx.sess.dcx().struct_span_err( + let guar = tcx.sess.dcx().struct_span_err( span, format!( "offload kernel return type mismatch: kernel returns `{}`, but offload call expects `{}`", norm_kernel_ret, norm_offload_ret ) - ).emit(); - result = Err(err); + ).emit_err(); + result = Err(guar); } result diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs index dd3b5d4429975..474a390171514 100644 --- a/compiler/rustc_hir_typeck/src/lib.rs +++ b/compiler/rustc_hir_typeck/src/lib.rs @@ -607,7 +607,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } _ => err.with_span_label(span, format!("not a {expected}")), } - .emit() + .emit_err() } } @@ -714,7 +714,7 @@ fn fatally_break_rust(tcx: TyCtxt<'_>, span: Span) -> ! { diag.note("some of the compiler flags provided by cargo are hidden"); } } - diag.emit() + diag.emit_bug() } /// Adds query implementations to the [Providers] vtable, see [`rustc_middle::query`] diff --git a/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs b/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs index d961fdc0885b7..4587e9726a9d7 100644 --- a/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs +++ b/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs @@ -24,8 +24,8 @@ struct AmbiguousTraitMethodCall<'a, 'tcx> { edition: &'static str, } -impl<'a, 'b, 'tcx> Diagnostic<'a, ()> for AmbiguousTraitMethodCall<'b, 'tcx> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a, 'b, 'tcx> Diagnostic<'a> for AmbiguousTraitMethodCall<'b, 'tcx> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { segment_name, self_expr_span, pick, tcx, edition } = self; let mut lint = Diag::new( dcx, @@ -91,8 +91,8 @@ struct AmbiguousTraitMethod<'a, 'tcx, 'fnctx> { this: &'a FnCtxt<'fnctx, 'tcx>, } -impl<'a, 'c, 'tcx, 'fnctx> Diagnostic<'a, ()> for AmbiguousTraitMethod<'c, 'tcx, 'fnctx> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a, 'c, 'tcx, 'fnctx> Diagnostic<'a> for AmbiguousTraitMethod<'c, 'tcx, 'fnctx> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { segment, call_expr, self_expr, pick, args, edition, span, this } = self; let mut lint = Diag::new( dcx, @@ -289,8 +289,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self_ty: Ty<'tcx>, } - impl<'a, 'b, 'fnctx, 'tcx> Diagnostic<'a, ()> for AmbiguousTraitAssocFunc<'b, 'fnctx, 'tcx> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a, 'b, 'fnctx, 'tcx> Diagnostic<'a> for AmbiguousTraitAssocFunc<'b, 'fnctx, 'tcx> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { method_name, this, pick, span, expr_id, self_ty_span, self_ty } = self; let mut lint = Diag::new( dcx, diff --git a/compiler/rustc_hir_typeck/src/method/probe.rs b/compiler/rustc_hir_typeck/src/method/probe.rs index 79b8ef15d7e13..58e482adff190 100644 --- a/compiler/rustc_hir_typeck/src/method/probe.rs +++ b/compiler/rustc_hir_typeck/src/method/probe.rs @@ -555,7 +555,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if raw_ptr_call { err.span_label(span, "cannot call a method on a raw pointer with an unknown pointee type"); } - err.emit() + err.emit_err() } ty::Error(guar) => guar, _ => bug!("unexpected bad final type in method autoderef"), @@ -1876,8 +1876,8 @@ impl<'tcx> Pick<'tcx> { span: Span, } - impl<'a, 'b, 'tcx> Diagnostic<'a, ()> for ItemMaybeBeAddedToStd<'b, 'tcx> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a, 'b, 'tcx> Diagnostic<'a> for ItemMaybeBeAddedToStd<'b, 'tcx> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { this, tcx, span } = self; let def_kind = this.item.as_def_kind(); let mut lint = Diag::new( diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index aebfeac2e7e85..e074ebf01bda4 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -352,7 +352,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &mut sources, Some(expr_span), ); - err.emit() + err.emit_err() } MethodError::PrivateMatch(kind, def_id, out_of_scope_traits) => { @@ -374,7 +374,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } self.suggest_valid_traits(&mut err, item_name, out_of_scope_traits, true); self.suggest_unwrapping_inner_self(&mut err, source, rcvr_ty, item_name); - err.emit() + err.emit_err() } MethodError::IllegalSizedBound { candidates, needs_mut, bound_span, self_expr } => { @@ -471,7 +471,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } } - err.emit() + err.emit_err() } MethodError::ErrorReported(guar) => guar, @@ -1360,7 +1360,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &static_candidates, ) else { - return err.emit(); + return err.emit_err(); }; let similar_candidate = no_match_data.similar_candidate; @@ -1438,7 +1438,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.note_derefed_ty_has_method(&mut err, source, rcvr_ty, item_ident, expected); self.suggest_bounds_for_range_to_method(&mut err, source, item_ident); - err.emit() + err.emit_err() } fn set_not_found_span_label( @@ -3123,7 +3123,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } _ => {} } - return Err(err.emit()); + return Err(err.emit_err()); } Ok(()) } diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs index c5d082fba8016..48a0ec756d8d9 100644 --- a/compiler/rustc_hir_typeck/src/op.rs +++ b/compiler/rustc_hir_typeck/src/op.rs @@ -557,7 +557,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &mut err, ); - Ty::new_error(self.tcx, err.emit()) + Ty::new_error(self.tcx, err.emit_err()) } fn suggest_deref_or_call_for_binop_error( @@ -1060,7 +1060,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } } - err.emit() + err.emit_err() }); Ty::new_error(self.tcx, guar) } diff --git a/compiler/rustc_hir_typeck/src/opaque_types.rs b/compiler/rustc_hir_typeck/src/opaque_types.rs index 2fc2c0d80a255..c96144d849944 100644 --- a/compiler/rustc_hir_typeck/src/opaque_types.rs +++ b/compiler/rustc_hir_typeck/src/opaque_types.rs @@ -202,7 +202,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> { // hint that the ambiguity is in an opaque's hidden type rather than an // ordinary local inference failure. .with_note("cannot infer type of hidden type of opaque") - .emit() + .emit_err() } } }; diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index a017b0dfcb507..cb1e66b710c79 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -156,7 +156,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { actual: Ty<'tcx>, ti: &TopInfo<'tcx>, ) -> Result<(), ErrorGuaranteed> { - self.demand_eqtype_pat_diag(cause_span, expected, actual, ti).map_err(|err| err.emit()) + self.demand_eqtype_pat_diag(cause_span, expected, actual, ti).map_err(|err| err.emit_err()) } } @@ -1143,7 +1143,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { type between two end-points, you can use a guard.", ); } - err.emit() + err.emit_err() } fn check_pat_ident( @@ -1493,7 +1493,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { if self.tcx.sess.teach(err.code.unwrap()) { err.note(CANNOT_IMPLICITLY_DEREF_POINTER_TRAIT_OBJ); } - return Err(err.emit()); + return Err(err.emit_err()); } Ok(()) } @@ -2028,7 +2028,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - err.emit() + err.emit_err() } fn check_pat_tuple( @@ -2198,7 +2198,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Err(e) } else { i.emit(); - Err(u.emit()) + Err(u.emit_err()) } } (None, Some(u)) => { @@ -2206,10 +2206,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { u.delay_as_bug(); Err(e) } else { - Err(u.emit()) + Err(u.emit_err()) } } - (Some(err), None) => Err(err.emit()), + (Some(err), None) => Err(err.emit_err()), (None, None) => { self.error_tuple_variant_index_shorthand(variant, pat, fields)?; result @@ -2244,7 +2244,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { format!("({})", self.get_suggested_tuple_struct_pattern(fields, variant)), Applicability::MaybeIncorrect, ); - return Err(err.emit()); + return Err(err.emit_err()); } } Ok(()) @@ -2287,7 +2287,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ) .with_span_label(span, format!("multiple uses of `{ident}` in pattern")) .with_span_label(other_field, format!("first use of `{ident}`")) - .emit() + .emit_err() } fn error_inexistent_fields( @@ -2441,7 +2441,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { format!("({sugg})"), appl, ); - return Err(err.emit()); + return Err(err.emit_err()); } Ok(()) } @@ -2550,8 +2550,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ty: Ty<'tcx>, } - impl<'a, 'b, 'c, 'tcx> Diagnostic<'a, ()> for FieldsNotListed<'b, 'c, 'tcx> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a, 'b, 'c, 'tcx> Diagnostic<'a> for FieldsNotListed<'b, 'c, 'tcx> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { pat_span, unmentioned_fields, joined_patterns, ty } = self; Diag::new(dcx, level, "some fields are not explicitly listed") .with_span_label(pat_span, format!("field{} {} not listed", rustc_errors::pluralize!(unmentioned_fields.len()), joined_patterns)) @@ -2997,7 +2997,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } else { self.dcx().struct_span_err(pat.span, err_msg) }; - err.emit() + err.emit_err() } fn try_resolve_slice_ty_to_array_ty( @@ -3194,7 +3194,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { size, ) .with_span_label(span, format!("expected {} element{}", size, pluralize!(size))) - .emit() + .emit_err() } fn error_scrutinee_with_rest_inconsistent_length( @@ -3216,7 +3216,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { span, format!("pattern cannot match array of {} element{}", size, pluralize!(size),), ) - .emit() + .emit_err() } fn error_scrutinee_unfixed_length(&self, span: Span) -> ErrorGuaranteed { @@ -3226,7 +3226,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { E0730, "cannot pattern-match on an array without a fixed length", ) - .emit() + .emit_err() } fn error_expected_array_or_slice( diff --git a/compiler/rustc_hir_typeck/src/place_op.rs b/compiler/rustc_hir_typeck/src/place_op.rs index 42ca305d3e00d..f3cba3a27d69f 100644 --- a/compiler/rustc_hir_typeck/src/place_op.rs +++ b/compiler/rustc_hir_typeck/src/place_op.rs @@ -92,8 +92,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { Applicability::MachineApplicable, ); } - let reported = err.emit(); - Some((Ty::new_error(self.tcx, reported), Ty::new_error(self.tcx, reported))) + let guar = err.emit_err(); + Some((Ty::new_error(self.tcx, guar), Ty::new_error(self.tcx, guar))) } /// To type-check `base_expr[index_expr]`, we progressively autoderef diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index 875517ee4c87e..0443d48c597f1 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -1085,8 +1085,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { migration_message: String, } - impl<'a, 'b, 'tcx> Diagnostic<'a, ()> for MigrationLint<'b, 'tcx> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + impl<'a, 'b, 'tcx> Diagnostic<'a> for MigrationLint<'b, 'tcx> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { closure_def_id, closure_drop_location_span, diff --git a/compiler/rustc_hir_typeck/src/writeback.rs b/compiler/rustc_hir_typeck/src/writeback.rs index f4fe38924351a..5ae65ad26f916 100644 --- a/compiler/rustc_hir_typeck/src/writeback.rs +++ b/compiler/rustc_hir_typeck/src/writeback.rs @@ -619,7 +619,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { guar } else { let (Ok(guar) | Err(guar)) = - prev.build_mismatch_error(&hidden_type, tcx).map(|d| d.emit()); + prev.build_mismatch_error(&hidden_type, tcx).map(|d| d.emit_err()); guar }; *entry = DefinitionSiteHiddenType::new_error(tcx, guar); @@ -656,7 +656,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { .dcx() .struct_span_err(span, "cannot resolve opaque type") .with_code(E0720) - .emit(); + .emit_err(); self.typeck_results .hidden_types .insert(def_id, DefinitionSiteHiddenType::new_error(tcx, guar)); @@ -947,7 +947,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> { TypeAnnotationNeeded::E0282, false, ) - .emit() + .emit_err() } } diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 1950a29661249..3e73bdbf5985f 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -135,7 +135,7 @@ pub(crate) fn parse_check_cfg(sess: &Session, specs: Vec) -> CheckCfg { sess.dcx().struct_fatal(format!("invalid `--check-cfg` argument: `{s}`")); diag.note($reason); diag.note(VISIT); - diag.emit() + diag.emit_fatal() }}; (in $arg:expr, $reason:expr) => {{ let mut diag = @@ -154,7 +154,7 @@ pub(crate) fn parse_check_cfg(sess: &Session, specs: Vec) -> CheckCfg { diag.note($reason); diag.note(VISIT); - diag.emit() + diag.emit_fatal() }}; } diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 2316e80b6e945..610eb5fd099d2 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -72,7 +72,7 @@ pub fn parse<'a>(sess: &'a Session) -> ast::Crate { parser.parse_crate_mod() }) .unwrap_or_else(|parse_error| { - let guar: ErrorGuaranteed = parse_error.emit(); + let guar: ErrorGuaranteed = parse_error.emit_err(); guar.raise_fatal(); }); @@ -1057,13 +1057,13 @@ pub fn create_and_enter_global_ctxt FnOnce(TyCtxt<'tcx>) -> T>( struct DiagCallback<'tcx> { callback: Box< - dyn for<'b> FnOnce(DiagCtxtHandle<'b>, Level, &dyn Any) -> Diag<'b, ()> + DynSend + DynSync, + dyn for<'b> FnOnce(DiagCtxtHandle<'b>, Level, &dyn Any) -> Diag<'b> + DynSend + DynSync, >, tcx: TyCtxt<'tcx>, } -impl<'a, 'tcx> Diagnostic<'a, ()> for DiagCallback<'tcx> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a, 'tcx> Diagnostic<'a> for DiagCallback<'tcx> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { (self.callback)(dcx, level, self.tcx.sess) } } diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 87b2bb94cd4f9..b6bfee02eed66 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -161,7 +161,7 @@ fn init_stack_size(early_dcx: &EarlyDiagCtxt) -> usize { r#"`RUST_MIN_STACK` should be a number of bytes, but was "{s}""#, )); err.note("you can also unset `RUST_MIN_STACK` to use the default stack size"); - err.emit() + err.emit_fatal() }) }) // otherwise pick a consistent default @@ -338,7 +338,7 @@ internal compiler error: query cycle handler thread panicked, aborting process"; diag.help( "try lowering `-Z threads` or checking the operating system's resource limits", ); - diag.emit() + diag.emit_fatal() }) }) }) diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 2d571d8b8e13d..795e0b9130907 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -195,7 +195,7 @@ impl UnsafeCode { &self, cx: &EarlyContext<'_>, span: Span, - decorate: impl for<'a> Diagnostic<'a, ()>, + decorate: impl for<'a> Diagnostic<'a>, ) { // This comes from a macro that has `#[allow_internal_unsafe]`. if span.allows_unsafe() { diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index bd8e059bf0f95..68b2e2a3b6e7b 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -521,7 +521,7 @@ pub trait LintContext { &self, lint: &'static Lint, span: Option, - decorate: impl for<'a> Diagnostic<'a, ()>, + decorate: impl for<'a> Diagnostic<'a>, ); /// Emit a lint at `span` from a lint struct (some type that implements `Diagnostic`, @@ -531,7 +531,7 @@ pub trait LintContext { &self, lint: &'static Lint, span: S, - decorator: impl for<'a> Diagnostic<'a, ()>, + decorator: impl for<'a> Diagnostic<'a>, ) { self.opt_span_lint(lint, Some(span), decorator); } @@ -595,7 +595,7 @@ impl<'tcx> LintContext for LateContext<'tcx> { &self, lint: &'static Lint, span: Option, - decorate: impl for<'a> Diagnostic<'a, ()>, + decorate: impl for<'a> Diagnostic<'a>, ) { let hir_id = self.last_node_with_lint_attrs; @@ -622,7 +622,7 @@ impl LintContext for EarlyContext<'_> { &self, lint: &'static Lint, span: Option, - decorator: impl for<'a> Diagnostic<'a, ()>, + decorator: impl for<'a> Diagnostic<'a>, ) { self.builder.opt_span_lint(lint, span.map(|s| s.into()), decorator) } diff --git a/compiler/rustc_lint/src/default_could_be_derived.rs b/compiler/rustc_lint/src/default_could_be_derived.rs index eba5efa25546b..6b20d6ffc41fe 100644 --- a/compiler/rustc_lint/src/default_could_be_derived.rs +++ b/compiler/rustc_lint/src/default_could_be_derived.rs @@ -164,8 +164,8 @@ struct WrongDefaultImpl<'a, 'tcx> { impl_span: Span, } -impl<'a, 'b, 'tcx> Diagnostic<'a, ()> for WrongDefaultImpl<'b, 'tcx> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a, 'b, 'tcx> Diagnostic<'a> for WrongDefaultImpl<'b, 'tcx> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { tcx, type_def_id, orig_fields, fields, impl_span } = self; let mut diag = Diag::new(dcx, level, "`Default` impl doesn't use the declared default field values"); diff --git a/compiler/rustc_lint/src/diagnostics.rs b/compiler/rustc_lint/src/diagnostics.rs index d96cadaca87eb..defb95e1f5fdc 100644 --- a/compiler/rustc_lint/src/diagnostics.rs +++ b/compiler/rustc_lint/src/diagnostics.rs @@ -42,7 +42,7 @@ pub(crate) enum OverruledAttributeSub { } impl Subdiagnostic for OverruledAttributeSub { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { match self { OverruledAttributeSub::DefaultSource { id } => { diag.note(msg!("`forbid` lint level is the default for {$id}")); @@ -308,8 +308,8 @@ pub(crate) struct BuiltinMissingDebugImpl<'a> { } // Needed for def_path_str -impl<'a> Diagnostic<'a, ()> for BuiltinMissingDebugImpl<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for BuiltinMissingDebugImpl<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { tcx, def_id } = self; Diag::new( dcx, @@ -368,8 +368,8 @@ pub(crate) struct BuiltinUngatedAsyncFnTrackCaller<'a> { pub session: &'a Session, } -impl<'a> Diagnostic<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for BuiltinUngatedAsyncFnTrackCaller<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new(dcx, level, "`#[track_caller]` on async functions is a no-op") .with_span_label(self.label, "this function will not propagate the caller location"); rustc_session::diagnostics::add_feature_diagnostics( @@ -412,8 +412,8 @@ pub(crate) struct BuiltinTypeAliasBounds<'hir> { pub ty: Option<&'hir hir::Ty<'hir>>, } -impl<'a> Diagnostic<'a, ()> for BuiltinTypeAliasBounds<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for BuiltinTypeAliasBounds<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new(dcx, level, if self.in_where_clause { msg!("where clauses on type aliases are not enforced") } else { @@ -615,8 +615,8 @@ pub(crate) struct BuiltinUnpermittedTypeInit<'a> { pub tcx: TyCtxt<'a>, } -impl<'a> Diagnostic<'a, ()> for BuiltinUnpermittedTypeInit<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for BuiltinUnpermittedTypeInit<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new(dcx, level, self.msg) .with_arg("ty", self.ty) .with_span_label(self.label, msg!("this code causes undefined behavior when executed")); @@ -638,7 +638,7 @@ pub(crate) struct BuiltinUnpermittedTypeInitSub { } impl Subdiagnostic for BuiltinUnpermittedTypeInitSub { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { let mut err = self.err; loop { if let Some(span) = err.span { @@ -689,7 +689,7 @@ pub(crate) struct BuiltinClashingExternSub<'a> { } impl Subdiagnostic for BuiltinClashingExternSub<'_> { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { let mut expected_str = DiagStyledString::new(); expected_str.push(self.expected.fn_sig(self.tcx).to_string(), false); let mut found_str = DiagStyledString::new(); @@ -1363,7 +1363,7 @@ pub(crate) struct NonBindingLetSub { } impl Subdiagnostic for NonBindingLetSub { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { let can_suggest_binding = self.drop_fn_start_end.is_some() || !self.is_assign_desugar; if can_suggest_binding { @@ -1639,8 +1639,8 @@ pub(crate) struct NonFmtPanicUnused { } // Used because of two suggestions based on one Option -impl<'a> Diagnostic<'a, ()> for NonFmtPanicUnused { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for NonFmtPanicUnused { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new(dcx, level, msg!( "panic message contains {$count -> [one] an unused @@ -1740,7 +1740,7 @@ pub(crate) enum NonSnakeCaseDiagSub { } impl Subdiagnostic for NonSnakeCaseDiagSub { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { match self { NonSnakeCaseDiagSub::Label { span } => { diag.span_label(span, msg!("should have a snake_case name")); @@ -1876,8 +1876,8 @@ pub(crate) enum NonLocalDefinitionsDiag { }, } -impl<'a> Diagnostic<'a, ()> for NonLocalDefinitionsDiag { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for NonLocalDefinitionsDiag { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new(dcx, level, ""); match self { NonLocalDefinitionsDiag::Impl { @@ -2046,8 +2046,8 @@ pub(crate) struct DropTraitConstraintsDiag<'a> { } // Needed for def_path_str -impl<'a> Diagnostic<'a, ()> for DropTraitConstraintsDiag<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for DropTraitConstraintsDiag<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { Diag::new(dcx, level, msg!("bounds on `{$clause}` are most likely incorrect, consider instead using `{$needs_drop}` to detect whether a type can be trivially dropped")) .with_arg("clause", self.clause) .with_arg("needs_drop", self.tcx.def_path_str(self.def_id)) @@ -2060,8 +2060,8 @@ pub(crate) struct DropGlue<'a> { } // Needed for def_path_str -impl<'a> Diagnostic<'a, ()> for DropGlue<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for DropGlue<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { Diag::new(dcx, level, msg!("types that do not implement `Drop` can still have drop glue, consider instead using `{$needs_drop}` to detect whether a type is trivially dropped")) .with_arg("needs_drop", self.tcx.def_path_str(self.def_id)) } @@ -2514,8 +2514,8 @@ pub(crate) struct ImproperCTypes<'a> { } // Used because of the complexity of Option, DiagMessage, and Option -impl<'a> Diagnostic<'a, ()> for ImproperCTypes<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for ImproperCTypes<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new( dcx, level, @@ -2691,8 +2691,8 @@ pub(crate) enum UnusedDefSuggestion { } // Needed because of def_path_str -impl<'a> Diagnostic<'a, ()> for UnusedDef<'_, '_> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for UnusedDef<'_, '_> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new(dcx, level, msg!("unused {$pre}`{$def}`{$post} that must be used")) .with_arg("pre", self.pre) @@ -2778,8 +2778,8 @@ pub(crate) struct AsyncFnInTraitDiag { pub sugg: Option>, } -impl<'a> Diagnostic<'a, ()> for AsyncFnInTraitDiag { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for AsyncFnInTraitDiag { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new( dcx, level, @@ -2924,8 +2924,8 @@ pub(crate) struct MismatchedLifetimeSyntaxes { pub suggestions: Vec, } -impl<'a, G> Diagnostic<'a, G> for MismatchedLifetimeSyntaxes { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { +impl<'a> Diagnostic<'a> for MismatchedLifetimeSyntaxes { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let counts = self.inputs.len() + self.outputs.len(); let message = match counts { LifetimeSyntaxCategories { hidden: 0, elided: 0, named: 0 } => { @@ -3037,7 +3037,7 @@ impl MismatchedLifetimeSyntaxesSuggestion { } impl Subdiagnostic for MismatchedLifetimeSyntaxesSuggestion { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { use MismatchedLifetimeSyntaxesSuggestion::*; let style = |optional_alternative| { diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index 91259b010178d..95a925d1c1455 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -6,13 +6,13 @@ use rustc_session::Session; pub struct DiagAndSess<'sess> { pub callback: Box< - dyn for<'b> FnOnce(DiagCtxtHandle<'b>, Level, &dyn Any) -> Diag<'b, ()> + DynSend + 'static, + dyn for<'b> FnOnce(DiagCtxtHandle<'b>, Level, &dyn Any) -> Diag<'b> + DynSend + 'static, >, pub sess: &'sess Session, } -impl<'a> Diagnostic<'a, ()> for DiagAndSess<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a> Diagnostic<'a> for DiagAndSess<'_> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { (self.callback)(dcx, level, self.sess) } } diff --git a/compiler/rustc_lint/src/if_let_rescope.rs b/compiler/rustc_lint/src/if_let_rescope.rs index 1cd701db7d10e..c29cff23acee1 100644 --- a/compiler/rustc_lint/src/if_let_rescope.rs +++ b/compiler/rustc_lint/src/if_let_rescope.rs @@ -324,7 +324,7 @@ struct IfLetRescopeRewrite { } impl Subdiagnostic for IfLetRescopeRewrite { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { let mut suggestions = vec![]; for match_head in self.match_heads { match match_head { diff --git a/compiler/rustc_lint/src/impl_trait_overcaptures.rs b/compiler/rustc_lint/src/impl_trait_overcaptures.rs index f8e4c70d193d6..9d7d0a0df475f 100644 --- a/compiler/rustc_lint/src/impl_trait_overcaptures.rs +++ b/compiler/rustc_lint/src/impl_trait_overcaptures.rs @@ -452,12 +452,12 @@ struct ImplTraitOvercapturesLint<'tcx> { suggestion: Option, } -impl<'a> Diagnostic<'a, ()> for ImplTraitOvercapturesLint<'_> { +impl<'a> Diagnostic<'a> for ImplTraitOvercapturesLint<'_> { fn into_diag( self, dcx: rustc_errors::DiagCtxtHandle<'a>, level: rustc_errors::Level, - ) -> rustc_errors::Diag<'a, ()> { + ) -> rustc_errors::Diag<'a> { let mut diag = rustc_errors::Diag::new( dcx, level, diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 7f3d7fa8d2a10..f847d4c6ae904 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -960,12 +960,8 @@ where lint_from_cli: bool, } - impl<'a, 'b> Diagnostic<'a, ()> for UnknownLint<'b> { - fn into_diag( - self, - dcx: DiagCtxtHandle<'a>, - level: rustc_errors::Level, - ) -> Diag<'a, ()> { + impl<'a, 'b> Diagnostic<'a> for UnknownLint<'b> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: rustc_errors::Level) -> Diag<'a> { let Self { sess, lint_id, feature, lint_from_cli } = self; let mut lint = Diag::new(dcx, level, msg!("unknown lint: `{$name}`")) .with_arg("name", lint_id.lint.name_lower()) @@ -1013,7 +1009,7 @@ where &self, lint: &'static Lint, span: Option, - decorator: impl for<'a> Diagnostic<'a, ()>, + decorator: impl for<'a> Diagnostic<'a>, ) { let level_spec = self.lint_level_spec(lint); emit_lint_base(self.sess, lint, level_spec, span, decorator) @@ -1024,14 +1020,14 @@ where &self, lint: &'static Lint, span: MultiSpan, - decorator: impl for<'a> Diagnostic<'a, ()>, + decorator: impl for<'a> Diagnostic<'a>, ) { let level_spec = self.lint_level_spec(lint); emit_lint_base(self.sess, lint, level_spec, Some(span), decorator); } #[track_caller] - pub fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> Diagnostic<'a, ()>) { + pub fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> Diagnostic<'a>) { let level_spec = self.lint_level_spec(lint); emit_lint_base(self.sess, lint, level_spec, None, decorator); } diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index 991b1083b3272..cb811421be5c6 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -96,8 +96,8 @@ struct PanicMessageNotLiteral<'a, 'tcx> { panic: Option, } -impl<'a, 'b, 'tcx> Diagnostic<'a, ()> for PanicMessageNotLiteral<'b, 'tcx> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { +impl<'a, 'b, 'tcx> Diagnostic<'a> for PanicMessageNotLiteral<'b, 'tcx> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { arg_span, symbol, span, arg_macro, cx, arg, panic } = self; let mut lint = Diag::new(dcx, level, "panic message is not a string literal") .with_arg("name", symbol) diff --git a/compiler/rustc_lint/src/nonstandard_style.rs b/compiler/rustc_lint/src/nonstandard_style.rs index d1057c4f9ead3..b7bb7865ea080 100644 --- a/compiler/rustc_lint/src/nonstandard_style.rs +++ b/compiler/rustc_lint/src/nonstandard_style.rs @@ -484,10 +484,10 @@ struct NonUpperCaseGlobalGenerator<'a, F: FnOnce() -> NonUpperCaseGlobal<'a>> { callback: F, } -impl<'a, 'b, F: FnOnce() -> NonUpperCaseGlobal<'b>> Diagnostic<'a, ()> +impl<'a, 'b, F: FnOnce() -> NonUpperCaseGlobal<'b>> Diagnostic<'a> for NonUpperCaseGlobalGenerator<'b, F> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let Self { callback } = self; callback().into_diag(dcx, level) } diff --git a/compiler/rustc_macros/src/diagnostics/diagnostic.rs b/compiler/rustc_macros/src/diagnostics/diagnostic.rs index 72e7423fc2d88..5bc15eb3d2a5c 100644 --- a/compiler/rustc_macros/src/diagnostics/diagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/diagnostic.rs @@ -48,13 +48,13 @@ impl<'a> DiagnosticDerive<'a> { // A lifetime of `'a` causes conflicts, but `_sess` is fine. structure.gen_impl(quote! { - gen impl<'_sess, G> rustc_errors::Diagnostic<'_sess, G> for @Self { + gen impl<'_sess> rustc_errors::Diagnostic<'_sess> for @Self { #[track_caller] fn into_diag( self, dcx: rustc_errors::DiagCtxtHandle<'_sess>, level: rustc_errors::Level - ) -> rustc_errors::Diag<'_sess, G> { + ) -> rustc_errors::Diag<'_sess> { #implementation } } diff --git a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs index d6b101ca0addf..baf38d2fc381f 100644 --- a/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs +++ b/compiler/rustc_macros/src/diagnostics/subdiagnostic.rs @@ -94,10 +94,7 @@ impl SubdiagnosticDerive { let ret = structure.gen_impl(quote! { gen impl rustc_errors::Subdiagnostic for @Self { - fn add_to_diag<__G>( - self, - #diag: &mut rustc_errors::Diag<'_, __G>, - ) { + fn add_to_diag(self, #diag: &mut rustc_errors::Diag<'_>) { #implementation } } diff --git a/compiler/rustc_metadata/src/diagnostics.rs b/compiler/rustc_metadata/src/diagnostics.rs index a093e7990ea28..18796f51375a1 100644 --- a/compiler/rustc_metadata/src/diagnostics.rs +++ b/compiler/rustc_metadata/src/diagnostics.rs @@ -305,8 +305,8 @@ pub(crate) struct MultipleCandidates { pub candidates: Vec, } -impl Diagnostic<'_, G> for MultipleCandidates { - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { +impl Diagnostic<'_> for MultipleCandidates { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { let mut diag = Diag::new( dcx, level, @@ -418,9 +418,9 @@ pub(crate) struct InvalidMetadataFiles { pub crate_rejections: Vec, } -impl Diagnostic<'_, G> for InvalidMetadataFiles { +impl Diagnostic<'_> for InvalidMetadataFiles { #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { let mut diag = Diag::new( dcx, level, @@ -450,9 +450,9 @@ pub(crate) struct CannotFindCrate { pub is_tier_3: bool, } -impl Diagnostic<'_, G> for CannotFindCrate { +impl Diagnostic<'_> for CannotFindCrate { #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> { let mut diag = Diag::new(dcx, level, msg!("can't find crate for `{$crate_name}`{$add_info}")); diag.arg("crate_name", self.crate_name); diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 49fbbd9164f38..820375ada47a5 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -285,7 +285,7 @@ fn explain_lint_level_source( lint: &'static Lint, level: Level, src: LintLevelSource, - err: &mut Diag<'_, ()>, + err: &mut Diag<'_>, ) { // Find the name of the lint group that contains the given lint. // Assumes the lint only belongs to one group. @@ -382,7 +382,7 @@ fn explain_lint_level_source( /// - [`TyCtxt::emit_node_span_lint`] /// - `LintContext::opt_span_lint` #[track_caller] -pub fn emit_lint_base<'a, D: Diagnostic<'a, ()> + 'a>( +pub fn emit_lint_base<'a, D: Diagnostic<'a> + 'a>( sess: &'a Session, lint: &'static Lint, level_spec: impl Into, @@ -398,7 +398,7 @@ pub fn emit_lint_base<'a, D: Diagnostic<'a, ()> + 'a>( level_spec: LevelSpec, span: Option, decorate: Box< - dyn FnOnce(rustc_errors::DiagCtxtHandle<'a>, rustc_errors::Level) -> Diag<'a, ()> + 'a, + dyn FnOnce(rustc_errors::DiagCtxtHandle<'a>, rustc_errors::Level) -> Diag<'a> + 'a, >, ) { let LevelSpec { level, lint_id, src } = level_spec; @@ -484,7 +484,7 @@ pub fn emit_lint_base<'a, D: Diagnostic<'a, ()> + 'a>( // will be emitted if `can_emit_warnings` is true. let skip = err_level == rustc_errors::Level::Warning && !sess.dcx().can_emit_warnings(); - let mut err: Diag<'_, ()> = if !skip { + let mut err: Diag<'_> = if !skip { decorate(sess.dcx(), err_level) } else { Diag::new(sess.dcx(), err_level, "") diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs index 2ad73c8894da5..8213646b4625d 100644 --- a/compiler/rustc_middle/src/middle/stability.rs +++ b/compiler/rustc_middle/src/middle/stability.rs @@ -114,12 +114,12 @@ pub(crate) struct Deprecated { pub since_kind: DeprecatedSinceKind, } -impl<'a, G> rustc_errors::Diagnostic<'a, G> for Deprecated { +impl<'a> rustc_errors::Diagnostic<'a> for Deprecated { fn into_diag( self, dcx: rustc_errors::DiagCtxtHandle<'a>, level: rustc_errors::Level, - ) -> Diag<'a, G> { + ) -> Diag<'a> { let Self { sub, kind, path, note, since_kind } = self; let mut diag = Diag::new(dcx, level, match &since_kind { DeprecatedSinceKind::InEffect => msg!( diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs index f88b7ff0f8a85..8dccead861de7 100644 --- a/compiler/rustc_middle/src/traits/mod.rs +++ b/compiler/rustc_middle/src/traits/mod.rs @@ -914,7 +914,7 @@ pub enum DynCompatibilityViolationSolution { } impl DynCompatibilityViolationSolution { - pub fn add_to(self, err: &mut Diag<'_, G>) { + pub fn add_to(self, err: &mut Diag<'_>) { match self { DynCompatibilityViolationSolution::None => {} DynCompatibilityViolationSolution::AddSelfOrMakeSized { diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 9d0b334b63fbd..bd9a5e80b1855 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2609,7 +2609,7 @@ impl<'tcx> TyCtxt<'tcx> { lint: &'static Lint, hir_id: HirId, span: impl Into, - decorator: impl for<'a> Diagnostic<'a, ()>, + decorator: impl for<'a> Diagnostic<'a>, ) { let level_spec = self.lint_level_spec_at_node(lint, hir_id); emit_lint_base(self.sess, lint, level_spec, Some(span.into()), decorator) @@ -2622,9 +2622,9 @@ impl<'tcx> TyCtxt<'tcx> { m.spans.inject_use_span.shrink_to_lo() } - pub fn disabled_nightly_features( + pub fn disabled_nightly_features( self, - diag: &mut Diag<'_, G>, + diag: &mut Diag<'_>, features: impl IntoIterator, ) { if !self.sess.is_nightly_build() { @@ -2652,7 +2652,7 @@ impl<'tcx> TyCtxt<'tcx> { self, lint: &'static Lint, id: HirId, - decorator: impl for<'a> Diagnostic<'a, ()>, + decorator: impl for<'a> Diagnostic<'a>, ) { let level_spec = self.lint_level_spec_at_node(lint, id); emit_lint_base(self.sess, lint, level_spec, None, decorator); diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 22fbb306849da..80d34d8747344 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -1346,8 +1346,8 @@ pub enum FnAbiError<'tcx> { Layout(LayoutError<'tcx>), } -impl<'a, 'b, G> Diagnostic<'a, G> for FnAbiError<'b> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { +impl<'a, 'b> Diagnostic<'a> for FnAbiError<'b> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { match self { Self::Layout(e) => Diag::new(dcx, level, e.to_string()), } diff --git a/compiler/rustc_middle/src/ty/opaque_types.rs b/compiler/rustc_middle/src/ty/opaque_types.rs index 63146ff7ed765..7333d17e259e0 100644 --- a/compiler/rustc_middle/src/ty/opaque_types.rs +++ b/compiler/rustc_middle/src/ty/opaque_types.rs @@ -125,7 +125,7 @@ impl<'tcx> TypeFolder> for ReverseMapper<'tcx> { Some(u) => panic!("region mapped to unexpected kind: {u:?}"), None if self.do_not_error => self.tcx.lifetimes.re_static, None => { - let e = self + let guar = self .tcx .dcx() .struct_span_err(self.span, "non-defining opaque type use in defining scope") @@ -136,9 +136,9 @@ impl<'tcx> TypeFolder> for ReverseMapper<'tcx> { parameter list of the `impl Trait` type alias", ), ) - .emit(); + .emit_err(); - ty::Region::new_error(self.cx(), e) + ty::Region::new_error(self.cx(), guar) } } } @@ -179,7 +179,7 @@ impl<'tcx> TypeFolder> for ReverseMapper<'tcx> { used in parameter list for the `impl Trait` type alias" ), ) - .emit(); + .emit_err(); Ty::new_error(self.tcx, guar) } } diff --git a/compiler/rustc_mir_build/src/check_tail_calls.rs b/compiler/rustc_mir_build/src/check_tail_calls.rs index 6c5b4384bd913..298e7898af7f8 100644 --- a/compiler/rustc_mir_build/src/check_tail_calls.rs +++ b/compiler/rustc_mir_build/src/check_tail_calls.rs @@ -205,12 +205,12 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> { } fn report_in_closure(&mut self, expr: &Expr<'_>) { - let err = self.tcx.dcx().span_err(expr.span, "`become` is not allowed in closures"); - self.found_errors = Err(err); + let guar = self.tcx.dcx().span_err(expr.span, "`become` is not allowed in closures"); + self.found_errors = Err(guar); } fn report_builtin_op(&mut self, value: &Expr<'_>, expr: &Expr<'_>) { - let err = self + let guar = self .tcx .dcx() .struct_span_err(value.span, "`become` does not support operators") @@ -221,8 +221,8 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> { "return ", Applicability::MachineApplicable, ) - .emit(); - self.found_errors = Err(err); + .emit_err(); + self.found_errors = Err(guar); } fn report_op(&mut self, fun_ty: Ty<'_>, args: &[ExprId], fn_span: Span, expr: &Expr<'_>) { @@ -265,11 +265,11 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> { } } - self.found_errors = Err(err.emit()); + self.found_errors = Err(err.emit_err()); } fn report_non_call(&mut self, value: &Expr<'_>, expr: &Expr<'_>) { - let err = self + let guar = self .tcx .dcx() .struct_span_err(value.span, "`become` requires a function call") @@ -280,8 +280,8 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> { "return ", Applicability::MaybeIncorrect, ) - .emit(); - self.found_errors = Err(err); + .emit_err(); + self.found_errors = Err(guar); } fn report_calling_closure(&mut self, fun: &Expr<'_>, tupled_args: Ty<'_>, expr: &Expr<'_>) { @@ -291,7 +291,7 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> { _ => "_".to_owned(), }; - let err = self + let guar = self .tcx .dcx() .struct_span_err(expr.span, "tail calling closures directly is not allowed") @@ -303,18 +303,18 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> { ], Applicability::MaybeIncorrect, ) - .emit(); - self.found_errors = Err(err); + .emit_err(); + self.found_errors = Err(guar); } fn report_calling_intrinsic(&mut self, expr: &Expr<'_>) { - let err = self + let guar = self .tcx .dcx() .struct_span_err(expr.span, "tail calling intrinsics is not allowed") - .emit(); + .emit_err(); - self.found_errors = Err(err); + self.found_errors = Err(guar); } fn report_nonfn_callee(&mut self, call_sp: Span, fun_sp: Span, ty: Ty<'_>) { @@ -347,29 +347,29 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> { ); } - let err = err.emit(); - self.found_errors = Err(err); + let guar = err.emit_err(); + self.found_errors = Err(guar); } fn report_abi_mismatch(&mut self, sp: Span, caller_abi: ExternAbi, callee_abi: ExternAbi) { - let err = self + let guar = self .tcx .dcx() .struct_span_err(sp, "mismatched function ABIs") .with_note("`become` requires caller and callee to have the same ABI") .with_note(format!("caller ABI is `{caller_abi}`, while callee ABI is `{callee_abi}`")) - .emit(); - self.found_errors = Err(err); + .emit_err(); + self.found_errors = Err(guar); } fn report_unsupported_abi(&mut self, sp: Span, callee_abi: ExternAbi) { - let err = self + let guar = self .tcx .dcx() .struct_span_err(sp, "ABI does not support guaranteed tail calls") .with_note(format!("`become` is not supported for `extern {callee_abi}` functions")) - .emit(); - self.found_errors = Err(err); + .emit_err(); + self.found_errors = Err(guar); } fn report_signature_mismatch( @@ -378,61 +378,61 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> { caller_sig: ty::FnSig<'_>, callee_sig: ty::FnSig<'_>, ) { - let err = self + let guar = self .tcx .dcx() .struct_span_err(sp, "mismatched signatures") .with_note("`become` requires caller and callee to have matching signatures") .with_note(format!("caller signature: `{caller_sig}`")) .with_note(format!("callee signature: `{callee_sig}`")) - .emit(); - self.found_errors = Err(err); + .emit_err(); + self.found_errors = Err(guar); } fn report_track_caller_caller(&mut self, sp: Span) { - let err = self + let guar = self .tcx .dcx() .struct_span_err( sp, "a function marked with `#[track_caller]` cannot perform a tail-call", ) - .emit(); + .emit_err(); - self.found_errors = Err(err); + self.found_errors = Err(guar); } fn report_c_variadic_caller(&mut self, sp: Span) { - let err = self + let guar = self .tcx .dcx() // FIXME(explicit_tail_calls): highlight the `...` .struct_span_err(sp, "tail-calls are not allowed in c-variadic functions") - .emit(); + .emit_err(); - self.found_errors = Err(err); + self.found_errors = Err(guar); } fn report_c_variadic_callee(&mut self, sp: Span) { - let err = self + let guar = self .tcx .dcx() // FIXME(explicit_tail_calls): highlight the function or something... .struct_span_err(sp, "c-variadic functions can't be tail-called") - .emit(); + .emit_err(); - self.found_errors = Err(err); + self.found_errors = Err(guar); } fn report_unsized_argument(&mut self, sp: Span, arg_ty: Ty<'tcx>) { - let err = self + let guar = self .tcx .dcx() .struct_span_err(sp, format!("unsized arguments cannot be used in a tail call")) .with_note(format!("unsized argument of type `{arg_ty}`")) - .emit(); + .emit_err(); - self.found_errors = Err(err); + self.found_errors = Err(guar); } } diff --git a/compiler/rustc_mir_build/src/diagnostics.rs b/compiler/rustc_mir_build/src/diagnostics.rs index 83bfd322d6444..40d9b0990b2fc 100644 --- a/compiler/rustc_mir_build/src/diagnostics.rs +++ b/compiler/rustc_mir_build/src/diagnostics.rs @@ -585,7 +585,7 @@ pub(crate) struct UnsafeNotInheritedLintNote { } impl Subdiagnostic for UnsafeNotInheritedLintNote { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { diag.span_note( self.signature_span, msg!("an unsafe function restricts its caller, but its body is safe by default"), @@ -625,8 +625,8 @@ pub(crate) struct NonExhaustivePatternsTypeNotEmpty<'a, 'tcx> { pub(crate) ty: Ty<'tcx>, } -impl<'a, G> Diagnostic<'a, G> for NonExhaustivePatternsTypeNotEmpty<'_, '_> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { +impl<'a> Diagnostic<'a> for NonExhaustivePatternsTypeNotEmpty<'_, '_> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = Diag::new(dcx, level, msg!("non-exhaustive patterns: type `{$ty}` is non-empty")); diag.span(self.scrut_span); @@ -730,9 +730,9 @@ pub(crate) struct UnreachablePattern<'tcx> { pub(crate) inner: UnreachablePatternInner<'tcx>, } -impl<'a, 'tcx, G> Diagnostic<'a, G> for UnreachablePattern<'tcx> { +impl<'a, 'tcx> Diagnostic<'a> for UnreachablePattern<'tcx> { #[track_caller] - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G> { + fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a> { let mut diag = self.inner.into_diag(dcx, level); if let Some(covered_by_many_n_more_count) = self.covered_by_many_n_more_count { diag.arg("covered_by_many_n_more_count", covered_by_many_n_more_count); @@ -1260,7 +1260,7 @@ pub(crate) struct Variant { } impl<'tcx> Subdiagnostic for AdtDefinedHere<'tcx> { - fn add_to_diag(self, diag: &mut Diag<'_, G>) { + fn add_to_diag(self, diag: &mut Diag<'_>) { diag.arg("ty", self.ty); let mut spans = MultiSpan::from(self.adt_def_span); diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 3414ee751585c..5a3870eec57ad 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -1469,7 +1469,7 @@ fn report_non_exhaustive_match<'p, 'tcx>( } else { err.help(msg); } - err.emit() + err.emit_err() } fn joined_uncovered_patterns<'p, 'tcx>( diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs index e24ef5ea5b52d..df39350bd5c8c 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs @@ -94,7 +94,7 @@ impl<'tcx> ConstToPat<'tcx> { err.span_label(self.tcx.def_span(def_id), msg!("constant defined here")); } } - Box::new(Pat { span: self.span, ty, kind: PatKind::Error(err.emit()), extra: None }) + Box::new(Pat { span: self.span, ty, kind: PatKind::Error(err.emit_err()), extra: None }) } fn alias_to_pat(&mut self, alias_const: ty::AliasConst<'tcx>, ty: Ty<'tcx>) -> Box> { diff --git a/compiler/rustc_mir_build/src/thir/pattern/migration.rs b/compiler/rustc_mir_build/src/thir/pattern/migration.rs index e6db030557703..7c789a62b04e2 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/migration.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/migration.rs @@ -90,7 +90,7 @@ impl<'a> PatMigration<'a> { format!("cannot {verb1}{or_verb2} within an implicitly-borrowing pattern{in_rust_2024}") } - fn format_subdiagnostics(self, diag: &mut Diag<'_, G>) { + fn format_subdiagnostics(self, diag: &mut Diag<'_>) { // Format and emit explanatory notes about default binding modes. Reversing the spans' order // means if we have nested spans, the innermost ones will be visited first. for (span, def_br_mutbl) in self.default_mode_labels.into_iter().rev() { diff --git a/compiler/rustc_mir_transform/src/diagnostics.rs b/compiler/rustc_mir_transform/src/diagnostics.rs index c851b55f9623a..6e083fef20928 100644 --- a/compiler/rustc_mir_transform/src/diagnostics.rs +++ b/compiler/rustc_mir_transform/src/diagnostics.rs @@ -97,8 +97,8 @@ pub(crate) enum AssertLintKind { UnconditionalPanic, } -impl<'a, P: std::fmt::Debug> Diagnostic<'a, ()> for AssertLint