diff options
| -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 |
