File tree Expand file tree Collapse file tree 3 files changed +14
-23
lines changed
rustc_error_messages/locales/en-US Expand file tree Collapse file tree 3 files changed +14
-23
lines changed Original file line number Diff line number Diff line change @@ -121,30 +121,9 @@ impl<'a> AstValidator<'a> {
121121 fn ban_let_expr ( & self , expr : & ' a Expr , forbidden_let_reason : ForbiddenLetReason ) {
122122 let sess = & self . session ;
123123 if sess. opts . unstable_features . is_nightly_build ( ) {
124- let err = "`let` expressions are not supported here" ;
125- let mut diag = sess. struct_span_err ( expr. span , err) ;
126- diag. note ( "only supported directly in conditions of `if` and `while` expressions" ) ;
127- match forbidden_let_reason {
128- ForbiddenLetReason :: GenericForbidden => { }
129- ForbiddenLetReason :: NotSupportedOr ( span) => {
130- diag. span_note (
131- span,
132- "`||` operators are not supported in let chain expressions" ,
133- ) ;
134- }
135- ForbiddenLetReason :: NotSupportedParentheses ( span) => {
136- diag. span_note (
137- span,
138- "`let`s wrapped in parentheses are not supported in a context with let \
139- chains",
140- ) ;
141- }
142- }
143- diag. emit ( ) ;
124+ sess. emit_err ( ForbiddenLet { span : expr. span , reason : forbidden_let_reason } ) ;
144125 } else {
145- sess. struct_span_err ( expr. span , "expected expression, found statement (`let`)" )
146- . note ( "variable declaration using `let` is a statement" )
147- . emit ( ) ;
126+ sess. emit_err ( ForbiddenLetStable { span : expr. span } ) ;
148127 }
149128 }
150129
Original file line number Diff line number Diff line change @@ -30,6 +30,14 @@ impl AddSubdiagnostic for ForbiddenLetReason {
3030 }
3131}
3232
33+ #[ derive( SessionDiagnostic ) ]
34+ #[ diag( ast_passes:: forbidden_let_stable) ]
35+ #[ note]
36+ pub struct ForbiddenLetStable {
37+ #[ primary_span]
38+ pub span : Span ,
39+ }
40+
3341#[ derive( SessionDiagnostic ) ]
3442#[ diag( ast_passes:: forbidden_assoc_constraint) ]
3543pub struct ForbiddenAssocConstraint {
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ ast_passes_forbidden_let =
44 .not_supported_or = `||` operators are not supported in let chain expressions
55 .not_supported_parentheses = `let`s wrapped in parentheses are not supported in a context with let chains
66
7+ ast_passes_forbidden_let_stable =
8+ expected expression, found statement (`let`)
9+ .note = variable declaration using `let` is a statement
10+
711ast_passes_deprecated_where_clause_location =
812 where clause not allowed here
913
You can’t perform that action at this time.
0 commit comments