Skip to content

Commit

Permalink
Rollup merge of rust-lang#91882 - Patrick-Poitras:remove-in-band-life…
Browse files Browse the repository at this point in the history
…times-from-rustc-typeck, r=jackh726

Remove `in_band_lifetimes` from `rustc_typeck`

Joining in on the effort to remove the `in_band_lifetimes` features, as described in issue rust-lang#91867.
  • Loading branch information
matthiaskrgr authored Dec 14, 2021
2 parents d9f11aa + a586e7d commit 00cd222
Show file tree
Hide file tree
Showing 26 changed files with 72 additions and 70 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/astconv/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
&self,
span: Span,
trait_def_id: DefId,
trait_segment: &'a hir::PathSegment<'a>,
trait_segment: &'_ hir::PathSegment<'_>,
) {
let trait_def = self.tcx().trait_def(trait_def_id);

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

fn arms_contain_ref_bindings(arms: &'tcx [hir::Arm<'tcx>]) -> Option<hir::Mutability> {
fn arms_contain_ref_bindings<'tcx>(arms: &'tcx [hir::Arm<'tcx>]) -> Option<hir::Mutability> {
arms.iter().filter_map(|a| a.pat.contains_explicit_ref_binding()).max_by_key(|m| match *m {
hir::Mutability::Mut => 1,
hir::Mutability::Not => 0,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_typeck/src/check/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ pub(super) fn check_opaque<'tcx>(
/// Checks that an opaque type does not use `Self` or `T::Foo` projections that would result
/// in "inheriting lifetimes".
#[instrument(level = "debug", skip(tcx, span))]
pub(super) fn check_opaque_for_inheriting_lifetimes(
pub(super) fn check_opaque_for_inheriting_lifetimes<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: LocalDefId,
span: Span,
Expand Down Expand Up @@ -517,7 +517,7 @@ pub(super) fn check_opaque_for_inheriting_lifetimes(
}
}

impl Visitor<'tcx> for ProhibitOpaqueVisitor<'tcx> {
impl<'tcx> Visitor<'tcx> for ProhibitOpaqueVisitor<'tcx> {
type Map = rustc_middle::hir::map::Map<'tcx>;

fn nested_visit_map(&mut self) -> hir::intravisit::NestedVisitorMap<Self::Map> {
Expand Down Expand Up @@ -1512,7 +1512,7 @@ pub(super) use wfcheck::check_trait_item as check_trait_item_well_formed;

pub(super) use wfcheck::check_impl_item as check_impl_item_well_formed;

fn async_opaque_type_cycle_error(tcx: TyCtxt<'tcx>, span: Span) {
fn async_opaque_type_cycle_error(tcx: TyCtxt<'_>, span: Span) {
struct_span_err!(tcx.sess, span, E0733, "recursion in an `async fn` requires boxing")
.span_label(span, "recursive `async fn`")
.note("a recursive `async fn` must be rewritten to return a boxed `dyn Future`")
Expand All @@ -1530,7 +1530,7 @@ fn async_opaque_type_cycle_error(tcx: TyCtxt<'tcx>, span: Span) {
///
/// If all the return expressions evaluate to `!`, then we explain that the error will go away
/// after changing it. This can happen when a user uses `panic!()` or similar as a placeholder.
fn opaque_type_cycle_error(tcx: TyCtxt<'tcx>, def_id: LocalDefId, span: Span) {
fn opaque_type_cycle_error(tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span) {
let mut err = struct_span_err!(tcx.sess, span, E0720, "cannot resolve opaque type");

let mut label = false;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn identity(_: Ty<'_>) -> Vec<Adjustment<'_>> {
vec![]
}

fn simple(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>> {
fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>> {
move |target| vec![Adjustment { kind, target }]
}

Expand Down Expand Up @@ -1694,7 +1694,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
err.help("you could instead create a new `enum` with a variant for each returned type");
}

fn is_return_ty_unsized(&self, fcx: &FnCtxt<'a, 'tcx>, blk_id: hir::HirId) -> bool {
fn is_return_ty_unsized<'a>(&self, fcx: &FnCtxt<'a, 'tcx>, blk_id: hir::HirId) -> bool {
if let Some((fn_decl, _)) = fcx.get_fn_decl(blk_id) {
if let hir::FnRetTy::Return(ty) = fn_decl.output {
let ty = <dyn AstConv<'_>>::ast_ty_to_ty(fcx, ty);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/dropck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ impl<'tcx> SimpleEqRelation<'tcx> {
}
}

impl TypeRelation<'tcx> for SimpleEqRelation<'tcx> {
impl<'tcx> TypeRelation<'tcx> for SimpleEqRelation<'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check/inherited.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub struct InheritedBuilder<'tcx> {
def_id: LocalDefId,
}

impl Inherited<'_, 'tcx> {
impl<'tcx> Inherited<'_, 'tcx> {
pub fn build(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> InheritedBuilder<'tcx> {
let hir_owner = tcx.hir().local_def_id_to_hir_id(def_id).owner;

Expand All @@ -97,7 +97,7 @@ impl<'tcx> InheritedBuilder<'tcx> {
}
}

impl Inherited<'a, 'tcx> {
impl<'a, 'tcx> Inherited<'a, 'tcx> {
pub(super) fn new(infcx: InferCtxt<'a, 'tcx>, def_id: LocalDefId) -> Self {
let tcx = infcx.tcx;
let item_id = tcx.hir().local_def_id_to_hir_id(def_id);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ fn find_use_placement<'tcx>(tcx: TyCtxt<'tcx>, target_module: LocalDefId) -> (Op
(span, found_use)
}

fn print_disambiguation_help(
fn print_disambiguation_help<'tcx>(
item_name: Ident,
args: Option<&'tcx [hir::Expr<'tcx>]>,
err: &mut DiagnosticBuilder<'_>,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ struct GeneratorTypes<'tcx> {

/// Given a `DefId` for an opaque type in return position, find its parent item's return
/// expressions.
fn get_owner_return_paths(
fn get_owner_return_paths<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: LocalDefId,
) -> Option<(hir::HirId, ReturnsVisitor<'tcx>)> {
Expand Down Expand Up @@ -906,7 +906,7 @@ struct CheckItemTypesVisitor<'tcx> {
tcx: TyCtxt<'tcx>,
}

impl ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'tcx> {
impl<'tcx> ItemLikeVisitor<'tcx> for CheckItemTypesVisitor<'tcx> {
fn visit_item(&mut self, i: &'tcx hir::Item<'tcx>) {
check_item_type(self.tcx, i);
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ enum Op {
}

/// Dereferences a single level of immutable referencing.
fn deref_ty_if_possible(ty: Ty<'tcx>) -> Ty<'tcx> {
fn deref_ty_if_possible<'tcx>(ty: Ty<'tcx>) -> Ty<'tcx> {
match ty.kind() {
ty::Ref(_, ty, hir::Mutability::Not) => ty,
_ => ty,
Expand Down Expand Up @@ -1007,7 +1007,7 @@ impl<'tcx> TypeVisitor<'tcx> for TypeParamVisitor<'tcx> {

struct TypeParamEraser<'a, 'tcx>(&'a FnCtxt<'a, 'tcx>, Span);

impl TypeFolder<'tcx> for TypeParamEraser<'_, 'tcx> {
impl<'tcx> TypeFolder<'tcx> for TypeParamEraser<'_, 'tcx> {
fn tcx(&self) -> TyCtxt<'tcx> {
self.0.tcx
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}

fn check_pat_path(
fn check_pat_path<'b>(
&self,
pat: &Pat<'_>,
path_resolution: (Res, Option<Ty<'tcx>>, &'b [hir::PathSegment<'b>]),
Expand Down Expand Up @@ -816,7 +816,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
false
}

fn emit_bad_pat_path(
fn emit_bad_pat_path<'b>(
&self,
mut e: DiagnosticBuilder<'_>,
pat_span: Span,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check/regionck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ macro_rules! ignore_err {
pub(crate) trait OutlivesEnvironmentExt<'tcx> {
fn add_implied_bounds(
&mut self,
infcx: &InferCtxt<'a, 'tcx>,
infcx: &InferCtxt<'_, 'tcx>,
fn_sig_tys: FxHashSet<Ty<'tcx>>,
body_id: hir::HirId,
span: Span,
Expand All @@ -130,7 +130,7 @@ impl<'tcx> OutlivesEnvironmentExt<'tcx> for OutlivesEnvironment<'tcx> {
/// add those assumptions into the outlives-environment.
///
/// Tests: `src/test/ui/regions/regions-free-region-ordering-*.rs`
fn add_implied_bounds(
fn add_implied_bounds<'a>(
&mut self,
infcx: &InferCtxt<'a, 'tcx>,
fn_sig_tys: FxHashSet<Ty<'tcx>>,
Expand Down
20 changes: 10 additions & 10 deletions compiler/rustc_typeck/src/check/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1672,7 +1672,7 @@ fn restrict_repr_packed_field_ref_capture<'tcx>(
}

/// Returns a Ty that applies the specified capture kind on the provided capture Ty
fn apply_capture_kind_on_capture_ty(
fn apply_capture_kind_on_capture_ty<'tcx>(
tcx: TyCtxt<'tcx>,
ty: Ty<'tcx>,
capture_kind: UpvarCapture<'tcx>,
Expand All @@ -1685,7 +1685,7 @@ fn apply_capture_kind_on_capture_ty(
}

/// Returns the Span of where the value with the provided HirId would be dropped
fn drop_location_span(tcx: TyCtxt<'tcx>, hir_id: &hir::HirId) -> Span {
fn drop_location_span<'tcx>(tcx: TyCtxt<'tcx>, hir_id: &hir::HirId) -> Span {
let owner_id = tcx.hir().get_enclosing_scope(*hir_id).unwrap();

let owner_node = tcx.hir().get(owner_id);
Expand Down Expand Up @@ -1999,7 +1999,7 @@ fn restrict_precision_for_drop_types<'a, 'tcx>(
/// - No projections are applied to raw pointers, since these require unsafe blocks. We capture
/// them completely.
/// - No projections are applied on top of Union ADTs, since these require unsafe blocks.
fn restrict_precision_for_unsafe(
fn restrict_precision_for_unsafe<'tcx>(
mut place: Place<'tcx>,
mut curr_mode: ty::UpvarCapture<'tcx>,
) -> (Place<'tcx>, ty::UpvarCapture<'tcx>) {
Expand Down Expand Up @@ -2097,7 +2097,7 @@ fn adjust_for_non_move_closure<'tcx>(
(place, kind)
}

fn construct_place_string(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String {
fn construct_place_string<'tcx>(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String {
let variable_name = match place.base {
PlaceBase::Upvar(upvar_id) => var_name(tcx, upvar_id.var_path.hir_id).to_string(),
_ => bug!("Capture_information should only contain upvars"),
Expand All @@ -2120,7 +2120,7 @@ fn construct_place_string(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String {
format!("{}[{}]", variable_name, projections_str)
}

fn construct_capture_kind_reason_string(
fn construct_capture_kind_reason_string<'tcx>(
tcx: TyCtxt<'_>,
place: &Place<'tcx>,
capture_info: &ty::CaptureInfo<'tcx>,
Expand All @@ -2135,13 +2135,13 @@ fn construct_capture_kind_reason_string(
format!("{} captured as {} here", place_str, capture_kind_str)
}

fn construct_path_string(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String {
fn construct_path_string<'tcx>(tcx: TyCtxt<'_>, place: &Place<'tcx>) -> String {
let place_str = construct_place_string(tcx, place);

format!("{} used here", place_str)
}

fn construct_capture_info_string(
fn construct_capture_info_string<'tcx>(
tcx: TyCtxt<'_>,
place: &Place<'tcx>,
capture_info: &ty::CaptureInfo<'tcx>,
Expand Down Expand Up @@ -2233,7 +2233,7 @@ fn migration_suggestion_for_2229(
/// would've already handled `E1`, and have an existing capture_information for it.
/// Calling `determine_capture_info(existing_info_e1, current_info_e2)` will return
/// `existing_info_e1` in this case, allowing us to point to `E1` in case of diagnostics.
fn determine_capture_info(
fn determine_capture_info<'tcx>(
capture_info_a: ty::CaptureInfo<'tcx>,
capture_info_b: ty::CaptureInfo<'tcx>,
) -> ty::CaptureInfo<'tcx> {
Expand Down Expand Up @@ -2292,7 +2292,7 @@ fn determine_capture_info(
///
/// Note: Capture kind changes from `MutBorrow` to `UniqueImmBorrow` if the truncated part of the `place`
/// contained `Deref` of `&mut`.
fn truncate_place_to_len_and_update_capture_kind(
fn truncate_place_to_len_and_update_capture_kind<'tcx>(
place: &mut Place<'tcx>,
curr_mode: &mut ty::UpvarCapture<'tcx>,
len: usize,
Expand Down Expand Up @@ -2330,7 +2330,7 @@ fn truncate_place_to_len_and_update_capture_kind(
/// `PlaceAncestryRelation::Ancestor` implies Place A is ancestor of Place B
/// `PlaceAncestryRelation::Descendant` implies Place A is descendant of Place B
/// `PlaceAncestryRelation::Divergent` implies neither of them is the ancestor of the other.
fn determine_place_ancestry_relation(
fn determine_place_ancestry_relation<'tcx>(
place_a: &Place<'tcx>,
place_b: &Place<'tcx>,
) -> PlaceAncestryRelation {
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_typeck/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1488,7 +1488,7 @@ fn check_method_receiver<'fcx, 'tcx>(
}
}

fn e0307(fcx: &FnCtxt<'fcx, 'tcx>, span: Span, receiver_ty: Ty<'_>) {
fn e0307<'tcx>(fcx: &FnCtxt<'_, 'tcx>, span: Span, receiver_ty: Ty<'_>) {
struct_span_err!(
fcx.tcx.sess.diagnostic(),
span,
Expand Down Expand Up @@ -1591,7 +1591,7 @@ fn receiver_is_valid<'fcx, 'tcx>(
true
}

fn receiver_is_implemented(
fn receiver_is_implemented<'tcx>(
fcx: &FnCtxt<'_, 'tcx>,
receiver_trait_def_id: DefId,
cause: ObligationCause<'tcx>,
Expand Down Expand Up @@ -1734,13 +1734,13 @@ pub struct CheckTypeWellFormedVisitor<'tcx> {
tcx: TyCtxt<'tcx>,
}

impl CheckTypeWellFormedVisitor<'tcx> {
impl<'tcx> CheckTypeWellFormedVisitor<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>) -> CheckTypeWellFormedVisitor<'tcx> {
CheckTypeWellFormedVisitor { tcx }
}
}

impl ParItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
impl<'tcx> ParItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
fn visit_item(&self, i: &'tcx hir::Item<'tcx>) {
Visitor::visit_item(&mut self.clone(), i);
}
Expand All @@ -1758,7 +1758,7 @@ impl ParItemLikeVisitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
}
}

impl Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
impl<'tcx> Visitor<'tcx> for CheckTypeWellFormedVisitor<'tcx> {
type Map = hir_map::Map<'tcx>;

fn nested_visit_map(&mut self) -> hir_visit::NestedVisitorMap<Self::Map> {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check_unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
unused_crates_lint(tcx);
}

impl ItemLikeVisitor<'v> for CheckVisitor<'tcx> {
impl<'tcx> ItemLikeVisitor<'_> for CheckVisitor<'tcx> {
fn visit_item(&mut self, item: &hir::Item<'_>) {
if item.vis.node.is_pub() || item.span.is_dummy() {
return;
Expand All @@ -43,7 +43,7 @@ struct CheckVisitor<'tcx> {
used_trait_imports: FxHashSet<LocalDefId>,
}

impl CheckVisitor<'tcx> {
impl<'tcx> CheckVisitor<'tcx> {
fn check_import(&self, item_id: hir::ItemId, span: Span) {
if !self.tcx.maybe_unused_trait_import(item_id.def_id) {
return;
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_typeck/src/coherence/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
}
}

fn visit_implementation_of_coerce_unsized(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) {
fn visit_implementation_of_coerce_unsized<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) {
debug!("visit_implementation_of_coerce_unsized: impl_did={:?}", impl_did);

// Just compute this for the side-effects, in particular reporting
Expand All @@ -118,7 +118,7 @@ fn visit_implementation_of_coerce_unsized(tcx: TyCtxt<'tcx>, impl_did: LocalDefI
tcx.at(span).coerce_unsized_info(impl_did);
}

fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
fn visit_implementation_of_dispatch_from_dyn<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) {
debug!("visit_implementation_of_dispatch_from_dyn: impl_did={:?}", impl_did);

let impl_hir_id = tcx.hir().local_def_id_to_hir_id(impl_did);
Expand Down Expand Up @@ -287,7 +287,7 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
})
}

pub fn coerce_unsized_info(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo {
pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUnsizedInfo {
debug!("compute_coerce_unsized_info(impl_did={:?})", impl_did);

// this provider should only get invoked for local def-ids
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/coherence/inherent_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct InherentCollect<'tcx> {
impls_map: CrateInherentImpls,
}

impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
impl<'tcx> ItemLikeVisitor<'_> for InherentCollect<'tcx> {
fn visit_item(&mut self, item: &hir::Item<'_>) {
let (ty, assoc_items) = match item.kind {
hir::ItemKind::Impl(hir::Impl { of_trait: None, ref self_ty, items, .. }) => {
Expand Down Expand Up @@ -370,7 +370,7 @@ impl ItemLikeVisitor<'v> for InherentCollect<'tcx> {
fn visit_foreign_item(&mut self, _foreign_item: &hir::ForeignItem<'_>) {}
}

impl InherentCollect<'tcx> {
impl<'tcx> InherentCollect<'tcx> {
fn check_def_id(&mut self, item: &hir::Item<'_>, def_id: DefId) {
if let Some(def_id) = def_id.as_local() {
// Add the implementation to the mapping from implementation to base
Expand Down
Loading

0 comments on commit 00cd222

Please sign in to comment.