diff --git a/Cargo.lock b/Cargo.lock index e4612d8a954..5e6b11032ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3398,9 +3398,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.18" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e3bad0ee36814ca07d7968269dd4b7ec89ec2da10c4bb613928d3077083c232" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" dependencies = [ "compiler_builtins", "rustc-std-workspace-core", diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index 6187f4000fb..521ce344180 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -15,7 +15,7 @@ measureme = "9.1.0" snap = "1" tracing = "0.1" rustc_middle = { path = "../rustc_middle" } -rustc-demangle = "0.1.18" +rustc-demangle = "0.1.21" rustc_attr = { path = "../rustc_attr" } rustc_codegen_ssa = { path = "../rustc_codegen_ssa" } rustc_data_structures = { path = "../rustc_data_structures" } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 4befeb1d827..56be2843056 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1220,13 +1220,20 @@ pub trait PrettyPrinter<'tcx>: } p!(")"); } - ty::Adt(def, substs) if def.variants.is_empty() => { - p!(print_value_path(def.did, substs)); + ty::Adt(def, _) if def.variants.is_empty() => { + self = self.typed_value( + |mut this| { + write!(this, "unreachable()")?; + Ok(this) + }, + |this| this.print_type(ty), + ": ", + )?; } ty::Adt(def, substs) => { - let variant_id = - contents.variant.expect("destructed const of adt without variant id"); - let variant_def = &def.variants[variant_id]; + let variant_idx = + contents.variant.expect("destructed const of adt without variant idx"); + let variant_def = &def.variants[variant_idx]; p!(print_value_path(variant_def.def_id, substs)); match variant_def.ctor_kind { diff --git a/compiler/rustc_symbol_mangling/Cargo.toml b/compiler/rustc_symbol_mangling/Cargo.toml index aa8fd304527..aebf77a1fd8 100644 --- a/compiler/rustc_symbol_mangling/Cargo.toml +++ b/compiler/rustc_symbol_mangling/Cargo.toml @@ -9,7 +9,7 @@ doctest = false [dependencies] tracing = "0.1" punycode = "0.4.0" -rustc-demangle = "0.1.18" +rustc-demangle = "0.1.21" rustc_span = { path = "../rustc_span" } rustc_middle = { path = "../rustc_middle" } diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs index 850d44eb339..551309f4a8c 100644 --- a/compiler/rustc_symbol_mangling/src/lib.rs +++ b/compiler/rustc_symbol_mangling/src/lib.rs @@ -91,6 +91,7 @@ #![feature(never_type)] #![feature(nll)] #![feature(in_band_lifetimes)] +#![feature(iter_zip)] #![recursion_limit = "256"] #[macro_use] diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index c4c1ec8ce4e..80f29aa9c4f 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -1,8 +1,10 @@ use rustc_data_structures::base_n; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir as hir; +use rustc_hir::def::CtorKind; use rustc_hir::def_id::{CrateNum, DefId}; use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData}; +use rustc_middle::mir::interpret::ConstValue; use rustc_middle::ty::layout::IntegerExt; use rustc_middle::ty::print::{Print, Printer}; use rustc_middle::ty::subst::{GenericArg, GenericArgKind, Subst}; @@ -11,6 +13,7 @@ use rustc_target::abi::Integer; use rustc_target::spec::abi::Abi; use std::fmt::Write; +use std::iter; use std::ops::Range; pub(super) fn mangle( @@ -534,39 +537,153 @@ impl Printer<'tcx> for &mut SymbolMangler<'tcx> { } fn print_const(mut self, ct: &'tcx ty::Const<'tcx>) -> Result { + // We only mangle a typed value if the const can be evaluated. + let ct = ct.eval(self.tcx, ty::ParamEnv::reveal_all()); + match ct.val { + ty::ConstKind::Value(_) => {} + + // Placeholders (should be demangled as `_`). + // NOTE(eddyb) despite `Unevaluated` having a `DefId` (and therefore + // a path), even for it we still need to encode a placeholder, as + // the path could refer back to e.g. an `impl` using the constant. + ty::ConstKind::Unevaluated(_) + | ty::ConstKind::Param(_) + | ty::ConstKind::Infer(_) + | ty::ConstKind::Bound(..) + | ty::ConstKind::Placeholder(_) + | ty::ConstKind::Error(_) => { + // Never cached (single-character). + self.push("p"); + return Ok(self); + } + } + if let Some(&i) = self.consts.get(&ct) { return self.print_backref(i); } let start = self.out.len(); - let mut neg = false; - let val = match ct.ty.kind() { - ty::Uint(_) | ty::Bool | ty::Char => { - ct.try_eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ct.ty) - } - ty::Int(ity) => { - ct.try_eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ct.ty).and_then(|b| { - let val = Integer::from_int_ty(&self.tcx, *ity).size().sign_extend(b) as i128; + match ct.ty.kind() { + ty::Uint(_) | ty::Int(_) | ty::Bool | ty::Char => { + self = ct.ty.print(self)?; + + let mut bits = ct.eval_bits(self.tcx, ty::ParamEnv::reveal_all(), ct.ty); + + // Negative integer values are mangled using `n` as a "sign prefix". + if let ty::Int(ity) = ct.ty.kind() { + let val = + Integer::from_int_ty(&self.tcx, *ity).size().sign_extend(bits) as i128; if val < 0 { - neg = true; + self.push("n"); } - Some(val.unsigned_abs()) - }) + bits = val.unsigned_abs(); + } + + let _ = write!(self.out, "{:x}_", bits); } + + // HACK(eddyb) because `ty::Const` only supports sized values (for now), + // we can't use `deref_const` + supporting `str`, we have to specially + // handle `&str` and include both `&` ("R") and `str` ("e") prefixes. + ty::Ref(_, ty, hir::Mutability::Not) if *ty == self.tcx.types.str_ => { + self.push("R"); + match ct.val { + ty::ConstKind::Value(ConstValue::Slice { data, start, end }) => { + // NOTE(eddyb) the following comment was kept from `ty::print::pretty`: + // The `inspect` here is okay since we checked the bounds, and there are no + // relocations (we have an active `str` reference here). We don't use this + // result to affect interpreter execution. + let slice = + data.inspect_with_uninit_and_ptr_outside_interpreter(start..end); + let s = std::str::from_utf8(slice).expect("non utf8 str from miri"); + + self.push("e"); + // FIXME(eddyb) use a specialized hex-encoding loop. + for byte in s.bytes() { + let _ = write!(self.out, "{:02x}", byte); + } + self.push("_"); + } + + _ => { + bug!("symbol_names: unsupported `&str` constant: {:?}", ct); + } + } + } + + ty::Ref(_, _, mutbl) => { + self.push(match mutbl { + hir::Mutability::Not => "R", + hir::Mutability::Mut => "Q", + }); + self = self.tcx.deref_const(ty::ParamEnv::reveal_all().and(ct)).print(self)?; + } + + ty::Array(..) | ty::Tuple(..) | ty::Adt(..) => { + let contents = self.tcx.destructure_const(ty::ParamEnv::reveal_all().and(ct)); + let fields = contents.fields.iter().copied(); + + let print_field_list = |mut this: Self| { + for field in fields.clone() { + this = field.print(this)?; + } + this.push("E"); + Ok(this) + }; + + match *ct.ty.kind() { + ty::Array(..) => { + self.push("A"); + self = print_field_list(self)?; + } + ty::Tuple(..) => { + self.push("T"); + self = print_field_list(self)?; + } + ty::Adt(def, substs) => { + let variant_idx = + contents.variant.expect("destructed const of adt without variant idx"); + let variant_def = &def.variants[variant_idx]; + + self.push("V"); + self = self.print_def_path(variant_def.def_id, substs)?; + + match variant_def.ctor_kind { + CtorKind::Const => { + self.push("U"); + } + CtorKind::Fn => { + self.push("T"); + self = print_field_list(self)?; + } + CtorKind::Fictive => { + self.push("S"); + for (field_def, field) in iter::zip(&variant_def.fields, fields) { + // HACK(eddyb) this mimics `path_append`, + // instead of simply using `field_def.ident`, + // just to be able to handle disambiguators. + let disambiguated_field = + self.tcx.def_key(field_def.did).disambiguated_data; + let field_name = + disambiguated_field.data.get_opt_name().map(|s| s.as_str()); + self.push_disambiguator( + disambiguated_field.disambiguator as u64, + ); + self.push_ident(&field_name.as_ref().map_or("", |s| &s[..])); + + self = field.print(self)?; + } + self.push("E"); + } + } + } + _ => unreachable!(), + } + } + _ => { bug!("symbol_names: unsupported constant of type `{}` ({:?})", ct.ty, ct); } - }; - - if let Some(bits) = val { - // We only print the type if the const can be evaluated. - self = ct.ty.print(self)?; - let _ = write!(self.out, "{}{:x}_", if neg { "n" } else { "" }, bits); - } else { - // NOTE(eddyb) despite having the path, we need to - // encode a placeholder, as the path could refer - // back to e.g. an `impl` using the constant. - self.push("p"); } // Only cache consts that do not refer to an enclosing diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 38291b3f57e..1b051b0d0f6 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -24,7 +24,7 @@ std_detect = { path = "../stdarch/crates/std_detect", default-features = false, # Dependencies of the `backtrace` crate addr2line = { version = "0.16.0", optional = true, default-features = false } -rustc-demangle = { version = "0.1.18", features = ['rustc-dep-of-std'] } +rustc-demangle = { version = "0.1.21", features = ['rustc-dep-of-std'] } miniz_oxide = { version = "0.4.0", optional = true, default-features = false } [dependencies.object] version = "0.26.1" diff --git a/src/test/debuginfo/function-call.rs b/src/test/debuginfo/function-call.rs index a5d5942b539..75334558b58 100644 --- a/src/test/debuginfo/function-call.rs +++ b/src/test/debuginfo/function-call.rs @@ -1,5 +1,5 @@ // This test does not passed with gdb < 8.0. See #53497. -// min-gdb-version: 8.0 +// min-gdb-version: 10.1 // compile-flags:-g diff --git a/src/test/debuginfo/function-names.rs b/src/test/debuginfo/function-names.rs index 28ab176ba50..b9e59f8e829 100644 --- a/src/test/debuginfo/function-names.rs +++ b/src/test/debuginfo/function-names.rs @@ -1,5 +1,5 @@ // Function names are formatted differently in old versions of GDB -// min-gdb-version: 9.2 +// min-gdb-version: 10.1 // compile-flags:-g diff --git a/src/test/ui/panics/issue-47429-short-backtraces.run.stderr b/src/test/ui/panics/issue-47429-short-backtraces.legacy.run.stderr similarity index 91% rename from src/test/ui/panics/issue-47429-short-backtraces.run.stderr rename to src/test/ui/panics/issue-47429-short-backtraces.legacy.run.stderr index 32879638907..fcdc070a4c3 100644 --- a/src/test/ui/panics/issue-47429-short-backtraces.run.stderr +++ b/src/test/ui/panics/issue-47429-short-backtraces.legacy.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:16:5 +thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:21:5 stack backtrace: 0: std::panicking::begin_panic 1: issue_47429_short_backtraces::main diff --git a/src/test/ui/panics/issue-47429-short-backtraces.rs b/src/test/ui/panics/issue-47429-short-backtraces.rs index 015ab8fdd80..35ecfc0b271 100644 --- a/src/test/ui/panics/issue-47429-short-backtraces.rs +++ b/src/test/ui/panics/issue-47429-short-backtraces.rs @@ -12,6 +12,11 @@ // ignore-emscripten no panic or subprocess support // ignore-sgx no subprocess support +// NOTE(eddyb) output differs between symbol mangling schemes +// revisions: legacy v0 +// [legacy] compile-flags: -Zsymbol-mangling-version=legacy +// [v0] compile-flags: -Zsymbol-mangling-version=v0 + fn main() { panic!() } diff --git a/src/test/ui/panics/issue-47429-short-backtraces.v0.run.stderr b/src/test/ui/panics/issue-47429-short-backtraces.v0.run.stderr new file mode 100644 index 00000000000..1cbf11739bf --- /dev/null +++ b/src/test/ui/panics/issue-47429-short-backtraces.v0.run.stderr @@ -0,0 +1,5 @@ +thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:21:5 +stack backtrace: + 0: std::panicking::begin_panic::<&str> + 1: issue_47429_short_backtraces::main +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/src/test/ui/symbol-names/const-generics-demangling.rs b/src/test/ui/symbol-names/const-generics-demangling.rs index 05c6b8352de..38b07acbdb2 100644 --- a/src/test/ui/symbol-names/const-generics-demangling.rs +++ b/src/test/ui/symbol-names/const-generics-demangling.rs @@ -1,37 +1,37 @@ // build-fail -// compile-flags: -Z symbol-mangling-version=v0 +// compile-flags: -Z symbol-mangling-version=v0 --crate-name=c #![feature(rustc_attrs)] pub struct Unsigned; #[rustc_symbol_name] -//~^ ERROR symbol-name(_RMCsaP8qXevlYG3_25const_generics_demanglingINtB0_8UnsignedKhb_E) -//~| ERROR demangling(>) -//~| ERROR demangling-alt(>) +//~^ ERROR symbol-name(_RMCsno73SFvQKx_1cINtB0_8UnsignedKhb_E) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) impl Unsigned<11> {} pub struct Signed; #[rustc_symbol_name] -//~^ ERROR symbol-name(_RMs_CsaP8qXevlYG3_25const_generics_demanglingINtB2_6SignedKsn98_E) -//~| ERROR demangling(>) -//~| ERROR demangling-alt(>) +//~^ ERROR symbol-name(_RMs_Csno73SFvQKx_1cINtB2_6SignedKsn98_E) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) impl Signed<-152> {} pub struct Bool; #[rustc_symbol_name] -//~^ ERROR symbol-name(_RMs0_CsaP8qXevlYG3_25const_generics_demanglingINtB3_4BoolKb1_E) -//~| ERROR demangling(>) -//~| ERROR demangling-alt(>) +//~^ ERROR symbol-name(_RMs0_Csno73SFvQKx_1cINtB3_4BoolKb1_E) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) impl Bool {} pub struct Char; #[rustc_symbol_name] -//~^ ERROR symbol-name(_RMs1_CsaP8qXevlYG3_25const_generics_demanglingINtB3_4CharKc2202_E) -//~| ERROR demangling(>) -//~| ERROR demangling-alt(>) +//~^ ERROR symbol-name(_RMs1_Csno73SFvQKx_1cINtB3_4CharKc2202_E) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) impl Char<'∂'> {} fn main() {} diff --git a/src/test/ui/symbol-names/const-generics-demangling.stderr b/src/test/ui/symbol-names/const-generics-demangling.stderr index 05c485d001f..2abf293071f 100644 --- a/src/test/ui/symbol-names/const-generics-demangling.stderr +++ b/src/test/ui/symbol-names/const-generics-demangling.stderr @@ -1,70 +1,70 @@ -error: symbol-name(_RMCsaP8qXevlYG3_25const_generics_demanglingINtB0_8UnsignedKhb_E) +error: symbol-name(_RMCsno73SFvQKx_1cINtB0_8UnsignedKhb_E) --> $DIR/const-generics-demangling.rs:7:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(>) +error: demangling(>) --> $DIR/const-generics-demangling.rs:7:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling-alt(>) +error: demangling-alt(>) --> $DIR/const-generics-demangling.rs:7:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: symbol-name(_RMs_CsaP8qXevlYG3_25const_generics_demanglingINtB2_6SignedKsn98_E) +error: symbol-name(_RMs_Csno73SFvQKx_1cINtB2_6SignedKsn98_E) --> $DIR/const-generics-demangling.rs:15:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(>) +error: demangling(>) --> $DIR/const-generics-demangling.rs:15:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling-alt(>) +error: demangling-alt(>) --> $DIR/const-generics-demangling.rs:15:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: symbol-name(_RMs0_CsaP8qXevlYG3_25const_generics_demanglingINtB3_4BoolKb1_E) +error: symbol-name(_RMs0_Csno73SFvQKx_1cINtB3_4BoolKb1_E) --> $DIR/const-generics-demangling.rs:23:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(>) +error: demangling(>) --> $DIR/const-generics-demangling.rs:23:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling-alt(>) +error: demangling-alt(>) --> $DIR/const-generics-demangling.rs:23:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: symbol-name(_RMs1_CsaP8qXevlYG3_25const_generics_demanglingINtB3_4CharKc2202_E) +error: symbol-name(_RMs1_Csno73SFvQKx_1cINtB3_4CharKc2202_E) --> $DIR/const-generics-demangling.rs:31:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(>) +error: demangling(>) --> $DIR/const-generics-demangling.rs:31:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling-alt(>) +error: demangling-alt(>) --> $DIR/const-generics-demangling.rs:31:1 | LL | #[rustc_symbol_name] diff --git a/src/test/ui/symbol-names/const-generics-str-demangling.rs b/src/test/ui/symbol-names/const-generics-str-demangling.rs new file mode 100644 index 00000000000..af111dd39fa --- /dev/null +++ b/src/test/ui/symbol-names/const-generics-str-demangling.rs @@ -0,0 +1,44 @@ +// build-fail +// compile-flags: -Z symbol-mangling-version=v0 --crate-name=c +#![feature(const_generics, rustc_attrs)] +#![allow(incomplete_features)] + +pub struct Str; + +#[rustc_symbol_name] +//~^ ERROR symbol-name(_RMCsno73SFvQKx_1cINtB0_3StrKRe616263_E) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) +impl Str<"abc"> {} + +#[rustc_symbol_name] +//~^ ERROR symbol-name(_RMs_Csno73SFvQKx_1cINtB2_3StrKRe27_E) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) +impl Str<"'"> {} + +#[rustc_symbol_name] +//~^ ERROR symbol-name(_RMs0_Csno73SFvQKx_1cINtB3_3StrKRe090a_E) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) +impl Str<"\t\n"> {} + +#[rustc_symbol_name] +//~^ ERROR symbol-name(_RMs1_Csno73SFvQKx_1cINtB3_3StrKRee28882c3bc_E) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) +impl Str<"∂ü"> {} + +#[rustc_symbol_name] +//~^ ERROR symbol-name(_RMs2_Csno73SFvQKx_1cINtB3_3StrKRee183a1e18390e183ade1839be18394e1839ae18390e183935fe18392e18394e1839be183a0e18398e18394e1839ae183985fe183a1e18390e18393e18398e1839ae18398_E) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) +impl Str<"საჭმელად_გემრიელი_სადილი"> {} + +#[rustc_symbol_name] +//~^ ERROR symbol-name(_RMs3_Csno73SFvQKx_1cINtB3_3StrKRef09f908af09fa688f09fa686f09f90ae20c2a720f09f90b6f09f9192e29895f09f94a520c2a720f09fa7a1f09f929bf09f929af09f9299f09f929c_E) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) +impl Str<"🐊🦈🦆🐮 § 🐶👒☕🔥 § 🧡💛💚💙💜"> {} + +fn main() {} diff --git a/src/test/ui/symbol-names/const-generics-str-demangling.stderr b/src/test/ui/symbol-names/const-generics-str-demangling.stderr new file mode 100644 index 00000000000..f401997017f --- /dev/null +++ b/src/test/ui/symbol-names/const-generics-str-demangling.stderr @@ -0,0 +1,110 @@ +error: symbol-name(_RMCsno73SFvQKx_1cINtB0_3StrKRe616263_E) + --> $DIR/const-generics-str-demangling.rs:8:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling(>) + --> $DIR/const-generics-str-demangling.rs:8:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling-alt(>) + --> $DIR/const-generics-str-demangling.rs:8:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: symbol-name(_RMs_Csno73SFvQKx_1cINtB2_3StrKRe27_E) + --> $DIR/const-generics-str-demangling.rs:14:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling(>) + --> $DIR/const-generics-str-demangling.rs:14:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling-alt(>) + --> $DIR/const-generics-str-demangling.rs:14:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: symbol-name(_RMs0_Csno73SFvQKx_1cINtB3_3StrKRe090a_E) + --> $DIR/const-generics-str-demangling.rs:20:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling(>) + --> $DIR/const-generics-str-demangling.rs:20:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling-alt(>) + --> $DIR/const-generics-str-demangling.rs:20:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: symbol-name(_RMs1_Csno73SFvQKx_1cINtB3_3StrKRee28882c3bc_E) + --> $DIR/const-generics-str-demangling.rs:26:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling(>) + --> $DIR/const-generics-str-demangling.rs:26:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling-alt(>) + --> $DIR/const-generics-str-demangling.rs:26:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: symbol-name(_RMs2_Csno73SFvQKx_1cINtB3_3StrKRee183a1e18390e183ade1839be18394e1839ae18390e183935fe18392e18394e1839be183a0e18398e18394e1839ae183985fe183a1e18390e18393e18398e1839ae18398_E) + --> $DIR/const-generics-str-demangling.rs:32:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling(>) + --> $DIR/const-generics-str-demangling.rs:32:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling-alt(>) + --> $DIR/const-generics-str-demangling.rs:32:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: symbol-name(_RMs3_Csno73SFvQKx_1cINtB3_3StrKRef09f908af09fa688f09fa686f09f90ae20c2a720f09f90b6f09f9192e29895f09f94a520c2a720f09fa7a1f09f929bf09f929af09f9299f09f929c_E) + --> $DIR/const-generics-str-demangling.rs:38:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling(>) + --> $DIR/const-generics-str-demangling.rs:38:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling-alt(>) + --> $DIR/const-generics-str-demangling.rs:38:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 18 previous errors + diff --git a/src/test/ui/symbol-names/const-generics-structural-demangling.rs b/src/test/ui/symbol-names/const-generics-structural-demangling.rs new file mode 100644 index 00000000000..9da6a0f18e6 --- /dev/null +++ b/src/test/ui/symbol-names/const-generics-structural-demangling.rs @@ -0,0 +1,96 @@ +// build-fail +// compile-flags: -Z symbol-mangling-version=v0 --crate-name=c + +// NOTE(eddyb) we need `core` for `core::option::Option`, normalize away its +// disambiguator hash, which can/should change (including between stage{1,2}). +// normalize-stderr-test: "Cs[0-9a-zA-Z]+_4core" -> "Cs$$HASH_4core" +// normalize-stderr-test: "core\[[0-9a-f]+\]" -> "core[$$HASH_HEX]" + +#![feature(const_generics, decl_macro, rustc_attrs)] +#![allow(incomplete_features)] + +pub struct RefByte; + +#[rustc_symbol_name] +//~^ ERROR symbol-name(_RMCsno73SFvQKx_1cINtB0_7RefByteKRh7b_E) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) +impl RefByte<{&123}> {} + +// FIXME(eddyb) this was supposed to be `RefMutZst` with `&mut []`, +// but that is currently not allowed in const generics. +pub struct RefZst; + +#[rustc_symbol_name] +//~^ ERROR symbol-name(_RMs_Csno73SFvQKx_1cINtB2_6RefZstKRAEE) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) +impl RefZst<{&[]}> {} + +pub struct Array3Bytes; + +#[rustc_symbol_name] +//~^ ERROR symbol-name(_RMs0_Csno73SFvQKx_1cINtB3_11Array3BytesKAh1_h2_h3_EE) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) +impl Array3Bytes<{[1, 2, 3]}> {} + +pub struct TupleByteBool; + +#[rustc_symbol_name] +//~^ ERROR symbol-name(_RMs1_Csno73SFvQKx_1cINtB3_13TupleByteBoolKTh1_b0_EE) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) +impl TupleByteBool<{(1, false)}> {} + +pub struct OptionUsize>; + +// HACK(eddyb) the full mangling is only in `.stderr` because we can normalize +// the `core` disambiguator hash away there, but not here. +#[rustc_symbol_name] +//~^ ERROR symbol-name(_RMs2_Csno73SFvQKx_1cINtB3_11OptionUsizeKVNtINtNtCs +//~| ERROR demangling(::None}>>) +impl OptionUsize<{None}> {} + +// HACK(eddyb) the full mangling is only in `.stderr` because we can normalize +// the `core` disambiguator hash away there, but not here. +#[rustc_symbol_name] +//~^ ERROR symbol-name(_RMs3_Csno73SFvQKx_1cINtB3_11OptionUsizeKVNtINtNtCs +//~| ERROR demangling(::Some(0)}>>) +impl OptionUsize<{Some(0)}> {} + +#[derive(PartialEq, Eq)] +pub struct Foo { + s: &'static str, + ch: char, + slice: &'static [u8], +} +pub struct Foo_; + +#[rustc_symbol_name] +//~^ ERROR symbol-name(_RMs4_Csno73SFvQKx_1cINtB3_4Foo_KVNtB3_3FooS1sRe616263_2chc78_5sliceRAh1_h2_h3_EEE) +//~| ERROR demangling(>) +//~| ERROR demangling-alt(>) +impl Foo_<{Foo { s: "abc", ch: 'x', slice: &[1, 2, 3] }}> {} + +// NOTE(eddyb) this tests specifically the use of disambiguators in field names, +// using macros 2.0 hygiene to create a `struct` with conflicting field names. +macro duplicate_field_name_test($x:ident) { + #[derive(PartialEq, Eq)] + pub struct Bar { + $x: u8, + x: u16, + } + pub struct Bar_; + + #[rustc_symbol_name] + //~^ ERROR symbol-name(_RMs9_Csno73SFvQKx_1cINtB3_4Bar_KVNtB3_3BarS1xh7b_s_1xt1000_EE) + //~| ERROR demangling(>) + //~| ERROR demangling-alt(>) + impl Bar_<{Bar { $x: 123, x: 4096 }}> {} +} +duplicate_field_name_test!(x); + +fn main() {} diff --git a/src/test/ui/symbol-names/const-generics-structural-demangling.stderr b/src/test/ui/symbol-names/const-generics-structural-demangling.stderr new file mode 100644 index 00000000000..b3c5bd2b89d --- /dev/null +++ b/src/test/ui/symbol-names/const-generics-structural-demangling.stderr @@ -0,0 +1,161 @@ +error: symbol-name(_RMCsno73SFvQKx_1cINtB0_7RefByteKRh7b_E) + --> $DIR/const-generics-structural-demangling.rs:14:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling(>) + --> $DIR/const-generics-structural-demangling.rs:14:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling-alt(>) + --> $DIR/const-generics-structural-demangling.rs:14:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: symbol-name(_RMs_Csno73SFvQKx_1cINtB2_6RefZstKRAEE) + --> $DIR/const-generics-structural-demangling.rs:24:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling(>) + --> $DIR/const-generics-structural-demangling.rs:24:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling-alt(>) + --> $DIR/const-generics-structural-demangling.rs:24:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: symbol-name(_RMs0_Csno73SFvQKx_1cINtB3_11Array3BytesKAh1_h2_h3_EE) + --> $DIR/const-generics-structural-demangling.rs:32:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling(>) + --> $DIR/const-generics-structural-demangling.rs:32:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling-alt(>) + --> $DIR/const-generics-structural-demangling.rs:32:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: symbol-name(_RMs1_Csno73SFvQKx_1cINtB3_13TupleByteBoolKTh1_b0_EE) + --> $DIR/const-generics-structural-demangling.rs:40:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling(>) + --> $DIR/const-generics-structural-demangling.rs:40:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling-alt(>) + --> $DIR/const-generics-structural-demangling.rs:40:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: symbol-name(_RMs2_Csno73SFvQKx_1cINtB3_11OptionUsizeKVNtINtNtCs$HASH_4core6option6OptionjE4NoneUE) + --> $DIR/const-generics-structural-demangling.rs:50:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling(::None}>>) + --> $DIR/const-generics-structural-demangling.rs:50:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling-alt(::None}>>) + --> $DIR/const-generics-structural-demangling.rs:50:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: symbol-name(_RMs3_Csno73SFvQKx_1cINtB3_11OptionUsizeKVNtINtNtCs$HASH_4core6option6OptionjE4SomeTj0_EE) + --> $DIR/const-generics-structural-demangling.rs:58:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling(::Some(0usize)}>>) + --> $DIR/const-generics-structural-demangling.rs:58:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling-alt(::Some(0)}>>) + --> $DIR/const-generics-structural-demangling.rs:58:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: symbol-name(_RMs4_Csno73SFvQKx_1cINtB3_4Foo_KVNtB3_3FooS1sRe616263_2chc78_5sliceRAh1_h2_h3_EEE) + --> $DIR/const-generics-structural-demangling.rs:72:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling(>) + --> $DIR/const-generics-structural-demangling.rs:72:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: demangling-alt(>) + --> $DIR/const-generics-structural-demangling.rs:72:1 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ + +error: symbol-name(_RMs9_Csno73SFvQKx_1cINtB3_4Bar_KVNtB3_3BarS1xh7b_s_1xt1000_EE) + --> $DIR/const-generics-structural-demangling.rs:88:5 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | duplicate_field_name_test!(x); + | ------------------------------ in this macro invocation + | + = note: this error originates in the macro `duplicate_field_name_test` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: demangling(>) + --> $DIR/const-generics-structural-demangling.rs:88:5 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | duplicate_field_name_test!(x); + | ------------------------------ in this macro invocation + | + = note: this error originates in the macro `duplicate_field_name_test` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: demangling-alt(>) + --> $DIR/const-generics-structural-demangling.rs:88:5 + | +LL | #[rustc_symbol_name] + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | duplicate_field_name_test!(x); + | ------------------------------ in this macro invocation + | + = note: this error originates in the macro `duplicate_field_name_test` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 24 previous errors + diff --git a/src/test/ui/symbol-names/impl1.rs b/src/test/ui/symbol-names/impl1.rs index 960049be793..60f19266ba9 100644 --- a/src/test/ui/symbol-names/impl1.rs +++ b/src/test/ui/symbol-names/impl1.rs @@ -64,7 +64,7 @@ fn main() { //[legacy]~| ERROR demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method //[legacy]~| ERROR demangling-alt(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; 3] as impl1::main::{{closure}}::Bar>::method) //[v0]~^^^^ ERROR symbol-name(_RNvXNCNvCs2qSCrjELJET_5impl14mains_0ARDNtB6_3Foop5AssocFG_KCRL0_hvEuNtB6_9AutoTraitEL_j3_NtB2_3Bar6method) - //[v0]~| ERROR demangling(<[&dyn impl1[1c5860ab79c9e305]::Foo extern "C" fn(&'a u8, ...)> + impl1[1c5860ab79c9e305]::AutoTrait; 3: usize] as impl1[1c5860ab79c9e305]::main::{closure#1}::Bar>::method) + //[v0]~| ERROR demangling(<[&dyn impl1[1c5860ab79c9e305]::Foo extern "C" fn(&'a u8, ...)> + impl1[1c5860ab79c9e305]::AutoTrait; 3usize] as impl1[1c5860ab79c9e305]::main::{closure#1}::Bar>::method) //[v0]~| ERROR demangling-alt(<[&dyn impl1::Foo extern "C" fn(&'a u8, ...)> + impl1::AutoTrait; 3] as impl1::main::{closure#1}::Bar>::method) #[rustc_def_path] //[legacy]~^ ERROR def-path(<[&dyn Foo extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method) diff --git a/src/test/ui/symbol-names/impl1.v0.stderr b/src/test/ui/symbol-names/impl1.v0.stderr index a7c3a389909..926e750e3cd 100644 --- a/src/test/ui/symbol-names/impl1.v0.stderr +++ b/src/test/ui/symbol-names/impl1.v0.stderr @@ -52,7 +52,7 @@ error: symbol-name(_RNvXNCNvCs2qSCrjELJET_5impl14mains_0ARDNtB6_3Foop5AssocFG_KC LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<[&dyn impl1[1c5860ab79c9e305]::Foo extern "C" fn(&'a u8, ...)> + impl1[1c5860ab79c9e305]::AutoTrait; 3: usize] as impl1[1c5860ab79c9e305]::main::{closure#1}::Bar>::method) +error: demangling(<[&dyn impl1[1c5860ab79c9e305]::Foo extern "C" fn(&'a u8, ...)> + impl1[1c5860ab79c9e305]::AutoTrait; 3usize] as impl1[1c5860ab79c9e305]::main::{closure#1}::Bar>::method) --> $DIR/impl1.rs:62:13 | LL | #[rustc_symbol_name] diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index f291918225f..51a4d74109a 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3227,7 +3227,7 @@ impl<'test> TestCx<'test> { // so it needs to be removed when comparing the run-pass test execution output lazy_static! { static ref REMOTE_TEST_RE: Regex = Regex::new( - "^uploaded \"\\$TEST_BUILD_DIR(/[[:alnum:]_\\-]+)+\", waiting for result\n" + "^uploaded \"\\$TEST_BUILD_DIR(/[[:alnum:]_\\-.]+)+\", waiting for result\n" ) .unwrap(); }