let_and_return: lint more cases in edition ≥ 2024
This commit is contained in:
parent
657dda7b50
commit
5d2fe079ab
7 changed files with 923 additions and 6 deletions
|
|
@ -199,7 +199,7 @@ impl<'a, 'tcx> SigDropChecker<'a, 'tcx> {
|
|||
return false;
|
||||
}
|
||||
|
||||
let result = match ty.kind() {
|
||||
match ty.kind() {
|
||||
rustc_middle::ty::Adt(adt, args) => {
|
||||
// if some field has significant drop,
|
||||
adt.all_fields()
|
||||
|
|
@ -223,9 +223,7 @@ impl<'a, 'tcx> SigDropChecker<'a, 'tcx> {
|
|||
rustc_middle::ty::Tuple(tys) => tys.iter().any(|ty| self.has_sig_drop_attr_impl(ty)),
|
||||
rustc_middle::ty::Array(ty, _) | rustc_middle::ty::Slice(ty) => self.has_sig_drop_attr_impl(*ty),
|
||||
_ => false,
|
||||
};
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use rustc_middle::ty::adjustment::Adjust;
|
|||
use rustc_middle::ty::{self, GenericArgKind, Ty};
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::{BytePos, Pos, Span, sym};
|
||||
use std::borrow::Cow;
|
||||
use std::fmt::Display;
|
||||
|
|
@ -235,7 +236,7 @@ impl<'tcx> LateLintPass<'tcx> for Return {
|
|||
&& let Some(initexpr) = &local.init
|
||||
&& let PatKind::Binding(_, local_id, _, _) = local.pat.kind
|
||||
&& path_to_local_id(retexpr, local_id)
|
||||
&& !last_statement_borrows(cx, initexpr)
|
||||
&& (cx.sess().edition() >= Edition::Edition2024 || !last_statement_borrows(cx, initexpr))
|
||||
&& !initexpr.span.in_external_macro(cx.sess().source_map())
|
||||
&& !retexpr.span.in_external_macro(cx.sess().source_map())
|
||||
&& !local.span.from_expansion()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue