Skip to content

Commit fdeb4ca

Browse files
committed
review comments
1 parent ab86cec commit fdeb4ca

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
@@ -864,12 +864,12 @@ impl<'hir> Map<'hir> {
864864
}
865865

866866
/// Returns the defining scope for an opaque type definition.
867-
pub fn get_defining_scope(&self, id: HirId) -> Option<HirId> {
867+
pub fn get_defining_scope(&self, id: HirId) -> HirId {
868868
let mut scope = id;
869869
loop {
870870
scope = self.get_enclosing_scope(scope).unwrap_or(CRATE_HIR_ID);
871871
if scope == CRATE_HIR_ID {
872-
return Some(CRATE_HIR_ID);
872+
return CRATE_HIR_ID;
873873
}
874874
match self.get(scope) {
875875
Node::Item(i) => {
@@ -882,7 +882,7 @@ impl<'hir> Map<'hir> {
882882
_ => break,
883883
}
884884
}
885-
Some(scope)
885+
scope
886886
}
887887

888888
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
@@ -1201,7 +1201,7 @@ pub fn may_define_opaque_type(
12011201
let mut hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
12021202

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

src/librustc_typeck/collect.rs

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

16961696
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
1697-
let scope = tcx.hir()
1698-
.get_defining_scope(hir_id)
1699-
.expect("could not get defining scope");
1697+
let scope = tcx.hir().get_defining_scope(hir_id);
17001698
let mut locator = ConstraintLocator {
17011699
def_id,
17021700
tcx,

0 commit comments

Comments
 (0)