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

Add a warning for casts with loss of precision #17900

Closed
bfops opened this issue Oct 9, 2014 · 3 comments
Closed

Add a warning for casts with loss of precision #17900

bfops opened this issue Oct 9, 2014 · 3 comments

Comments

@bfops
Copy link
Contributor

bfops commented Oct 9, 2014

e.g. this code should probably generate a warning:

fn main() {
    let i: u16 = 257;
    println!("{}", i as u8);
}

(Sorry if this has been mentioned elsewhere - I didn't see it when searching for "cast warning")

@japaric
Copy link
Member

japaric commented Oct 10, 2014

(For the general case, you could use num::cast which returns None if the operation under/overflows (it does a check at runtime).)

As for the lint request, I think that's a dupe of #14165

@bfops
Copy link
Contributor Author

bfops commented Oct 10, 2014

Ah good to know! Thanks!

I don't think it's quite a dupe because that issue only refers to literals - it should maybe be generalized?

@steveklabnik
Copy link
Member

closing as dup of #5477

lnicola pushed a commit to lnicola/rust that referenced this issue Aug 29, 2024
…r=davidbarsky

Add scip/lsif flag to exclude vendored libaries

rust-lang#17809 changed StaticIndex to include vendored libraries. This PR adds a flag to disable that behavior.

At work, our monorepo has too many rust targets to index all at once, so we split them up into several shards. Since all of our libraries are vendored, if rust-analyzer includes them, sharding no longer has much benefit, because every shard will have to index the entire transitive dependency graphs of all of its targets. We get around the issue presented in rust-lang#17809 because some other shard will index the libraries directly.
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

3 participants