Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also run UnusedBrokenConst on associated consts. #70017

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
Skip reveal_all if needs_subst.
jumbatm committed Mar 29, 2020
commit 2bd7a232bfe711c8124d95023a1762b2de6b55aa
9 changes: 8 additions & 1 deletion src/librustc/mir/interpret/queries.rs
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ use super::{ConstEvalResult, ErrorHandled, GlobalId};
use crate::mir;
use crate::ty::subst::{InternalSubsts, SubstsRef};
use crate::ty::{self, TyCtxt};
use crate::ty::fold::TypeFoldable;
use rustc_hir::def_id::DefId;
use rustc_span::Span;

@@ -18,7 +19,13 @@ impl<'tcx> TyCtxt<'tcx> {
let substs = InternalSubsts::identity_for_item(self, def_id);
let instance = ty::Instance::new(def_id, substs);
let cid = GlobalId { instance, promoted: None };
let param_env = self.param_env(def_id).with_reveal_all();
let needs_subst = instance.needs_subst();
let param_env = if needs_subst {
self.param_env(def_id)
} else {
self.param_env(def_id).with_reveal_all()
};
debug!("const_eval_poly: needs_subst = {:?}. param_env = {:?}", needs_subst, param_env);
self.const_eval_global_id(param_env, cid, None)
}

4 changes: 3 additions & 1 deletion src/librustc_mir/interpret/place.rs
Original file line number Diff line number Diff line change
@@ -305,7 +305,9 @@ where
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
let pointee_type =
val.layout.ty.builtin_deref(true).expect("`ref_to_mplace` called on non-ptr type").ty;
let layout = self.layout_of(pointee_type)?;
let layout = self.layout_of(pointee_type);
debug!("ref_to_mplace: layout_of(pointee_type = {:?}) = {:?}", pointee_type, layout);
let layout = layout?;
let (ptr, meta) = match *val {
Immediate::Scalar(ptr) => (ptr.not_undef()?, MemPlaceMeta::None),
Immediate::ScalarPair(ptr, meta) => {