use TypingEnv when no infcx is available
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
This commit is contained in:
@@ -9,9 +9,9 @@ pub(super) struct CheckPackedRef;
|
||||
|
||||
impl<'tcx> crate::MirLint<'tcx> for CheckPackedRef {
|
||||
fn run_lint(&self, tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
|
||||
let param_env = tcx.param_env(body.source.def_id());
|
||||
let typing_env = body.typing_env(tcx);
|
||||
let source_info = SourceInfo::outermost(body.span);
|
||||
let mut checker = PackedRefChecker { body, tcx, param_env, source_info };
|
||||
let mut checker = PackedRefChecker { body, tcx, typing_env, source_info };
|
||||
checker.visit_body(body);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ impl<'tcx> crate::MirLint<'tcx> for CheckPackedRef {
|
||||
struct PackedRefChecker<'a, 'tcx> {
|
||||
body: &'a Body<'tcx>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
typing_env: ty::TypingEnv<'tcx>,
|
||||
source_info: SourceInfo,
|
||||
}
|
||||
|
||||
@@ -37,7 +37,8 @@ impl<'tcx> Visitor<'tcx> for PackedRefChecker<'_, 'tcx> {
|
||||
}
|
||||
|
||||
fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, _location: Location) {
|
||||
if context.is_borrow() && util::is_disaligned(self.tcx, self.body, self.param_env, *place) {
|
||||
if context.is_borrow() && util::is_disaligned(self.tcx, self.body, self.typing_env, *place)
|
||||
{
|
||||
let def_id = self.body.source.instance.def_id();
|
||||
if let Some(impl_def_id) = self.tcx.impl_of_method(def_id)
|
||||
&& self.tcx.is_builtin_derived(impl_def_id)
|
||||
|
||||
Reference in New Issue
Block a user