-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #67866 - GuillaumeGomez:rollup-32vsg5b, r=GuillaumeGomez
Rollup of 4 pull requests Successful merges: - #67822 (Revert `const_err` lint checking of casts) - #67823 (improve some `Drop`-related error messages) - #67837 (Clean up err codes) - #67848 (Remove unused `#[link_name = "m"]` attributes) Failed merges: r? @ghost
- Loading branch information
Showing
23 changed files
with
204 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,44 @@ | ||
This error means that an attempt was made to match a struct type enum | ||
variant as a non-struct type: | ||
Something which is neither a tuple struct nor a tuple variant was used as a | ||
pattern. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0164 | ||
enum Foo { B { i: u32 } } | ||
enum A { | ||
B, | ||
C, | ||
} | ||
impl A { | ||
fn new() {} | ||
} | ||
fn bar(foo: Foo) -> u32 { | ||
fn bar(foo: A) { | ||
match foo { | ||
Foo::B(i) => i, // error E0164 | ||
A::new() => (), // error! | ||
_ => {} | ||
} | ||
} | ||
``` | ||
|
||
Try using `{}` instead: | ||
This error means that an attempt was made to match something which is neither a | ||
tuple struct nor a tuple variant. Only these two elements are allowed as a | ||
pattern: | ||
|
||
``` | ||
enum Foo { B { i: u32 } } | ||
enum A { | ||
B, | ||
C, | ||
} | ||
impl A { | ||
fn new() {} | ||
} | ||
fn bar(foo: Foo) -> u32 { | ||
fn bar(foo: A) { | ||
match foo { | ||
Foo::B{i} => i, | ||
A::B => (), // ok! | ||
_ => {} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
// build-fail | ||
// ignore-tidy-linelength | ||
// check-pass | ||
|
||
enum Foo { | ||
Bar = -42, | ||
Baz = 42, | ||
} | ||
|
||
fn main() { | ||
let _ = 0u8 as u32; | ||
let _ = (1u32 << 31) as u16; //~ ERROR truncating cast: the value 2147483648 requires 32 bits but the target type is only 16 bits | ||
let _ = (1u16 << 15) as u8; //~ ERROR truncating cast: the value 32768 requires 16 bits but the target type is only 8 bits | ||
let _ = (!0u16) as u8; //~ ERROR truncating cast: the value 65535 requires 16 bits but the target type is only 8 bits | ||
let _ = (1u32 << 31) as u16; | ||
let _ = (1u16 << 15) as u8; | ||
let _ = (!0u16) as u8; | ||
let _ = (-1i16) as i8; | ||
let _ = (Foo::Bar) as i8; | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.