about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-05-14 09:55:29 -0400
committerGitHub <noreply@github.com>2024-05-14 09:55:29 -0400
commit8c64acdbdcdc8f19d8f93bb976f39786bb8f45f6 (patch)
tree0a7ff8047bcc0079e48356e80f7c50fecd3baa77 /tests
parent844c7e826ec2259247f426fd3d8999472ea97b65 (diff)
parentade33b02f237d484bef950ebf550bc12d49313d1 (diff)
Rollup merge of #125080 - bvanjoi:fix-124946, r=nnethercote
only find segs chain for missing methods when no available candidates

Fixes #124946

This PR includes two changes:
- Extracting the lookup for the missing method in chains into a single function.
- Calling this function only when there are no candidates available.
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/const-generics/lookup-method.rs19
-rw-r--r--tests/ui/const-generics/lookup-method.stderr15
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/ui/const-generics/lookup-method.rs b/tests/ui/const-generics/lookup-method.rs
new file mode 100644
index 00000000000..915935c94a5
--- /dev/null
+++ b/tests/ui/const-generics/lookup-method.rs
@@ -0,0 +1,19 @@
+// https://github.com/rust-lang/rust/issues/124946
+
+struct Builder<const A: bool, const B: bool>;
+
+impl<const A: bool> Builder<A, false> {
+    fn cast(self) -> Builder<A, true> {
+        Builder
+    }
+}
+
+impl Builder<true, true> {
+    fn build(self) {}
+}
+
+fn main() {
+    let b = Builder::<false, false>;
+    b.cast().build();
+    //~^ ERROR: no method named `build` found for struct `Builder<false, true>` in the current scope
+}
diff --git a/tests/ui/const-generics/lookup-method.stderr b/tests/ui/const-generics/lookup-method.stderr
new file mode 100644
index 00000000000..4cbd1e17c7b
--- /dev/null
+++ b/tests/ui/const-generics/lookup-method.stderr
@@ -0,0 +1,15 @@
+error[E0599]: no method named `build` found for struct `Builder<false, true>` in the current scope
+  --> $DIR/lookup-method.rs:17:14
+   |
+LL | struct Builder<const A: bool, const B: bool>;
+   | -------------------------------------------- method `build` not found for this struct
+...
+LL |     b.cast().build();
+   |              ^^^^^ method not found in `Builder<false, true>`
+   |
+   = note: the method was found for
+           - `Builder<true, true>`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0599`.