forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#89293 - TaKO8Ki:fix-confusing-error-for-path-…
…separator-to-refer-to-an-struct-item, r=estebank Suggest using the path separator for tuple struct Fix confusing error message `constructor is not visible here due to private fields` for tuple struct closes rust-lang#83450
- Loading branch information
Showing
3 changed files
with
52 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,26 @@ | ||
mod module { | ||
pub struct SomeTupleStruct(u8); | ||
pub struct SomeRegularStruct { | ||
foo: u8 | ||
} | ||
|
||
impl SomeTupleStruct { | ||
pub fn new() -> Self { | ||
Self(0) | ||
} | ||
} | ||
impl SomeRegularStruct { | ||
pub fn new() -> Self { | ||
Self { foo: 0 } | ||
} | ||
} | ||
} | ||
|
||
use module::{SomeTupleStruct, SomeRegularStruct}; | ||
|
||
fn main() { | ||
let _ = SomeTupleStruct.new(); | ||
//~^ ERROR expected value, found struct `SomeTupleStruct` | ||
let _ = SomeRegularStruct.new(); | ||
//~^ ERROR expected value, found struct `SomeRegularStruct` | ||
} |
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,19 @@ | ||
error[E0423]: expected value, found struct `SomeTupleStruct` | ||
--> $DIR/suggest-path-for-tuple-struct.rs:22:13 | ||
| | ||
LL | let _ = SomeTupleStruct.new(); | ||
| ^^^^^^^^^^^^^^^---- | ||
| | | ||
| help: use the path separator to refer to an item: `SomeTupleStruct::new` | ||
|
||
error[E0423]: expected value, found struct `SomeRegularStruct` | ||
--> $DIR/suggest-path-for-tuple-struct.rs:24:13 | ||
| | ||
LL | let _ = SomeRegularStruct.new(); | ||
| ^^^^^^^^^^^^^^^^^---- | ||
| | | ||
| help: use the path separator to refer to an item: `SomeRegularStruct::new` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0423`. |