Skip to content

Commit e537d06

Browse files
committed
review comments
1 parent 46a38dc commit e537d06

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

src/librustc/hir/map/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -862,12 +862,12 @@ impl<'hir> Map<'hir> {
862862
}
863863

864864
/// Returns the defining scope for an opaque type definition.
865-
pub fn get_defining_scope(&self, id: HirId) -> Option<HirId> {
865+
pub fn get_defining_scope(&self, id: HirId) -> HirId {
866866
let mut scope = id;
867867
loop {
868868
scope = self.get_enclosing_scope(scope).unwrap_or(CRATE_HIR_ID);
869869
if scope == CRATE_HIR_ID {
870-
return Some(CRATE_HIR_ID);
870+
return CRATE_HIR_ID;
871871
}
872872
match self.get(scope) {
873873
Node::Item(i) => {
@@ -880,7 +880,7 @@ impl<'hir> Map<'hir> {
880880
_ => break,
881881
}
882882
}
883-
Some(scope)
883+
scope
884884
}
885885

886886
pub fn get_parent_did(&self, id: HirId) -> DefId {

src/librustc/infer/opaque_types/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,7 @@ pub fn may_define_opaque_type(
12151215
let mut hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
12161216

12171217
// Named opaque types can be defined by any siblings or children of siblings.
1218-
let scope = tcx.hir().get_defining_scope(opaque_hir_id).expect("could not get defining scope");
1218+
let scope = tcx.hir().get_defining_scope(opaque_hir_id);
12191219
// We walk up the node tree until we hit the root or the scope of the opaque type.
12201220
while hir_id != scope && hir_id != hir::CRATE_HIR_ID {
12211221
hir_id = tcx.hir().get_parent_item(hir_id);

src/librustc_typeck/collect.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1717,9 +1717,7 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
17171717
}
17181718

17191719
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
1720-
let scope = tcx.hir()
1721-
.get_defining_scope(hir_id)
1722-
.expect("could not get defining scope");
1720+
let scope = tcx.hir().get_defining_scope(hir_id);
17231721
let mut locator = ConstraintLocator {
17241722
def_id,
17251723
tcx,

0 commit comments

Comments
 (0)