Skip to content

Commit ea95e94

Browse files
Fix nits from review
1 parent 1e840f8 commit ea95e94

File tree

7 files changed

+23
-19
lines changed

7 files changed

+23
-19
lines changed

src/librustc/mir/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -2770,8 +2770,12 @@ pub struct BorrowCheckResult<'tcx> {
27702770
}
27712771

27722772
/// The result of the `mir_const_qualif` query.
2773+
///
2774+
/// Each field corresponds to an implementer of the `Qualif` trait in
2775+
/// `librustc_mir/transform/check_consts/qualifs.rs`. See that file for more information on each
2776+
/// `Qualif`.
27732777
#[derive(Clone, Copy, Debug, Default, RustcEncodable, RustcDecodable, HashStable)]
2774-
pub struct QualifSet {
2778+
pub struct ConstQualifs {
27752779
pub has_mut_interior: bool,
27762780
pub needs_drop: bool,
27772781
}

src/librustc/query/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ rustc_queries! {
9191
}
9292

9393
/// Maps DefId's that have an associated `mir::Body` to the result
94-
/// of the MIR qualify_consts pass. The actual meaning of
95-
/// the value isn't known except to the pass itself.
96-
query mir_const_qualif(key: DefId) -> mir::QualifSet {
94+
/// of the MIR const-checking pass. This is the set of qualifs in
95+
/// the final value of a `const`.
96+
query mir_const_qualif(key: DefId) -> mir::ConstQualifs {
9797
desc { |tcx| "const checking `{}`", tcx.def_path_str(key) }
9898
cache_on_disk_if { key.is_local() }
9999
}

src/librustc_metadata/rmeta/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ impl<'a, 'tcx> CrateMetadata {
952952
.decode((self, tcx))
953953
}
954954

955-
fn mir_const_qualif(&self, id: DefIndex) -> mir::QualifSet {
955+
fn mir_const_qualif(&self, id: DefIndex) -> mir::ConstQualifs {
956956
match self.kind(id) {
957957
EntryKind::Const(qualif, _) |
958958
EntryKind::AssocConst(AssocContainer::ImplDefault, qualif, _) |

src/librustc_metadata/rmeta/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ enum EntryKind<'tcx> {
295295
/// Additional data for EntryKind::Const and EntryKind::AssocConst
296296
#[derive(Clone, Copy, RustcEncodable, RustcDecodable)]
297297
struct ConstQualif {
298-
mir: mir::QualifSet,
298+
mir: mir::ConstQualifs,
299299
}
300300

301301
/// Contains a constant which has been rendered to a String.

src/librustc_mir/transform/check_consts/qualifs.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use syntax_pos::DUMMY_SP;
66

77
use super::{ConstKind, Item as ConstCx};
88

9-
pub fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> QualifSet {
10-
QualifSet {
9+
pub fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> ConstQualifs {
10+
ConstQualifs {
1111
has_mut_interior: HasMutInterior::in_any_value_of_ty(cx, ty),
1212
needs_drop: NeedsDrop::in_any_value_of_ty(cx, ty),
1313
}
@@ -26,7 +26,7 @@ pub trait Qualif {
2626
/// Whether this `Qualif` is cleared when a local is moved from.
2727
const IS_CLEARED_ON_MOVE: bool = false;
2828

29-
fn in_qualif_set(set: &QualifSet) -> bool;
29+
fn in_qualifs(qualifs: &ConstQualifs) -> bool;
3030

3131
/// Return the qualification that is (conservatively) correct for any value
3232
/// of the type.
@@ -121,7 +121,7 @@ pub trait Qualif {
121121
Self::in_any_value_of_ty(cx, constant.literal.ty)
122122
} else {
123123
let qualifs = cx.tcx.at(constant.span).mir_const_qualif(def_id);
124-
let qualif = Self::in_qualif_set(&qualifs);
124+
let qualif = Self::in_qualifs(&qualifs);
125125

126126
// Just in case the type is more specific than
127127
// the definition, e.g., impl associated const
@@ -209,8 +209,8 @@ pub struct HasMutInterior;
209209
impl Qualif for HasMutInterior {
210210
const ANALYSIS_NAME: &'static str = "flow_has_mut_interior";
211211

212-
fn in_qualif_set(set: &QualifSet) -> bool {
213-
set.has_mut_interior
212+
fn in_qualifs(qualifs: &ConstQualifs) -> bool {
213+
qualifs.has_mut_interior
214214
}
215215

216216
fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
@@ -278,8 +278,8 @@ impl Qualif for NeedsDrop {
278278
const ANALYSIS_NAME: &'static str = "flow_needs_drop";
279279
const IS_CLEARED_ON_MOVE: bool = true;
280280

281-
fn in_qualif_set(set: &QualifSet) -> bool {
282-
set.needs_drop
281+
fn in_qualifs(qualifs: &ConstQualifs) -> bool {
282+
qualifs.needs_drop
283283
}
284284

285285
fn in_any_value_of_ty(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {

src/librustc_mir/transform/check_consts/validation.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl Qualifs<'a, 'mir, 'tcx> {
113113
|| self.indirectly_mutable.get().contains(local)
114114
}
115115

116-
fn in_return_place(&mut self, item: &Item<'_, 'tcx>) -> QualifSet {
116+
fn in_return_place(&mut self, item: &Item<'_, 'tcx>) -> ConstQualifs {
117117
// Find the `Return` terminator if one exists.
118118
//
119119
// If no `Return` terminator exists, this MIR is divergent. Just return the conservative
@@ -136,7 +136,7 @@ impl Qualifs<'a, 'mir, 'tcx> {
136136

137137
let return_loc = item.body.terminator_loc(return_block);
138138

139-
QualifSet {
139+
ConstQualifs {
140140
needs_drop: self.needs_drop_lazy_seek(RETURN_PLACE, return_loc),
141141
has_mut_interior: self.has_mut_interior_lazy_seek(RETURN_PLACE, return_loc),
142142
}
@@ -253,7 +253,7 @@ impl Validator<'a, 'mir, 'tcx> {
253253
}
254254
}
255255

256-
pub fn qualifs_in_return_place(&mut self) -> QualifSet {
256+
pub fn qualifs_in_return_place(&mut self) -> ConstQualifs {
257257
self.qualifs.in_return_place(self.item)
258258
}
259259

src/librustc_mir/transform/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{build, shim};
22
use rustc_index::vec::IndexVec;
33
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
4-
use rustc::mir::{Body, MirPhase, Promoted, QualifSet};
4+
use rustc::mir::{Body, MirPhase, Promoted, ConstQualifs};
55
use rustc::ty::{TyCtxt, InstanceDef, TypeFoldable};
66
use rustc::ty::query::Providers;
77
use rustc::ty::steal::Steal;
@@ -184,7 +184,7 @@ pub fn run_passes(
184184
body.phase = mir_phase;
185185
}
186186

187-
fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> QualifSet {
187+
fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> ConstQualifs {
188188
let const_kind = check_consts::ConstKind::for_item(tcx, def_id);
189189

190190
// No need to const-check a non-const `fn`.

0 commit comments

Comments
 (0)