diff options
| author | bors <bors@rust-lang.org> | 2021-07-23 12:33:58 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-07-23 12:33:58 +0000 |
| commit | 0443424954f32d94f847322e85c77df50d44f80f (patch) | |
| tree | 5bdebedf6bc132939c7687c1c719124b40c594e3 /compiler | |
| parent | b2b7c859c1aae39d26884e760201f5e6c7feeff9 (diff) | |
| parent | 7c0c329635cde6602dc6d49a0f44459ff0c8b544 (diff) | |
| download | rust-0443424954f32d94f847322e85c77df50d44f80f.tar.gz rust-0443424954f32d94f847322e85c77df50d44f80f.zip | |
Auto merge of #87400 - JohnTitor:rollup-zbwyuxi, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #87034 (DOC: fix hypothetical Rust code in `step_by()` docstring) - #87298 (memorialize Anna Harren in the bastion of the turbofish) - #87332 (Don't hide fields of enum struct variants) - #87362 (Make `x.py d` an alias for `x.py doc`) - #87372 (Move calls to test_main into one function) - #87373 (Extend HIR WF checking to fields) - #87376 (Change rustdoc logo to use the full container size) - #87383 (Add regression tests for the impl_trait_in_bindings ICEs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_typeck/src/check/wfcheck.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/hir_wf_check.rs | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs index 98980c65bc8..e33cc603b5e 100644 --- a/compiler/rustc_typeck/src/check/wfcheck.rs +++ b/compiler/rustc_typeck/src/check/wfcheck.rs @@ -523,8 +523,7 @@ fn check_type_defn<'tcx, F>( fcx.register_wf_obligation( field.ty.into(), field.span, - // We don't have an HIR id for the field - ObligationCauseCode::WellFormed(None), + ObligationCauseCode::WellFormed(Some(WellFormedLoc::Ty(field.def_id))), ) } @@ -1467,6 +1466,7 @@ struct AdtVariant<'tcx> { struct AdtField<'tcx> { ty: Ty<'tcx>, + def_id: LocalDefId, span: Span, } @@ -1477,11 +1477,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .fields() .iter() .map(|field| { - let field_ty = self.tcx.type_of(self.tcx.hir().local_def_id(field.hir_id)); + let def_id = self.tcx.hir().local_def_id(field.hir_id); + let field_ty = self.tcx.type_of(def_id); let field_ty = self.normalize_associated_types_in(field.ty.span, field_ty); let field_ty = self.resolve_vars_if_possible(field_ty); debug!("non_enum_variant: type of field {:?} is {:?}", field, field_ty); - AdtField { ty: field_ty, span: field.ty.span } + AdtField { ty: field_ty, span: field.ty.span, def_id } }) .collect(); AdtVariant { fields, explicit_discr: None } diff --git a/compiler/rustc_typeck/src/hir_wf_check.rs b/compiler/rustc_typeck/src/hir_wf_check.rs index c1af10f5ce4..e7503d3d71c 100644 --- a/compiler/rustc_typeck/src/hir_wf_check.rs +++ b/compiler/rustc_typeck/src/hir_wf_check.rs @@ -25,7 +25,7 @@ fn diagnostic_hir_wf_check<'tcx>( WellFormedLoc::Ty(def_id) => def_id, WellFormedLoc::Param { function, param_idx: _ } => function, }; - let hir_id = HirId::make_owner(def_id); + let hir_id = hir.local_def_id_to_hir_id(def_id); // HIR wfcheck should only ever happen as part of improving an existing error tcx.sess @@ -140,6 +140,7 @@ fn diagnostic_hir_wf_check<'tcx>( } ref item => bug!("Unexpected item {:?}", item), }, + hir::Node::Field(field) => Some(field.ty), ref node => bug!("Unexpected node {:?}", node), }, WellFormedLoc::Param { function: _, param_idx } => { |
