diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_ast/src/mut_visit.rs | 23 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/const_eval/machine.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/machine.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/memory.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_passes/src/check_attr.rs | 3 |
5 files changed, 46 insertions, 5 deletions
diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index b159e136245..4edd0864300 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -238,6 +238,10 @@ pub trait MutVisitor: Sized { walk_ident(self, i); } + fn visit_modifiers(&mut self, m: &mut TraitBoundModifiers) { + walk_modifiers(self, m); + } + fn visit_path(&mut self, p: &mut Path) { walk_path(self, p); } @@ -1156,12 +1160,29 @@ fn walk_trait_ref<T: MutVisitor>(vis: &mut T, TraitRef { path, ref_id }: &mut Tr } fn walk_poly_trait_ref<T: MutVisitor>(vis: &mut T, p: &mut PolyTraitRef) { - let PolyTraitRef { bound_generic_params, modifiers: _, trait_ref, span } = p; + let PolyTraitRef { bound_generic_params, modifiers, trait_ref, span } = p; + vis.visit_modifiers(modifiers); bound_generic_params.flat_map_in_place(|param| vis.flat_map_generic_param(param)); vis.visit_trait_ref(trait_ref); vis.visit_span(span); } +fn walk_modifiers<V: MutVisitor>(vis: &mut V, m: &mut TraitBoundModifiers) { + let TraitBoundModifiers { constness, asyncness, polarity } = m; + match constness { + BoundConstness::Never => {} + BoundConstness::Always(span) | BoundConstness::Maybe(span) => vis.visit_span(span), + } + match asyncness { + BoundAsyncness::Normal => {} + BoundAsyncness::Async(span) => vis.visit_span(span), + } + match polarity { + BoundPolarity::Positive => {} + BoundPolarity::Negative(span) | BoundPolarity::Maybe(span) => vis.visit_span(span), + } +} + pub fn walk_field_def<T: MutVisitor>(visitor: &mut T, fd: &mut FieldDef) { let FieldDef { span, ident, vis, id, ty, attrs, is_placeholder: _, safety, default } = fd; visitor.visit_id(id); diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 4db862afd9f..496f6c86f71 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -22,7 +22,7 @@ use crate::errors::{LongRunning, LongRunningWarn}; use crate::fluent_generated as fluent; use crate::interpret::{ self, AllocId, AllocInit, AllocRange, ConstAllocation, CtfeProvenance, FnArg, Frame, - GlobalAlloc, ImmTy, InterpCx, InterpResult, MPlaceTy, OpTy, RangeSet, Scalar, + GlobalAlloc, ImmTy, InterpCx, InterpResult, MPlaceTy, OpTy, Pointer, RangeSet, Scalar, compile_time_machine, interp_ok, throw_exhaust, throw_inval, throw_ub, throw_ub_custom, throw_unsup, throw_unsup_format, }; @@ -688,6 +688,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> { _tcx: TyCtxtAt<'tcx>, _machine: &mut Self, _alloc_extra: &mut Self::AllocExtra, + _ptr: Pointer<Option<Self::Provenance>>, (_alloc_id, immutable): (AllocId, bool), range: AllocRange, ) -> InterpResult<'tcx> { diff --git a/compiler/rustc_const_eval/src/interpret/machine.rs b/compiler/rustc_const_eval/src/interpret/machine.rs index a21bf018d01..e5026eff21f 100644 --- a/compiler/rustc_const_eval/src/interpret/machine.rs +++ b/compiler/rustc_const_eval/src/interpret/machine.rs @@ -400,6 +400,8 @@ pub trait Machine<'tcx>: Sized { ) -> InterpResult<'tcx, Self::AllocExtra>; /// Hook for performing extra checks on a memory read access. + /// `ptr` will always be a pointer with the provenance in `prov` pointing to the beginning of + /// `range`. /// /// This will *not* be called during validation! /// @@ -413,6 +415,7 @@ pub trait Machine<'tcx>: Sized { _tcx: TyCtxtAt<'tcx>, _machine: &Self, _alloc_extra: &Self::AllocExtra, + _ptr: Pointer<Option<Self::Provenance>>, _prov: (AllocId, Self::ProvenanceExtra), _range: AllocRange, ) -> InterpResult<'tcx> { @@ -432,11 +435,14 @@ pub trait Machine<'tcx>: Sized { /// Hook for performing extra checks on a memory write access. /// This is not invoked for ZST accesses, as no write actually happens. + /// `ptr` will always be a pointer with the provenance in `prov` pointing to the beginning of + /// `range`. #[inline(always)] fn before_memory_write( _tcx: TyCtxtAt<'tcx>, _machine: &mut Self, _alloc_extra: &mut Self::AllocExtra, + _ptr: Pointer<Option<Self::Provenance>>, _prov: (AllocId, Self::ProvenanceExtra), _range: AllocRange, ) -> InterpResult<'tcx> { @@ -444,11 +450,14 @@ pub trait Machine<'tcx>: Sized { } /// Hook for performing extra operations on a memory deallocation. + /// `ptr` will always be a pointer with the provenance in `prov` pointing to the beginning of + /// the allocation. #[inline(always)] fn before_memory_deallocation( _tcx: TyCtxtAt<'tcx>, _machine: &mut Self, _alloc_extra: &mut Self::AllocExtra, + _ptr: Pointer<Option<Self::Provenance>>, _prov: (AllocId, Self::ProvenanceExtra), _size: Size, _align: Align, diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs index 75726269a86..8f286971e63 100644 --- a/compiler/rustc_const_eval/src/interpret/memory.rs +++ b/compiler/rustc_const_eval/src/interpret/memory.rs @@ -385,6 +385,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { self.tcx, &mut self.machine, &mut alloc.extra, + ptr, (alloc_id, prov), size, alloc.align, @@ -727,6 +728,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { self.tcx, &self.machine, &alloc.extra, + ptr, (alloc_id, prov), range, )?; @@ -816,7 +818,14 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { if let Some((alloc_id, offset, prov, alloc, machine)) = ptr_and_alloc { let range = alloc_range(offset, size); if !validation_in_progress { - M::before_memory_write(tcx, machine, &mut alloc.extra, (alloc_id, prov), range)?; + M::before_memory_write( + tcx, + machine, + &mut alloc.extra, + ptr, + (alloc_id, prov), + range, + )?; } interp_ok(Some(AllocRefMut { alloc, range, tcx: *tcx, alloc_id })) } else { @@ -1373,6 +1382,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { tcx, &self.machine, &src_alloc.extra, + src, (src_alloc_id, src_prov), src_range, )?; @@ -1403,6 +1413,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { tcx, extra, &mut dest_alloc.extra, + dest, (dest_alloc_id, dest_prov), dest_range, )?; diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index dca6f2959d2..e0739c342df 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -954,8 +954,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { tcx.dcx().emit_err(errors::DocAliasBadLocation { span, attr_str, location }); return; } - let item_name = self.tcx.hir_name(hir_id); - if item_name == doc_alias { + if self.tcx.hir_opt_name(hir_id) == Some(doc_alias) { tcx.dcx().emit_err(errors::DocAliasNotAnAlias { span, attr_str }); return; } |
