Try to evaluate constants in legacy mangling
This commit is contained in:
parent
2ce89ee1c4
commit
9ecdc54d82
4 changed files with 37 additions and 10 deletions
|
@ -2,7 +2,7 @@ use std::fmt::{self, Write};
|
||||||
use std::mem::{self, discriminant};
|
use std::mem::{self, discriminant};
|
||||||
|
|
||||||
use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher};
|
use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher};
|
||||||
use rustc_hir::def_id::CrateNum;
|
use rustc_hir::def_id::{CrateNum, DefId};
|
||||||
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
use rustc_middle::ty::print::{PrettyPrinter, Print, PrintError, Printer};
|
use rustc_middle::ty::print::{PrettyPrinter, Print, PrintError, Printer};
|
||||||
|
@ -378,6 +378,33 @@ impl<'tcx> Printer<'tcx> for SymbolPrinter<'tcx> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn print_impl_path(
|
||||||
|
&mut self,
|
||||||
|
impl_def_id: DefId,
|
||||||
|
args: &'tcx [GenericArg<'tcx>],
|
||||||
|
mut self_ty: Ty<'tcx>,
|
||||||
|
mut impl_trait_ref: Option<ty::TraitRef<'tcx>>,
|
||||||
|
) -> Result<(), PrintError> {
|
||||||
|
let mut typing_env = ty::TypingEnv::post_analysis(self.tcx, impl_def_id);
|
||||||
|
if !args.is_empty() {
|
||||||
|
typing_env.param_env =
|
||||||
|
ty::EarlyBinder::bind(typing_env.param_env).instantiate(self.tcx, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
match &mut impl_trait_ref {
|
||||||
|
Some(impl_trait_ref) => {
|
||||||
|
assert_eq!(impl_trait_ref.self_ty(), self_ty);
|
||||||
|
*impl_trait_ref = self.tcx.normalize_erasing_regions(typing_env, *impl_trait_ref);
|
||||||
|
self_ty = impl_trait_ref.self_ty();
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
self_ty = self.tcx.normalize_erasing_regions(typing_env, self_ty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.default_print_impl_path(impl_def_id, args, self_ty, impl_trait_ref)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> PrettyPrinter<'tcx> for SymbolPrinter<'tcx> {
|
impl<'tcx> PrettyPrinter<'tcx> for SymbolPrinter<'tcx> {
|
||||||
|
|
|
@ -502,19 +502,19 @@ error: demangling-alt(a::b::Type<[T; N]>)
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: symbol-name(_ZN1a1b35Type$LT$$u5b$u8$u3b$$u20$_$u5d$$GT$17h[HASH]E)
|
error: symbol-name(_ZN1a1b35Type$LT$$u5b$u8$u3b$$u20$0$u5d$$GT$17h[HASH]E)
|
||||||
--> $DIR/types.rs:272:5
|
--> $DIR/types.rs:272:5
|
||||||
|
|
|
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: demangling(a::b::Type<[u8; _]>::h[HASH])
|
error: demangling(a::b::Type<[u8; 0]>::h[HASH])
|
||||||
--> $DIR/types.rs:272:5
|
--> $DIR/types.rs:272:5
|
||||||
|
|
|
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: demangling-alt(a::b::Type<[u8; _]>)
|
error: demangling-alt(a::b::Type<[u8; 0]>)
|
||||||
--> $DIR/types.rs:272:5
|
--> $DIR/types.rs:272:5
|
||||||
|
|
|
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
|
|
|
@ -270,9 +270,9 @@ pub fn b() {
|
||||||
const ZERO: usize = 0;
|
const ZERO: usize = 0;
|
||||||
|
|
||||||
#[rustc_symbol_name]
|
#[rustc_symbol_name]
|
||||||
//[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b35Type$LT$$u5b$u8$u3b$$u20$_$u5d$$GT$
|
//[legacy,verbose-legacy]~^ ERROR symbol-name(_ZN1a1b35Type$LT$$u5b$u8$u3b$$u20$0$u5d$$GT$
|
||||||
//[legacy,verbose-legacy]~| ERROR demangling(a::b::Type<[u8; _]>::
|
//[legacy,verbose-legacy]~| ERROR demangling(a::b::Type<[u8; 0]>::
|
||||||
//[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type<[u8; _]>)
|
//[legacy,verbose-legacy]~| ERROR demangling-alt(a::b::Type<[u8; 0]>)
|
||||||
//[v0]~^^^^ ERROR symbol-name(_RMsq_NvCsCRATE_HASH_1a1bINtB<REF>_4TypeAhj0_E)
|
//[v0]~^^^^ ERROR symbol-name(_RMsq_NvCsCRATE_HASH_1a1bINtB<REF>_4TypeAhj0_E)
|
||||||
//[v0]~| ERROR ::b::Type<[u8; 0usize]>>)
|
//[v0]~| ERROR ::b::Type<[u8; 0usize]>>)
|
||||||
//[v0]~| ERROR demangling-alt(<a::b::Type<[u8; 0]>>)
|
//[v0]~| ERROR demangling-alt(<a::b::Type<[u8; 0]>>)
|
||||||
|
|
|
@ -502,19 +502,19 @@ error: demangling-alt(a::b::Type<[T; N]>)
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: symbol-name(_ZN1a1b35Type$LT$$u5b$u8$u3b$$u20$_$u5d$$GT$17h[HASH]E)
|
error: symbol-name(_ZN1a1b35Type$LT$$u5b$u8$u3b$$u20$0$u5d$$GT$17h[HASH]E)
|
||||||
--> $DIR/types.rs:272:5
|
--> $DIR/types.rs:272:5
|
||||||
|
|
|
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: demangling(a::b::Type<[u8; _]>::h[HASH])
|
error: demangling(a::b::Type<[u8; 0]>::h[HASH])
|
||||||
--> $DIR/types.rs:272:5
|
--> $DIR/types.rs:272:5
|
||||||
|
|
|
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: demangling-alt(a::b::Type<[u8; _]>)
|
error: demangling-alt(a::b::Type<[u8; 0]>)
|
||||||
--> $DIR/types.rs:272:5
|
--> $DIR/types.rs:272:5
|
||||||
|
|
|
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue