Skip to content

Commit ff1741b

Browse files
committed
elided_named_lifetimes: Lint stub
Currently ICEs because we buffer it with NodeId of the missing lifetime, so it ends up not getting emitted
1 parent 357633b commit ff1741b

File tree

6 files changed

+26
-1
lines changed

6 files changed

+26
-1
lines changed

compiler/rustc_lint/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@ lint_duplicate_macro_attribute =
252252
253253
lint_duplicate_matcher_binding = duplicate matcher binding
254254
255+
lint_elided_lifetime_static =
256+
this lifetime is static, lol
257+
255258
lint_enum_intrinsics_mem_discriminant =
256259
the return value of `mem::discriminant` is unspecified when called with a non-enum type
257260
.note = the argument to `discriminant` should be a reference to an enum, but it was passed a reference to a `{$ty_param}`, which is not an enum

compiler/rustc_lint/src/context/diagnostics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,5 +441,6 @@ pub(super) fn decorate_lint(sess: &Session, diagnostic: BuiltinLintDiag, diag: &
441441
BuiltinLintDiag::UnexpectedBuiltinCfg { cfg, cfg_name, controlled_by } => {
442442
lints::UnexpectedBuiltinCfg { cfg, cfg_name, controlled_by }.decorate_lint(diag)
443443
}
444+
BuiltinLintDiag::ElidedIsStatic => lints::ElidedIsStatic {}.decorate_lint(diag),
444445
}
445446
}

compiler/rustc_lint/src/lints.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,6 +2611,10 @@ pub struct ElidedLifetimesInPaths {
26112611
pub subdiag: ElidedLifetimeInPathSubdiag,
26122612
}
26132613

2614+
#[derive(LintDiagnostic)]
2615+
#[diag(lint_elided_lifetime_static)]
2616+
pub struct ElidedIsStatic {}
2617+
26142618
#[derive(LintDiagnostic)]
26152619
#[diag(lint_invalid_crate_type_value)]
26162620
pub struct UnknownCrateTypes {

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ declare_lint_pass! {
4242
DUPLICATE_MACRO_ATTRIBUTES,
4343
ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
4444
ELIDED_LIFETIMES_IN_PATHS,
45+
ELIDED_NAMED_LIFETIMES,
4546
EXPLICIT_BUILTIN_CFGS_IN_FLAGS,
4647
EXPORTED_PRIVATE_DEPENDENCIES,
4748
FFI_UNWIND_CALLS,
@@ -1863,6 +1864,13 @@ declare_lint! {
18631864
"hidden lifetime parameters in types are deprecated"
18641865
}
18651866

1867+
declare_lint! {
1868+
/// TODO
1869+
pub ELIDED_NAMED_LIFETIMES,
1870+
Allow,
1871+
"TODO"
1872+
}
1873+
18661874
declare_lint! {
18671875
/// The `bare_trait_objects` lint suggests using `dyn Trait` for trait
18681876
/// objects.

compiler/rustc_lint_defs/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ pub enum BuiltinLintDiag {
585585
},
586586
MacroExpandedMacroExportsAccessedByAbsolutePaths(Span),
587587
ElidedLifetimesInPaths(usize, Span, bool, Span),
588+
ElidedIsStatic,
588589
UnknownCrateTypes {
589590
span: Span,
590591
candidate: Option<Symbol>,

compiler/rustc_resolve/src/late.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2041,7 +2041,15 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
20412041
}
20422042
match candidate {
20432043
LifetimeElisionCandidate::Missing(missing) => match res {
2044-
LifetimeRes::Static => tracing::warn!(?missing, "static"),
2044+
LifetimeRes::Static => {
2045+
self.r.lint_buffer.buffer_lint(
2046+
lint::builtin::ELIDED_NAMED_LIFETIMES,
2047+
missing.id,
2048+
missing.span,
2049+
BuiltinLintDiag::ElidedIsStatic {},
2050+
);
2051+
tracing::warn!(?missing, "static")
2052+
}
20452053
LifetimeRes::Param { param, binder } => {
20462054
tracing::warn!(?missing, ?param, ?binder, "named")
20472055
}

0 commit comments

Comments
 (0)