diff options
| author | Joshua Nelson <jyn514@gmail.com> | 2020-06-07 13:45:02 -0400 |
|---|---|---|
| committer | Joshua Nelson <jyn514@gmail.com> | 2020-07-16 18:26:57 -0400 |
| commit | 20106d5a2fda0f2fef97ce253e5d78d4cf030289 (patch) | |
| tree | 4aa9162f264e68d6b16bebf58aebd05f34090e70 /src | |
| parent | c3d9a730b748a3c8bf673b88a265faad67ec7d9d (diff) | |
| download | rust-20106d5a2fda0f2fef97ce253e5d78d4cf030289.tar.gz rust-20106d5a2fda0f2fef97ce253e5d78d4cf030289.zip | |
unwrap() -> expect()
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_resolve/build_reduced_graph.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 8db27babd05..45253fc8782 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -111,12 +111,17 @@ impl<'a> Resolver<'a> { (self.cstore().crate_name_untracked(def_id.krate), None) } else { let def_key = self.cstore().def_key(def_id); - ( - // This unwrap is safe: crates must always have a name - def_key.disambiguated_data.data.get_opt_name().unwrap(), - // This unwrap is safe since we know this isn't the root - Some(self.get_module(DefId { index: def_key.parent.unwrap(), ..def_id })), - ) + let name = def_key + .disambiguated_data + .data + .get_opt_name() + .expect("given a DefId that wasn't a module"); + // This unwrap is safe since we know this isn't the root + let parent = Some(self.get_module(DefId { + index: def_key.parent.expect("failed to get parent for module"), + ..def_id + })); + (name, parent) }; // Allocate and return a new module with the information we found |
