Skip to content

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

Closed
@nikomatsakis

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.

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