about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-08-27 00:42:00 +0200
committerGitHub <noreply@github.com>2024-08-27 00:42:00 +0200
commitd4d4b6b4fa76f67d2577f4f659891ce263d91bd5 (patch)
tree4414f30c7589814303d2cb34ac1605f570a70197 /tests/ui
parent29923b68019a4547d41b36299b2cefe19303e902 (diff)
parent4a088d90708830ac6217554545badb89904f19b0 (diff)
downloadrust-d4d4b6b4fa76f67d2577f4f659891ce263d91bd5.tar.gz
rust-d4d4b6b4fa76f67d2577f4f659891ce263d91bd5.zip
Rollup merge of #129250 - estebank:issue-129205, r=compiler-errors
Do not ICE on non-ADT rcvr type when looking for crate version collision

When looking for multiple versions of the same crate, do not blindly construct the receiver type.

Follow up to #128786.
Fixes #129205
Fixes #129216
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/methods/missing-method-on-type-parameter.rs6
-rw-r--r--tests/ui/methods/missing-method-on-type-parameter.stderr19
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/methods/missing-method-on-type-parameter.rs b/tests/ui/methods/missing-method-on-type-parameter.rs
new file mode 100644
index 00000000000..cbcbeea4d4c
--- /dev/null
+++ b/tests/ui/methods/missing-method-on-type-parameter.rs
@@ -0,0 +1,6 @@
+// Regression test for https://github.com/rust-lang/rust/issues/129205
+fn x<T: Copy>() {
+    T::try_from(); //~ ERROR E0599
+}
+
+fn main() {}
diff --git a/tests/ui/methods/missing-method-on-type-parameter.stderr b/tests/ui/methods/missing-method-on-type-parameter.stderr
new file mode 100644
index 00000000000..c53d7afe4e2
--- /dev/null
+++ b/tests/ui/methods/missing-method-on-type-parameter.stderr
@@ -0,0 +1,19 @@
+error[E0599]: no function or associated item named `try_from` found for type parameter `T` in the current scope
+  --> $DIR/missing-method-on-type-parameter.rs:3:8
+   |
+LL | fn x<T: Copy>() {
+   |      - function or associated item `try_from` not found for this type parameter
+LL |     T::try_from();
+   |        ^^^^^^^^ function or associated item not found in `T`
+   |
+   = help: items from traits can only be used if the trait is in scope
+help: there is an associated function `from` with a similar name
+  --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
+help: trait `TryFrom` which provides `try_from` is implemented but not in scope; perhaps you want to import it
+   |
+LL + use std::convert::TryFrom;
+   |
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0599`.