File tree 3 files changed +14
-23
lines changed
rustc_error_messages/locales/en-US
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> {
121
121
fn ban_let_expr ( & self , expr : & ' a Expr , forbidden_let_reason : ForbiddenLetReason ) {
122
122
let sess = & self . session ;
123
123
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 } ) ;
144
125
} 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 } ) ;
148
127
}
149
128
}
150
129
Original file line number Diff line number Diff line change @@ -30,6 +30,14 @@ impl AddSubdiagnostic for ForbiddenLetReason {
30
30
}
31
31
}
32
32
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
+
33
41
#[ derive( SessionDiagnostic ) ]
34
42
#[ diag( ast_passes:: forbidden_assoc_constraint) ]
35
43
pub struct ForbiddenAssocConstraint {
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ ast_passes_forbidden_let =
4
4
.not_supported_or = `||` operators are not supported in let chain expressions
5
5
.not_supported_parentheses = `let`s wrapped in parentheses are not supported in a context with let chains
6
6
7
+ ast_passes_forbidden_let_stable =
8
+ expected expression, found statement (`let`)
9
+ .note = variable declaration using `let` is a statement
10
+
7
11
ast_passes_deprecated_where_clause_location =
8
12
where clause not allowed here
9
13
You can’t perform that action at this time.
0 commit comments