about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2023-10-26 19:56:46 +0000
committerEsteban Küber <esteban@kuber.com.ar>2023-10-27 16:24:01 +0000
commit7449478c2f6fd2d72c12a51d8562f1e6108facab (patch)
tree78485fd244aed1a2752a849e370ed42d9be4b469 /tests/ui
parent3bbc70a5f72a8e54e50d981c01d748d3d9087b5d (diff)
downloadrust-7449478c2f6fd2d72c12a51d8562f1e6108facab.tar.gz
rust-7449478c2f6fd2d72c12a51d8562f1e6108facab.zip
Account for type param from other item in `note_and_explain`
Fix #89868.
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/malformed/do-not-ice-on-note_and_explain.rs7
-rw-r--r--tests/ui/malformed/do-not-ice-on-note_and_explain.stderr79
2 files changed, 86 insertions, 0 deletions
diff --git a/tests/ui/malformed/do-not-ice-on-note_and_explain.rs b/tests/ui/malformed/do-not-ice-on-note_and_explain.rs
new file mode 100644
index 00000000000..e65276fb738
--- /dev/null
+++ b/tests/ui/malformed/do-not-ice-on-note_and_explain.rs
@@ -0,0 +1,7 @@
+struct A<B>(B);
+impl<B>A<B>{fn d(){fn d(){Self(1)}}}
+//~^ ERROR the size for values of type `B` cannot be known at compilation time
+//~| ERROR the size for values of type `B` cannot be known at compilation time
+//~| ERROR mismatched types
+//~| ERROR mismatched types
+//~| ERROR `main` function not found in crate
diff --git a/tests/ui/malformed/do-not-ice-on-note_and_explain.stderr b/tests/ui/malformed/do-not-ice-on-note_and_explain.stderr
new file mode 100644
index 00000000000..27b86145e90
--- /dev/null
+++ b/tests/ui/malformed/do-not-ice-on-note_and_explain.stderr
@@ -0,0 +1,79 @@
+error[E0601]: `main` function not found in crate `do_not_ice_on_note_and_explain`
+  --> $DIR/do-not-ice-on-note_and_explain.rs:2:37
+   |
+LL | impl<B>A<B>{fn d(){fn d(){Self(1)}}}
+   |                                     ^ consider adding a `main` function to `$DIR/do-not-ice-on-note_and_explain.rs`
+
+error[E0277]: the size for values of type `B` cannot be known at compilation time
+  --> $DIR/do-not-ice-on-note_and_explain.rs:2:32
+   |
+LL | impl<B>A<B>{fn d(){fn d(){Self(1)}}}
+   |      -                    ---- ^ doesn't have a size known at compile-time
+   |      |                    |
+   |      |                    required by a bound introduced by this call
+   |      this type parameter needs to be `Sized`
+   |
+note: required by a bound in `A`
+  --> $DIR/do-not-ice-on-note_and_explain.rs:1:10
+   |
+LL | struct A<B>(B);
+   |          ^ required by this bound in `A`
+
+error[E0308]: mismatched types
+  --> $DIR/do-not-ice-on-note_and_explain.rs:2:32
+   |
+LL | impl<B>A<B>{fn d(){fn d(){Self(1)}}}
+   |                           ---- ^ expected type parameter `B`, found integer
+   |                           |
+   |                           arguments to this function are incorrect
+   |
+   = note: expected type parameter `B`
+                        found type `{integer}`
+note: tuple struct defined here
+  --> $DIR/do-not-ice-on-note_and_explain.rs:1:8
+   |
+LL | struct A<B>(B);
+   |        ^
+
+error[E0308]: mismatched types
+  --> $DIR/do-not-ice-on-note_and_explain.rs:2:27
+   |
+LL | impl<B>A<B>{fn d(){fn d(){Self(1)}}}
+   |                           ^^^^^^^ expected `()`, found `A<B>`
+   |
+   = note: expected unit type `()`
+                 found struct `A<B>`
+help: consider using a semicolon here
+   |
+LL | impl<B>A<B>{fn d(){fn d(){Self(1);}}}
+   |                                  +
+help: try adding a return type
+   |
+LL | impl<B>A<B>{fn d(){fn d() -> A<B>{Self(1)}}}
+   |                           +++++++
+
+error[E0277]: the size for values of type `B` cannot be known at compilation time
+  --> $DIR/do-not-ice-on-note_and_explain.rs:2:27
+   |
+LL | impl<B>A<B>{fn d(){fn d(){Self(1)}}}
+   |      -                    ^^^^^^^ doesn't have a size known at compile-time
+   |      |
+   |      this type parameter needs to be `Sized`
+   |
+note: required by a bound in `A`
+  --> $DIR/do-not-ice-on-note_and_explain.rs:1:10
+   |
+LL | struct A<B>(B);
+   |          ^ required by this bound in `A`
+help: you could relax the implicit `Sized` bound on `B` if it were used through indirection like `&B` or `Box<B>`
+  --> $DIR/do-not-ice-on-note_and_explain.rs:1:10
+   |
+LL | struct A<B>(B);
+   |          ^  - ...if indirection were used here: `Box<B>`
+   |          |
+   |          this could be changed to `B: ?Sized`...
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0277, E0308, E0601.
+For more information about an error, try `rustc --explain E0277`.