Skip to content

Items defined in a function inherit the stability of the function and trigger lint checker #17488

Closed
@elinorbgr

Description

@elinorbgr

Example code:

#[deprecated = "You shouldn't double 42"]
fn double_of_42() -> uint {

    fn compute_42() -> uint {
        42u
    }

    2*compute_42()
}

generates the warning:

<anon>:8:7: 8:17 warning: use of deprecated item: You shouldn't double 42, #[warn(deprecated)] on by default
<anon>:8     2*compute_42()
               ^~~~~~~~~~

Which is quite confusing as the warning message is hardly related to the code warned against.
And I would not expect a warning being generated in such a case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions