Skip to content

suggesting for traits to import are not prefaced with crate in Rust 2018 #54559

Description

@nikomatsakis

Consider this test case in Rust 2018 (playground):

mod foo {
    pub(crate) trait Bar {
        fn bar(&self) { }
    } 
    
    impl Bar for u32 { }
}

fn main() {
    let x: u32 = 22;
    x.bar();
}

I get this error:

error[E0599]: no method named `bar` found for type `u32` in the current scope
  --> src/main.rs:11:7
   |
11 |     x.bar();
   |       ^^^
   |
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope, perhaps add a `use` for it:
   |
1  | use foo::Bar;
   |

I would like to see use crate::foo::Bar, however.

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Sep 25, 2018
  2. nikomatsakis commented on Sep 25, 2018

    @nikomatsakis
    ContributorAuthor

    cc @Mark-Simulacrum @Centril — Rust 2018 related bug, not sure how best to label/triage

  3. Mark-Simulacrum commented on Sep 25, 2018

    @Mark-Simulacrum
    Member

    Cc @alexcrichton @eddyb - I think there might already be a similar bug elsewhere, not sure

  4. self-assigned this
    on Sep 25, 2018
  5. added 2 commits that reference this issue on Oct 2, 2018
    014878e
    f70f6ec
  6. added
    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.
    and removed on Dec 21, 2024
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-edition-2018Area: The 2018 editionA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.F-rust_2018_preview`#![feature(rust_2018_preview)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions