-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggest assoc fn
new
when trying to build tuple struct with private…
… fields Fix #22488.
- Loading branch information
Showing
4 changed files
with
72 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// run-rustfix | ||
#![allow(dead_code)] | ||
struct U <T> { | ||
wtf: Option<Box<U<T>>>, | ||
x: T, | ||
} | ||
fn main() { | ||
U { | ||
wtf: Some(Box::new(U { //~ ERROR cannot initialize a tuple struct which contains private fields | ||
wtf: None, | ||
x: (), | ||
})), | ||
x: () | ||
}; | ||
} | ||
|
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,16 @@ | ||
// run-rustfix | ||
#![allow(dead_code)] | ||
struct U <T> { | ||
wtf: Option<Box<U<T>>>, | ||
x: T, | ||
} | ||
fn main() { | ||
U { | ||
wtf: Some(Box(U { //~ ERROR cannot initialize a tuple struct which contains private fields | ||
wtf: None, | ||
x: (), | ||
})), | ||
x: () | ||
}; | ||
} | ||
|
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,20 @@ | ||
error[E0423]: cannot initialize a tuple struct which contains private fields | ||
--> $DIR/suggest-box-new.rs:9:19 | ||
| | ||
LL | wtf: Some(Box(U { | ||
| ^^^ | ||
| | ||
note: constructor is not visible here due to private fields | ||
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL | ||
| | ||
= note: private field | ||
| | ||
= note: private field | ||
help: you might have meant to use the `new` associated function | ||
| | ||
LL | wtf: Some(Box::new(U { | ||
| +++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0423`. |