From 207531606476a1fa03de815c2a112f3909cda48a Mon Sep 17 00:00:00 2001 From: Masaki Hara Date: Thu, 27 Sep 2018 00:14:38 +0900 Subject: Include InstanceDef's discriminant in the symbol hash. --- src/librustc_codegen_utils/symbol_names.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/librustc_codegen_utils') diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs index 27700bab245..0d95b0c7bbc 100644 --- a/src/librustc_codegen_utils/symbol_names.rs +++ b/src/librustc_codegen_utils/symbol_names.rs @@ -114,6 +114,7 @@ use rustc_mir::monomorphize::Instance; use syntax_pos::symbol::Symbol; use std::fmt::Write; +use std::mem::discriminant; pub fn provide(providers: &mut Providers) { *providers = Providers { @@ -220,8 +221,9 @@ fn get_symbol_hash<'a, 'tcx>( (&tcx.crate_disambiguator(instantiating_crate)).hash_stable(&mut hcx, &mut hasher); } - let is_vtable_shim = instance.is_vtable_shim(); - is_vtable_shim.hash_stable(&mut hcx, &mut hasher); + // We want to avoid accidental collision between different types of instances. + // Especially, VtableShim may overlap with its original instance without this. + discriminant(&instance.def).hash_stable(&mut hcx, &mut hasher); }); // 64 bits should be enough to avoid collisions. -- cgit 1.4.1-3-g733a5