diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2023-10-21 01:18:41 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2023-11-07 00:54:10 +0000 |
| commit | f926031ea50ef58c1c8bfccd98da73d86d5fc937 (patch) | |
| tree | ecd76d25ae1eaa3df2418337f7d42f19a77cfe35 /tests/ui/resolve | |
| parent | b049093560aa1c69face8c1893bd8acd99fff275 (diff) | |
| download | rust-f926031ea50ef58c1c8bfccd98da73d86d5fc937.tar.gz rust-f926031ea50ef58c1c8bfccd98da73d86d5fc937.zip | |
When not finding assoc fn on type, look for builder fn
When we have a resolution error when looking at a fully qualified path on a type, look for all associated functions on inherent impls that return `Self` and mention them to the user. Fix #69512.
Diffstat (limited to 'tests/ui/resolve')
| -rw-r--r-- | tests/ui/resolve/fn-new-doesnt-exist.rs | 5 | ||||
| -rw-r--r-- | tests/ui/resolve/fn-new-doesnt-exist.stderr | 14 | ||||
| -rw-r--r-- | tests/ui/resolve/issue-82865.stderr | 7 |
3 files changed, 26 insertions, 0 deletions
diff --git a/tests/ui/resolve/fn-new-doesnt-exist.rs b/tests/ui/resolve/fn-new-doesnt-exist.rs new file mode 100644 index 00000000000..4f6290808fc --- /dev/null +++ b/tests/ui/resolve/fn-new-doesnt-exist.rs @@ -0,0 +1,5 @@ +use std::net::TcpStream; + +fn main() { + let stream = TcpStream::new(); //~ ERROR no function or associated item named `new` found +} diff --git a/tests/ui/resolve/fn-new-doesnt-exist.stderr b/tests/ui/resolve/fn-new-doesnt-exist.stderr new file mode 100644 index 00000000000..39adc0fde44 --- /dev/null +++ b/tests/ui/resolve/fn-new-doesnt-exist.stderr @@ -0,0 +1,14 @@ +error[E0599]: no function or associated item named `new` found for struct `TcpStream` in the current scope + --> $DIR/fn-new-doesnt-exist.rs:4:28 + | +LL | let stream = TcpStream::new(); + | ^^^ function or associated item not found in `TcpStream` + | +note: if you're trying to build a new `TcpStream` consider using one of the following associated functions: + TcpStream::connect + TcpStream::connect_timeout + --> $SRC_DIR/std/src/net/tcp.rs:LL:COL + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/resolve/issue-82865.stderr b/tests/ui/resolve/issue-82865.stderr index 730fd6d6026..9d0439d9d87 100644 --- a/tests/ui/resolve/issue-82865.stderr +++ b/tests/ui/resolve/issue-82865.stderr @@ -15,6 +15,13 @@ LL | Box::z LL | mac!(); | ------ in this macro invocation | +note: if you're trying to build a new `Box<_, _>` consider using one of the following associated functions: + Box::<T>::new + Box::<T>::new_uninit + Box::<T>::new_zeroed + Box::<T>::try_new + and 18 others + --> $SRC_DIR/alloc/src/boxed.rs:LL:COL = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors |
