diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2024-02-13 22:28:46 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2024-02-22 18:04:55 +0000 |
| commit | 14277ef20128751ce6cc1c8ebd48f988c6607f21 (patch) | |
| tree | 35afefb175ef1da4d707aac086ba1fed5c6b4c45 | |
| parent | 76885673d64c5da4657a2059c80390f06d76a112 (diff) | |
| download | rust-14277ef20128751ce6cc1c8ebd48f988c6607f21.tar.gz rust-14277ef20128751ce6cc1c8ebd48f988c6607f21.zip | |
Better account for associated const found for fn call expr
| -rw-r--r-- | compiler/rustc_hir_typeck/src/method/suggest.rs | 4 | ||||
| -rw-r--r-- | tests/ui/traits/item-privacy.stderr | 18 |
2 files changed, 13 insertions, 9 deletions
diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index 202df8dcc12..56329123a8a 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -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, diff --git a/tests/ui/traits/item-privacy.stderr b/tests/ui/traits/item-privacy.stderr index ede1764efdc..a9469952976 100644 --- a/tests/ui/traits/item-privacy.stderr +++ b/tests/ui/traits/item-privacy.stderr @@ -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 |
