Skip to content

No warning for unused function using impl Trait on beta and nightly #54754

Closed

Description

@jonas-schievink

The following code only warns that f is unused on stable, not on beta or nightly:

trait Trait {}
impl<T> Trait for T {}

fn f() -> impl Trait {}

(apologies if this is a duplicate, but a quick search didn't turn anything up)

Activity

  1. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    A-diagnosticsArea: Messages for errors, warnings, and lints
    on Oct 2, 2018
  2. jonas-schievink commented on Oct 2, 2018

    @jonas-schievink
    ContributorAuthor

    This has appeared between 63d6649 and d41f21f (commits in that range).

    Likely culprit is #53545 (cc @FelixMcFelix). It introduces a new reachability level to rustc (ReachableFromImplTrait), which marks any function with an impl Trait return type with that level. Maybe the level required by the lint to consider an item reachable needs to be higher than that?

  3. FelixMcFelix commented on Oct 4, 2018

    @FelixMcFelix
    Contributor

    Yeah, the likely fix for this is to create a query for lints that removes all levels under AccessLevel::Reachable, or manually strip the entries each time. The former probably makes more sense. I wasn't sure we'd need to do this at the time, it shouldn't take too long.

  4. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Oct 4, 2018
  5. added this to the 1.30 milestone on Oct 4, 2018
  6. jonas-schievink commented on Oct 4, 2018

    @jonas-schievink
    ContributorAuthor

    I've implemented a more minimal fix at #54810. It should be safe to backport to beta, if this is wanted at all.

  7. self-assigned this
    on Oct 4, 2018
  8. pnkfelix commented on Oct 4, 2018

    @pnkfelix
    Contributor

    (assigning self just to make sure everything gets followed up on here)

  9. pnkfelix commented on Oct 4, 2018

    @pnkfelix
    Contributor

    tagged as P-high since it was a regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions