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
4 changes: 2 additions & 2 deletions compiler/rustc_parse/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_ast::{
LocalKind, MacCall, MacCallStmt, MacStmtStyle, Recovered, Stmt, StmtKind,
};
use rustc_errors::{Applicability, Diag, PResult};
use rustc_span::{BytePos, ErrorGuaranteed, Ident, Span, kw, sym};
use rustc_span::{ErrorGuaranteed, Ident, Span, kw, sym};
use thin_vec::{ThinVec, thin_vec};

use super::attr::InnerAttrForbiddenReason;
Expand Down Expand Up @@ -467,7 +467,7 @@ impl<'a> Parser<'a> {
),
};
self.dcx().emit_err(diagnostics::InvalidCurlyInLetElse {
span: span.with_lo(span.hi() - BytePos(1)),
span: self.psess.source_map().end_point(span),
sugg,
});
}
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/parser/let-else-fullwidth-brace.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#![allow(irrefutable_let_patterns)]

fn main() {
let x = {1} else { return; };
//~^ ERROR unknown start of token: \u{ff5d}
//~| ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
}
25 changes: 25 additions & 0 deletions tests/ui/parser/let-else-fullwidth-brace.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
error: unknown start of token: \u{ff5d}
--> $DIR/let-else-fullwidth-brace.rs:4:15
|
LL | let x = {1} else { return; };
| ^^
|
help: Unicode character '}' (Fullwidth Right Curly Bracket) looks like '}' (Right Curly Brace), but it is not
|
LL - let x = {1} else { return; };
LL + let x = {1} else { return; };
|

error: right curly brace `}` before `else` in a `let...else` statement not allowed
--> $DIR/let-else-fullwidth-brace.rs:4:15
|
LL | let x = {1} else { return; };
| ^^
|
help: wrap the expression in parentheses
|
LL | let x = ({1}) else { return; };
| + +

error: aborting due to 2 previous errors

Loading