Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to resolve name collision in local item #5468

Closed
ammkrn opened this issue Jul 20, 2020 · 2 comments
Closed

Failure to resolve name collision in local item #5468

ammkrn opened this issue Jul 20, 2020 · 2 comments

Comments

@ammkrn
Copy link
Contributor

ammkrn commented Jul 20, 2020

rust-analyzer version: 2020-07-20 (c9c518e)
rustc 1.45.0 (5c1f21c3b 2020-07-13)
vscode 1.47.2 (darwin)

The following code is accepted by rustc, but is rejected as a hard error by RA, since RA believes Box to be std::Box. If I move Box outside of the function block, it both compiles and is accepted by RA.

struct X;

impl X {
    pub fn mk_box() -> impl std::fmt::Debug {

        #[derive(Debug)]
        struct Box {
            height : u64,
            width : u64,
        }

        impl Box {
            pub fn new(height : u64, width : u64) -> Box {
                Box { height, width }
            }
        }

        Box::new(1, 2)
    }
}

fn main() {
    let _x = X::mk_box();
    println!("x : {:#?}\n", _x);
}

Hovering on the error shows the docs for std::Box, with the message:

Expected 1 argument, found 2
@cynecx
Copy link
Contributor

cynecx commented Jul 21, 2020

This is a duplicate of #1559 I'd say.

@ammkrn
Copy link
Contributor Author

ammkrn commented Jul 21, 2020

This is a duplicate of #1559 I'd say.

Thanks, I guess I just didn't look hard enough.

@ammkrn ammkrn closed this as completed Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants