rust/tests/ui/error-codes/E0609-private-method.rs
Kevin Reid 7b837e075a Don't suggest adding parentheses to call an inaccessible method.
Previously, the test code would emit E0615, thus revealing the existence
of private methods that the programmer probably does not care about.
Now it ignores their existence instead, producing error E0609 (no field).

The motivating example is:

```rust
let x = std::rc::Rc::new(());
x.inner;
```

which would previously mention the private method `Rc::inner()`, even
though `Rc<T>` intentionally has no public methods so that it can be a
transparent smart pointer for any `T`.
2023-08-29 14:47:28 -07:00

17 lines
286 B
Rust

// This error is an E0609 and *not* an E0615 because the fact that the method exists is not
// relevant.
mod foo {
pub struct Foo {
x: u32,
}
impl Foo {
fn method(&self) {}
}
}
fn main() {
let f = foo::Foo { x: 0 };
f.method; //~ ERROR E0609
}