Skip to content

Commit d4a62a7

Browse files
authored
Rollup merge of #58722 - Centril:deny-elided_lifetimes_in_paths-librustc_typeck, r=oli-obk
librustc_typeck: deny(elided_lifetimes_in_paths) As part of the Rust 2018 transition, remove `#![allow(elided_lifetimes_in_paths)]` from `librustc_typeck`. r? @oli-obk
2 parents 2a69aec + e8ce56f commit d4a62a7

22 files changed

+59
-53
lines changed

src/librustc_typeck/astconv.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
196196

197197
/// Report error if there is an explicit type parameter when using `impl Trait`.
198198
fn check_impl_trait(
199-
tcx: TyCtxt,
199+
tcx: TyCtxt<'_, '_, '_>,
200200
span: Span,
201201
seg: &hir::PathSegment,
202202
generics: &ty::Generics,
@@ -227,7 +227,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
227227
/// Checks that the correct number of generic arguments have been provided.
228228
/// Used specifically for function calls.
229229
pub fn check_generic_arg_count_for_call(
230-
tcx: TyCtxt,
230+
tcx: TyCtxt<'_, '_, '_>,
231231
span: Span,
232232
def: &ty::Generics,
233233
seg: &hir::PathSegment,
@@ -259,7 +259,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
259259
/// Checks that the correct number of generic arguments have been provided.
260260
/// This is used both for datatypes and function calls.
261261
fn check_generic_arg_count(
262-
tcx: TyCtxt,
262+
tcx: TyCtxt<'_, '_, '_>,
263263
span: Span,
264264
def: &ty::Generics,
265265
args: &hir::GenericArgs,
@@ -1502,7 +1502,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx> + 'o {
15021502
has_err
15031503
}
15041504

1505-
pub fn prohibit_assoc_ty_binding(tcx: TyCtxt, span: Span) {
1505+
pub fn prohibit_assoc_ty_binding(tcx: TyCtxt<'_, '_, '_>, span: Span) {
15061506
let mut err = struct_span_err!(tcx.sess, span, E0229,
15071507
"associated type bindings are not allowed here");
15081508
err.span_label(span, "associated type not allowed here").emit();

src/librustc_typeck/check/_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
183183
let rhs_ty = self.check_expr(end);
184184

185185
// Check that both end-points are of numeric or char type.
186-
let numeric_or_char = |ty: Ty| ty.is_numeric() || ty.is_char();
186+
let numeric_or_char = |ty: Ty<'_>| ty.is_numeric() || ty.is_char();
187187
let lhs_compat = numeric_or_char(lhs_ty);
188188
let rhs_compat = numeric_or_char(rhs_ty);
189189

src/librustc_typeck/check/callee.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc::hir;
1818
/// Checks that it is legal to call methods of the trait corresponding
1919
/// to `trait_id` (this only cares about the trait, not the specific
2020
/// method that is called).
21-
pub fn check_legal_trait_for_method_call(tcx: TyCtxt, span: Span, trait_id: DefId) {
21+
pub fn check_legal_trait_for_method_call(tcx: TyCtxt<'_, '_, '_>, span: Span, trait_id: DefId) {
2222
if tcx.lang_items().drop_trait() == Some(trait_id) {
2323
struct_span_err!(tcx.sess, span, E0040, "explicit use of destructor method")
2424
.span_label(span, "explicit destructor calls not allowed")

src/librustc_typeck/check/closure.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
574574
expr_def_id: DefId,
575575
decl: &hir::FnDecl,
576576
) -> ty::PolyFnSig<'tcx> {
577-
let astconv: &dyn AstConv = self;
577+
let astconv: &dyn AstConv<'_, '_> = self;
578578

579579
// First, convert the types that the user supplied (if any).
580580
let supplied_arguments = decl.inputs.iter().map(|a| astconv.ast_ty_to_ty(a));
@@ -606,7 +606,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
606606
/// so should yield an error, but returns back a signature where
607607
/// all parameters are of type `TyErr`.
608608
fn error_sig_of_closure(&self, decl: &hir::FnDecl) -> ty::PolyFnSig<'tcx> {
609-
let astconv: &dyn AstConv = self;
609+
let astconv: &dyn AstConv<'_, '_> = self;
610610

611611
let supplied_arguments = decl.inputs.iter().map(|a| {
612612
// Convert the types that the user supplied (if any), but ignore them.

src/librustc_typeck/check/coercion.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn coerce_mutbls<'tcx>(from_mutbl: hir::Mutability,
101101
}
102102
}
103103

104-
fn identity(_: Ty) -> Vec<Adjustment> { vec![] }
104+
fn identity(_: Ty<'_>) -> Vec<Adjustment<'_>> { vec![] }
105105

106106
fn simple<'tcx>(kind: Adjust<'tcx>) -> impl FnOnce(Ty<'tcx>) -> Vec<Adjustment<'tcx>> {
107107
move |target| vec![Adjustment { kind, target }]
@@ -1084,7 +1084,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
10841084
pub fn coerce_forced_unit<'a>(&mut self,
10851085
fcx: &FnCtxt<'a, 'gcx, 'tcx>,
10861086
cause: &ObligationCause<'tcx>,
1087-
augment_error: &mut dyn FnMut(&mut DiagnosticBuilder),
1087+
augment_error: &mut dyn FnMut(&mut DiagnosticBuilder<'_>),
10881088
label_unit_as_expected: bool)
10891089
{
10901090
self.coerce_inner(fcx,
@@ -1103,7 +1103,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
11031103
cause: &ObligationCause<'tcx>,
11041104
expression: Option<&'gcx hir::Expr>,
11051105
mut expression_ty: Ty<'tcx>,
1106-
augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder)>,
1106+
augment_error: Option<&mut dyn FnMut(&mut DiagnosticBuilder<'_>)>,
11071107
label_expression_as_expected: bool)
11081108
{
11091109
// Incorporate whatever type inference information we have

src/librustc_typeck/check/compare_method.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
408408

409409
fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
410410
param_env: ty::ParamEnv<'tcx>,
411-
terr: &TypeError,
411+
terr: &TypeError<'_>,
412412
cause: &ObligationCause<'tcx>,
413413
impl_m: &ty::AssociatedItem,
414414
impl_sig: ty::FnSig<'tcx>,

src/librustc_typeck/check/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
544544
};
545545

546546
let into_sugg = into_suggestion.clone();
547-
let suggest_to_change_suffix_or_into = |err: &mut DiagnosticBuilder,
547+
let suggest_to_change_suffix_or_into = |err: &mut DiagnosticBuilder<'_>,
548548
note: Option<&str>| {
549549
let suggest_msg = if literal_is_ty_suffixed(expr) {
550550
format!(

src/librustc_typeck/check/method/confirm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
598598
})
599599
}
600600

601-
fn enforce_illegal_method_limitations(&self, pick: &probe::Pick) {
601+
fn enforce_illegal_method_limitations(&self, pick: &probe::Pick<'_>) {
602602
// Disallow calls to the method `drop` defined in the `Drop` trait.
603603
match pick.item.container {
604604
ty::TraitContainer(trait_def_id) => {

src/librustc_typeck/check/method/probe.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
388388
}
389389
}
390390

391-
pub fn provide(providers: &mut ty::query::Providers) {
391+
pub fn provide(providers: &mut ty::query::Providers<'_>) {
392392
providers.method_autoderef_steps = method_autoderef_steps;
393393
}
394394

@@ -1180,7 +1180,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
11801180

11811181
fn emit_unstable_name_collision_hint(
11821182
&self,
1183-
stable_pick: &Pick,
1183+
stable_pick: &Pick<'_>,
11841184
unstable_candidates: &[(&Candidate<'tcx>, Symbol)],
11851185
) {
11861186
let mut diag = self.tcx.struct_span_lint_hir(

src/librustc_typeck/check/method/suggest.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
7272
return;
7373
}
7474

75-
let report_candidates = |err: &mut DiagnosticBuilder, mut sources: Vec<CandidateSource>| {
75+
let report_candidates = |err: &mut DiagnosticBuilder<'_>,
76+
mut sources: Vec<CandidateSource>| {
7677
sources.sort();
7778
sources.dedup();
7879
// Dynamic limit to avoid hiding just one candidate, which is silly.
@@ -497,7 +498,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
497498
}
498499

499500
fn suggest_use_candidates(&self,
500-
err: &mut DiagnosticBuilder,
501+
err: &mut DiagnosticBuilder<'_>,
501502
mut msg: String,
502503
candidates: Vec<DefId>) {
503504
let module_did = self.tcx.hir().get_module_parent_by_hir_id(self.body_id);
@@ -549,7 +550,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
549550
}
550551

551552
fn suggest_valid_traits(&self,
552-
err: &mut DiagnosticBuilder,
553+
err: &mut DiagnosticBuilder<'_>,
553554
valid_out_of_scope_traits: Vec<DefId>) -> bool {
554555
if !valid_out_of_scope_traits.is_empty() {
555556
let mut candidates = valid_out_of_scope_traits;
@@ -577,7 +578,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
577578
}
578579

579580
fn suggest_traits_to_import<'b>(&self,
580-
err: &mut DiagnosticBuilder,
581+
err: &mut DiagnosticBuilder<'_>,
581582
span: Span,
582583
rcvr_ty: Ty<'tcx>,
583584
item_name: ast::Ident,
@@ -648,8 +649,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
648649
fn type_derefs_to_local(&self,
649650
span: Span,
650651
rcvr_ty: Ty<'tcx>,
651-
source: SelfSource) -> bool {
652-
fn is_local(ty: Ty) -> bool {
652+
source: SelfSource<'_>) -> bool {
653+
fn is_local(ty: Ty<'_>) -> bool {
653654
match ty.sty {
654655
ty::Adt(def, _) => def.did.is_local(),
655656
ty::Foreign(did) => did.is_local(),
@@ -749,7 +750,7 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec<DefId>
749750
// Cross-crate:
750751

751752
let mut external_mods = FxHashSet::default();
752-
fn handle_external_def(tcx: TyCtxt,
753+
fn handle_external_def(tcx: TyCtxt<'_, '_, '_>,
753754
traits: &mut Vec<DefId>,
754755
external_mods: &mut FxHashSet<DefId>,
755756
def: Def) {
@@ -779,7 +780,7 @@ fn compute_all_traits<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Vec<DefId>
779780
traits
780781
}
781782

782-
pub fn provide(providers: &mut ty::query::Providers) {
783+
pub fn provide(providers: &mut ty::query::Providers<'_>) {
783784
providers.all_traits = |tcx, cnum| {
784785
assert_eq!(cnum, LOCAL_CRATE);
785786
Lrc::new(compute_all_traits(tcx))

src/librustc_typeck/check/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ fn check_impl_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: De
738738
wfcheck::check_impl_item(tcx, def_id);
739739
}
740740

741-
pub fn provide(providers: &mut Providers) {
741+
pub fn provide(providers: &mut Providers<'_>) {
742742
method::provide(providers);
743743
*providers = Providers {
744744
typeck_item_bodies,
@@ -1437,7 +1437,7 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite
14371437
}
14381438
}
14391439

1440-
fn maybe_check_static_with_link_section(tcx: TyCtxt, id: DefId, span: Span) {
1440+
fn maybe_check_static_with_link_section(tcx: TyCtxt<'_, '_, '_>, id: DefId, span: Span) {
14411441
// Only restricted on wasm32 target for now
14421442
if !tcx.sess.opts.target_triple.triple().starts_with("wasm32") {
14431443
return
@@ -2122,7 +2122,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
21222122
}
21232123

21242124
pub fn tag(&self) -> String {
2125-
let self_ptr: *const FnCtxt = self;
2125+
let self_ptr: *const FnCtxt<'_, '_, '_> = self;
21262126
format!("{:?}", self_ptr)
21272127
}
21282128

@@ -3369,7 +3369,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
33693369
// (`only_has_type`); otherwise, we just go with a
33703370
// fresh type variable.
33713371
let coerce_to_ty = expected.coercion_target_type(self, sp);
3372-
let mut coerce: DynamicCoerceMany = CoerceMany::new(coerce_to_ty);
3372+
let mut coerce: DynamicCoerceMany<'_, '_> = CoerceMany::new(coerce_to_ty);
33733373

33743374
coerce.coerce(self, &self.misc(sp), then_expr, then_ty);
33753375

@@ -5043,7 +5043,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50435043
}
50445044

50455045
/// Given a function `Node`, return its `FnDecl` if it exists, or `None` otherwise.
5046-
fn get_node_fn_decl(&self, node: Node) -> Option<(hir::FnDecl, ast::Ident, bool)> {
5046+
fn get_node_fn_decl(&self, node: Node<'_>) -> Option<(hir::FnDecl, ast::Ident, bool)> {
50475047
match node {
50485048
Node::Item(&hir::Item {
50495049
ident, node: hir::ItemKind::Fn(ref decl, ..), ..

src/librustc_typeck/check/op.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
416416
rhs_expr: &'gcx hir::Expr,
417417
lhs_ty: Ty<'tcx>,
418418
rhs_ty: Ty<'tcx>,
419-
err: &mut errors::DiagnosticBuilder,
419+
err: &mut errors::DiagnosticBuilder<'_>,
420420
is_assign: bool,
421421
) -> bool {
422422
let source_map = self.tcx.sess.source_map();
@@ -688,7 +688,7 @@ enum Op {
688688
/// Reason #2 is the killer. I tried for a while to always use
689689
/// overloaded logic and just check the types in constants/codegen after
690690
/// the fact, and it worked fine, except for SIMD types. -nmatsakis
691-
fn is_builtin_binop(lhs: Ty, rhs: Ty, op: hir::BinOp) -> bool {
691+
fn is_builtin_binop(lhs: Ty<'_>, rhs: Ty<'_>, op: hir::BinOp) -> bool {
692692
match BinOpCategory::from(op) {
693693
BinOpCategory::Shortcircuit => {
694694
true

src/librustc_typeck/check/upvar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,6 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for InferBorrowKind<'a, 'gcx, 'tcx> {
649649
}
650650
}
651651

652-
fn var_name(tcx: TyCtxt, var_hir_id: hir::HirId) -> ast::Name {
652+
fn var_name(tcx: TyCtxt<'_, '_, '_>, var_hir_id: hir::HirId) -> ast::Name {
653653
tcx.hir().name_by_hir_id(var_hir_id)
654654
}

src/librustc_typeck/check/wfcheck.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ fn report_bivariance<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
938938
err.emit();
939939
}
940940

941-
fn reject_shadowing_parameters(tcx: TyCtxt, def_id: DefId) {
941+
fn reject_shadowing_parameters(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) {
942942
let generics = tcx.generics_of(def_id);
943943
let parent = tcx.generics_of(generics.parent.unwrap());
944944
let impl_params: FxHashMap<_, _> = parent.params.iter().flat_map(|param| match param.kind {
@@ -1093,7 +1093,7 @@ fn error_392<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span, param_name: ast:
10931093
err
10941094
}
10951095

1096-
fn error_194(tcx: TyCtxt, span: Span, trait_decl_span: Span, name: &str) {
1096+
fn error_194(tcx: TyCtxt<'_, '_, '_>, span: Span, trait_decl_span: Span, name: &str) {
10971097
struct_span_err!(tcx.sess, span, E0194,
10981098
"type parameter `{}` shadows another type parameter of the same name",
10991099
name)

src/librustc_typeck/check/writeback.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -729,30 +729,30 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> {
729729
}
730730

731731
trait Locatable {
732-
fn to_span(&self, tcx: &TyCtxt) -> Span;
732+
fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span;
733733
}
734734

735735
impl Locatable for Span {
736-
fn to_span(&self, _: &TyCtxt) -> Span {
736+
fn to_span(&self, _: &TyCtxt<'_, '_, '_>) -> Span {
737737
*self
738738
}
739739
}
740740

741741
impl Locatable for ast::NodeId {
742-
fn to_span(&self, tcx: &TyCtxt) -> Span {
742+
fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span {
743743
tcx.hir().span(*self)
744744
}
745745
}
746746

747747
impl Locatable for DefIndex {
748-
fn to_span(&self, tcx: &TyCtxt) -> Span {
748+
fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span {
749749
let hir_id = tcx.hir().def_index_to_hir_id(*self);
750750
tcx.hir().span_by_hir_id(hir_id)
751751
}
752752
}
753753

754754
impl Locatable for hir::HirId {
755-
fn to_span(&self, tcx: &TyCtxt) -> Span {
755+
fn to_span(&self, tcx: &TyCtxt<'_, '_, '_>) -> Span {
756756
tcx.hir().span_by_hir_id(*self)
757757
}
758758
}

src/librustc_typeck/coherence/inherent_impls_overlap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct InherentOverlapChecker<'a, 'tcx: 'a> {
2020

2121
impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
2222
fn check_for_common_items_in_impls(&self, impl1: DefId, impl2: DefId,
23-
overlap: traits::OverlapResult,
23+
overlap: traits::OverlapResult<'_>,
2424
used_to_be_allowed: bool) {
2525

2626
let name_and_namespace = |def_id| {

src/librustc_typeck/coherence/mod.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) {
4141
}
4242
}
4343

44-
fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_def_id: DefId) {
44+
fn enforce_trait_manually_implementable(
45+
tcx: TyCtxt<'_, '_, '_>,
46+
impl_def_id: DefId,
47+
trait_def_id: DefId
48+
) {
4549
let did = Some(trait_def_id);
4650
let li = tcx.lang_items();
4751
let span = tcx.sess.source_map().def_span(tcx.span_of_impl(impl_def_id).unwrap());
@@ -93,7 +97,11 @@ fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_d
9397

9498
/// We allow impls of marker traits to overlap, so they can't override impls
9599
/// as that could make it ambiguous which associated item to use.
96-
fn enforce_empty_impls_for_marker_traits(tcx: TyCtxt, impl_def_id: DefId, trait_def_id: DefId) {
100+
fn enforce_empty_impls_for_marker_traits(
101+
tcx: TyCtxt<'_, '_, '_>,
102+
impl_def_id: DefId,
103+
trait_def_id: DefId
104+
) {
97105
if !tcx.trait_def(trait_def_id).is_marker {
98106
return;
99107
}
@@ -110,7 +118,7 @@ fn enforce_empty_impls_for_marker_traits(tcx: TyCtxt, impl_def_id: DefId, trait_
110118
.emit();
111119
}
112120

113-
pub fn provide(providers: &mut Providers) {
121+
pub fn provide(providers: &mut Providers<'_>) {
114122
use self::builtin::coerce_unsized_info;
115123
use self::inherent_impls::{crate_inherent_impls, inherent_impls};
116124
use self::inherent_impls_overlap::crate_inherent_impls_overlap_check;

0 commit comments

Comments
 (0)