forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#98283 - TaKO8Ki:point-at-private-fields-in-…
…struct-literal, r=compiler-errors Point at private fields in struct literal closes rust-lang#95872
- Loading branch information
Showing
10 changed files
with
107 additions
and
19 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
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
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
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
error: cannot construct `Foo` with struct literal syntax due to inaccessible fields | ||
error: cannot construct `Foo` with struct literal syntax due to private fields | ||
--> $DIR/issue-76077.rs:8:5 | ||
| | ||
LL | foo::Foo {}; | ||
| ^^^^^^^^ | ||
| | ||
= note: ... and other private field `you_cant_use_this_field` that was not provided | ||
|
||
error: aborting due to previous error | ||
|
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
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
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
4 changes: 3 additions & 1 deletion
4
src/test/ui/typeck/issue-87872-missing-inaccessible-field-literal.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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
error: cannot construct `Foo` with struct literal syntax due to inaccessible fields | ||
error: cannot construct `Foo` with struct literal syntax due to private fields | ||
--> $DIR/issue-87872-missing-inaccessible-field-literal.rs:9:5 | ||
| | ||
LL | foo::Foo {}; | ||
| ^^^^^^^^ | ||
| | ||
= note: ... and other private field `you_cant_use_this_field` that was not provided | ||
|
||
error: aborting due to previous error | ||
|
18 changes: 18 additions & 0 deletions
18
src/test/ui/typeck/missing-private-fields-in-struct-literal.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,18 @@ | ||
pub mod m { | ||
pub struct S { | ||
pub visible: bool, | ||
a: (), | ||
b: (), | ||
c: (), | ||
d: (), | ||
e: (), | ||
} | ||
} | ||
|
||
fn main() { | ||
let _ = m::S { //~ ERROR cannot construct `S` with struct literal syntax due to private fields | ||
visible: true, | ||
a: (), | ||
b: (), | ||
}; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/ui/typeck/missing-private-fields-in-struct-literal.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,15 @@ | ||
error: cannot construct `S` with struct literal syntax due to private fields | ||
--> $DIR/missing-private-fields-in-struct-literal.rs:13:13 | ||
| | ||
LL | let _ = m::S { | ||
| ^^^^ | ||
LL | visible: true, | ||
LL | a: (), | ||
| ----- private field | ||
LL | b: (), | ||
| ----- private field | ||
| | ||
= note: ... and other private fields `c`, `d` and `e` that were not provided | ||
|
||
error: aborting due to previous error | ||
|