-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Bug: The compiler claims that a variable isn't read from when it is #56436
Comments
The warning is about the initial value fn main() {
let read_compiler_error;
let mut i = 0;
loop {
i += 1;
if i == 4 {
read_compiler_error = i;
break;
}
}
let loops = 25 % read_compiler_error;
println!("Loops are {}", loops)
} |
Ah ok that makes sense . Thanks for explaining :) I don't know how generic this lint catching is, but some text like or maybe |
Clearer error message for dead assign I'm not that this is the right place for this (if it needs an RFC or not). I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/. I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons. I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change. If this is the wrong place for this sort of thing I'll happily delete/move it.
Clearer error message for dead assign I'm not that this is the right place for this (if it needs an RFC or not). I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/. I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons. I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change. If this is the wrong place for this sort of thing I'll happily delete/move it.
Clearer error message for dead assign I'm not that this is the right place for this (if it needs an RFC or not). I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/. I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons. I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change. If this is the wrong place for this sort of thing I'll happily delete/move it.
Clearer error message for dead assign I'm not that this is the right place for this (if it needs an RFC or not). I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/. I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons. I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change. If this is the wrong place for this sort of thing I'll happily delete/move it.
Clearer error message for dead assign I'm not that this is the right place for this (if it needs an RFC or not). I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/. I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons. I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change. If this is the wrong place for this sort of thing I'll happily delete/move it.
Clearer error message for dead assign I'm not that this is the right place for this (if it needs an RFC or not). I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/. I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons. I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change. If this is the wrong place for this sort of thing I'll happily delete/move it.
Clearer error message for dead assign I'm not that this is the right place for this (if it needs an RFC or not). I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/. I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons. I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change. If this is the wrong place for this sort of thing I'll happily delete/move it.
Clearer error message for dead assign I'm not that this is the right place for this (if it needs an RFC or not). I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/. I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons. I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change. If this is the wrong place for this sort of thing I'll happily delete/move it.
Clearer error message for dead assign I'm not that this is the right place for this (if it needs an RFC or not). I had the problem where I misunderstood the compiler lint message rust-lang#56436 and other people seem to have had the same problem https://www.reddit.com/r/rust/comments/8cy9p4/value_assigned_to_is_never_read/. I think this new wording might be slightly clearer (and help out beginners like me). I'm very new though, so there might be some nuance I'm missing that would make this more confusing or a bad idea for other reasons. I thought I would create a PR to make it easy to change the code if the consensus was that it would make sense to make a change. If this is the wrong place for this sort of thing I'll happily delete/move it.
The compiler claims that a variable isn't read from when it is
I tried this code:
I expected to see this happen:
The code to compile without warning
Instead, this happened:
It has to have been read, otherwise it wouldn't give loops are 1.
Meta
rustc --version --verbose
:I might be doing something wrong, I'm fairly new to rust, but this seems like a bug to me.
The text was updated successfully, but these errors were encountered: