diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2021-11-06 23:12:03 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-06 23:12:03 +0100 |
| commit | 4c49db35fc671a522dbe07bfbeda8c7e7897108c (patch) | |
| tree | 34b20baf5a11984124823ef681e2e856d79a7ea6 /src | |
| parent | de332b52afa45dc60d1fda2b8122241632f7ebb0 (diff) | |
| parent | f5560754591532d7cde4c9f5dd51dfbd7670e98f (diff) | |
| download | rust-4c49db35fc671a522dbe07bfbeda8c7e7897108c.tar.gz rust-4c49db35fc671a522dbe07bfbeda8c7e7897108c.zip | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/typeck/issue-90483-inaccessible-field-adjustment.rs | 14 | ||||
| -rw-r--r-- | src/test/ui/typeck/issue-90483-inaccessible-field-adjustment.stderr | 14 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/typeck/issue-90483-inaccessible-field-adjustment.rs b/src/test/ui/typeck/issue-90483-inaccessible-field-adjustment.rs new file mode 100644 index 00000000000..74e50d46e8d --- /dev/null +++ b/src/test/ui/typeck/issue-90483-inaccessible-field-adjustment.rs @@ -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() {} diff --git a/src/test/ui/typeck/issue-90483-inaccessible-field-adjustment.stderr b/src/test/ui/typeck/issue-90483-inaccessible-field-adjustment.stderr new file mode 100644 index 00000000000..02cdc102c15 --- /dev/null +++ b/src/test/ui/typeck/issue-90483-inaccessible-field-adjustment.stderr @@ -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`. |
