forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#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 rust-lang#90483 `@rustbot` label: T-compiler
- Loading branch information
Showing
3 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/test/ui/typeck/issue-90483-inaccessible-field-adjustment.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
14 changes: 14 additions & 0 deletions
14
src/test/ui/typeck/issue-90483-inaccessible-field-adjustment.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |