diff options
| author | bohan <bohan-zhang@foxmail.com> | 2024-05-13 22:57:44 +0800 |
|---|---|---|
| committer | bohan <bohan-zhang@foxmail.com> | 2024-05-14 20:28:55 +0800 |
| commit | ade33b02f237d484bef950ebf550bc12d49313d1 (patch) | |
| tree | 9efce51233d1db4aea41ca76db9ff614306fe0f8 /tests | |
| parent | 34582118afaf00b0eb2d209a90b181c7156b501c (diff) | |
| download | rust-ade33b02f237d484bef950ebf550bc12d49313d1.tar.gz rust-ade33b02f237d484bef950ebf550bc12d49313d1.zip | |
only find segs chain for missing methods when no available candidates
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/const-generics/lookup-method.rs | 19 | ||||
| -rw-r--r-- | tests/ui/const-generics/lookup-method.stderr | 15 |
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`. |
