simplify the suggestion notes
This commit is contained in:
parent
89682a5313
commit
b4b2b356d9
7 changed files with 205 additions and 385 deletions
|
@ -337,9 +337,7 @@ lint_identifier_uncommon_codepoints = identifier contains {$codepoints_len ->
|
||||||
lint_if_let_rescope = `if let` assigns a shorter lifetime since Edition 2024
|
lint_if_let_rescope = `if let` assigns a shorter lifetime since Edition 2024
|
||||||
.label = this value has a significant drop implementation which may observe a major change in drop order and requires your discretion
|
.label = this value has a significant drop implementation which may observe a major change in drop order and requires your discretion
|
||||||
.help = the value is now dropped here in Edition 2024
|
.help = the value is now dropped here in Edition 2024
|
||||||
|
.suggestion = a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
lint_if_let_rescope_suggestion = a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
.suggestion = rewrite this `if let` into `match`
|
|
||||||
|
|
||||||
lint_ignored_unless_crate_specified = {$level}({$name}) is ignored unless specified at crate level
|
lint_ignored_unless_crate_specified = {$level}({$name}) is ignored unless specified at crate level
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use rustc_errors::{
|
||||||
Applicability, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic, SuggestionStyle,
|
Applicability, Diag, EmissionGuarantee, SubdiagMessageOp, Subdiagnostic, SuggestionStyle,
|
||||||
};
|
};
|
||||||
use rustc_hir::{self as hir, HirIdSet};
|
use rustc_hir::{self as hir, HirIdSet};
|
||||||
use rustc_macros::{LintDiagnostic, Subdiagnostic};
|
use rustc_macros::LintDiagnostic;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_session::lint::{FutureIncompatibilityReason, Level};
|
use rustc_session::lint::{FutureIncompatibilityReason, Level};
|
||||||
use rustc_session::{declare_lint, impl_lint_pass};
|
use rustc_session::{declare_lint, impl_lint_pass};
|
||||||
|
@ -124,103 +124,109 @@ impl IfLetRescope {
|
||||||
let source_map = tcx.sess.source_map();
|
let source_map = tcx.sess.source_map();
|
||||||
let expr_end = expr.span.shrink_to_hi();
|
let expr_end = expr.span.shrink_to_hi();
|
||||||
let mut add_bracket_to_match_head = match_head_needs_bracket(tcx, expr);
|
let mut add_bracket_to_match_head = match_head_needs_bracket(tcx, expr);
|
||||||
|
let mut significant_droppers = vec![];
|
||||||
|
let mut lifetime_ends = vec![];
|
||||||
let mut closing_brackets = 0;
|
let mut closing_brackets = 0;
|
||||||
let mut alt_heads = vec![];
|
let mut alt_heads = vec![];
|
||||||
let mut match_heads = vec![];
|
let mut match_heads = vec![];
|
||||||
let mut consequent_heads = vec![];
|
let mut consequent_heads = vec![];
|
||||||
let mut first_if_to_rewrite = None;
|
let mut first_if_to_lint = None;
|
||||||
|
let mut first_if_to_rewrite = false;
|
||||||
let mut empty_alt = false;
|
let mut empty_alt = false;
|
||||||
while let hir::ExprKind::If(cond, conseq, alt) = expr.kind {
|
while let hir::ExprKind::If(cond, conseq, alt) = expr.kind {
|
||||||
self.skip.insert(expr.hir_id);
|
self.skip.insert(expr.hir_id);
|
||||||
let hir::ExprKind::Let(&hir::LetExpr {
|
// We are interested in `let` fragment of the condition.
|
||||||
|
// Otherwise, we probe into the `else` fragment.
|
||||||
|
if let hir::ExprKind::Let(&hir::LetExpr {
|
||||||
span,
|
span,
|
||||||
pat,
|
pat,
|
||||||
init,
|
init,
|
||||||
ty: ty_ascription,
|
ty: ty_ascription,
|
||||||
recovered: Recovered::No,
|
recovered: Recovered::No,
|
||||||
}) = cond.kind
|
}) = cond.kind
|
||||||
else {
|
|
||||||
if let Some(alt) = alt {
|
|
||||||
add_bracket_to_match_head = matches!(alt.kind, hir::ExprKind::If(..));
|
|
||||||
expr = alt;
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
// finalize and emit span
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let if_let_pat = expr.span.shrink_to_lo().between(init.span);
|
|
||||||
// the consequent fragment is always a block
|
|
||||||
let before_conseq = conseq.span.shrink_to_lo();
|
|
||||||
let lifetime_end = source_map.end_point(conseq.span);
|
|
||||||
|
|
||||||
if let ControlFlow::Break(significant_dropper) =
|
|
||||||
(FindSignificantDropper { cx }).visit_expr(init)
|
|
||||||
{
|
{
|
||||||
tcx.emit_node_span_lint(
|
let if_let_pat = expr.span.shrink_to_lo().between(init.span);
|
||||||
IF_LET_RESCOPE,
|
// The consequent fragment is always a block.
|
||||||
expr.hir_id,
|
let before_conseq = conseq.span.shrink_to_lo();
|
||||||
span,
|
let lifetime_end = source_map.end_point(conseq.span);
|
||||||
IfLetRescopeLint { significant_dropper, lifetime_end },
|
|
||||||
);
|
if let ControlFlow::Break(significant_dropper) =
|
||||||
if ty_ascription.is_some()
|
(FindSignificantDropper { cx }).visit_expr(init)
|
||||||
|| !expr.span.can_be_used_for_suggestions()
|
|
||||||
|| !pat.span.can_be_used_for_suggestions()
|
|
||||||
{
|
{
|
||||||
// Our `match` rewrites does not support type ascription,
|
first_if_to_lint = first_if_to_lint.or_else(|| Some((span, expr.hir_id)));
|
||||||
// so we just bail.
|
significant_droppers.push(significant_dropper);
|
||||||
// Alternatively when the span comes from proc macro expansion,
|
lifetime_ends.push(lifetime_end);
|
||||||
// we will also bail.
|
if ty_ascription.is_some()
|
||||||
// FIXME(#101728): change this when type ascription syntax is stabilized again
|
|| !expr.span.can_be_used_for_suggestions()
|
||||||
} else if let Ok(pat) = source_map.span_to_snippet(pat.span) {
|
|| !pat.span.can_be_used_for_suggestions()
|
||||||
let emit_suggestion = || {
|
{
|
||||||
first_if_to_rewrite =
|
// Our `match` rewrites does not support type ascription,
|
||||||
first_if_to_rewrite.or_else(|| Some((expr.span, expr.hir_id)));
|
// so we just bail.
|
||||||
if add_bracket_to_match_head {
|
// Alternatively when the span comes from proc macro expansion,
|
||||||
closing_brackets += 2;
|
// we will also bail.
|
||||||
match_heads.push(SingleArmMatchBegin::WithOpenBracket(if_let_pat));
|
// FIXME(#101728): change this when type ascription syntax is stabilized again
|
||||||
|
} else if let Ok(pat) = source_map.span_to_snippet(pat.span) {
|
||||||
|
let emit_suggestion = |alt_span| {
|
||||||
|
first_if_to_rewrite = true;
|
||||||
|
if add_bracket_to_match_head {
|
||||||
|
closing_brackets += 2;
|
||||||
|
match_heads.push(SingleArmMatchBegin::WithOpenBracket(if_let_pat));
|
||||||
|
} else {
|
||||||
|
// Sometimes, wrapping `match` into a block is undesirable,
|
||||||
|
// because the scrutinee temporary lifetime is shortened and
|
||||||
|
// the proposed fix will not work.
|
||||||
|
closing_brackets += 1;
|
||||||
|
match_heads
|
||||||
|
.push(SingleArmMatchBegin::WithoutOpenBracket(if_let_pat));
|
||||||
|
}
|
||||||
|
consequent_heads.push(ConsequentRewrite { span: before_conseq, pat });
|
||||||
|
if let Some(alt_span) = alt_span {
|
||||||
|
alt_heads.push(AltHead(alt_span));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if let Some(alt) = alt {
|
||||||
|
let alt_head = conseq.span.between(alt.span);
|
||||||
|
if alt_head.can_be_used_for_suggestions() {
|
||||||
|
// We lint only when the `else` span is user code, too.
|
||||||
|
emit_suggestion(Some(alt_head));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// It has to be a block
|
// This is the end of the `if .. else ..` cascade.
|
||||||
closing_brackets += 1;
|
// We can stop here.
|
||||||
match_heads.push(SingleArmMatchBegin::WithoutOpenBracket(if_let_pat));
|
emit_suggestion(None);
|
||||||
|
empty_alt = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
consequent_heads.push(ConsequentRewrite { span: before_conseq, pat });
|
|
||||||
};
|
|
||||||
if let Some(alt) = alt {
|
|
||||||
let alt_head = conseq.span.between(alt.span);
|
|
||||||
if alt_head.can_be_used_for_suggestions() {
|
|
||||||
// lint
|
|
||||||
emit_suggestion();
|
|
||||||
alt_heads.push(AltHead(alt_head));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
emit_suggestion();
|
|
||||||
empty_alt = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// At this point, any `if let` fragment in the cascade is definitely preceeded by `else`,
|
||||||
|
// so a opening bracket is mandatory before each `match`.
|
||||||
|
add_bracket_to_match_head = true;
|
||||||
if let Some(alt) = alt {
|
if let Some(alt) = alt {
|
||||||
add_bracket_to_match_head = matches!(alt.kind, hir::ExprKind::If(..));
|
|
||||||
expr = alt;
|
expr = alt;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some((span, hir_id)) = first_if_to_rewrite {
|
if let Some((span, hir_id)) = first_if_to_lint {
|
||||||
tcx.emit_node_span_lint(
|
tcx.emit_node_span_lint(
|
||||||
IF_LET_RESCOPE,
|
IF_LET_RESCOPE,
|
||||||
hir_id,
|
hir_id,
|
||||||
span,
|
span,
|
||||||
IfLetRescopeRewrite {
|
IfLetRescopeLint {
|
||||||
match_heads,
|
significant_droppers,
|
||||||
consequent_heads,
|
lifetime_ends,
|
||||||
closing_brackets: ClosingBrackets {
|
rewrite: first_if_to_rewrite.then_some(IfLetRescopeRewrite {
|
||||||
span: expr_end,
|
match_heads,
|
||||||
count: closing_brackets,
|
consequent_heads,
|
||||||
empty_alt,
|
closing_brackets: ClosingBrackets {
|
||||||
},
|
span: expr_end,
|
||||||
alt_heads,
|
count: closing_brackets,
|
||||||
|
empty_alt,
|
||||||
|
},
|
||||||
|
alt_heads,
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -254,32 +260,68 @@ impl<'tcx> LateLintPass<'tcx> for IfLetRescope {
|
||||||
#[diag(lint_if_let_rescope)]
|
#[diag(lint_if_let_rescope)]
|
||||||
struct IfLetRescopeLint {
|
struct IfLetRescopeLint {
|
||||||
#[label]
|
#[label]
|
||||||
significant_dropper: Span,
|
significant_droppers: Vec<Span>,
|
||||||
#[help]
|
#[help]
|
||||||
lifetime_end: Span,
|
lifetime_ends: Vec<Span>,
|
||||||
|
#[subdiagnostic]
|
||||||
|
rewrite: Option<IfLetRescopeRewrite>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
// #[derive(Subdiagnostic)]
|
||||||
#[diag(lint_if_let_rescope_suggestion)]
|
|
||||||
struct IfLetRescopeRewrite {
|
struct IfLetRescopeRewrite {
|
||||||
#[subdiagnostic]
|
|
||||||
match_heads: Vec<SingleArmMatchBegin>,
|
match_heads: Vec<SingleArmMatchBegin>,
|
||||||
#[subdiagnostic]
|
|
||||||
consequent_heads: Vec<ConsequentRewrite>,
|
consequent_heads: Vec<ConsequentRewrite>,
|
||||||
#[subdiagnostic]
|
|
||||||
closing_brackets: ClosingBrackets,
|
closing_brackets: ClosingBrackets,
|
||||||
#[subdiagnostic]
|
|
||||||
alt_heads: Vec<AltHead>,
|
alt_heads: Vec<AltHead>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
impl Subdiagnostic for IfLetRescopeRewrite {
|
||||||
#[multipart_suggestion(lint_suggestion, applicability = "machine-applicable")]
|
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
||||||
struct AltHead(#[suggestion_part(code = " _ => ")] Span);
|
self,
|
||||||
|
diag: &mut Diag<'_, G>,
|
||||||
|
f: &F,
|
||||||
|
) {
|
||||||
|
let mut suggestions = vec![];
|
||||||
|
for match_head in self.match_heads {
|
||||||
|
match match_head {
|
||||||
|
SingleArmMatchBegin::WithOpenBracket(span) => {
|
||||||
|
suggestions.push((span, "{ match ".into()))
|
||||||
|
}
|
||||||
|
SingleArmMatchBegin::WithoutOpenBracket(span) => {
|
||||||
|
suggestions.push((span, "match ".into()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ConsequentRewrite { span, pat } in self.consequent_heads {
|
||||||
|
suggestions.push((span, format!("{{ {pat} => ")));
|
||||||
|
}
|
||||||
|
for AltHead(span) in self.alt_heads {
|
||||||
|
suggestions.push((span, " _ => ".into()));
|
||||||
|
}
|
||||||
|
let closing_brackets = self.closing_brackets;
|
||||||
|
suggestions.push((
|
||||||
|
closing_brackets.span,
|
||||||
|
closing_brackets
|
||||||
|
.empty_alt
|
||||||
|
.then_some(" _ => {}".chars())
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
|
.chain(repeat('}').take(closing_brackets.count))
|
||||||
|
.collect(),
|
||||||
|
));
|
||||||
|
let msg = f(diag, crate::fluent_generated::lint_suggestion.into());
|
||||||
|
diag.multipart_suggestion_with_style(
|
||||||
|
msg,
|
||||||
|
suggestions,
|
||||||
|
Applicability::MachineApplicable,
|
||||||
|
SuggestionStyle::ShowCode,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AltHead(Span);
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
|
||||||
#[multipart_suggestion(lint_suggestion, applicability = "machine-applicable")]
|
|
||||||
struct ConsequentRewrite {
|
struct ConsequentRewrite {
|
||||||
#[suggestion_part(code = "{{ {pat} => ")]
|
|
||||||
span: Span,
|
span: Span,
|
||||||
pat: String,
|
pat: String,
|
||||||
}
|
}
|
||||||
|
@ -289,36 +331,9 @@ struct ClosingBrackets {
|
||||||
count: usize,
|
count: usize,
|
||||||
empty_alt: bool,
|
empty_alt: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Subdiagnostic for ClosingBrackets {
|
|
||||||
fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>(
|
|
||||||
self,
|
|
||||||
diag: &mut Diag<'_, G>,
|
|
||||||
f: &F,
|
|
||||||
) {
|
|
||||||
let code: String = self
|
|
||||||
.empty_alt
|
|
||||||
.then_some(" _ => {}".chars())
|
|
||||||
.into_iter()
|
|
||||||
.flatten()
|
|
||||||
.chain(repeat('}').take(self.count))
|
|
||||||
.collect();
|
|
||||||
let msg = f(diag, crate::fluent_generated::lint_suggestion.into());
|
|
||||||
diag.multipart_suggestion_with_style(
|
|
||||||
msg,
|
|
||||||
vec![(self.span, code)],
|
|
||||||
Applicability::MachineApplicable,
|
|
||||||
SuggestionStyle::ShowCode,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Subdiagnostic)]
|
|
||||||
enum SingleArmMatchBegin {
|
enum SingleArmMatchBegin {
|
||||||
#[multipart_suggestion(lint_suggestion, applicability = "machine-applicable")]
|
WithOpenBracket(Span),
|
||||||
WithOpenBracket(#[suggestion_part(code = "{{ match ")] Span),
|
WithoutOpenBracket(Span),
|
||||||
#[multipart_suggestion(lint_suggestion, applicability = "machine-applicable")]
|
|
||||||
WithoutOpenBracket(#[suggestion_part(code = "match ")] Span),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FindSignificantDropper<'tcx, 'a> {
|
struct FindSignificantDropper<'tcx, 'a> {
|
||||||
|
|
|
@ -26,9 +26,9 @@ impl Droppy {
|
||||||
fn main() {
|
fn main() {
|
||||||
if let Some(_value) = Droppy.get() {
|
if let Some(_value) = Droppy.get() {
|
||||||
//[with_feature_gate]~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
//[with_feature_gate]~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
//[with_feature_gate]~| ERROR: a `match` with a single arm can preserve the drop order up to Edition 2021
|
//[with_feature_gate]~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
//[with_feature_gate]~| WARN: this changes meaning in Rust 2024
|
|
||||||
//[with_feature_gate]~| WARN: this changes meaning in Rust 2024
|
//[with_feature_gate]~| WARN: this changes meaning in Rust 2024
|
||||||
} else {
|
} else {
|
||||||
|
//[with_feature_gate]~^ HELP: the value is now dropped here in Edition 2024
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ LL | if let Some(_value) = Droppy.get() {
|
||||||
= warning: this changes meaning in Rust 2024
|
= warning: this changes meaning in Rust 2024
|
||||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
||||||
help: the value is now dropped here in Edition 2024
|
help: the value is now dropped here in Edition 2024
|
||||||
--> $DIR/lint-if-let-rescope-gated.rs:32:5
|
--> $DIR/lint-if-let-rescope-gated.rs:31:5
|
||||||
|
|
|
|
||||||
LL | } else {
|
LL | } else {
|
||||||
| ^
|
| ^
|
||||||
|
@ -18,37 +18,16 @@ note: the lint level is defined here
|
||||||
|
|
|
|
||||||
LL | #![deny(if_let_rescope)]
|
LL | #![deny(if_let_rescope)]
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
help: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
|
|
|
||||||
|
LL ~ match Droppy.get() { Some(_value) => {
|
||||||
|
LL |
|
||||||
|
LL |
|
||||||
|
LL |
|
||||||
|
LL ~ } _ => {
|
||||||
|
LL |
|
||||||
|
LL ~ }}
|
||||||
|
|
|
||||||
|
|
||||||
error: a `match` with a single arm can preserve the drop order up to Edition 2021
|
error: aborting due to 1 previous error
|
||||||
--> $DIR/lint-if-let-rescope-gated.rs:27:5
|
|
||||||
|
|
|
||||||
LL | / if let Some(_value) = Droppy.get() {
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | | } else {
|
|
||||||
LL | | }
|
|
||||||
| |_____^
|
|
||||||
|
|
|
||||||
= warning: this changes meaning in Rust 2024
|
|
||||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | match Droppy.get() {
|
|
||||||
| ~~~~~
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | if let Some(_value) = Droppy.get() { Some(_value) => {
|
|
||||||
| +++++++++++++++++
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | }}
|
|
||||||
| +
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | } _ => {
|
|
||||||
| ~~~~
|
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
|
||||||
|
|
||||||
|
|
|
@ -27,73 +27,45 @@ fn main() {
|
||||||
match droppy().get() { Some(_value) => {
|
match droppy().get() { Some(_value) => {
|
||||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| WARN: this changes meaning in Rust 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
//~| ERROR a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
// do something
|
// do something
|
||||||
} _ => {
|
} _ => {
|
||||||
//~^ HELP: the value is now dropped here in Edition 2024
|
//~^ HELP: the value is now dropped here in Edition 2024
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
// do something else
|
// do something else
|
||||||
}}
|
}}
|
||||||
//~^ HELP: rewrite this `if let` into `match`
|
|
||||||
|
|
||||||
match droppy().get() { Some(_value) => {
|
match droppy().get() { Some(_value) => {
|
||||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| WARN: this changes meaning in Rust 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
//~| ERROR a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
// do something
|
// do something
|
||||||
} _ => { match droppy().get() { Some(_value) => {
|
} _ => { match droppy().get() { Some(_value) => {
|
||||||
//~^ HELP: the value is now dropped here in Edition 2024
|
//~^ HELP: the value is now dropped here in Edition 2024
|
||||||
//~| ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
// do something else
|
// do something else
|
||||||
} _ => {}}}}
|
} _ => {}}}}
|
||||||
//~^ HELP: rewrite this `if let` into `match`
|
//~^ HELP: the value is now dropped here in Edition 2024
|
||||||
//~| HELP: the value is now dropped here in Edition 2024
|
|
||||||
|
|
||||||
if droppy().get().is_some() {
|
if droppy().get().is_some() {
|
||||||
// Should not lint
|
// Should not lint
|
||||||
} else { match droppy().get() { Some(_value) => {
|
} else { match droppy().get() { Some(_value) => {
|
||||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
//~| ERROR a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| WARN: this changes meaning in Rust 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
} _ => if droppy().get().is_none() {
|
} _ => if droppy().get().is_none() {
|
||||||
//~^ HELP: the value is now dropped here in Edition 2024
|
//~^ HELP: the value is now dropped here in Edition 2024
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
}}}
|
}}}
|
||||||
//~^ HELP: rewrite this `if let` into `match`
|
|
||||||
|
|
||||||
if let Some(1) = { match Droppy.get() { Some(_value) => { Some(1) } _ => { None }} } {
|
if let Some(1) = { match Droppy.get() { Some(_value) => { Some(1) } _ => { None }} } {
|
||||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
//~| ERROR a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| WARN: this changes meaning in Rust 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: the value is now dropped here in Edition 2024
|
//~| HELP: the value is now dropped here in Edition 2024
|
||||||
|
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
}
|
}
|
||||||
|
|
||||||
if let () = { match Droppy.get() { Some(_value) => {} _ => {}} } {
|
if let () = { match Droppy.get() { Some(_value) => {} _ => {}} } {
|
||||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
//~| ERROR a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| WARN: this changes meaning in Rust 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: the value is now dropped here in Edition 2024
|
//~| HELP: the value is now dropped here in Edition 2024
|
||||||
|
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,73 +27,45 @@ fn main() {
|
||||||
if let Some(_value) = droppy().get() {
|
if let Some(_value) = droppy().get() {
|
||||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| WARN: this changes meaning in Rust 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
//~| ERROR a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
// do something
|
// do something
|
||||||
} else {
|
} else {
|
||||||
//~^ HELP: the value is now dropped here in Edition 2024
|
//~^ HELP: the value is now dropped here in Edition 2024
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
// do something else
|
// do something else
|
||||||
}
|
}
|
||||||
//~^ HELP: rewrite this `if let` into `match`
|
|
||||||
|
|
||||||
if let Some(_value) = droppy().get() {
|
if let Some(_value) = droppy().get() {
|
||||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| WARN: this changes meaning in Rust 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
//~| ERROR a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
// do something
|
// do something
|
||||||
} else if let Some(_value) = droppy().get() {
|
} else if let Some(_value) = droppy().get() {
|
||||||
//~^ HELP: the value is now dropped here in Edition 2024
|
//~^ HELP: the value is now dropped here in Edition 2024
|
||||||
//~| ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
// do something else
|
// do something else
|
||||||
}
|
}
|
||||||
//~^ HELP: rewrite this `if let` into `match`
|
//~^ HELP: the value is now dropped here in Edition 2024
|
||||||
//~| HELP: the value is now dropped here in Edition 2024
|
|
||||||
|
|
||||||
if droppy().get().is_some() {
|
if droppy().get().is_some() {
|
||||||
// Should not lint
|
// Should not lint
|
||||||
} else if let Some(_value) = droppy().get() {
|
} else if let Some(_value) = droppy().get() {
|
||||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
//~| ERROR a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| WARN: this changes meaning in Rust 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
} else if droppy().get().is_none() {
|
} else if droppy().get().is_none() {
|
||||||
//~^ HELP: the value is now dropped here in Edition 2024
|
//~^ HELP: the value is now dropped here in Edition 2024
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
}
|
}
|
||||||
//~^ HELP: rewrite this `if let` into `match`
|
|
||||||
|
|
||||||
if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } else { None } } {
|
if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } else { None } } {
|
||||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
//~| ERROR a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| WARN: this changes meaning in Rust 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: the value is now dropped here in Edition 2024
|
//~| HELP: the value is now dropped here in Edition 2024
|
||||||
|
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
}
|
}
|
||||||
|
|
||||||
if let () = { if let Some(_value) = Droppy.get() {} } {
|
if let () = { if let Some(_value) = Droppy.get() {} } {
|
||||||
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
//~^ ERROR: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
//~| ERROR a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
//~| WARN: this changes meaning in Rust 2024
|
||||||
//~| WARN: this changes meaning in Rust 2024
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: rewrite this `if let` into `match`
|
|
||||||
//~| HELP: the value is now dropped here in Edition 2024
|
//~| HELP: the value is now dropped here in Edition 2024
|
||||||
|
//~| HELP: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ LL | if let Some(_value) = droppy().get() {
|
||||||
= warning: this changes meaning in Rust 2024
|
= warning: this changes meaning in Rust 2024
|
||||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
||||||
help: the value is now dropped here in Edition 2024
|
help: the value is now dropped here in Edition 2024
|
||||||
--> $DIR/lint-if-let-rescope.rs:35:5
|
--> $DIR/lint-if-let-rescope.rs:32:5
|
||||||
|
|
|
|
||||||
LL | } else {
|
LL | } else {
|
||||||
| ^
|
| ^
|
||||||
|
@ -18,53 +18,52 @@ note: the lint level is defined here
|
||||||
|
|
|
|
||||||
LL | #![deny(if_let_rescope)]
|
LL | #![deny(if_let_rescope)]
|
||||||
| ^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^
|
||||||
|
help: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
error: a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
--> $DIR/lint-if-let-rescope.rs:27:5
|
|
||||||
|
|
|
|
||||||
LL | / if let Some(_value) = droppy().get() {
|
LL ~ match droppy().get() { Some(_value) => {
|
||||||
LL | |
|
LL |
|
||||||
LL | |
|
...
|
||||||
LL | |
|
LL | // do something
|
||||||
... |
|
LL ~ } _ => {
|
||||||
LL | | // do something else
|
LL |
|
||||||
LL | | }
|
LL | // do something else
|
||||||
| |_____^
|
LL ~ }}
|
||||||
|
|
|
|
||||||
= warning: this changes meaning in Rust 2024
|
|
||||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | match droppy().get() {
|
|
||||||
| ~~~~~
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | if let Some(_value) = droppy().get() { Some(_value) => {
|
|
||||||
| +++++++++++++++++
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | }}
|
|
||||||
| +
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | } _ => {
|
|
||||||
| ~~~~
|
|
||||||
|
|
||||||
error: `if let` assigns a shorter lifetime since Edition 2024
|
error: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
--> $DIR/lint-if-let-rescope.rs:42:8
|
--> $DIR/lint-if-let-rescope.rs:37:8
|
||||||
|
|
|
|
||||||
LL | if let Some(_value) = droppy().get() {
|
LL | if let Some(_value) = droppy().get() {
|
||||||
| ^^^^^^^^^^^^^^^^^^^--------^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^--------^^^^^^
|
||||||
| |
|
| |
|
||||||
| this value has a significant drop implementation which may observe a major change in drop order and requires your discretion
|
| this value has a significant drop implementation which may observe a major change in drop order and requires your discretion
|
||||||
|
...
|
||||||
|
LL | } else if let Some(_value) = droppy().get() {
|
||||||
|
| -------- this value has a significant drop implementation which may observe a major change in drop order and requires your discretion
|
||||||
|
|
|
|
||||||
= warning: this changes meaning in Rust 2024
|
= warning: this changes meaning in Rust 2024
|
||||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
||||||
help: the value is now dropped here in Edition 2024
|
help: the value is now dropped here in Edition 2024
|
||||||
--> $DIR/lint-if-let-rescope.rs:50:5
|
--> $DIR/lint-if-let-rescope.rs:42:5
|
||||||
|
|
|
|
||||||
LL | } else if let Some(_value) = droppy().get() {
|
LL | } else if let Some(_value) = droppy().get() {
|
||||||
| ^
|
| ^
|
||||||
|
help: the value is now dropped here in Edition 2024
|
||||||
|
--> $DIR/lint-if-let-rescope.rs:45:5
|
||||||
|
|
|
||||||
|
LL | }
|
||||||
|
| ^
|
||||||
|
help: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
|
|
|
||||||
|
LL ~ match droppy().get() { Some(_value) => {
|
||||||
|
LL |
|
||||||
|
...
|
||||||
|
LL | // do something
|
||||||
|
LL ~ } _ => { match droppy().get() { Some(_value) => {
|
||||||
|
LL |
|
||||||
|
LL | // do something else
|
||||||
|
LL ~ } _ => {}}}}
|
||||||
|
|
|
||||||
|
|
||||||
error: `if let` assigns a shorter lifetime since Edition 2024
|
error: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
--> $DIR/lint-if-let-rescope.rs:50:15
|
--> $DIR/lint-if-let-rescope.rs:50:15
|
||||||
|
@ -77,100 +76,23 @@ LL | } else if let Some(_value) = droppy().get() {
|
||||||
= warning: this changes meaning in Rust 2024
|
= warning: this changes meaning in Rust 2024
|
||||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
||||||
help: the value is now dropped here in Edition 2024
|
help: the value is now dropped here in Edition 2024
|
||||||
--> $DIR/lint-if-let-rescope.rs:58:5
|
--> $DIR/lint-if-let-rescope.rs:54:5
|
||||||
|
|
|
||||||
LL | }
|
|
||||||
| ^
|
|
||||||
|
|
||||||
error: a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
--> $DIR/lint-if-let-rescope.rs:42:5
|
|
||||||
|
|
|
||||||
LL | / if let Some(_value) = droppy().get() {
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
... |
|
|
||||||
LL | | // do something else
|
|
||||||
LL | | }
|
|
||||||
| |_____^
|
|
||||||
|
|
|
||||||
= warning: this changes meaning in Rust 2024
|
|
||||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | match droppy().get() {
|
|
||||||
| ~~~~~
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | } else { match droppy().get() {
|
|
||||||
| ~~~~~~~
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | if let Some(_value) = droppy().get() { Some(_value) => {
|
|
||||||
| +++++++++++++++++
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | } else if let Some(_value) = droppy().get() { Some(_value) => {
|
|
||||||
| +++++++++++++++++
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | } _ => {}}}}
|
|
||||||
| ++++++++++
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | } _ => if let Some(_value) = droppy().get() {
|
|
||||||
| ~~~~
|
|
||||||
|
|
||||||
error: `if let` assigns a shorter lifetime since Edition 2024
|
|
||||||
--> $DIR/lint-if-let-rescope.rs:64:15
|
|
||||||
|
|
|
||||||
LL | } else if let Some(_value) = droppy().get() {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^--------^^^^^^
|
|
||||||
| |
|
|
||||||
| this value has a significant drop implementation which may observe a major change in drop order and requires your discretion
|
|
||||||
|
|
|
||||||
= warning: this changes meaning in Rust 2024
|
|
||||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
|
||||||
help: the value is now dropped here in Edition 2024
|
|
||||||
--> $DIR/lint-if-let-rescope.rs:71:5
|
|
||||||
|
|
|
|
||||||
LL | } else if droppy().get().is_none() {
|
LL | } else if droppy().get().is_none() {
|
||||||
| ^
|
| ^
|
||||||
|
help: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
error: a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
--> $DIR/lint-if-let-rescope.rs:64:12
|
|
||||||
|
|
|
|
||||||
LL | } else if let Some(_value) = droppy().get() {
|
LL ~ } else { match droppy().get() { Some(_value) => {
|
||||||
| ____________^
|
LL |
|
||||||
LL | |
|
LL |
|
||||||
LL | |
|
LL |
|
||||||
LL | |
|
LL ~ } _ => if droppy().get().is_none() {
|
||||||
... |
|
LL |
|
||||||
LL | |
|
LL ~ }}}
|
||||||
LL | | }
|
|
||||||
| |_____^
|
|
||||||
|
|
|
|
||||||
= warning: this changes meaning in Rust 2024
|
|
||||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | } else { match droppy().get() {
|
|
||||||
| ~~~~~~~
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | } else if let Some(_value) = droppy().get() { Some(_value) => {
|
|
||||||
| +++++++++++++++++
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | }}}
|
|
||||||
| ++
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | } _ => if droppy().get().is_none() {
|
|
||||||
| ~~~~
|
|
||||||
|
|
||||||
error: `if let` assigns a shorter lifetime since Edition 2024
|
error: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
--> $DIR/lint-if-let-rescope.rs:77:27
|
--> $DIR/lint-if-let-rescope.rs:58:27
|
||||||
|
|
|
|
||||||
LL | if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } else { None } } {
|
LL | if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } else { None } } {
|
||||||
| ^^^^^^^^^^^^^^^^^^^------^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^------^^^^^^
|
||||||
|
@ -180,38 +102,17 @@ LL | if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } else
|
||||||
= warning: this changes meaning in Rust 2024
|
= warning: this changes meaning in Rust 2024
|
||||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
||||||
help: the value is now dropped here in Edition 2024
|
help: the value is now dropped here in Edition 2024
|
||||||
--> $DIR/lint-if-let-rescope.rs:77:69
|
--> $DIR/lint-if-let-rescope.rs:58:69
|
||||||
|
|
|
|
||||||
LL | if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } else { None } } {
|
LL | if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } else { None } } {
|
||||||
| ^
|
| ^
|
||||||
|
help: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
error: a `match` with a single arm can preserve the drop order up to Edition 2021
|
|
||||||
--> $DIR/lint-if-let-rescope.rs:77:24
|
|
||||||
|
|
|
|
||||||
LL | if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } else { None } } {
|
LL | if let Some(1) = { match Droppy.get() { Some(_value) => { Some(1) } _ => { None }} } {
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ~~~~~ +++++++++++++++++ ~~~~ +
|
||||||
|
|
|
||||||
= warning: this changes meaning in Rust 2024
|
|
||||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | if let Some(1) = { match Droppy.get() { Some(1) } else { None } } {
|
|
||||||
| ~~~~~
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | if let Some(1) = { if let Some(_value) = Droppy.get() { Some(_value) => { Some(1) } else { None } } {
|
|
||||||
| +++++++++++++++++
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } else { None }} } {
|
|
||||||
| +
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | if let Some(1) = { if let Some(_value) = Droppy.get() { Some(1) } _ => { None } } {
|
|
||||||
| ~~~~
|
|
||||||
|
|
||||||
error: `if let` assigns a shorter lifetime since Edition 2024
|
error: `if let` assigns a shorter lifetime since Edition 2024
|
||||||
--> $DIR/lint-if-let-rescope.rs:89:22
|
--> $DIR/lint-if-let-rescope.rs:65:22
|
||||||
|
|
|
|
||||||
LL | if let () = { if let Some(_value) = Droppy.get() {} } {
|
LL | if let () = { if let Some(_value) = Droppy.get() {} } {
|
||||||
| ^^^^^^^^^^^^^^^^^^^------^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^------^^^^^^
|
||||||
|
@ -221,31 +122,14 @@ LL | if let () = { if let Some(_value) = Droppy.get() {} } {
|
||||||
= warning: this changes meaning in Rust 2024
|
= warning: this changes meaning in Rust 2024
|
||||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
||||||
help: the value is now dropped here in Edition 2024
|
help: the value is now dropped here in Edition 2024
|
||||||
--> $DIR/lint-if-let-rescope.rs:89:55
|
--> $DIR/lint-if-let-rescope.rs:65:55
|
||||||
|
|
|
|
||||||
LL | if let () = { if let Some(_value) = Droppy.get() {} } {
|
LL | if let () = { if let Some(_value) = Droppy.get() {} } {
|
||||||
| ^
|
| ^
|
||||||
|
help: a `match` with a single arm can preserve the drop order up to Edition 2021
|
||||||
|
|
|
||||||
|
LL | if let () = { match Droppy.get() { Some(_value) => {} _ => {}} } {
|
||||||
|
| ~~~~~ +++++++++++++++++ ++++++++
|
||||||
|
|
||||||
error: a `match` with a single arm can preserve the drop order up to Edition 2021
|
error: aborting due to 5 previous errors
|
||||||
--> $DIR/lint-if-let-rescope.rs:89:19
|
|
||||||
|
|
|
||||||
LL | if let () = { if let Some(_value) = Droppy.get() {} } {
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= warning: this changes meaning in Rust 2024
|
|
||||||
= note: for more information, see issue #124085 <https://github.com/rust-lang/rust/issues/124085>
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | if let () = { match Droppy.get() {} } {
|
|
||||||
| ~~~~~
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | if let () = { if let Some(_value) = Droppy.get() { Some(_value) => {} } {
|
|
||||||
| +++++++++++++++++
|
|
||||||
help: rewrite this `if let` into `match`
|
|
||||||
|
|
|
||||||
LL | if let () = { if let Some(_value) = Droppy.get() {} _ => {}} } {
|
|
||||||
| ++++++++
|
|
||||||
|
|
||||||
error: aborting due to 11 previous errors
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue