Rollup merge of #90508 - nbdd0121:issue-90483, r=davidtwco
Apply adjustments for field expression even if inaccessible The adjustments are used later by ExprUseVisitor to build Place projections and without adjustments it can produce invalid result. Fix #90483 ``@rustbot`` label: T-compiler
This commit is contained in:
commit
4c49db35fc
3 changed files with 34 additions and 3 deletions
|
|
@ -0,0 +1,14 @@
|
|||
// edition:2021
|
||||
|
||||
mod m {
|
||||
pub struct S { foo: i32 }
|
||||
impl S {
|
||||
pub fn foo(&self) -> i32 { 42 }
|
||||
}
|
||||
}
|
||||
|
||||
fn bar(s: &m::S) {
|
||||
|| s.foo() + s.foo; //~ ERROR E0616
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
error[E0616]: field `foo` of struct `S` is private
|
||||
--> $DIR/issue-90483-inaccessible-field-adjustment.rs:11:18
|
||||
|
|
||||
LL | || s.foo() + s.foo;
|
||||
| ^^^ private field
|
||||
|
|
||||
help: a method `foo` also exists, call it with parentheses
|
||||
|
|
||||
LL | || s.foo() + s.foo();
|
||||
| ++
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0616`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue