diff options
| author | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-07-16 11:19:36 +0200 |
|---|---|---|
| committer | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-07-18 10:53:08 +0200 |
| commit | 160cbdaeeaa1e401328bdc206ff451d168ea4f1d (patch) | |
| tree | 43fd85af1680ceff26c2c2e7946807cf8248a3fc /src | |
| parent | 4e8cc76a91d22d060e0278be8f441533227a05fa (diff) | |
| download | rust-160cbdaeeaa1e401328bdc206ff451d168ea4f1d.tar.gz rust-160cbdaeeaa1e401328bdc206ff451d168ea4f1d.zip | |
Don't call `local_def_id` twice on the same node id
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/collect.rs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index ab81cb8788f..e9510d118f7 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1185,8 +1185,7 @@ fn find_existential_constraints<'a, 'tcx>( found: Option<(Span, ty::Ty<'tcx>)>, } impl<'a, 'tcx> ConstraintLocator<'a, 'tcx> { - fn check(&mut self, node_id: ast::NodeId) { - let def_id = self.tcx.hir.local_def_id(node_id); + fn check(&mut self, def_id: DefId) { // don't try to check items that cannot possibly constrain the type if !self.tcx.has_typeck_tables(def_id) { return; @@ -1221,21 +1220,24 @@ fn find_existential_constraints<'a, 'tcx>( intravisit::NestedVisitorMap::All(&self.tcx.hir) } fn visit_item(&mut self, it: &'tcx Item) { + let def_id = self.tcx.hir.local_def_id(it.id); // the existential type itself or its children are not within its reveal scope - if self.tcx.hir.local_def_id(it.id) != self.def_id { - self.check(it.id); + if def_id != self.def_id { + self.check(def_id); intravisit::walk_item(self, it); } } fn visit_impl_item(&mut self, it: &'tcx ImplItem) { + let def_id = self.tcx.hir.local_def_id(it.id); // the existential type itself or its children are not within its reveal scope - if self.tcx.hir.local_def_id(it.id) != self.def_id { - self.check(it.id); + if def_id != self.def_id { + self.check(def_id); intravisit::walk_impl_item(self, it); } } fn visit_trait_item(&mut self, it: &'tcx TraitItem) { - self.check(it.id); + let def_id = self.tcx.hir.local_def_id(it.id); + self.check(def_id); intravisit::walk_trait_item(self, it); } } |
