diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-07-25 18:46:54 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-25 18:46:54 +0900 |
| commit | cb512888f353fd56be0074ab2b1f49da215ca440 (patch) | |
| tree | 5459d28929cfdefe0fe6227b7ee68bbad4a402ce | |
| parent | f4c25270d4df28e48f78a9b2bcbcccbf53b1e63b (diff) | |
| parent | f7326989e63ab8944493e8ff03447bb9a7d83141 (diff) | |
| download | rust-cb512888f353fd56be0074ab2b1f49da215ca440.tar.gz rust-cb512888f353fd56be0074ab2b1f49da215ca440.zip | |
Rollup merge of #99659 - compiler-errors:opaque-type-nit, r=oli-obk
Use `VecMap::get` in `ConstraintLocator::check` Also rename the `def_id` param to `item_def_id` because that's easily confused with `self.def_id` (which is the opaque ty did).
| -rw-r--r-- | compiler/rustc_typeck/src/collect/type_of.rs | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index faa4f3700bb..1d7406e00ad 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -538,9 +538,9 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { impl ConstraintLocator<'_> { #[instrument(skip(self), level = "debug")] - fn check(&mut self, def_id: LocalDefId) { + fn check(&mut self, item_def_id: LocalDefId) { // Don't try to check items that cannot possibly constrain the type. - if !self.tcx.has_typeck_results(def_id) { + if !self.tcx.has_typeck_results(item_def_id) { debug!("no constraint: no typeck results"); return; } @@ -555,26 +555,20 @@ fn find_opaque_ty_constraints(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Ty<'_> { // // because we again need to reveal `Foo` so we can check whether the // // constant does not contain interior mutability. // ``` - let tables = self.tcx.typeck(def_id); + let tables = self.tcx.typeck(item_def_id); if let Some(_) = tables.tainted_by_errors { self.found = Some(ty::OpaqueHiddenType { span: DUMMY_SP, ty: self.tcx.ty_error() }); return; } - if tables.concrete_opaque_types.get(&self.def_id).is_none() { + if !tables.concrete_opaque_types.contains_key(&self.def_id) { debug!("no constraints in typeck results"); return; } // Use borrowck to get the type with unerased regions. - let concrete_opaque_types = &self.tcx.mir_borrowck(def_id).concrete_opaque_types; + let concrete_opaque_types = &self.tcx.mir_borrowck(item_def_id).concrete_opaque_types; debug!(?concrete_opaque_types); - for &(def_id, concrete_type) in concrete_opaque_types { - if def_id != self.def_id { - // Ignore constraints for other opaque types. - continue; - } - + if let Some(&concrete_type) = concrete_opaque_types.get(&self.def_id) { debug!(?concrete_type, "found constraint"); - if let Some(prev) = self.found { if concrete_type.ty != prev.ty && !(concrete_type, prev).references_error() { prev.report_mismatch(&concrete_type, self.tcx); |
