about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-05 08:03:13 +0000
committerbors <bors@rust-lang.org>2024-03-05 08:03:13 +0000
commit0c2e9feaee603d4e27215f5f276ea66ddf7e6904 (patch)
treeaea6b092fd526c1e4977bf5f7cefe48c9c7e1ba1 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent58e10c7d17fd501de8183a684ec122b698ec50f7 (diff)
parent2a4ba4295b3bb53e672cb2dded2247a5553cf089 (diff)
downloadrust-0c2e9feaee603d4e27215f5f276ea66ddf7e6904.tar.gz
rust-0c2e9feaee603d4e27215f5f276ea66ddf7e6904.zip
Auto merge of #16752 - Lindronics:destructure-struct-binding, r=Veykril
fix: Don't destructure struct with no public fields

Unfortunately I missed this case in #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.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions