Skip to content

Commit be9758a

Browse files
committed
rename elided_lifetimes_in_paths lint to hidden_lifetimes_in_types
It's only with reluctance and sadness that we rename a lint that has already been renamed once (rust-lang#50879), but it seems worth it to pick the best name now because since the lint is relatively new and has heretofore been allow-by-default, the ecosystem breakage should be minimal. (And—also sadly—the fact that the original implementation was so buggy for so long testifies that not very many people are tuning up the allow-by-default lints. Also, as always, lint capping prevents lint changes from spreading contagiously to dependencies.) The rationales here are that— • "hidden" is less potentially ambiguous than "elided", because this lint is specifically about angle-bracketed lifetime parameters, whereas the term "elided" has a strong precedent for also encompassing omitted lifetime names in reference ('&') types, which is not the concern of this lint, and • "types" is a more specific description of where the lint fires than "paths" (indeed, previous implementations of the lint used to fire on non-type paths in ways that proved to be erroneous false-positives, as evidenced by applications of the suggestion to use an anonymous lifetime (`'_`) resulting in code that didn't even parse) This comes from discussion on rust-lang#52069.
1 parent 47aabb3 commit be9758a

File tree

6 files changed

+39
-36
lines changed

6 files changed

+39
-36
lines changed

src/librustc/lint/builtin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ declare_lint! {
250250
}
251251

252252
declare_lint! {
253-
pub ELIDED_LIFETIMES_IN_PATHS,
253+
pub HIDDEN_LIFETIMES_IN_TYPES,
254254
Allow,
255-
"implicit lifetime parameters are deprecated"
255+
"hidden lifetime parameters in types are deprecated"
256256
}
257257

258258
declare_lint! {
@@ -376,7 +376,7 @@ impl LintPass for HardwiredLints {
376376
UNUSED_LIFETIMES,
377377
UNUSED_LABELS,
378378
TYVAR_BEHIND_RAW_POINTER,
379-
ELIDED_LIFETIMES_IN_PATHS,
379+
HIDDEN_LIFETIMES_IN_TYPES,
380380
BARE_TRAIT_OBJECTS,
381381
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
382382
UNSTABLE_NAME_COLLISIONS,

src/librustc/middle/resolve_lifetime.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2102,10 +2102,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
21022102
}
21032103

21042104
let mut err = self.tcx.struct_span_lint_node(
2105-
lint::builtin::ELIDED_LIFETIMES_IN_PATHS,
2105+
lint::builtin::HIDDEN_LIFETIMES_IN_TYPES,
21062106
implicit_lifetimes[0].id, // FIXME: HirIdify #50928
21072107
path.span,
2108-
&format!("implicit lifetime parameters in types are deprecated"),
2108+
&format!("hidden lifetime parameters in types are deprecated"),
21092109
);
21102110

21112111
if implicit_lifetimes.len() == 1 {

src/librustc_lint/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extern crate syntax_pos;
4545
use rustc::lint;
4646
use rustc::lint::{LateContext, LateLintPass, LintPass, LintArray};
4747
use rustc::lint::builtin::{BARE_TRAIT_OBJECTS, ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE,
48-
ELIDED_LIFETIMES_IN_PATHS, MACRO_USE_EXTERN_CRATE};
48+
HIDDEN_LIFETIMES_IN_TYPES, MACRO_USE_EXTERN_CRATE};
4949

5050
use rustc::session;
5151
use rustc::util;
@@ -184,7 +184,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
184184
UNREACHABLE_PUB,
185185
UNUSED_EXTERN_CRATES,
186186
MACRO_USE_EXTERN_CRATE,
187-
ELIDED_LIFETIMES_IN_PATHS,
187+
HIDDEN_LIFETIMES_IN_TYPES,
188188
ELLIPSIS_INCLUSIVE_RANGE_PATTERNS);
189189

190190
// Guidelines for creating a future incompatibility lint:
@@ -308,11 +308,14 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
308308

309309
// Register renamed and removed lints
310310
store.register_renamed("single_use_lifetime", "single_use_lifetimes");
311-
store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths");
312311
store.register_renamed("bare_trait_object", "bare_trait_objects");
313312
store.register_renamed("unstable_name_collision", "unstable_name_collisions");
314313
store.register_renamed("unused_doc_comment", "unused_doc_comments");
315314
store.register_renamed("unknown_features", "unused_features");
315+
// Yes, it got renamed twice :'(
316+
store.register_renamed("elided_lifetime_in_path", "hidden_lifetimes_in_types");
317+
store.register_renamed("elided_lifetimes_in_paths", "hidden_lifetimes_in_types");
318+
316319
store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
317320
store.register_removed("negate_unsigned", "cast a signed value instead");
318321
store.register_removed("raw_pointer_derive", "using derive with raw pointers is ok");

src/test/ui/in-band-lifetimes/elided-lifetimes.fixed renamed to src/test/ui/lint/hidden-lifetimes-in-types.fixed

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// compile-flags: --edition 2018
1313

1414
#![allow(unused)]
15-
#![deny(elided_lifetimes_in_paths)]
15+
#![deny(hidden_lifetimes_in_types)]
1616
//~^ NOTE lint level defined here
1717

1818
use std::cell::{RefCell, Ref};
@@ -21,7 +21,7 @@ use std::cell::{RefCell, Ref};
2121
struct Foo<'a> { x: &'a u32 }
2222

2323
fn foo(x: &Foo<'_>) {
24-
//~^ ERROR implicit lifetime parameters in types are deprecated
24+
//~^ ERROR hidden lifetime parameters in types are deprecated
2525
//~| HELP indicate the anonymous lifetime
2626
}
2727

@@ -35,13 +35,13 @@ struct WrappedWithBow<'a> {
3535
}
3636

3737
fn wrap_gift(gift: &str) -> Wrapped<'_> {
38-
//~^ ERROR implicit lifetime parameters in types are deprecated
38+
//~^ ERROR hidden lifetime parameters in types are deprecated
3939
//~| HELP indicate the anonymous lifetime
4040
Wrapped(gift)
4141
}
4242

4343
fn wrap_gift_with_bow(gift: &str) -> WrappedWithBow<'_> {
44-
//~^ ERROR implicit lifetime parameters in types are deprecated
44+
//~^ ERROR hidden lifetime parameters in types are deprecated
4545
//~| HELP indicate the anonymous lifetime
4646
WrappedWithBow { gift }
4747
}
@@ -53,7 +53,7 @@ macro_rules! autowrapper {
5353
}
5454

5555
fn $fn_name(gift: &str) -> $type_name<'_> {
56-
//~^ ERROR implicit lifetime parameters in types are deprecated
56+
//~^ ERROR hidden lifetime parameters in types are deprecated
5757
//~| HELP indicate the anonymous lifetime
5858
$type_name { gift }
5959
}
@@ -67,15 +67,15 @@ autowrapper!(Autowrapped, autowrap_gift, 'a);
6767
macro_rules! anytuple_ref_ty {
6868
($($types:ty),*) => {
6969
Ref<'_, ($($types),*)>
70-
//~^ ERROR implicit lifetime parameters in types are deprecated
70+
//~^ ERROR hidden lifetime parameters in types are deprecated
7171
//~| HELP indicate the anonymous lifetime
7272
}
7373
}
7474

7575
fn main() {
7676
let honesty = RefCell::new((4, 'e'));
7777
let loyalty: Ref<'_, (u32, char)> = honesty.borrow();
78-
//~^ ERROR implicit lifetime parameters in types are deprecated
78+
//~^ ERROR hidden lifetime parameters in types are deprecated
7979
//~| HELP indicate the anonymous lifetime
8080
let generosity = Ref::map(loyalty, |t| &t.0);
8181

src/test/ui/in-band-lifetimes/elided-lifetimes.rs renamed to src/test/ui/lint/hidden-lifetimes-in-types.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// compile-flags: --edition 2018
1313

1414
#![allow(unused)]
15-
#![deny(elided_lifetimes_in_paths)]
15+
#![deny(hidden_lifetimes_in_types)]
1616
//~^ NOTE lint level defined here
1717

1818
use std::cell::{RefCell, Ref};
@@ -21,7 +21,7 @@ use std::cell::{RefCell, Ref};
2121
struct Foo<'a> { x: &'a u32 }
2222

2323
fn foo(x: &Foo) {
24-
//~^ ERROR implicit lifetime parameters in types are deprecated
24+
//~^ ERROR hidden lifetime parameters in types are deprecated
2525
//~| HELP indicate the anonymous lifetime
2626
}
2727

@@ -35,13 +35,13 @@ struct WrappedWithBow<'a> {
3535
}
3636

3737
fn wrap_gift(gift: &str) -> Wrapped {
38-
//~^ ERROR implicit lifetime parameters in types are deprecated
38+
//~^ ERROR hidden lifetime parameters in types are deprecated
3939
//~| HELP indicate the anonymous lifetime
4040
Wrapped(gift)
4141
}
4242

4343
fn wrap_gift_with_bow(gift: &str) -> WrappedWithBow {
44-
//~^ ERROR implicit lifetime parameters in types are deprecated
44+
//~^ ERROR hidden lifetime parameters in types are deprecated
4545
//~| HELP indicate the anonymous lifetime
4646
WrappedWithBow { gift }
4747
}
@@ -53,7 +53,7 @@ macro_rules! autowrapper {
5353
}
5454

5555
fn $fn_name(gift: &str) -> $type_name {
56-
//~^ ERROR implicit lifetime parameters in types are deprecated
56+
//~^ ERROR hidden lifetime parameters in types are deprecated
5757
//~| HELP indicate the anonymous lifetime
5858
$type_name { gift }
5959
}
@@ -67,15 +67,15 @@ autowrapper!(Autowrapped, autowrap_gift, 'a);
6767
macro_rules! anytuple_ref_ty {
6868
($($types:ty),*) => {
6969
Ref<($($types),*)>
70-
//~^ ERROR implicit lifetime parameters in types are deprecated
70+
//~^ ERROR hidden lifetime parameters in types are deprecated
7171
//~| HELP indicate the anonymous lifetime
7272
}
7373
}
7474

7575
fn main() {
7676
let honesty = RefCell::new((4, 'e'));
7777
let loyalty: Ref<(u32, char)> = honesty.borrow();
78-
//~^ ERROR implicit lifetime parameters in types are deprecated
78+
//~^ ERROR hidden lifetime parameters in types are deprecated
7979
//~| HELP indicate the anonymous lifetime
8080
let generosity = Ref::map(loyalty, |t| &t.0);
8181

src/test/ui/in-band-lifetimes/elided-lifetimes.stderr renamed to src/test/ui/lint/hidden-lifetimes-in-types.stderr

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
error: implicit lifetime parameters in types are deprecated
2-
--> $DIR/elided-lifetimes.rs:23:12
1+
error: hidden lifetime parameters in types are deprecated
2+
--> $DIR/hidden-lifetimes-in-types.rs:23:12
33
|
44
LL | fn foo(x: &Foo) {
55
| ^^^- help: indicate the anonymous lifetime: `<'_>`
66
|
77
note: lint level defined here
8-
--> $DIR/elided-lifetimes.rs:15:9
8+
--> $DIR/hidden-lifetimes-in-types.rs:15:9
99
|
10-
LL | #![deny(elided_lifetimes_in_paths)]
10+
LL | #![deny(hidden_lifetimes_in_types)]
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^
1212

13-
error: implicit lifetime parameters in types are deprecated
14-
--> $DIR/elided-lifetimes.rs:37:29
13+
error: hidden lifetime parameters in types are deprecated
14+
--> $DIR/hidden-lifetimes-in-types.rs:37:29
1515
|
1616
LL | fn wrap_gift(gift: &str) -> Wrapped {
1717
| ^^^^^^^- help: indicate the anonymous lifetime: `<'_>`
1818

19-
error: implicit lifetime parameters in types are deprecated
20-
--> $DIR/elided-lifetimes.rs:43:38
19+
error: hidden lifetime parameters in types are deprecated
20+
--> $DIR/hidden-lifetimes-in-types.rs:43:38
2121
|
2222
LL | fn wrap_gift_with_bow(gift: &str) -> WrappedWithBow {
2323
| ^^^^^^^^^^^^^^- help: indicate the anonymous lifetime: `<'_>`
2424

25-
error: implicit lifetime parameters in types are deprecated
26-
--> $DIR/elided-lifetimes.rs:77:18
25+
error: hidden lifetime parameters in types are deprecated
26+
--> $DIR/hidden-lifetimes-in-types.rs:77:18
2727
|
2828
LL | let loyalty: Ref<(u32, char)> = honesty.borrow();
2929
| ^^^^^^^^^^^^^^^^ help: indicate the anonymous lifetime: `Ref<'_, (u32, char)>`
3030

31-
error: implicit lifetime parameters in types are deprecated
32-
--> $DIR/elided-lifetimes.rs:69:9
31+
error: hidden lifetime parameters in types are deprecated
32+
--> $DIR/hidden-lifetimes-in-types.rs:69:9
3333
|
3434
LL | Ref<($($types),*)>
3535
| ^^^^^^^^^^^^^^^^^^ help: indicate the anonymous lifetime: `Ref<'_, ($($types),*)>`
3636
...
3737
LL | let yellow: anytuple_ref_ty!(bool, &str) = laughter.borrow();
3838
| ---------------------------- in this macro invocation
3939

40-
error: implicit lifetime parameters in types are deprecated
41-
--> $DIR/elided-lifetimes.rs:55:36
40+
error: hidden lifetime parameters in types are deprecated
41+
--> $DIR/hidden-lifetimes-in-types.rs:55:36
4242
|
4343
LL | fn $fn_name(gift: &str) -> $type_name {
4444
| ^^^^^^^^^^- help: indicate the anonymous lifetime: `<'_>`

0 commit comments

Comments
 (0)