about summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-07-26 15:27:59 +0200
committerGitHub <noreply@github.com>2025-07-26 15:27:59 +0200
commit43096cc9326c72da1976c5aa9cd1989c667cf98d (patch)
tree5bdb38d5eb2e8ddbea1670e7245c4fc9d3f2a4b5 /compiler/rustc_pattern_analysis/src
parentc9541a2bf86ed4d620abcf2f4eee3d0ce8e0e8cd (diff)
parent78fc7c351db02f29d0d4fbdf9025898225e32939 (diff)
downloadrust-43096cc9326c72da1976c5aa9cd1989c667cf98d.tar.gz
rust-43096cc9326c72da1976c5aa9cd1989c667cf98d.zip
Rollup merge of #144376 - estebank:issue-143795, r=lcnr
Suggest unwrapping when private method name is available in inner type

Given

```rust
fn main() {
    let maybe_vec = Some(vec![1,2,3]);
    assert_eq!(maybe_vec.len(), 3);
}
```

suggest unwraping `maybe_vec` to call `.len()` on the `Vec<_>`.

```
error[E0624]: method `len` is private
  --> $DIR/enum-method-probe.rs:61:9
   |
LL |     res.len();
   |         ^^^ private method
  --> $SRC_DIR/core/src/option.rs:LL:COL
   |
   = note: private method defined here
   |
note: the method `len` exists on the type `Vec<{integer}>`
  --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
help: consider using `Option::expect` to unwrap the `Vec<{integer}>` value, panicking if the value is an `Option::None`
   |
LL |     res.expect("REASON").len();
   |        +++++++++++++++++
```

When a method isn't available, we emit E0599, but when it is private we emit E0624. We now just invoke the same suggestion logic from the later that we already did in the former.

Fix rust-lang/rust#143795.
Diffstat (limited to 'compiler/rustc_pattern_analysis/src')
0 files changed, 0 insertions, 0 deletions