Rollup merge of #103875 - oli-obk:ast_conv_simplification, r=spastorino
Simplify astconv item def id handling
This commit is contained in:
commit
bb201b5d95
4 changed files with 9 additions and 15 deletions
|
@ -177,11 +177,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
.all_traits()
|
||||
.filter(|trait_def_id| {
|
||||
let viz = self.tcx().visibility(*trait_def_id);
|
||||
if let Some(def_id) = self.item_def_id() {
|
||||
viz.is_accessible_from(def_id, self.tcx())
|
||||
} else {
|
||||
viz.is_visible_locally()
|
||||
}
|
||||
let def_id = self.item_def_id();
|
||||
viz.is_accessible_from(def_id, self.tcx())
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ pub struct PathSeg(pub DefId, pub usize);
|
|||
pub trait AstConv<'tcx> {
|
||||
fn tcx<'a>(&'a self) -> TyCtxt<'tcx>;
|
||||
|
||||
fn item_def_id(&self) -> Option<DefId>;
|
||||
fn item_def_id(&self) -> DefId;
|
||||
|
||||
/// Returns predicates in scope of the form `X: Foo<T>`, where `X`
|
||||
/// is a type parameter `X` with the given id `def_id` and T
|
||||
|
@ -2082,17 +2082,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
|
||||
debug!("qpath_to_ty: self.item_def_id()={:?}", def_id);
|
||||
|
||||
let parent_def_id = def_id
|
||||
.and_then(|def_id| {
|
||||
def_id.as_local().map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id))
|
||||
})
|
||||
let parent_def_id = def_id.as_local().map(|def_id| tcx.hir().local_def_id_to_hir_id(def_id))
|
||||
.map(|hir_id| tcx.hir().get_parent_item(hir_id).to_def_id());
|
||||
|
||||
debug!("qpath_to_ty: parent_def_id={:?}", parent_def_id);
|
||||
|
||||
// If the trait in segment is the same as the trait defining the item,
|
||||
// use the `<Self as ..>` syntax in the error.
|
||||
let is_part_of_self_trait_constraints = def_id == Some(trait_def_id);
|
||||
let is_part_of_self_trait_constraints = def_id == trait_def_id;
|
||||
let is_part_of_fn_in_self_trait = parent_def_id == Some(trait_def_id);
|
||||
|
||||
let type_name = if is_part_of_self_trait_constraints || is_part_of_fn_in_self_trait {
|
||||
|
|
|
@ -379,8 +379,8 @@ impl<'tcx> AstConv<'tcx> for ItemCtxt<'tcx> {
|
|||
self.tcx
|
||||
}
|
||||
|
||||
fn item_def_id(&self) -> Option<DefId> {
|
||||
Some(self.item_def_id)
|
||||
fn item_def_id(&self) -> DefId {
|
||||
self.item_def_id
|
||||
}
|
||||
|
||||
fn get_type_parameter_bounds(
|
||||
|
|
|
@ -194,8 +194,8 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> {
|
|||
self.tcx
|
||||
}
|
||||
|
||||
fn item_def_id(&self) -> Option<DefId> {
|
||||
None
|
||||
fn item_def_id(&self) -> DefId {
|
||||
self.body_id.owner.to_def_id()
|
||||
}
|
||||
|
||||
fn get_type_parameter_bounds(
|
||||
|
|
Loading…
Add table
Reference in a new issue