Rollup merge of #75675 - davidtwco:symbol-mangling-impl-params, r=eddyb
mangling: mangle impl params w/ v0 scheme This PR modifies v0 symbol mangling to include all generic parameters from impl blocks (not just those used in the self type) - an alternative fix to #75326. ``` original: _RNCNvXCs4fqI2P2rA04_19impl_param_manglingINtB4_3FooppENtNtNtNtCsfnEnqCNU58Z_4core4iter6traits8iterator8Iterator4next0B4_ // |------------ B4_ ----------------| // _R (N C (N v (X (C ((s 4fqI2p2rA04_) 19impl_param_mangling)) (I (N t B4_ 3Foo) pp E) (N t (N t (N t (N t (C ((s fnEnqCNU58Z_) 4core)) 4iter) 6traits) 8iterator) 8Iterator)) 4next) 0) B4_ modified: _RNvXINICs4fqI2P2rA04_11issue_753260pppEINtB5_3FooppENtNtNtNtCsfnEnqCNU58Z_4core4iter6traits8iterator8Iterator4nextB5_ // _R (N v (X (I (N I (C ((s 4fqI2P2rA04_) 11issue_75326)) 0) ppp E) (I (N t B5_ 3Foo) pp E) (N t (N t (N t (N t (C ((s fnEnqCNU58Z_) 4core)) 4iter) 6traits) 8iterator) 8Iterator)) 4next) B5_ // | ^ | // | | | // | new impl namespace | ``` ~~Submitted as a draft as after some discussion w/ @eddyb, I'm going to do some investigation into (yet more alternative) changes to polymorphization that might remove the necessity for this.~~ r? @eddyb
This commit is contained in:
commit
1643fd86a7
8 changed files with 159 additions and 44 deletions
|
@ -291,7 +291,17 @@ impl<'tcx> Instance<'tcx> {
|
|||
}
|
||||
|
||||
pub fn mono(tcx: TyCtxt<'tcx>, def_id: DefId) -> Instance<'tcx> {
|
||||
Instance::new(def_id, tcx.empty_substs_for_def_id(def_id))
|
||||
let substs = InternalSubsts::for_item(tcx, def_id, |param, _| match param.kind {
|
||||
ty::GenericParamDefKind::Lifetime => tcx.lifetimes.re_erased.into(),
|
||||
ty::GenericParamDefKind::Type { .. } => {
|
||||
bug!("Instance::mono: {:?} has type parameters", def_id)
|
||||
}
|
||||
ty::GenericParamDefKind::Const { .. } => {
|
||||
bug!("Instance::mono: {:?} has const parameters", def_id)
|
||||
}
|
||||
});
|
||||
|
||||
Instance::new(def_id, substs)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -6,9 +6,9 @@ use crate::mir::interpret::{sign_extend, truncate};
|
|||
use crate::ty::fold::TypeFolder;
|
||||
use crate::ty::layout::IntegerExt;
|
||||
use crate::ty::query::TyCtxtAt;
|
||||
use crate::ty::subst::{GenericArgKind, InternalSubsts, Subst, SubstsRef};
|
||||
use crate::ty::subst::{GenericArgKind, Subst, SubstsRef};
|
||||
use crate::ty::TyKind::*;
|
||||
use crate::ty::{self, DefIdTree, GenericParamDefKind, List, Ty, TyCtxt, TypeFoldable};
|
||||
use crate::ty::{self, DefIdTree, List, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_apfloat::Float as _;
|
||||
use rustc_ast as ast;
|
||||
use rustc_attr::{self as attr, SignedInt, UnsignedInt};
|
||||
|
@ -509,20 +509,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
Some(ty::Binder::bind(env_ty))
|
||||
}
|
||||
|
||||
/// Given the `DefId` of some item that has no type or const parameters, make
|
||||
/// a suitable "empty substs" for it.
|
||||
pub fn empty_substs_for_def_id(self, item_def_id: DefId) -> SubstsRef<'tcx> {
|
||||
InternalSubsts::for_item(self, item_def_id, |param, _| match param.kind {
|
||||
GenericParamDefKind::Lifetime => self.lifetimes.re_erased.into(),
|
||||
GenericParamDefKind::Type { .. } => {
|
||||
bug!("empty_substs_for_def_id: {:?} has type parameters", item_def_id)
|
||||
}
|
||||
GenericParamDefKind::Const { .. } => {
|
||||
bug!("empty_substs_for_def_id: {:?} has const parameters", item_def_id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns `true` if the node pointed to by `def_id` is a `static` item.
|
||||
pub fn is_static(self, def_id: DefId) -> bool {
|
||||
self.static_mutability(def_id).is_some()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue