about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorCameron Steffen <cam.steffen94@gmail.com>2022-11-09 10:05:38 -0600
committerCameron Steffen <cam.steffen94@gmail.com>2022-11-09 10:19:23 -0600
commit76cab67ed87a23df318c43ab84ae9f87fdf203de (patch)
tree3e20bbb46cbc05634fcc90ff7de0013ca7bf4df6 /src
parent0aaad9e757207657064d70bf9e6c1e6eb327bf15 (diff)
downloadrust-76cab67ed87a23df318c43ab84ae9f87fdf203de.tar.gz
rust-76cab67ed87a23df318c43ab84ae9f87fdf203de.zip
Add domain size check to fix ICE
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/parser/issue-103748-ICE-wrong-braces.rs8
-rw-r--r--src/test/ui/parser/issue-103748-ICE-wrong-braces.stderr51
2 files changed, 59 insertions, 0 deletions
diff --git a/src/test/ui/parser/issue-103748-ICE-wrong-braces.rs b/src/test/ui/parser/issue-103748-ICE-wrong-braces.rs
new file mode 100644
index 00000000000..8012cb652bd
--- /dev/null
+++ b/src/test/ui/parser/issue-103748-ICE-wrong-braces.rs
@@ -0,0 +1,8 @@
+#![crate_type = "lib"]
+
+struct Apple((Apple, Option(Banana ? Citron)));
+//~^ ERROR invalid `?` in type
+//~| ERROR expected one of `)` or `,`, found `Citron`
+//~| ERROR cannot find type `Citron` in this scope [E0412]
+//~| ERROR parenthesized type parameters may only be used with a `Fn` trait [E0214]
+//~| ERROR recursive type `Apple` has infinite size [E0072]
diff --git a/src/test/ui/parser/issue-103748-ICE-wrong-braces.stderr b/src/test/ui/parser/issue-103748-ICE-wrong-braces.stderr
new file mode 100644
index 00000000000..b0d8b03ae08
--- /dev/null
+++ b/src/test/ui/parser/issue-103748-ICE-wrong-braces.stderr
@@ -0,0 +1,51 @@
+error: invalid `?` in type
+  --> $DIR/issue-103748-ICE-wrong-braces.rs:3:36
+   |
+LL | struct Apple((Apple, Option(Banana ? Citron)));
+   |                                    ^ `?` is only allowed on expressions, not types
+   |
+help: if you meant to express that the type might not contain a value, use the `Option` wrapper type
+   |
+LL | struct Apple((Apple, Option(Option<Banana > Citron)));
+   |                             +++++++       ~
+
+error: expected one of `)` or `,`, found `Citron`
+  --> $DIR/issue-103748-ICE-wrong-braces.rs:3:38
+   |
+LL | struct Apple((Apple, Option(Banana ? Citron)));
+   |                                     -^^^^^^ expected one of `)` or `,`
+   |                                     |
+   |                                     help: missing `,`
+
+error[E0412]: cannot find type `Citron` in this scope
+  --> $DIR/issue-103748-ICE-wrong-braces.rs:3:38
+   |
+LL | struct Apple((Apple, Option(Banana ? Citron)));
+   |                                      ^^^^^^ not found in this scope
+
+error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
+  --> $DIR/issue-103748-ICE-wrong-braces.rs:3:22
+   |
+LL | struct Apple((Apple, Option(Banana ? Citron)));
+   |                      ^^^^^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses
+   |
+help: use angle brackets instead
+   |
+LL | struct Apple((Apple, Option<Banana ? Citron>));
+   |                            ~               ~
+
+error[E0072]: recursive type `Apple` has infinite size
+  --> $DIR/issue-103748-ICE-wrong-braces.rs:3:1
+   |
+LL | struct Apple((Apple, Option(Banana ? Citron)));
+   | ^^^^^^^^^^^^  ----- recursive without indirection
+   |
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
+   |
+LL | struct Apple((Box<Apple>, Option(Banana ? Citron)));
+   |               ++++     +
+
+error: aborting due to 5 previous errors
+
+Some errors have detailed explanations: E0072, E0214, E0412.
+For more information about an error, try `rustc --explain E0072`.