Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/librustc_const_eval/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ fn foo(x: Empty) {
However, this won't:

```compile_fail
enum Empty {}

fn foo(x: Option<String>) {
match x {
// empty
Expand Down Expand Up @@ -191,7 +189,7 @@ inner `String` to be moved into a variable called `s`.
let x = Some("s".to_string());

match x {
op_string @ Some(s) => {},
op_string @ Some(s) => {}, // error: cannot bind by-move with sub-bindings
None => {},
}
```
Expand Down Expand Up @@ -288,7 +286,8 @@ struct X { x: (), }

let x = Some((X { x: () }, X { x: () }));
match x {
Some((y, ref z)) => {},
Some((y, ref z)) => {}, // error: cannot bind by-move and by-ref in the
// same pattern
None => panic!()
}
```
Expand Down Expand Up @@ -574,6 +573,12 @@ be a compile-time constant. Erroneous code example:
let x = [0i32; len]; // error: expected constant integer for repeat count,
// found variable
```

Working example:

```
let x = [0i32; 10];
```
"##,

}
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Matching with the wrong number of fields has no sensible interpretation:

```compile_fail
enum Fruit {
Apple(String, String),
Pear(u32),
Fruit::Apple(String, String),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not look right.

Fruit::Pear(u32),
}

let x = Fruit::Apple(String::new(), String::new());
Expand Down Expand Up @@ -77,8 +77,8 @@ enum Number {

// Assuming x is a Number we can pattern match on its contents.
match x {
Zero(inside) => {},
One(inside) => {},
Number::Zero(inside) => {},
Number::One(inside) => {},
}
```

Expand Down