rustc_codegen_utils: test demangler output, not just symbol names.
This commit is contained in:
parent
e898905141
commit
654d0596d3
9 changed files with 78 additions and 13 deletions
|
@ -2688,6 +2688,7 @@ dependencies = [
|
||||||
"flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc 0.0.0",
|
"rustc 0.0.0",
|
||||||
|
"rustc-demangle 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc_data_structures 0.0.0",
|
"rustc_data_structures 0.0.0",
|
||||||
"rustc_metadata 0.0.0",
|
"rustc_metadata 0.0.0",
|
||||||
"rustc_mir 0.0.0",
|
"rustc_mir 0.0.0",
|
||||||
|
|
|
@ -13,6 +13,7 @@ test = false
|
||||||
[dependencies]
|
[dependencies]
|
||||||
flate2 = "1.0"
|
flate2 = "1.0"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
rustc-demangle = "0.1.15"
|
||||||
|
|
||||||
syntax = { path = "../libsyntax" }
|
syntax = { path = "../libsyntax" }
|
||||||
syntax_pos = { path = "../libsyntax_pos" }
|
syntax_pos = { path = "../libsyntax_pos" }
|
||||||
|
|
|
@ -39,8 +39,12 @@ impl<'a, 'tcx> SymbolNamesTest<'a, 'tcx> {
|
||||||
if attr.check_name(SYMBOL_NAME) {
|
if attr.check_name(SYMBOL_NAME) {
|
||||||
// for now, can only use on monomorphic names
|
// for now, can only use on monomorphic names
|
||||||
let instance = Instance::mono(tcx, def_id);
|
let instance = Instance::mono(tcx, def_id);
|
||||||
let name = self.tcx.symbol_name(instance);
|
let mangled = self.tcx.symbol_name(instance);
|
||||||
tcx.sess.span_err(attr.span, &format!("symbol-name({})", name));
|
tcx.sess.span_err(attr.span, &format!("symbol-name({})", mangled));
|
||||||
|
if let Ok(demangling) = rustc_demangle::try_demangle(&mangled.as_str()) {
|
||||||
|
tcx.sess.span_err(attr.span, &format!("demangling({})", demangling));
|
||||||
|
tcx.sess.span_err(attr.span, &format!("demangling-alt({:#})", demangling));
|
||||||
|
}
|
||||||
} else if attr.check_name(DEF_PATH) {
|
} else if attr.check_name(DEF_PATH) {
|
||||||
let path = tcx.def_path_str(def_id);
|
let path = tcx.def_path_str(def_id);
|
||||||
tcx.sess.span_err(attr.span, &format!("def-path({})", path));
|
tcx.sess.span_err(attr.span, &format!("def-path({})", path));
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#![feature(rustc_attrs)]
|
#![feature(rustc_attrs)]
|
||||||
|
|
||||||
#[rustc_symbol_name] //~ ERROR _ZN5basic4main
|
#[rustc_symbol_name]
|
||||||
|
//~^ ERROR symbol-name(_ZN5basic4main
|
||||||
|
//~| ERROR demangling(basic::main
|
||||||
|
//~| ERROR demangling-alt(basic::main)
|
||||||
#[rustc_def_path] //~ ERROR def-path(main)
|
#[rustc_def_path] //~ ERROR def-path(main)
|
||||||
fn main() {
|
fn main() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,23 @@ error: symbol-name(_ZN5basic4main17hd72940ef9669d526E)
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: demangling(basic::main::hd72940ef9669d526)
|
||||||
|
--> $DIR/basic.rs:3:1
|
||||||
|
|
|
||||||
|
LL | #[rustc_symbol_name]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: demangling-alt(basic::main)
|
||||||
|
--> $DIR/basic.rs:3:1
|
||||||
|
|
|
||||||
|
LL | #[rustc_symbol_name]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: def-path(main)
|
error: def-path(main)
|
||||||
--> $DIR/basic.rs:4:1
|
--> $DIR/basic.rs:7:1
|
||||||
|
|
|
|
||||||
LL | #[rustc_def_path]
|
LL | #[rustc_def_path]
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 4 previous errors
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,10 @@ mod foo {
|
||||||
pub struct Foo { x: u32 }
|
pub struct Foo { x: u32 }
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
#[rustc_symbol_name] //~ ERROR _ZN5impl13foo3Foo3bar
|
#[rustc_symbol_name]
|
||||||
|
//~^ ERROR symbol-name(_ZN5impl13foo3Foo3bar
|
||||||
|
//~| ERROR demangling(impl1::foo::Foo::bar
|
||||||
|
//~| ERROR demangling-alt(impl1::foo::Foo::bar)
|
||||||
#[rustc_def_path] //~ ERROR def-path(foo::Foo::bar)
|
#[rustc_def_path] //~ ERROR def-path(foo::Foo::bar)
|
||||||
fn bar() { }
|
fn bar() { }
|
||||||
}
|
}
|
||||||
|
@ -15,7 +18,10 @@ mod bar {
|
||||||
use foo::Foo;
|
use foo::Foo;
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
#[rustc_symbol_name] //~ ERROR _ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz
|
#[rustc_symbol_name]
|
||||||
|
//~^ ERROR symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz
|
||||||
|
//~| ERROR demangling(impl1::bar::<impl impl1::foo::Foo>::baz
|
||||||
|
//~| ERROR demangling-alt(impl1::bar::<impl impl1::foo::Foo>::baz)
|
||||||
#[rustc_def_path] //~ ERROR def-path(bar::<impl foo::Foo>::baz)
|
#[rustc_def_path] //~ ERROR def-path(bar::<impl foo::Foo>::baz)
|
||||||
fn baz() { }
|
fn baz() { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,23 +4,47 @@ error: symbol-name(_ZN5impl13foo3Foo3bar17he53b9bee7600ed8dE)
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: demangling(impl1::foo::Foo::bar::he53b9bee7600ed8d)
|
||||||
|
--> $DIR/impl1.rs:8:9
|
||||||
|
|
|
||||||
|
LL | #[rustc_symbol_name]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: demangling-alt(impl1::foo::Foo::bar)
|
||||||
|
--> $DIR/impl1.rs:8:9
|
||||||
|
|
|
||||||
|
LL | #[rustc_symbol_name]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: def-path(foo::Foo::bar)
|
error: def-path(foo::Foo::bar)
|
||||||
--> $DIR/impl1.rs:9:9
|
--> $DIR/impl1.rs:12:9
|
||||||
|
|
|
|
||||||
LL | #[rustc_def_path]
|
LL | #[rustc_def_path]
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17h86c41f0462d901d4E)
|
error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17h86c41f0462d901d4E)
|
||||||
--> $DIR/impl1.rs:18:9
|
--> $DIR/impl1.rs:21:9
|
||||||
|
|
|
||||||
|
LL | #[rustc_symbol_name]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: demangling(impl1::bar::<impl impl1::foo::Foo>::baz::h86c41f0462d901d4)
|
||||||
|
--> $DIR/impl1.rs:21:9
|
||||||
|
|
|
||||||
|
LL | #[rustc_symbol_name]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: demangling-alt(impl1::bar::<impl impl1::foo::Foo>::baz)
|
||||||
|
--> $DIR/impl1.rs:21:9
|
||||||
|
|
|
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: def-path(bar::<impl foo::Foo>::baz)
|
error: def-path(bar::<impl foo::Foo>::baz)
|
||||||
--> $DIR/impl1.rs:19:9
|
--> $DIR/impl1.rs:25:9
|
||||||
|
|
|
|
||||||
LL | #[rustc_def_path]
|
LL | #[rustc_def_path]
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,9 @@ mod foo {
|
||||||
|
|
||||||
impl Foo<::llvm::Foo> {
|
impl Foo<::llvm::Foo> {
|
||||||
#[rustc_symbol_name]
|
#[rustc_symbol_name]
|
||||||
//~^ ERROR _ZN11issue_609253foo36Foo$LT$issue_60925..llv$6d$..Foo$GT$3foo17h059a991a004536adE
|
//~^ ERROR symbol-name(_ZN11issue_609253foo36Foo$LT$issue_60925..llv$6d$..Foo$GT$3foo
|
||||||
|
//~| ERROR demangling(issue_60925::foo::Foo<issue_60925::llv$6d$..Foo$GT$::foo
|
||||||
|
//~| ERROR demangling-alt(issue_60925::foo::Foo<issue_60925::llv$6d$..Foo$GT$::foo)
|
||||||
pub(crate) fn foo() {
|
pub(crate) fn foo() {
|
||||||
for _ in 0..0 {
|
for _ in 0..0 {
|
||||||
for _ in &[::dummy()] {
|
for _ in &[::dummy()] {
|
||||||
|
|
|
@ -4,5 +4,17 @@ error: symbol-name(_ZN11issue_609253foo36Foo$LT$issue_60925..llv$6d$..Foo$GT$3fo
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: demangling(issue_60925::foo::Foo<issue_60925::llv$6d$..Foo$GT$::foo::h059a991a004536ad)
|
||||||
|
--> $DIR/issue-60925.rs:16:9
|
||||||
|
|
|
||||||
|
LL | #[rustc_symbol_name]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: demangling-alt(issue_60925::foo::Foo<issue_60925::llv$6d$..Foo$GT$::foo)
|
||||||
|
--> $DIR/issue-60925.rs:16:9
|
||||||
|
|
|
||||||
|
LL | #[rustc_symbol_name]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue