-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Improve --dep-info to include crate dependencies #16638
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
Labels
A-frontend
Area: Compiler frontend (errors, parsing and HIR)
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
Comments
Triage: |
Triage: with no comments since this was filed, I don't think that this issue is relevant anymore. If you still want this, please open a new issue with details that are relevant to today's Rust. Thanks! |
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 3, 2024
…, r=Veykril feature: Add `destructure_struct_binding` Adds an assist for destructuring a struct in a binding (rust-lang#8673). I saw that rust-lang#13997 has been abandoned for a while, so I thought I'd give it a go. ## Example ```rust let foo = Foo { bar: 1, baz: 2 }; let bar2 = foo.bar; let baz2 = foo.baz; let foo2 = foo; let fizz = Fizz(1, 2); let buzz = fizz.0; ``` becomes ```rust let Foo { bar, baz } = Foo { bar: 1, baz: 2 }; let bar2 = bar; let baz2 = baz; let foo2 = todo!(); let Fizz(_0, _1) = Fizz(1, 2); let buzz = _0; ``` More examples in the tests. ## What is included? - [x] Destructure record, tuple, and unit struct bindings - [x] Edit field usages - [x] Non-exhaustive structs in foreign crates and private fields get hidden behind `..` - [x] Nested bindings - [x] Carry over `mut` and `ref mut` in nested bindings to fields, i.e. `let Foo { ref mut bar } = ...` becomes `let Foo { bar: Bar { baz: ref mut baz } } = ...` - [x] Attempt to resolve collisions with other names in the scope - [x] If the binding is to a reference, field usages are dereferenced if required - [x] Use shorthand notation if possible ## Known limitations - `let foo = Foo { bar: 1 }; foo;` currently results in `let Foo { bar } = Foo { bar: 1 }; todo!();` instead of reassembling the struct. This requires user intervention. - Unused fields are not currently omitted. I thought that this is more ergonomic, as there already is a quick fix action for adding `: _` to unused field patterns.
matthiaskrgr
pushed a commit
to matthiaskrgr/rust
that referenced
this issue
Mar 10, 2024
…, r=Veykril fix: Don't destructure struct with no public fields Unfortunately I missed this case in rust-lang#16638. If a struct only has private members, the assist should not be applicable. Though valid syntax exists (`Foo { .. }`), it isn't particularly useful. Since this case applies to a lot of common types (`Arc`, `Vec`, ...), it probably makes the most sense to hide the action. As a side effect, this also disables the action for unit structs, where it also isn't particularly useful. I'd be open to changing it though if you think it makes more sense to keep it. This also fixes the `make::record_pat_field_list` function to produce valid syntax if the field list is empty, as it is used in other places too. ## Current behaviour ```rust // In crate `other_crate` pub struct Foo { bar: i32 } // In current crate fn do_something(foo: other_crate::Foo) {} // Becomes fn do_something(other_crate::Foo { , .. }: other_crate::Foo) {} ``` ## Fixed behaviour Assist should not be applicable in this case anymore.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-frontend
Area: Compiler frontend (errors, parsing and HIR)
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
The --dep-info flag to rustc only prints out the source file(s) that make up the output crate. It does not print out any libraries though.
For an example file "a.rs" compiled into a binary crate "a", if "a.rs" has "extern crate b" and rustc statically links in "libb.rlib", I would expect dependency info to include the fact as "a: libb.rlib", so that whenever libb.rlib changes, a.rs is recompiled into a. Similarly for other crate types.
If --dep-info can not be modified, perhaps --full-dep-info will be considered.
The text was updated successfully, but these errors were encountered: