Warn users about || in let chain expressions
This commit is contained in:
parent
10dccdc7fc
commit
915f9a599c
3 changed files with 179 additions and 96 deletions
|
@ -64,8 +64,8 @@ struct AstValidator<'a> {
|
|||
/// certain positions.
|
||||
is_assoc_ty_bound_banned: bool,
|
||||
|
||||
/// Used to allow `let` expressions in certain syntactic locations.
|
||||
is_let_allowed: bool,
|
||||
/// See [ForbiddenLetReason]
|
||||
forbidden_let_reason: Option<ForbiddenLetReason>,
|
||||
|
||||
lint_buffer: &'a mut LintBuffer,
|
||||
}
|
||||
|
@ -103,20 +103,28 @@ impl<'a> AstValidator<'a> {
|
|||
self.is_tilde_const_allowed = old;
|
||||
}
|
||||
|
||||
fn with_let_allowed(&mut self, allowed: bool, f: impl FnOnce(&mut Self, bool)) {
|
||||
let old = mem::replace(&mut self.is_let_allowed, allowed);
|
||||
fn with_let_management(
|
||||
&mut self,
|
||||
forbidden_let_reason: Option<ForbiddenLetReason>,
|
||||
f: impl FnOnce(&mut Self, Option<ForbiddenLetReason>),
|
||||
) {
|
||||
let old = mem::replace(&mut self.forbidden_let_reason, forbidden_let_reason);
|
||||
f(self, old);
|
||||
self.is_let_allowed = old;
|
||||
self.forbidden_let_reason = old;
|
||||
}
|
||||
|
||||
/// Emits an error banning the `let` expression provided in the given location.
|
||||
fn ban_let_expr(&self, expr: &'a Expr) {
|
||||
fn ban_let_expr(&self, expr: &'a Expr, forbidden_let_reason: ForbiddenLetReason) {
|
||||
let sess = &self.session;
|
||||
if sess.opts.unstable_features.is_nightly_build() {
|
||||
sess.struct_span_err(expr.span, "`let` expressions are not supported here")
|
||||
.note("only supported directly in conditions of `if`- and `while`-expressions")
|
||||
.note("as well as when nested within `&&` and parentheses in those conditions")
|
||||
.emit();
|
||||
let err = "`let` expressions are not supported here";
|
||||
let mut diag = sess.struct_span_err(expr.span, err);
|
||||
diag.note("only supported directly in conditions of `if` and `while` expressions");
|
||||
diag.note("as well as when nested within `&&` and parentheses in those conditions");
|
||||
if let ForbiddenLetReason::ForbiddenWithOr(span) = forbidden_let_reason {
|
||||
diag.span_note(span, "`||` operators are not allowed in let chain expressions");
|
||||
}
|
||||
diag.emit();
|
||||
} else {
|
||||
sess.struct_span_err(expr.span, "expected expression, found statement (`let`)")
|
||||
.note("variable declaration using `let` is a statement")
|
||||
|
@ -988,39 +996,48 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
|
|||
}
|
||||
|
||||
fn visit_expr(&mut self, expr: &'a Expr) {
|
||||
self.with_let_allowed(false, |this, let_allowed| match &expr.kind {
|
||||
self.with_let_management(Some(ForbiddenLetReason::GenericForbidden), |this, forbidden_let_reason| {
|
||||
match &expr.kind {
|
||||
ExprKind::Binary(Spanned { node: BinOpKind::Or, span }, lhs, rhs) => {
|
||||
let forbidden_let_reason = Some(ForbiddenLetReason::ForbiddenWithOr(*span));
|
||||
this.with_let_management(forbidden_let_reason, |this, _| this.visit_expr(lhs));
|
||||
this.with_let_management(forbidden_let_reason, |this, _| this.visit_expr(rhs));
|
||||
}
|
||||
ExprKind::If(cond, then, opt_else) => {
|
||||
this.visit_block(then);
|
||||
walk_list!(this, visit_expr, opt_else);
|
||||
this.with_let_allowed(true, |this, _| this.visit_expr(cond));
|
||||
this.with_let_management(None, |this, _| this.visit_expr(cond));
|
||||
return;
|
||||
}
|
||||
ExprKind::Let(..) if !let_allowed => this.ban_let_expr(expr),
|
||||
ExprKind::Match(expr, arms) => {
|
||||
this.visit_expr(expr);
|
||||
ExprKind::Let(..) if let Some(elem) = forbidden_let_reason => {
|
||||
this.ban_let_expr(expr, elem);
|
||||
},
|
||||
ExprKind::Match(scrutinee, arms) => {
|
||||
this.visit_expr(scrutinee);
|
||||
for arm in arms {
|
||||
this.visit_expr(&arm.body);
|
||||
this.visit_pat(&arm.pat);
|
||||
walk_list!(this, visit_attribute, &arm.attrs);
|
||||
if let Some(ref guard) = arm.guard {
|
||||
if let ExprKind::Let(_, ref expr, _) = guard.kind {
|
||||
this.with_let_allowed(true, |this, _| this.visit_expr(expr));
|
||||
if let Some(guard) = &arm.guard && let ExprKind::Let(_, guard_expr, _) = &guard.kind {
|
||||
this.with_let_management(None, |this, _| {
|
||||
this.visit_expr(guard_expr)
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ExprKind::Paren(_) | ExprKind::Binary(Spanned { node: BinOpKind::And, .. }, ..) => {
|
||||
this.with_let_allowed(let_allowed, |this, _| visit::walk_expr(this, expr));
|
||||
this.with_let_management(forbidden_let_reason, |this, _| visit::walk_expr(this, expr));
|
||||
return;
|
||||
}
|
||||
ExprKind::While(cond, then, opt_label) => {
|
||||
walk_list!(this, visit_label, opt_label);
|
||||
this.visit_block(then);
|
||||
this.with_let_allowed(true, |this, _| this.visit_expr(cond));
|
||||
this.with_let_management(None, |this, _| this.visit_expr(cond));
|
||||
return;
|
||||
}
|
||||
_ => visit::walk_expr(this, expr),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1772,10 +1789,19 @@ pub fn check_crate(session: &Session, krate: &Crate, lints: &mut LintBuffer) ->
|
|||
is_tilde_const_allowed: false,
|
||||
is_impl_trait_banned: false,
|
||||
is_assoc_ty_bound_banned: false,
|
||||
is_let_allowed: false,
|
||||
forbidden_let_reason: Some(ForbiddenLetReason::GenericForbidden),
|
||||
lint_buffer: lints,
|
||||
};
|
||||
visit::walk_crate(&mut validator, krate);
|
||||
|
||||
validator.has_proc_macro_decls
|
||||
}
|
||||
|
||||
/// Used to forbid `let` expressions in certain syntactic locations.
|
||||
#[derive(Clone, Copy)]
|
||||
enum ForbiddenLetReason {
|
||||
/// A let chain with the `||` operator
|
||||
ForbiddenWithOr(Span),
|
||||
/// `let` is not valid and the source environment is not important
|
||||
GenericForbidden,
|
||||
}
|
||||
|
|
|
@ -4,11 +4,13 @@
|
|||
//!
|
||||
//! The crate also contains other misc AST visitors, e.g. `node_count` and `show_span`.
|
||||
|
||||
#![feature(iter_is_partitioned)]
|
||||
#![allow(rustc::potential_query_instability)]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(if_let_guard)]
|
||||
#![feature(iter_is_partitioned)]
|
||||
#![feature(let_chains)]
|
||||
#![feature(let_else)]
|
||||
#![recursion_limit = "256"]
|
||||
#![allow(rustc::potential_query_instability)]
|
||||
|
||||
pub mod ast_validation;
|
||||
pub mod feature_gate;
|
||||
|
|
|
@ -15,7 +15,7 @@ error: `let` expressions are not supported here
|
|||
LL | if &let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -24,7 +24,7 @@ error: `let` expressions are not supported here
|
|||
LL | if !let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -33,7 +33,7 @@ error: `let` expressions are not supported here
|
|||
LL | if *let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -42,7 +42,7 @@ error: `let` expressions are not supported here
|
|||
LL | if -let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -51,7 +51,7 @@ error: `let` expressions are not supported here
|
|||
LL | if (let 0 = 0)? {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -60,8 +60,13 @@ error: `let` expressions are not supported here
|
|||
LL | if true || let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
note: `||` operators are not allowed in let chain expressions
|
||||
--> $DIR/disallowed-positions.rs:47:13
|
||||
|
|
||||
LL | if true || let 0 = 0 {}
|
||||
| ^^
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
--> $DIR/disallowed-positions.rs:48:17
|
||||
|
@ -69,8 +74,13 @@ error: `let` expressions are not supported here
|
|||
LL | if (true || let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
note: `||` operators are not allowed in let chain expressions
|
||||
--> $DIR/disallowed-positions.rs:48:14
|
||||
|
|
||||
LL | if (true || let 0 = 0) {}
|
||||
| ^^
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
--> $DIR/disallowed-positions.rs:49:25
|
||||
|
@ -78,8 +88,13 @@ error: `let` expressions are not supported here
|
|||
LL | if true && (true || let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
note: `||` operators are not allowed in let chain expressions
|
||||
--> $DIR/disallowed-positions.rs:49:22
|
||||
|
|
||||
LL | if true && (true || let 0 = 0) {}
|
||||
| ^^
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
--> $DIR/disallowed-positions.rs:50:25
|
||||
|
@ -87,8 +102,13 @@ error: `let` expressions are not supported here
|
|||
LL | if true || (true && let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
note: `||` operators are not allowed in let chain expressions
|
||||
--> $DIR/disallowed-positions.rs:50:13
|
||||
|
|
||||
LL | if true || (true && let 0 = 0) {}
|
||||
| ^^
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
--> $DIR/disallowed-positions.rs:53:12
|
||||
|
@ -96,7 +116,7 @@ error: `let` expressions are not supported here
|
|||
LL | if x = let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -105,7 +125,7 @@ error: `let` expressions are not supported here
|
|||
LL | if true..(let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -114,7 +134,7 @@ error: `let` expressions are not supported here
|
|||
LL | if ..(let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -123,7 +143,7 @@ error: `let` expressions are not supported here
|
|||
LL | if (let 0 = 0).. {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -132,7 +152,7 @@ error: `let` expressions are not supported here
|
|||
LL | if let Range { start: _, end: _ } = true..true && false {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -141,7 +161,7 @@ error: `let` expressions are not supported here
|
|||
LL | if let Range { start: _, end: _ } = true..true || false {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -150,7 +170,7 @@ error: `let` expressions are not supported here
|
|||
LL | if let Range { start: F, end } = F..|| true {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -159,7 +179,7 @@ error: `let` expressions are not supported here
|
|||
LL | if let Range { start: true, end } = t..&&false {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -168,7 +188,7 @@ error: `let` expressions are not supported here
|
|||
LL | if let true = let true = true {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -177,7 +197,7 @@ error: `let` expressions are not supported here
|
|||
LL | while &let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -186,7 +206,7 @@ error: `let` expressions are not supported here
|
|||
LL | while !let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -195,7 +215,7 @@ error: `let` expressions are not supported here
|
|||
LL | while *let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -204,7 +224,7 @@ error: `let` expressions are not supported here
|
|||
LL | while -let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -213,7 +233,7 @@ error: `let` expressions are not supported here
|
|||
LL | while (let 0 = 0)? {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -222,8 +242,13 @@ error: `let` expressions are not supported here
|
|||
LL | while true || let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
note: `||` operators are not allowed in let chain expressions
|
||||
--> $DIR/disallowed-positions.rs:111:16
|
||||
|
|
||||
LL | while true || let 0 = 0 {}
|
||||
| ^^
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
--> $DIR/disallowed-positions.rs:112:20
|
||||
|
@ -231,8 +256,13 @@ error: `let` expressions are not supported here
|
|||
LL | while (true || let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
note: `||` operators are not allowed in let chain expressions
|
||||
--> $DIR/disallowed-positions.rs:112:17
|
||||
|
|
||||
LL | while (true || let 0 = 0) {}
|
||||
| ^^
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
--> $DIR/disallowed-positions.rs:113:28
|
||||
|
@ -240,8 +270,13 @@ error: `let` expressions are not supported here
|
|||
LL | while true && (true || let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
note: `||` operators are not allowed in let chain expressions
|
||||
--> $DIR/disallowed-positions.rs:113:25
|
||||
|
|
||||
LL | while true && (true || let 0 = 0) {}
|
||||
| ^^
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
--> $DIR/disallowed-positions.rs:114:28
|
||||
|
@ -249,8 +284,13 @@ error: `let` expressions are not supported here
|
|||
LL | while true || (true && let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
note: `||` operators are not allowed in let chain expressions
|
||||
--> $DIR/disallowed-positions.rs:114:16
|
||||
|
|
||||
LL | while true || (true && let 0 = 0) {}
|
||||
| ^^
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
--> $DIR/disallowed-positions.rs:117:15
|
||||
|
@ -258,7 +298,7 @@ error: `let` expressions are not supported here
|
|||
LL | while x = let 0 = 0 {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -267,7 +307,7 @@ error: `let` expressions are not supported here
|
|||
LL | while true..(let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -276,7 +316,7 @@ error: `let` expressions are not supported here
|
|||
LL | while ..(let 0 = 0) {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -285,7 +325,7 @@ error: `let` expressions are not supported here
|
|||
LL | while (let 0 = 0).. {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -294,7 +334,7 @@ error: `let` expressions are not supported here
|
|||
LL | while let Range { start: _, end: _ } = true..true && false {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -303,7 +343,7 @@ error: `let` expressions are not supported here
|
|||
LL | while let Range { start: _, end: _ } = true..true || false {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -312,7 +352,7 @@ error: `let` expressions are not supported here
|
|||
LL | while let Range { start: F, end } = F..|| true {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -321,7 +361,7 @@ error: `let` expressions are not supported here
|
|||
LL | while let Range { start: true, end } = t..&&false {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -330,7 +370,7 @@ error: `let` expressions are not supported here
|
|||
LL | while let true = let true = true {}
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -339,7 +379,7 @@ error: `let` expressions are not supported here
|
|||
LL | &let 0 = 0;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -348,7 +388,7 @@ error: `let` expressions are not supported here
|
|||
LL | !let 0 = 0;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -357,7 +397,7 @@ error: `let` expressions are not supported here
|
|||
LL | *let 0 = 0;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -366,7 +406,7 @@ error: `let` expressions are not supported here
|
|||
LL | -let 0 = 0;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -375,7 +415,7 @@ error: `let` expressions are not supported here
|
|||
LL | (let 0 = 0)?;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -384,8 +424,13 @@ error: `let` expressions are not supported here
|
|||
LL | true || let 0 = 0;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
note: `||` operators are not allowed in let chain expressions
|
||||
--> $DIR/disallowed-positions.rs:184:10
|
||||
|
|
||||
LL | true || let 0 = 0;
|
||||
| ^^
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
--> $DIR/disallowed-positions.rs:185:14
|
||||
|
@ -393,8 +438,13 @@ error: `let` expressions are not supported here
|
|||
LL | (true || let 0 = 0);
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
note: `||` operators are not allowed in let chain expressions
|
||||
--> $DIR/disallowed-positions.rs:185:11
|
||||
|
|
||||
LL | (true || let 0 = 0);
|
||||
| ^^
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
--> $DIR/disallowed-positions.rs:186:22
|
||||
|
@ -402,8 +452,13 @@ error: `let` expressions are not supported here
|
|||
LL | true && (true || let 0 = 0);
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
note: `||` operators are not allowed in let chain expressions
|
||||
--> $DIR/disallowed-positions.rs:186:19
|
||||
|
|
||||
LL | true && (true || let 0 = 0);
|
||||
| ^^
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
--> $DIR/disallowed-positions.rs:189:9
|
||||
|
@ -411,7 +466,7 @@ error: `let` expressions are not supported here
|
|||
LL | x = let 0 = 0;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -420,7 +475,7 @@ error: `let` expressions are not supported here
|
|||
LL | true..(let 0 = 0);
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -429,7 +484,7 @@ error: `let` expressions are not supported here
|
|||
LL | ..(let 0 = 0);
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -438,7 +493,7 @@ error: `let` expressions are not supported here
|
|||
LL | (let 0 = 0)..;
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -447,7 +502,7 @@ error: `let` expressions are not supported here
|
|||
LL | (let Range { start: _, end: _ } = true..true || false);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -456,7 +511,7 @@ error: `let` expressions are not supported here
|
|||
LL | (let true = let true = true);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -465,7 +520,7 @@ error: `let` expressions are not supported here
|
|||
LL | &let 0 = 0
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -474,7 +529,7 @@ error: `let` expressions are not supported here
|
|||
LL | true && let 1 = 1
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -483,7 +538,7 @@ error: `let` expressions are not supported here
|
|||
LL | true && let 1 = 1
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -492,7 +547,7 @@ error: `let` expressions are not supported here
|
|||
LL | true && let 1 = 1
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error: `let` expressions are not supported here
|
||||
|
@ -501,7 +556,7 @@ error: `let` expressions are not supported here
|
|||
LL | true && let 1 = 1
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: only supported directly in conditions of `if`- and `while`-expressions
|
||||
= note: only supported directly in conditions of `if` and `while` expressions
|
||||
= note: as well as when nested within `&&` and parentheses in those conditions
|
||||
|
||||
error[E0308]: mismatched types
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue