Skip to content

Commit

Permalink
Fix rustc_def_path to show the full path and not the trimmed one
Browse files Browse the repository at this point in the history
  • Loading branch information
da-x committed Oct 6, 2020
1 parent 8fe73e8 commit d25c580
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_symbol_mangling/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//! paths etc in all kinds of annoying scenarios.

use rustc_hir as hir;
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::{Instance, TyCtxt};
use rustc_span::symbol::{sym, Symbol};

Expand Down Expand Up @@ -44,7 +45,7 @@ impl SymbolNamesTest<'tcx> {
tcx.sess.span_err(attr.span, &format!("demangling-alt({:#})", demangling));
}
} else if tcx.sess.check_name(attr, DEF_PATH) {
let path = tcx.def_path_str(def_id.to_def_id());
let path = with_no_trimmed_paths(|| tcx.def_path_str(def_id.to_def_id()));
tcx.sess.span_err(attr.span, &format!("def-path({})", path));
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/symbol-names/impl1.legacy.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ error: demangling-alt(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::A
LL | #[rustc_symbol_name]
| ^^^^^^^^^^^^^^^^^^^^

error: def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as Bar>::method)
error: def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method)
--> $DIR/impl1.rs:71:13
|
LL | #[rustc_def_path]
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/symbol-names/impl1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ fn main() {
//[v0]~| ERROR demangling(<[&dyn impl1[317d481089b8c8fe]::Foo<Assoc = for<'a> extern "C" fn(&'a u8, ...)> + impl1[317d481089b8c8fe]::AutoTrait; 3: usize] as impl1[317d481089b8c8fe]::main::{closure#1}::Bar>::method)
//[v0]~| ERROR demangling-alt(<[&dyn impl1::Foo<Assoc = for<'a> extern "C" fn(&'a u8, ...)> + impl1::AutoTrait; 3] as impl1::main::{closure#1}::Bar>::method)
#[rustc_def_path]
//[legacy]~^ ERROR def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as Bar>::method)
//[v0]~^^ ERROR def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as Bar>::method)
//[legacy]~^ ERROR def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method)
//[v0]~^^ ERROR def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method)
fn method(&self) {}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/symbol-names/impl1.v0.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ error: demangling-alt(<[&dyn impl1::Foo<Assoc = for<'a> extern "C" fn(&'a u8, ..
LL | #[rustc_symbol_name]
| ^^^^^^^^^^^^^^^^^^^^

error: def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as Bar>::method)
error: def-path(<[&dyn Foo<Assoc = for<'r> extern "C" fn(&'r u8, ...)> + AutoTrait; 3] as main::{closure#1}::Bar>::method)
--> $DIR/impl1.rs:71:13
|
LL | #[rustc_def_path]
Expand Down

0 comments on commit d25c580

Please sign in to comment.