1
Fork 0

Remove in_band_lifetimes from borrowck

This commit is contained in:
Dániel Buga 2021-12-15 08:38:12 +01:00
parent 195e931b02
commit e837101890
15 changed files with 32 additions and 33 deletions

View file

@ -84,7 +84,7 @@ pub enum LocalsStateAtExit {
} }
impl LocalsStateAtExit { impl LocalsStateAtExit {
fn build( fn build<'tcx>(
locals_are_invalidated_at_exit: bool, locals_are_invalidated_at_exit: bool,
body: &Body<'tcx>, body: &Body<'tcx>,
move_data: &MoveData<'tcx>, move_data: &MoveData<'tcx>,

View file

@ -31,7 +31,7 @@ enum UniverseInfoInner<'tcx> {
Other, Other,
} }
impl UniverseInfo<'tcx> { impl<'tcx> UniverseInfo<'tcx> {
crate fn other() -> UniverseInfo<'tcx> { crate fn other() -> UniverseInfo<'tcx> {
UniverseInfo(UniverseInfoInner::Other) UniverseInfo(UniverseInfoInner::Other)
} }
@ -191,7 +191,7 @@ struct PredicateQuery<'tcx> {
base_universe: ty::UniverseIndex, base_universe: ty::UniverseIndex,
} }
impl TypeOpInfo<'tcx> for PredicateQuery<'tcx> { impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error"); let mut err = tcx.sess.struct_span_err(span, "higher-ranked lifetime error");
err.note(&format!("could not prove {}", self.canonical_query.value.value.predicate)); err.note(&format!("could not prove {}", self.canonical_query.value.value.predicate));
@ -231,7 +231,7 @@ struct NormalizeQuery<'tcx, T> {
base_universe: ty::UniverseIndex, base_universe: ty::UniverseIndex,
} }
impl<T> TypeOpInfo<'tcx> for NormalizeQuery<'tcx, T> impl<'tcx, T> TypeOpInfo<'tcx> for NormalizeQuery<'tcx, T>
where where
T: Copy + fmt::Display + TypeFoldable<'tcx> + 'tcx, T: Copy + fmt::Display + TypeFoldable<'tcx> + 'tcx,
{ {
@ -291,7 +291,7 @@ struct AscribeUserTypeQuery<'tcx> {
base_universe: ty::UniverseIndex, base_universe: ty::UniverseIndex,
} }
impl TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> { impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> { fn fallback_error(&self, tcx: TyCtxt<'tcx>, span: Span) -> DiagnosticBuilder<'tcx> {
// FIXME: This error message isn't great, but it doesn't show up in the existing UI tests, // FIXME: This error message isn't great, but it doesn't show up in the existing UI tests,
// and is only the fallback when the nice error fails. Consider improving this some more. // and is only the fallback when the nice error fails. Consider improving this some more.

View file

@ -1598,8 +1598,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
location: Location, location: Location,
mpi: MovePathIndex, mpi: MovePathIndex,
) -> (Vec<MoveSite>, Vec<Location>) { ) -> (Vec<MoveSite>, Vec<Location>) {
fn predecessor_locations( fn predecessor_locations<'a>(
body: &'a mir::Body<'tcx>, body: &'a mir::Body<'_>,
location: Location, location: Location,
) -> impl Iterator<Item = Location> + 'a { ) -> impl Iterator<Item = Location> + 'a {
if location.statement_index == 0 { if location.statement_index == 0 {

View file

@ -409,7 +409,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
/// Add a note that a type does not implement `Copy` /// Add a note that a type does not implement `Copy`
pub(super) fn note_type_does_not_implement_copy( pub(super) fn note_type_does_not_implement_copy(
&self, &self,
err: &mut DiagnosticBuilder<'a>, err: &mut DiagnosticBuilder<'_>,
place_desc: &str, place_desc: &str,
ty: Ty<'tcx>, ty: Ty<'tcx>,
span: Option<Span>, span: Option<Span>,
@ -733,7 +733,7 @@ pub(super) enum BorrowedContentSource<'tcx> {
OverloadedIndex(Ty<'tcx>), OverloadedIndex(Ty<'tcx>),
} }
impl BorrowedContentSource<'tcx> { impl<'tcx> BorrowedContentSource<'tcx> {
pub(super) fn describe_for_unnamed_place(&self, tcx: TyCtxt<'_>) -> String { pub(super) fn describe_for_unnamed_place(&self, tcx: TyCtxt<'_>) -> String {
match *self { match *self {
BorrowedContentSource::DerefRawPointer => "a raw pointer".to_string(), BorrowedContentSource::DerefRawPointer => "a raw pointer".to_string(),

View file

@ -747,7 +747,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
HirId, ImplItem, ImplItemKind, Item, ItemKind, HirId, ImplItem, ImplItemKind, Item, ItemKind,
}; };
fn maybe_body_id_of_fn(hir_map: &Map<'tcx>, id: HirId) -> Option<BodyId> { fn maybe_body_id_of_fn(hir_map: &Map<'_>, id: HirId) -> Option<BodyId> {
match hir_map.find(id) { match hir_map.find(id) {
Some(Node::Item(Item { kind: ItemKind::Fn(_, _, body_id), .. })) Some(Node::Item(Item { kind: ItemKind::Fn(_, _, body_id), .. }))
| Some(Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(_, body_id), .. })) => { | Some(Node::ImplItem(ImplItem { kind: ImplItemKind::Fn(_, body_id), .. })) => {
@ -1066,7 +1066,7 @@ fn is_closure_or_generator(ty: Ty<'_>) -> bool {
/// LL | s: &'a String /// LL | s: &'a String
/// | ---------- use `&'a mut String` here to make mutable /// | ---------- use `&'a mut String` here to make mutable
/// ``` /// ```
fn annotate_struct_field( fn annotate_struct_field<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
ty: Ty<'tcx>, ty: Ty<'tcx>,
field: &mir::Field, field: &mir::Field,

View file

@ -3,7 +3,6 @@
#![feature(bool_to_option)] #![feature(bool_to_option)]
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(in_band_lifetimes)]
#![feature(let_else)] #![feature(let_else)]
#![feature(min_specialization)] #![feature(min_specialization)]
#![feature(stmt_expr_attributes)] #![feature(stmt_expr_attributes)]

View file

@ -53,7 +53,7 @@ rustc_index::newtype_index! {
} }
} }
impl Default for MemberConstraintSet<'tcx, ty::RegionVid> { impl Default for MemberConstraintSet<'_, ty::RegionVid> {
fn default() -> Self { fn default() -> Self {
Self { Self {
first_constraints: Default::default(), first_constraints: Default::default(),
@ -97,7 +97,7 @@ impl<'tcx> MemberConstraintSet<'tcx, ty::RegionVid> {
} }
} }
impl<R1> MemberConstraintSet<'tcx, R1> impl<'tcx, R1> MemberConstraintSet<'tcx, R1>
where where
R1: Copy + Hash + Eq, R1: Copy + Hash + Eq,
{ {
@ -140,7 +140,7 @@ where
} }
} }
impl<R> MemberConstraintSet<'tcx, R> impl<R> MemberConstraintSet<'_, R>
where where
R: Copy + Hash + Eq, R: Copy + Hash + Eq,
{ {

View file

@ -141,7 +141,7 @@ pub(super) fn borrow_of_local_data(place: Place<'_>) -> bool {
/// then returns the index of the field being projected. Note that this closure will always /// then returns the index of the field being projected. Note that this closure will always
/// be `self` in the current MIR, because that is the only time we directly access the fields /// be `self` in the current MIR, because that is the only time we directly access the fields
/// of a closure type. /// of a closure type.
pub(crate) fn is_upvar_field_projection( pub(crate) fn is_upvar_field_projection<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
upvars: &[Upvar<'tcx>], upvars: &[Upvar<'tcx>],
place_ref: PlaceRef<'tcx>, place_ref: PlaceRef<'tcx>,

View file

@ -58,7 +58,7 @@ crate struct CreateResult<'tcx> {
crate normalized_inputs_and_output: NormalizedInputsAndOutput<'tcx>, crate normalized_inputs_and_output: NormalizedInputsAndOutput<'tcx>,
} }
crate fn create( crate fn create<'tcx>(
infcx: &InferCtxt<'_, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
implicit_region_bound: Option<ty::Region<'tcx>>, implicit_region_bound: Option<ty::Region<'tcx>>,
@ -81,7 +81,7 @@ crate fn create(
.create() .create()
} }
impl UniversalRegionRelations<'tcx> { impl UniversalRegionRelations<'_> {
/// Records in the `outlives_relation` (and /// Records in the `outlives_relation` (and
/// `inverse_outlives_relation`) that `fr_a: fr_b`. Invoked by the /// `inverse_outlives_relation`) that `fr_a: fr_b`. Invoked by the
/// builder below. /// builder below.
@ -110,7 +110,7 @@ impl UniversalRegionRelations<'tcx> {
/// outlives `fr` and (b) is not local. /// outlives `fr` and (b) is not local.
/// ///
/// (*) If there are multiple competing choices, we return all of them. /// (*) If there are multiple competing choices, we return all of them.
crate fn non_local_upper_bounds(&'a self, fr: &'a RegionVid) -> Vec<&'a RegionVid> { crate fn non_local_upper_bounds<'a>(&'a self, fr: &'a RegionVid) -> Vec<&'a RegionVid> {
debug!("non_local_upper_bound(fr={:?})", fr); debug!("non_local_upper_bound(fr={:?})", fr);
let res = self.non_local_bounds(&self.inverse_outlives, fr); let res = self.non_local_bounds(&self.inverse_outlives, fr);
assert!(!res.is_empty(), "can't find an upper bound!?"); assert!(!res.is_empty(), "can't find an upper bound!?");
@ -232,7 +232,7 @@ struct UniversalRegionRelationsBuilder<'this, 'tcx> {
region_bound_pairs: RegionBoundPairs<'tcx>, region_bound_pairs: RegionBoundPairs<'tcx>,
} }
impl UniversalRegionRelationsBuilder<'cx, 'tcx> { impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
crate fn create(mut self) -> CreateResult<'tcx> { crate fn create(mut self) -> CreateResult<'tcx> {
let unnormalized_input_output_tys = self let unnormalized_input_output_tys = self
.universal_regions .universal_regions

View file

@ -152,7 +152,7 @@ impl LocalUseMapBuild<'_> {
} }
} }
impl Visitor<'tcx> for LocalUseMapBuild<'_> { impl Visitor<'_> for LocalUseMapBuild<'_> {
fn visit_local(&mut self, &local: &Local, context: PlaceContext, location: Location) { fn visit_local(&mut self, &local: &Local, context: PlaceContext, location: Location) {
if self.locals_with_use_data[local] { if self.locals_with_use_data[local] {
match def_use::categorize(context) { match def_use::categorize(context) {

View file

@ -74,7 +74,7 @@ pub(super) fn generate<'mir, 'tcx>(
// to compute whether a variable `X` is live if that variable contains // to compute whether a variable `X` is live if that variable contains
// some region `R` in its type where `R` is not known to outlive a free // some region `R` in its type where `R` is not known to outlive a free
// region (i.e., where `R` may be valid for just a subset of the fn body). // region (i.e., where `R` may be valid for just a subset of the fn body).
fn compute_live_locals( fn compute_live_locals<'tcx>(
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
free_regions: &FxHashSet<RegionVid>, free_regions: &FxHashSet<RegionVid>,
body: &Body<'tcx>, body: &Body<'tcx>,
@ -104,7 +104,7 @@ fn compute_live_locals(
/// regions. For these regions, we do not need to compute /// regions. For these regions, we do not need to compute
/// liveness, since the outlives constraints will ensure that they /// liveness, since the outlives constraints will ensure that they
/// are live over the whole fn body anyhow. /// are live over the whole fn body anyhow.
fn regions_that_outlive_free_regions( fn regions_that_outlive_free_regions<'tcx>(
num_region_vars: usize, num_region_vars: usize,
universal_regions: &UniversalRegions<'tcx>, universal_regions: &UniversalRegions<'tcx>,
constraint_set: &OutlivesConstraintSet<'tcx>, constraint_set: &OutlivesConstraintSet<'tcx>,

View file

@ -53,7 +53,7 @@ impl UseFactsExtractor<'_> {
} }
} }
impl Visitor<'tcx> for UseFactsExtractor<'_> { impl Visitor<'_> for UseFactsExtractor<'_> {
fn visit_local(&mut self, &local: &Local, context: PlaceContext, location: Location) { fn visit_local(&mut self, &local: &Local, context: PlaceContext, location: Location) {
match def_use::categorize(context) { match def_use::categorize(context) {
Some(DefUse::Def) => self.insert_def(local, location), Some(DefUse::Def) => self.insert_def(local, location),
@ -63,7 +63,7 @@ impl Visitor<'tcx> for UseFactsExtractor<'_> {
} }
} }
fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) { fn visit_place(&mut self, place: &Place<'_>, context: PlaceContext, location: Location) {
self.super_place(place, context, location); self.super_place(place, context, location);
match context { match context {
PlaceContext::NonMutatingUse(_) => { PlaceContext::NonMutatingUse(_) => {
@ -82,7 +82,7 @@ impl Visitor<'tcx> for UseFactsExtractor<'_> {
} }
} }
pub(super) fn populate_access_facts( pub(super) fn populate_access_facts<'tcx>(
typeck: &mut TypeChecker<'_, 'tcx>, typeck: &mut TypeChecker<'_, 'tcx>,
body: &Body<'tcx>, body: &Body<'tcx>,
location_table: &LocationTable, location_table: &LocationTable,
@ -123,7 +123,7 @@ pub(super) fn populate_access_facts(
// For every potentially drop()-touched region `region` in `local`'s type // For every potentially drop()-touched region `region` in `local`'s type
// (`kind`), emit a Polonius `use_of_var_derefs_origin(local, origin)` fact. // (`kind`), emit a Polonius `use_of_var_derefs_origin(local, origin)` fact.
pub(super) fn add_drop_of_var_derefs_origin( pub(super) fn add_drop_of_var_derefs_origin<'tcx>(
typeck: &mut TypeChecker<'_, 'tcx>, typeck: &mut TypeChecker<'_, 'tcx>,
local: Local, local: Local,
kind: &GenericArg<'tcx>, kind: &GenericArg<'tcx>,

View file

@ -34,7 +34,7 @@ use crate::{
/// DROP-LIVE set are to the liveness sets for regions found in the /// DROP-LIVE set are to the liveness sets for regions found in the
/// `dropck_outlives` result of the variable's type (in particular, /// `dropck_outlives` result of the variable's type (in particular,
/// this respects `#[may_dangle]` annotations). /// this respects `#[may_dangle]` annotations).
pub(super) fn trace( pub(super) fn trace<'mir, 'tcx>(
typeck: &mut TypeChecker<'_, 'tcx>, typeck: &mut TypeChecker<'_, 'tcx>,
body: &Body<'tcx>, body: &Body<'tcx>,
elements: &Rc<RegionValueElements>, elements: &Rc<RegionValueElements>,
@ -119,7 +119,7 @@ struct LivenessResults<'me, 'typeck, 'flow, 'tcx> {
stack: Vec<PointIndex>, stack: Vec<PointIndex>,
} }
impl LivenessResults<'me, 'typeck, 'flow, 'tcx> { impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
fn new(cx: LivenessContext<'me, 'typeck, 'flow, 'tcx>) -> Self { fn new(cx: LivenessContext<'me, 'typeck, 'flow, 'tcx>) -> Self {
let num_points = cx.elements.num_points(); let num_points = cx.elements.num_points();
LivenessResults { LivenessResults {
@ -418,7 +418,7 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
} }
} }
impl LivenessContext<'_, '_, '_, 'tcx> { impl<'tcx> LivenessContext<'_, '_, '_, 'tcx> {
/// Returns `true` if the local variable (or some part of it) is initialized at the current /// Returns `true` if the local variable (or some part of it) is initialized at the current
/// cursor position. Callers should call one of the `seek` methods immediately before to point /// cursor position. Callers should call one of the `seek` methods immediately before to point
/// the cursor to the desired location. /// the cursor to the desired location.

View file

@ -945,7 +945,7 @@ crate struct MirTypeckRegionConstraints<'tcx> {
crate type_tests: Vec<TypeTest<'tcx>>, crate type_tests: Vec<TypeTest<'tcx>>,
} }
impl MirTypeckRegionConstraints<'tcx> { impl<'tcx> MirTypeckRegionConstraints<'tcx> {
fn placeholder_region( fn placeholder_region(
&mut self, &mut self,
infcx: &InferCtxt<'_, 'tcx>, infcx: &InferCtxt<'_, 'tcx>,

View file

@ -51,7 +51,7 @@ struct NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
universe_info: UniverseInfo<'tcx>, universe_info: UniverseInfo<'tcx>,
} }
impl NllTypeRelatingDelegate<'me, 'bccx, 'tcx> { impl<'me, 'bccx, 'tcx> NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
fn new( fn new(
type_checker: &'me mut TypeChecker<'bccx, 'tcx>, type_checker: &'me mut TypeChecker<'bccx, 'tcx>,
locations: Locations, locations: Locations,
@ -62,7 +62,7 @@ impl NllTypeRelatingDelegate<'me, 'bccx, 'tcx> {
} }
} }
impl TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> { impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx> {
fn param_env(&self) -> ty::ParamEnv<'tcx> { fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.type_checker.param_env self.type_checker.param_env
} }