Skip to content

Commit 20106d5

Browse files
committed
unwrap() -> expect()
1 parent c3d9a73 commit 20106d5

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,17 @@ impl<'a> Resolver<'a> {
111111
(self.cstore().crate_name_untracked(def_id.krate), None)
112112
} else {
113113
let def_key = self.cstore().def_key(def_id);
114-
(
115-
// This unwrap is safe: crates must always have a name
116-
def_key.disambiguated_data.data.get_opt_name().unwrap(),
117-
// This unwrap is safe since we know this isn't the root
118-
Some(self.get_module(DefId { index: def_key.parent.unwrap(), ..def_id })),
119-
)
114+
let name = def_key
115+
.disambiguated_data
116+
.data
117+
.get_opt_name()
118+
.expect("given a DefId that wasn't a module");
119+
// This unwrap is safe since we know this isn't the root
120+
let parent = Some(self.get_module(DefId {
121+
index: def_key.parent.expect("failed to get parent for module"),
122+
..def_id
123+
}));
124+
(name, parent)
120125
};
121126

122127
// Allocate and return a new module with the information we found

0 commit comments

Comments
 (0)