Rollup merge of #112529 - jieyouxu:block-expr-unused-must-use, r=oli-obk
Extend `unused_must_use` to cover block exprs Given code like ```rust #[must_use] fn foo() -> i32 { 42 } fn warns() { { foo(); } } fn does_not_warn() { { foo() }; } fn main() { warns(); does_not_warn(); } ``` ### Before This PR ``` warning: unused return value of `foo` that must be used --> test.rs:8:9 | 8 | foo(); | ^^^^^ | = note: `#[warn(unused_must_use)]` on by default help: use `let _ = ...` to ignore the resulting value | 8 | let _ = foo(); | +++++++ warning: 1 warning emitted ``` ### After This PR ``` warning: unused return value of `foo` that must be used --> test.rs:8:9 | 8 | foo(); | ^^^^^ | = note: `#[warn(unused_must_use)]` on by default help: use `let _ = ...` to ignore the resulting value | 8 | let _ = foo(); | +++++++ warning: unused return value of `foo` that must be used --> test.rs:14:9 | 14 | foo() | ^^^^^ | help: use `let _ = ...` to ignore the resulting value | 14 | let _ = foo(); | +++++++ + warning: 2 warnings emitted ``` Fixes #104253.
This commit is contained in:
commit
d233522418
19 changed files with 289 additions and 65 deletions
|
@ -308,7 +308,7 @@ mod prim_never {}
|
|||
///
|
||||
/// ```no_run
|
||||
/// // Undefined behaviour
|
||||
/// unsafe { char::from_u32_unchecked(0x110000) };
|
||||
/// let _ = unsafe { char::from_u32_unchecked(0x110000) };
|
||||
/// ```
|
||||
///
|
||||
/// USVs are also the exact set of values that may be encoded in UTF-8. Because
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue