Skip to content

False positive for explicit_outlives_requirements lint #60993

@dbeckwith

Description

@dbeckwith
#![allow(dead_code)]
#![deny(explicit_outlives_requirements)]

struct Test<'a, T>(&'a T) where T: ?Sized;

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error: outlives requirements can be inferred
 --> src/lib.rs:4:19
  |
4 | struct Test<'a, T>(&'a T) where T: ?Sized;
  |                   ^^^^^^^^^^^^^^^^^^^^^^^ help: remove these bounds
  |
note: lint level defined here
 --> src/lib.rs:2:9
  |
2 | #![deny(explicit_outlives_requirements)]
  |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

Maybe I'm missing something, but this lint error makes no sense in this context, as there are no outlives bounds written.

Curiously, struct Test<'a, T: ?Sized>(&'a T); compiles without error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions