-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Incorrect 'struct is never constructed' warning #59003
Comments
You seem to have posted the same snippet twice |
My bad! I've updated my comment. |
I think this is because |
That seems reasonable, but in that case, I'd expect to get a warning if |
This also happens with enum variants and "variant is never constructed" warning, see playground link. |
This also applies in connection with 47133: pub struct SlackStatus;
impl SlackStatus {
pub const STARTING: &'static str = "starting";
pub const SUCCESS: &'static str = "success";
pub const ERROR: &'static str = "error";
} I get warnings about But maybe I'm doing something wrong here or getting it wrong as a concept in my head; if so, I'm glad for some pointers and hints :-) |
None of the incorrect warnings are emitted anymore (nightly 2023-01-22). |
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
…errors Add regression test for rust-lang#59003 Closes rust-lang#59003 r? compiler-errors
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#109959 (Fix transmute intrinsic mir validation ICE) - rust-lang#110176 (Renumbering cleanups) - rust-lang#110182 (Use `itertools::Either` instead of own impl) - rust-lang#110188 (Remove orphaned remove_dir_all implementation from rust-installer) - rust-lang#110190 (Custom MIR: Support `BinOp::Offset`) - rust-lang#110209 (Add regression test for rust-lang#59003) - rust-lang#110210 (`DescriptionCtx` cleanups) - rust-lang#110217 (doc: loongarch: Fix typos) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Consider the following code snippet:
This will trigger a 'struct is never constructed' warning, even though the struct is clearly constructed in the implementation of
From<u32>
.The problem seems to be caused by using
Self
as the constructor. If I replaceSelf
with the name of the struct, as in the following code snippet, the warning goes away:The text was updated successfully, but these errors were encountered: