Skip to content

Commit f01f4b0

Browse files
committed
Replace elided_lifetime_in_paths with multiple renamed lints
Removing the `issue-91763` test as the implementation is completely different now.
1 parent 0c62f45 commit f01f4b0

26 files changed

+99
-242
lines changed

compiler/rustc_baked_icu_data/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
//! ```
2222
2323
// tidy-alphabetical-start
24-
#![allow(elided_lifetimes_in_paths)]
2524
#![allow(internal_features)]
2625
#![allow(unreachable_pub)] // because this crate is mostly generated code
2726
#![doc(rust_logo)]
2827
#![feature(rustdoc_internals)]
2928
// #![warn(unreachable_pub)] // don't use because this crate is mostly generated code
3029
// tidy-alphabetical-end
30+
#![cfg_attr(bootstrap, allow(elided_lifetimes_in_paths))]
31+
#![cfg_attr(not(bootstrap), allow(hidden_lifetimes_in_paths))]
3132

3233
mod data {
3334
include!("data/mod.rs");

compiler/rustc_lint/messages.ftl

-2
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,6 @@ lint_hidden_lifetime_in_path =
293293
lint_hidden_lifetime_in_path_suggestion =
294294
indicate the anonymous lifetime
295295
296-
lint_hidden_lifetime_parameters = hidden lifetime parameters in types are deprecated
297-
298296
lint_hidden_unicode_codepoints = unicode codepoint changing visible direction of text present in {$label}
299297
.label = this {$label} contains {$count ->
300298
[one] an invisible

compiler/rustc_lint/src/early/diagnostics.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
use std::borrow::Cow;
55

66
use rustc_ast::util::unicode::TEXT_FLOW_CONTROL_CHARS;
7-
use rustc_errors::{
8-
Applicability, Diag, DiagArgValue, LintDiagnostic, elided_lifetime_in_path_suggestion,
9-
};
7+
use rustc_errors::{Applicability, Diag, DiagArgValue, LintDiagnostic};
108
use rustc_middle::middle::stability;
119
use rustc_middle::ty::TyCtxt;
1210
use rustc_session::Session;
@@ -75,19 +73,6 @@ pub(super) fn decorate_lint(
7573
lints::MacroExpandedMacroExportsAccessedByAbsolutePaths { definition: span_def }
7674
.decorate_lint(diag)
7775
}
78-
79-
BuiltinLintDiag::ElidedLifetimesInPaths(n, path_span, incl_angl_brckt, insertion_span) => {
80-
lints::ElidedLifetimesInPaths {
81-
subdiag: elided_lifetime_in_path_suggestion(
82-
sess.source_map(),
83-
n,
84-
path_span,
85-
incl_angl_brckt,
86-
insertion_span,
87-
),
88-
}
89-
.decorate_lint(diag);
90-
}
9176
BuiltinLintDiag::UnknownCrateTypes { span, candidate } => {
9277
let sugg = candidate.map(|candidate| lints::UnknownCrateTypesSub { span, candidate });
9378
lints::UnknownCrateTypes { sugg }.decorate_lint(diag);

compiler/rustc_lint/src/lib.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,9 @@ fn register_builtins(store: &mut LintStore) {
319319
BARE_TRAIT_OBJECTS,
320320
UNUSED_EXTERN_CRATES,
321321
ELLIPSIS_INCLUSIVE_RANGE_PATTERNS,
322-
ELIDED_LIFETIMES_IN_PATHS,
322+
HIDDEN_LIFETIMES_IN_OUTPUT_PATHS,
323+
HIDDEN_LIFETIMES_IN_INPUT_PATHS,
324+
HIDDEN_LIFETIMES_IN_TYPE_PATHS,
323325
EXPLICIT_OUTLIVES_REQUIREMENTS,
324326
// FIXME(#52665, #47816) not always applicable and not all
325327
// macros are ready for this yet.
@@ -339,9 +341,15 @@ fn register_builtins(store: &mut LintStore) {
339341

340342
add_lint_group!("deprecated_safe", DEPRECATED_SAFE_2024);
341343

344+
add_lint_group!(
345+
"hidden_lifetimes_in_paths",
346+
HIDDEN_LIFETIMES_IN_OUTPUT_PATHS,
347+
HIDDEN_LIFETIMES_IN_INPUT_PATHS,
348+
HIDDEN_LIFETIMES_IN_TYPE_PATHS,
349+
);
350+
342351
// Register renamed and removed lints.
343352
store.register_renamed("single_use_lifetime", "single_use_lifetimes");
344-
store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths");
345353
store.register_renamed("bare_trait_object", "bare_trait_objects");
346354
store.register_renamed("unstable_name_collision", "unstable_name_collisions");
347355
store.register_renamed("unused_doc_comment", "unused_doc_comments");
@@ -357,6 +365,10 @@ fn register_builtins(store: &mut LintStore) {
357365
store.register_renamed("temporary_cstring_as_ptr", "dangling_pointers_from_temporaries");
358366
store.register_renamed("elided_named_lifetimes", "mismatched_lifetime_syntaxes");
359367

368+
// Register renamed lint groups
369+
store.register_renamed_group("elided_lifetime_in_path", "hidden_lifetimes_in_paths");
370+
store.register_renamed_group("elided_lifetimes_in_paths", "hidden_lifetimes_in_paths");
371+
360372
// These were moved to tool lints, but rustc still sees them when compiling normally, before
361373
// tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use
362374
// `register_removed` explicitly.

compiler/rustc_lint/src/lifetime_style.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ declare_lint! {
7070
}
7171

7272
declare_lint! {
73-
/// The `hidden_lifetimes_in_input_paths2` lint detects the use of
73+
/// The `hidden_lifetimes_in_input_paths` lint detects the use of
7474
/// hidden lifetime parameters in types occurring as a function
7575
/// argument.
7676
///
7777
/// ### Example
7878
///
7979
/// ```rust,compile_fail
80-
/// #![deny(hidden_lifetimes_in_input_paths2)]
80+
/// #![deny(hidden_lifetimes_in_input_paths)]
8181
///
8282
/// struct ContainsLifetime<'a>(&'a i32);
8383
///
@@ -99,20 +99,20 @@ declare_lint! {
9999
/// themselves do not usually cause much confusion.
100100
///
101101
/// [placeholder lifetime]: https://doc.rust-lang.org/reference/lifetime-elision.html#lifetime-elision-in-functions
102-
pub HIDDEN_LIFETIMES_IN_INPUT_PATHS2,
102+
pub HIDDEN_LIFETIMES_IN_INPUT_PATHS,
103103
Allow,
104104
"hidden lifetime parameters in types in function arguments may be confusing"
105105
}
106106

107107
declare_lint! {
108-
/// The `hidden_lifetimes_in_output_paths2` lint detects the use
108+
/// The `hidden_lifetimes_in_output_paths` lint detects the use
109109
/// of hidden lifetime parameters in types occurring as a function
110110
/// return value.
111111
///
112112
/// ### Example
113113
///
114114
/// ```rust,compile_fail
115-
/// #![deny(hidden_lifetimes_in_input_paths2)]
115+
/// #![deny(hidden_lifetimes_in_input_paths)]
116116
///
117117
/// struct ContainsLifetime<'a>(&'a i32);
118118
///
@@ -137,15 +137,15 @@ declare_lint! {
137137
/// lifetime].
138138
///
139139
/// [placeholder lifetime]: https://doc.rust-lang.org/reference/lifetime-elision.html#lifetime-elision-in-functions
140-
pub HIDDEN_LIFETIMES_IN_OUTPUT_PATHS2,
140+
pub HIDDEN_LIFETIMES_IN_OUTPUT_PATHS,
141141
Allow,
142142
"hidden lifetime parameters in types in function return values are deprecated"
143143
}
144144

145145
declare_lint_pass!(LifetimeStyle => [
146146
MISMATCHED_LIFETIME_SYNTAXES,
147-
HIDDEN_LIFETIMES_IN_INPUT_PATHS2,
148-
HIDDEN_LIFETIMES_IN_OUTPUT_PATHS2,
147+
HIDDEN_LIFETIMES_IN_INPUT_PATHS,
148+
HIDDEN_LIFETIMES_IN_OUTPUT_PATHS,
149149
]);
150150

151151
impl<'tcx> LateLintPass<'tcx> for LifetimeStyle {
@@ -171,8 +171,8 @@ impl<'tcx> LateLintPass<'tcx> for LifetimeStyle {
171171
}
172172

173173
report_mismatches(cx, &input_map, &output_map);
174-
report_hidden_in_paths(cx, &input_map, HIDDEN_LIFETIMES_IN_INPUT_PATHS2);
175-
report_hidden_in_paths(cx, &output_map, HIDDEN_LIFETIMES_IN_OUTPUT_PATHS2);
174+
report_hidden_in_paths(cx, &input_map, HIDDEN_LIFETIMES_IN_INPUT_PATHS);
175+
report_hidden_in_paths(cx, &output_map, HIDDEN_LIFETIMES_IN_OUTPUT_PATHS);
176176
}
177177
}
178178

@@ -454,14 +454,14 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeInfoCollector<'a, 'tcx> {
454454
}
455455

456456
declare_lint! {
457-
/// The `hidden_lifetimes_in_type_paths2` lint detects the use of
457+
/// The `hidden_lifetimes_in_type_paths` lint detects the use of
458458
/// hidden lifetime parameters in types not part of a function's
459459
/// arguments or return values.
460460
///
461461
/// ### Example
462462
///
463463
/// ```rust,compile_fail
464-
/// #![deny(hidden_lifetimes_in_input_paths2)]
464+
/// #![deny(hidden_lifetimes_in_input_paths)]
465465
///
466466
/// struct ContainsLifetime<'a>(&'a i32);
467467
///
@@ -480,7 +480,7 @@ declare_lint! {
480480
/// lifetime].
481481
///
482482
/// [placeholder lifetime]: https://doc.rust-lang.org/reference/lifetime-elision.html#lifetime-elision-in-functions
483-
pub HIDDEN_LIFETIMES_IN_TYPE_PATHS2,
483+
pub HIDDEN_LIFETIMES_IN_TYPE_PATHS,
484484
Allow,
485485
"hidden lifetime parameters in types outside function signatures are discouraged"
486486
}
@@ -490,7 +490,7 @@ pub(crate) struct HiddenLifetimesInTypePaths {
490490
inside_fn_signature: bool,
491491
}
492492

493-
impl_lint_pass!(HiddenLifetimesInTypePaths => [HIDDEN_LIFETIMES_IN_TYPE_PATHS2]);
493+
impl_lint_pass!(HiddenLifetimesInTypePaths => [HIDDEN_LIFETIMES_IN_TYPE_PATHS]);
494494

495495
impl<'tcx> LateLintPass<'tcx> for HiddenLifetimesInTypePaths {
496496
#[instrument(skip(self, cx))]
@@ -533,7 +533,7 @@ impl<'tcx> LateLintPass<'tcx> for HiddenLifetimesInTypePaths {
533533
}
534534

535535
cx.emit_span_lint(
536-
HIDDEN_LIFETIMES_IN_TYPE_PATHS2,
536+
HIDDEN_LIFETIMES_IN_TYPE_PATHS,
537537
ty.span,
538538
lints::HiddenLifetimeInPath {
539539
suggestions: lints::HiddenLifetimeInPathSuggestion { suggestions },

compiler/rustc_lint/src/lints.rs

+2-9
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use std::num::NonZero;
55
use rustc_abi::ExternAbi;
66
use rustc_errors::codes::*;
77
use rustc_errors::{
8-
Applicability, Diag, DiagArgValue, DiagMessage, DiagStyledString, ElidedLifetimeInPathSubdiag,
9-
EmissionGuarantee, LintDiagnostic, MultiSpan, Subdiagnostic, SuggestionStyle,
8+
Applicability, Diag, DiagArgValue, DiagMessage, DiagStyledString, EmissionGuarantee,
9+
LintDiagnostic, MultiSpan, Subdiagnostic, SuggestionStyle,
1010
};
1111
use rustc_hir as hir;
1212
use rustc_hir::def::Namespace;
@@ -2641,13 +2641,6 @@ pub(crate) struct MacroExpandedMacroExportsAccessedByAbsolutePaths {
26412641
pub definition: Span,
26422642
}
26432643

2644-
#[derive(LintDiagnostic)]
2645-
#[diag(lint_hidden_lifetime_parameters)]
2646-
pub(crate) struct ElidedLifetimesInPaths {
2647-
#[subdiagnostic]
2648-
pub subdiag: ElidedLifetimeInPathSubdiag,
2649-
}
2650-
26512644
#[derive(LintDiagnostic)]
26522645
#[diag(lint_invalid_crate_type_value)]
26532646
pub(crate) struct UnknownCrateTypes {

compiler/rustc_lint_defs/src/builtin.rs

-36
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ declare_lint_pass! {
3939
DEPRECATED_WHERE_CLAUSE_LOCATION,
4040
DUPLICATE_MACRO_ATTRIBUTES,
4141
ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
42-
ELIDED_LIFETIMES_IN_PATHS,
4342
EXPLICIT_BUILTIN_CFGS_IN_FLAGS,
4443
EXPORTED_PRIVATE_DEPENDENCIES,
4544
FFI_UNWIND_CALLS,
@@ -1791,41 +1790,6 @@ declare_lint! {
17911790
};
17921791
}
17931792

1794-
declare_lint! {
1795-
/// The `elided_lifetimes_in_paths` lint detects the use of hidden
1796-
/// lifetime parameters.
1797-
///
1798-
/// ### Example
1799-
///
1800-
/// ```rust,compile_fail
1801-
/// #![deny(elided_lifetimes_in_paths)]
1802-
/// #![deny(warnings)]
1803-
/// struct Foo<'a> {
1804-
/// x: &'a u32
1805-
/// }
1806-
///
1807-
/// fn foo(x: &Foo) {
1808-
/// }
1809-
/// ```
1810-
///
1811-
/// {{produces}}
1812-
///
1813-
/// ### Explanation
1814-
///
1815-
/// Elided lifetime parameters can make it difficult to see at a glance
1816-
/// that borrowing is occurring. This lint ensures that lifetime
1817-
/// parameters are always explicitly stated, even if it is the `'_`
1818-
/// [placeholder lifetime].
1819-
///
1820-
/// This lint is "allow" by default because it has some known issues, and
1821-
/// may require a significant transition for old code.
1822-
///
1823-
/// [placeholder lifetime]: https://doc.rust-lang.org/reference/lifetime-elision.html#lifetime-elision-in-functions
1824-
pub ELIDED_LIFETIMES_IN_PATHS,
1825-
Allow,
1826-
"hidden lifetime parameters in types are deprecated"
1827-
}
1828-
18291793
declare_lint! {
18301794
/// The `bare_trait_objects` lint suggests using `dyn Trait` for trait
18311795
/// objects.

compiler/rustc_lint_defs/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,6 @@ pub enum BuiltinLintDiag {
645645
ident: Ident,
646646
},
647647
MacroExpandedMacroExportsAccessedByAbsolutePaths(Span),
648-
ElidedLifetimesInPaths(usize, Span, bool, Span),
649648
UnknownCrateTypes {
650649
span: Span,
651650
candidate: Option<Symbol>,

compiler/rustc_resolve/src/late.rs

-16
Original file line numberDiff line numberDiff line change
@@ -2079,7 +2079,6 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
20792079
kind,
20802080
count: expected_lifetimes,
20812081
};
2082-
let mut should_lint = true;
20832082
for rib in self.lifetime_ribs.iter().rev() {
20842083
match rib.kind {
20852084
// In create-parameter mode we error here because we don't want to support
@@ -2102,7 +2101,6 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
21022101
span: path_span,
21032102
subdiag,
21042103
});
2105-
should_lint = false;
21062104

21072105
for id in node_ids {
21082106
self.record_lifetime_res(
@@ -2171,20 +2169,6 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
21712169
}
21722170
}
21732171
}
2174-
2175-
if should_lint {
2176-
self.r.lint_buffer.buffer_lint(
2177-
lint::builtin::ELIDED_LIFETIMES_IN_PATHS,
2178-
segment_id,
2179-
elided_lifetime_span,
2180-
lint::BuiltinLintDiag::ElidedLifetimesInPaths(
2181-
expected_lifetimes,
2182-
path_span,
2183-
!segment.has_generic_args,
2184-
elided_lifetime_span,
2185-
),
2186-
);
2187-
}
21882172
}
21892173
}
21902174

src/tools/lint-docs/src/groups.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ static GROUP_DESCRIPTIONS: &[(&str, &str)] = &[
1212
("let-underscore", "Lints that detect wildcard let bindings that are likely to be invalid"),
1313
("rustdoc", "Rustdoc-specific lints"),
1414
("rust-2018-idioms", "Lints to nudge you toward idiomatic features of Rust 2018"),
15+
("hidden-lifetimes-in-paths", "Lints that detect the use of hidden lifetime parameters"),
1516
("nonstandard-style", "Violation of standard naming conventions"),
1617
("future-incompatible", "Lints that detect code that has future-compatibility problems"),
1718
("rust-2018-compatibility", "Lints used to transition code from the 2015 edition to 2018"),

src/tools/tidy/src/issues.txt

-2
Original file line numberDiff line numberDiff line change
@@ -2637,7 +2637,6 @@ ui/let-else/issue-100103.rs
26372637
ui/let-else/issue-102317.rs
26382638
ui/let-else/issue-94176.rs
26392639
ui/let-else/issue-99975.rs
2640-
ui/lifetimes/auxiliary/issue-91763-aux.rs
26412640
ui/lifetimes/issue-103582-hint-for-missing-lifetime-bound-on-trait-object-using-type-alias.rs
26422641
ui/lifetimes/issue-104432-unused-lifetimes-in-expansion.rs
26432642
ui/lifetimes/issue-105227.rs
@@ -2670,7 +2669,6 @@ ui/lifetimes/issue-84398.rs
26702669
ui/lifetimes/issue-84604.rs
26712670
ui/lifetimes/issue-90170-elision-mismatch.rs
26722671
ui/lifetimes/issue-90600-expected-return-static-indirect.rs
2673-
ui/lifetimes/issue-91763.rs
26742672
ui/lifetimes/issue-93911.rs
26752673
ui/lifetimes/issue-95023.rs
26762674
ui/lifetimes/issue-97193.rs

tests/ui/lifetimes/auxiliary/issue-91763-aux.rs

-42
This file was deleted.

0 commit comments

Comments
 (0)