review comments

This commit is contained in:
Esteban Küber 2019-09-26 14:38:01 -07:00
parent 46a38dc183
commit e537d066f2
3 changed files with 5 additions and 7 deletions

View file

@ -862,12 +862,12 @@ impl<'hir> Map<'hir> {
}
/// Returns the defining scope for an opaque type definition.
pub fn get_defining_scope(&self, id: HirId) -> Option<HirId> {
pub fn get_defining_scope(&self, id: HirId) -> HirId {
let mut scope = id;
loop {
scope = self.get_enclosing_scope(scope).unwrap_or(CRATE_HIR_ID);
if scope == CRATE_HIR_ID {
return Some(CRATE_HIR_ID);
return CRATE_HIR_ID;
}
match self.get(scope) {
Node::Item(i) => {
@ -880,7 +880,7 @@ impl<'hir> Map<'hir> {
_ => break,
}
}
Some(scope)
scope
}
pub fn get_parent_did(&self, id: HirId) -> DefId {

View file

@ -1215,7 +1215,7 @@ pub fn may_define_opaque_type(
let mut hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
// Named opaque types can be defined by any siblings or children of siblings.
let scope = tcx.hir().get_defining_scope(opaque_hir_id).expect("could not get defining scope");
let scope = tcx.hir().get_defining_scope(opaque_hir_id);
// We walk up the node tree until we hit the root or the scope of the opaque type.
while hir_id != scope && hir_id != hir::CRATE_HIR_ID {
hir_id = tcx.hir().get_parent_item(hir_id);

View file

@ -1717,9 +1717,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
}
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
let scope = tcx.hir()
.get_defining_scope(hir_id)
.expect("could not get defining scope");
let scope = tcx.hir().get_defining_scope(hir_id);
let mut locator = ConstraintLocator {
def_id,
tcx,