Better account for associated const found for fn call expr

This commit is contained in:
Esteban Küber 2024-02-13 22:28:46 +00:00
parent 76885673d6
commit 14277ef201
2 changed files with 13 additions and 9 deletions

View File

@ -1421,7 +1421,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
),
);
}
} else if let Mode::Path = mode {
} else if let Mode::Path = mode
&& args.unwrap_or(&[]).is_empty()
{
// We have an associated item syntax and we found something that isn't an fn.
err.span_suggestion_verbose(
span,

View File

@ -58,14 +58,15 @@ LL | S::a(&S);
| ^ function or associated item not found in `S`
|
= help: items from traits can only be used if the trait is implemented and in scope
help: there is an associated constant `B` with a similar name
--> $DIR/item-privacy.rs:29:9
|
LL | const B: u8 = 0;
| ^^^^^^^^^^^
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL + use method::A;
|
help: there is an associated constant with a similar name
|
LL | S::B(&S);
| ~
error[E0599]: no function or associated item named `b` found for struct `S` in the current scope
--> $DIR/item-privacy.rs:80:8
@ -77,14 +78,15 @@ LL | S::b(&S);
| ^ function or associated item not found in `S`
|
= help: items from traits can only be used if the trait is in scope
help: there is an associated constant `B` with a similar name
--> $DIR/item-privacy.rs:29:9
|
LL | const B: u8 = 0;
| ^^^^^^^^^^^
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
|
LL + use method::B;
|
help: there is an associated constant with a similar name
|
LL | S::B(&S);
| ~
error[E0624]: method `a` is private
--> $DIR/item-privacy.rs:84:14