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

std::local_data broken with zero-sized types #13322

Closed
SimonSapin opened this issue Apr 4, 2014 · 2 comments
Closed

std::local_data broken with zero-sized types #13322

SimonSapin opened this issue Apr 4, 2014 · 2 comments

Comments

@SimonSapin
Copy link
Contributor

Test case:

use std::local_data;

local_data_key!(silence_errors: ())

fn main() {
    local_data::get(silence_errors, |silenced| println!("{}", silenced));
    local_data::set(silence_errors, ());
    local_data::get(silence_errors, |silenced| println!("{}", silenced));
}

Expected output:

None
Some(())

Actual output:

None
None

Replacing () with bool/true fixes the issue.

@SimonSapin
Copy link
Contributor Author

Sounds kinda possibly maybe related to #11998?

@alexcrichton
Copy link
Member

Fixed by 898669c (working on nightly)

SimonSapin added a commit to SimonSapin/servo that referenced this issue May 15, 2014
We’ve upgraded to a Rust version that fixed rust-lang/rust#13322.
SimonSapin added a commit to SimonSapin/servo that referenced this issue May 23, 2014
We’ve upgraded to a Rust version that fixed rust-lang/rust#13322.
bors added a commit to rust-lang-ci/rust that referenced this issue Sep 24, 2024
… r=y21

Unused trait imports (formerly anonymous trait import)

For rust-lang#11969

I'm looking for help and feedback on implementing a new lint for suggesting `use ... as _` for traits where possible.

I have had a go at implementing this but I don't know if this is the best way to do it as I am new to clippy.

There are some edge cases I can think of where this doesn't work but have aired on the side of false negatives instead of false positives.

An example of a false negative. I couldn't figure out the best way to resolve an import from within clippy. The sub module imports MyAny so that cannot be anonymized but `use std::any::Any` could be. In this case it is not caught because `Any` and `MyAny` have the same DefId.
```rust
mod nested_mod_used_bad1 {
    use std::any::Any;
    use std::any::Any as MyAny;
    mod foo {
        use crate::nested_mod_used_bad1::MyAny;
        fn foo() {
            println!("{:?}", MyAny::type_id("foo"));
        }
    }
}
```

Any feedback is much appreciated.

-------
changelog: new lint: `unused_trait_names`
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