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

needless_borrow complains when a type alias with reference is used #2908

Closed
hmvp opened this issue Jul 9, 2018 · 3 comments
Closed

needless_borrow complains when a type alias with reference is used #2908

hmvp opened this issue Jul 9, 2018 · 3 comments

Comments

@hmvp
Copy link

hmvp commented Jul 9, 2018

Example code:

pub type SomeError: &'static str;

pub enum MyError {
    SomeErrorKind(SomeError),
}

results in

error: this pattern creates a reference to a reference
  --> file.rs:3:15
   |
3  |     SomeErrorKind(SomeError),
   |                   ^^^^^^^^^ help: change this to: `SomeError`
   |

In my case the SomeError type comes from an external library

@oli-obk
Copy link
Contributor

oli-obk commented Jul 9, 2018

pub type SomeError = &'static str;

pub enum MyError {
    SomeErrorKind(SomeError),
}

fn main() {}

Produces no such error. Maybe there are derives involved?

@hmvp
Copy link
Author

hmvp commented Jul 9, 2018

You are right it needs a derive:

#![deny(needless_borrow)]

pub type SomeError = &'static str;

#[derive(Debug)]
pub enum MyError {
    SomeErrorKind(SomeError),
}

fn main() {}

So its probally a duplicate of #2740

@phansch
Copy link
Member

phansch commented Nov 3, 2018

This will probably be fixed by #3400

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

4 participants