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#59267 - estebank:assoc-const-as-field, r=da…
…vidtwco Provide suggestion when using field access instead of path When trying to access an associated constant as if it were a field of an instance, provide a suggestion for the correct syntax. Fix rust-lang#57316.
- Loading branch information
Showing
4 changed files
with
66 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pub mod Mod { | ||
pub struct Foo {} | ||
impl Foo { | ||
pub const BAR: usize = 42; | ||
} | ||
} | ||
|
||
fn foo(_: usize) {} | ||
|
||
fn main() { | ||
foo(Mod::Foo.Bar); | ||
//~^ ERROR expected value, found | ||
} |
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,11 @@ | ||
error[E0423]: expected value, found struct `Mod::Foo` | ||
--> $DIR/assoc-const-as-field.rs:11:9 | ||
| | ||
LL | foo(Mod::Foo.Bar); | ||
| ^^^^^^^^---- | ||
| | | ||
| help: use the path separator to refer to an item: `Mod::Foo::Bar` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0423`. |