Fix nits from review
This commit is contained in:
parent
1e840f8893
commit
ea95e94f51
7 changed files with 23 additions and 19 deletions
|
|
@ -2770,8 +2770,12 @@ pub struct BorrowCheckResult<'tcx> {
|
|||
}
|
||||
|
||||
/// The result of the `mir_const_qualif` query.
|
||||
///
|
||||
/// Each field corresponds to an implementer of the `Qualif` trait in
|
||||
/// `librustc_mir/transform/check_consts/qualifs.rs`. See that file for more information on each
|
||||
/// `Qualif`.
|
||||
#[derive(Clone, Copy, Debug, Default, RustcEncodable, RustcDecodable, HashStable)]
|
||||
pub struct QualifSet {
|
||||
pub struct ConstQualifs {
|
||||
pub has_mut_interior: bool,
|
||||
pub needs_drop: bool,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,9 +91,9 @@ rustc_queries! {
|
|||
}
|
||||
|
||||
/// Maps DefId's that have an associated `mir::Body` to the result
|
||||
/// of the MIR qualify_consts pass. The actual meaning of
|
||||
/// the value isn't known except to the pass itself.
|
||||
query mir_const_qualif(key: DefId) -> mir::QualifSet {
|
||||
/// of the MIR const-checking pass. This is the set of qualifs in
|
||||
/// the final value of a `const`.
|
||||
query mir_const_qualif(key: DefId) -> mir::ConstQualifs {
|
||||
desc { |tcx| "const checking `{}`", tcx.def_path_str(key) }
|
||||
cache_on_disk_if { key.is_local() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -952,7 +952,7 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
.decode((self, tcx))
|
||||
}
|
||||
|
||||
fn mir_const_qualif(&self, id: DefIndex) -> mir::QualifSet {
|
||||
fn mir_const_qualif(&self, id: DefIndex) -> mir::ConstQualifs {
|
||||
match self.kind(id) {
|
||||
EntryKind::Const(qualif, _) |
|
||||
EntryKind::AssocConst(AssocContainer::ImplDefault, qualif, _) |
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ enum EntryKind<'tcx> {
|
|||
/// Additional data for EntryKind::Const and EntryKind::AssocConst
|
||||
#[derive(Clone, Copy, RustcEncodable, RustcDecodable)]
|
||||
struct ConstQualif {
|
||||
mir: mir::QualifSet,
|
||||
mir: mir::ConstQualifs,
|
||||
}
|
||||
|
||||
/// Contains a constant which has been rendered to a String.
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ use syntax_pos::DUMMY_SP;
|
|||
|
||||
use super::{ConstKind, Item as ConstCx};
|
||||
|
||||
pub fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> QualifSet {
|
||||
QualifSet {
|
||||
pub fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> ConstQualifs {
|
||||
ConstQualifs {
|
||||
has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty),
|
||||
needs_drop: NeedsDrop::in_any_value_of_ty(cx, ty),
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ pub trait Qualif {
|
|||
/// Whether this `Qualif` is cleared when a local is moved from.
|
||||
const IS_CLEARED_ON_MOVE: bool = false;
|
||||
|
||||
fn in_qualif_set(set: &QualifSet) -> bool;
|
||||
fn in_qualifs(qualifs: &ConstQualifs) -> bool;
|
||||
|
||||
/// Return the qualification that is (conservatively) correct for any value
|
||||
/// of the type.
|
||||
|
|
@ -121,7 +121,7 @@ pub trait Qualif {
|
|||
Self::in_any_value_of_ty(cx, constant.literal.ty)
|
||||
} else {
|
||||
let qualifs = cx.tcx.at(constant.span).mir_const_qualif(def_id);
|
||||
let qualif = Self::in_qualif_set(&qualifs);
|
||||
let qualif = Self::in_qualifs(&qualifs);
|
||||
|
||||
// Just in case the type is more specific than
|
||||
// the definition, e.g., impl associated const
|
||||
|
|
@ -209,8 +209,8 @@ pub struct HasMutInterior;
|
|||
impl Qualif for HasMutInterior {
|
||||
const ANALYSIS_NAME: &'static str = "flow_has_mut_interior";
|
||||
|
||||
fn in_qualif_set(set: &QualifSet) -> bool {
|
||||
set.has_mut_interior
|
||||
fn in_qualifs(qualifs: &ConstQualifs) -> bool {
|
||||
qualifs.has_mut_interior
|
||||
}
|
||||
|
||||
fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
|
|
@ -278,8 +278,8 @@ impl Qualif for NeedsDrop {
|
|||
const ANALYSIS_NAME: &'static str = "flow_needs_drop";
|
||||
const IS_CLEARED_ON_MOVE: bool = true;
|
||||
|
||||
fn in_qualif_set(set: &QualifSet) -> bool {
|
||||
set.needs_drop
|
||||
fn in_qualifs(qualifs: &ConstQualifs) -> bool {
|
||||
qualifs.needs_drop
|
||||
}
|
||||
|
||||
fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ impl Qualifs<'a, 'mir, 'tcx> {
|
|||
|| self.indirectly_mutable.get().contains(local)
|
||||
}
|
||||
|
||||
fn in_return_place(&mut self, item: &Item<'_, 'tcx>) -> QualifSet {
|
||||
fn in_return_place(&mut self, item: &Item<'_, 'tcx>) -> ConstQualifs {
|
||||
// Find the `Return` terminator if one exists.
|
||||
//
|
||||
// If no `Return` terminator exists, this MIR is divergent. Just return the conservative
|
||||
|
|
@ -136,7 +136,7 @@ impl Qualifs<'a, 'mir, 'tcx> {
|
|||
|
||||
let return_loc = item.body.terminator_loc(return_block);
|
||||
|
||||
QualifSet {
|
||||
ConstQualifs {
|
||||
needs_drop: self.needs_drop_lazy_seek(RETURN_PLACE, return_loc),
|
||||
has_mut_interior: self.has_mut_interior_lazy_seek(RETURN_PLACE, return_loc),
|
||||
}
|
||||
|
|
@ -253,7 +253,7 @@ impl Validator<'a, 'mir, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn qualifs_in_return_place(&mut self) -> QualifSet {
|
||||
pub fn qualifs_in_return_place(&mut self) -> ConstQualifs {
|
||||
self.qualifs.in_return_place(self.item)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{build, shim};
|
||||
use rustc_index::vec::IndexVec;
|
||||
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
|
||||
use rustc::mir::{Body, MirPhase, Promoted, QualifSet};
|
||||
use rustc::mir::{Body, MirPhase, Promoted, ConstQualifs};
|
||||
use rustc::ty::{TyCtxt, InstanceDef, TypeFoldable};
|
||||
use rustc::ty::query::Providers;
|
||||
use rustc::ty::steal::Steal;
|
||||
|
|
@ -184,7 +184,7 @@ pub fn run_passes(
|
|||
body.phase = mir_phase;
|
||||
}
|
||||
|
||||
fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> QualifSet {
|
||||
fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> ConstQualifs {
|
||||
let const_kind = check_consts::ConstKind::for_item(tcx, def_id);
|
||||
|
||||
// No need to const-check a non-const `fn`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue