Make match in register_res easier to read#84880
Conversation
|
r? @ollie27 (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
- Don't duplicate DefKind -> ItemType handling; that's a good way to get bugs - Use exhaustive match - Add comments This found that register_res is very wrong in at least one way: if it registers a Res for `Variant`, it should also register one for `Field`. But I don't know whether the one for Variant should be removed or Field added. Maybe someone has ideas?
| @@ -0,0 +1,4 @@ | |||
| // @has field/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/ops/range/struct.Range.html#structfield.start"]' 'start' | |||
There was a problem hiding this comment.
Nitpicking: generally we tend to put such checks below the inner attributes. Not a blocker though.
GuillaumeGomez
left a comment
There was a problem hiding this comment.
Apart from the nitpick, looks good to me. r=me with or without it.
|
Thanks for the review :) do you have ideas about this bit?
|
|
Fields and variants are different: a variant can represent its enum whereas a field cannot represent its struct. So it seems logical that there is res for one but not for the other. |
What does this mean? |
|
I'm sorry, I'm really bad at explaining things... What I tried to say is that it's logical for variant to have Well, I guess that explanation doesn't make any sense either... XD |
|
@GuillaumeGomez maybe this is easier to answer - can you write a test case that fails if we ignore Variant? Or that fails currently because we ignore Field? |
|
After re-reading, I think I misunderstood and that we should have |
|
I'm unclear about the status of this, is it reviewed, approved, waiting for changes? |
|
@bstrie it's probably ok to approve as is, but I'd like to figure out what's going on with |
|
I won't have time to investigate this in the near future. I'll open an issue for the fishiness with Field. @bors r=GuillaumeGomez rollup |
|
📌 Commit 4029a03 has been approved by |
Rollup of 10 pull requests Successful merges: - rust-lang#83653 (Remove unused code from `rustc_data_structures::sync`) - rust-lang#84466 (rustdoc: Remove `PrimitiveType::{to_url_str, as_str}`) - rust-lang#84880 (Make match in `register_res` easier to read) - rust-lang#84942 (rustdoc: link to stable/beta docs consistently in documentation) - rust-lang#85853 (Warn against boxed DST in `improper_ctypes_definitions` lint) - rust-lang#85939 (Fix suggestion for removing &mut from &mut macro!().) - rust-lang#85966 (wasm: Make simd types passed via indirection again) - rust-lang#85979 (don't suggest unsized indirection in where-clauses) - rust-lang#85983 (Update to semver 1.0.3) - rust-lang#85988 (Note that `ninja = false` goes under `[llvm]`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This found that register_res is very wrong in at least one way: if it
registers a Res for
Variant, it should also register one forField.But I don't know whether the one for Variant should be removed or Field
added. Maybe someone has ideas?
Found while reviewing #84176.