mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-10 00:47:45 +00:00
Rollup merge of #137454 - mu001999-contrib:fix-137414, r=wesleywiser
not lint break with label and unsafe block fixes #137414 we can't label unsafe blocks, so that we can do not lint them
This commit is contained in:
commit
db98b72e34
@ -1884,13 +1884,15 @@ impl<'a> Parser<'a> {
|
|||||||
let mut expr = self.parse_expr_opt()?;
|
let mut expr = self.parse_expr_opt()?;
|
||||||
if let Some(expr) = &mut expr {
|
if let Some(expr) = &mut expr {
|
||||||
if label.is_some()
|
if label.is_some()
|
||||||
&& matches!(
|
&& match &expr.kind {
|
||||||
expr.kind,
|
|
||||||
ExprKind::While(_, _, None)
|
ExprKind::While(_, _, None)
|
||||||
| ExprKind::ForLoop { label: None, .. }
|
| ExprKind::ForLoop { label: None, .. }
|
||||||
| ExprKind::Loop(_, None, _)
|
| ExprKind::Loop(_, None, _) => true,
|
||||||
| ExprKind::Block(_, None)
|
ExprKind::Block(block, None) => {
|
||||||
)
|
matches!(block.rules, BlockCheckMode::Default)
|
||||||
|
}
|
||||||
|
_ => false,
|
||||||
|
}
|
||||||
{
|
{
|
||||||
self.psess.buffer_lint(
|
self.psess.buffer_lint(
|
||||||
BREAK_WITH_LABEL_AND_LOOP,
|
BREAK_WITH_LABEL_AND_LOOP,
|
||||||
|
11
tests/ui/lint/break-with-label-and-unsafe-block.rs
Normal file
11
tests/ui/lint/break-with-label-and-unsafe-block.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
#![deny(break_with_label_and_loop)]
|
||||||
|
|
||||||
|
unsafe fn foo() -> i32 { 42 }
|
||||||
|
|
||||||
|
fn main () {
|
||||||
|
'label: loop {
|
||||||
|
break 'label unsafe { foo() }
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user