/// Remove flags which are impossible for the given type.
fn restrict(&mut self, ty: Ty<'tcx>,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
- param_env: &ty::ParameterEnvironment<'tcx>) {
+ param_env: ty::ParamEnv<'tcx>) {
if ty.is_freeze(tcx, param_env, DUMMY_SP) {
*self = *self - Qualif::MUTABLE_INTERIOR;
}
mir: &'a Mir<'tcx>,
rpo: ReversePostorder<'a, 'tcx>,
tcx: TyCtxt<'a, 'gcx, 'tcx>,
- param_env: ty::ParameterEnvironment<'tcx>,
+ param_env: ty::ParamEnv<'tcx>,
temp_qualif: IndexVec<Local, Option<Qualif>>,
return_qualif: Option<Qualif>,
qualif: Qualif,
impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
- param_env: ty::ParameterEnvironment<'tcx>,
+ param_env: ty::ParamEnv<'tcx>,
def_id: DefId,
mir: &'a Mir<'tcx>,
mode: Mode)
/// Add the given type's qualification to self.qualif.
fn add_type(&mut self, ty: Ty<'tcx>) {
self.add(Qualif::MUTABLE_INTERIOR | Qualif::NEEDS_DROP);
- self.qualif.restrict(ty, self.tcx, &self.param_env);
+ self.qualif.restrict(ty, self.tcx, self.param_env);
}
/// Within the provided closure, self.qualif will start
/// Qualify a whole const, static initializer or const fn.
fn qualify_const(&mut self) -> Qualif {
- debug!("qualifying {} {}", self.mode, self.tcx.item_path_str(self.def_id));
+ debug!("qualifying {} {:?}", self.mode, self.def_id);
let mir = self.mir;
static, use a constant instead");
}
let ty = lvalue.ty(this.mir, this.tcx).to_ty(this.tcx);
- this.qualif.restrict(ty, this.tcx, &this.param_env);
+ this.qualif.restrict(ty, this.tcx, this.param_env);
}
ProjectionElem::ConstantIndex {..} |
match *rvalue {
Rvalue::Use(_) |
Rvalue::Repeat(..) |
- Rvalue::UnaryOp(..) |
+ Rvalue::UnaryOp(UnOp::Neg, _) |
+ Rvalue::UnaryOp(UnOp::Not, _) |
+ Rvalue::NullaryOp(NullOp::SizeOf, _) |
Rvalue::CheckedBinaryOp(..) |
Rvalue::Cast(CastKind::ReifyFnPointer, ..) |
Rvalue::Cast(CastKind::UnsafeFnPointer, ..) |
if let ty::TyRawPtr(_) = lhs.ty(self.mir, self.tcx).sty {
assert!(op == BinOp::Eq || op == BinOp::Ne ||
op == BinOp::Le || op == BinOp::Lt ||
- op == BinOp::Ge || op == BinOp::Gt);
+ op == BinOp::Ge || op == BinOp::Gt ||
+ op == BinOp::Offset);
self.add(Qualif::NOT_CONST);
if self.mode != Mode::Fn {
}
}
- Rvalue::Box(_) => {
+ Rvalue::NullaryOp(NullOp::Box, _) => {
self.add(Qualif::NOT_CONST);
if self.mode != Mode::Fn {
struct_span_err!(self.tcx.sess, self.span, E0010,
return Qualif::NOT_CONST.bits();
}
- let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
- let param_env = ty::ParameterEnvironment::for_item(tcx, node_id);
+ let param_env = tcx.param_env(def_id);
let mut qualifier = Qualifier::new(tcx, param_env, def_id, mir, Mode::Const);
qualifier.qualify_const().bits()
MirSource::Const(_) |
MirSource::Promoted(..) => return
};
- let param_env = ty::ParameterEnvironment::for_item(tcx, id);
+ let param_env = tcx.param_env(def_id);
if mode == Mode::Fn || mode == Mode::ConstFn {
// This is ugly because Qualifier holds onto mir,
// Statics must be Sync.
if mode == Mode::Static {
let ty = mir.return_ty;
- tcx.infer_ctxt((), Reveal::UserFacing).enter(|infcx| {
+ tcx.infer_ctxt(Reveal::UserFacing).enter(|infcx| {
let cause = traits::ObligationCause::new(mir.span, id, traits::SharedStatic);
let mut fulfillment_cx = traits::FulfillmentContext::new();
fulfillment_cx.register_bound(&infcx, ty,