bless clippy
This commit is contained in:
parent
be0b4d5a9b
commit
39fb315396
@ -3,7 +3,7 @@
|
||||
use clippy_utils::source::snippet_opt;
|
||||
use clippy_utils::{is_from_proc_macro, path_to_local};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
||||
use rustc_hir::{BinOpKind, Constness, Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass, Lint, LintContext};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||
@ -83,8 +83,10 @@ pub fn msg(self) -> &'static str {
|
||||
impl<'tcx> LateLintPass<'tcx> for ManualFloatMethods {
|
||||
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||
if !in_external_macro(cx.sess(), expr.span)
|
||||
&& cx.tcx.features().active(sym!(const_float_classify))
|
||||
&& let ExprKind::Binary(kind, lhs, rhs) = expr.kind
|
||||
&& (
|
||||
matches!(cx.tcx.constness(cx.tcx.hir().enclosing_body_owner(expr.hir_id)), Constness::NotConst)
|
||||
|| cx.tcx.features().active(sym!(const_float_classify))
|
||||
) && let ExprKind::Binary(kind, lhs, rhs) = expr.kind
|
||||
&& let ExprKind::Binary(lhs_kind, lhs_lhs, lhs_rhs) = lhs.kind
|
||||
&& let ExprKind::Binary(rhs_kind, rhs_lhs, rhs_rhs) = rhs.kind
|
||||
// Checking all possible scenarios using a function would be a hopeless task, as we have
|
||||
|
@ -391,6 +391,9 @@ fn is_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: &Msrv) -> bool {
|
||||
|
||||
#[expect(clippy::similar_names)] // bit too pedantic
|
||||
fn is_ty_const_destruct<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>) -> bool {
|
||||
// FIXME(effects, fee1-dead) revert to const destruct once it works again
|
||||
#[expect(unused)]
|
||||
fn is_ty_const_destruct_unused<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>) -> bool {
|
||||
// Avoid selecting for simple cases, such as builtin types.
|
||||
if ty::util::is_trivially_const_drop(ty) {
|
||||
return true;
|
||||
@ -420,3 +423,6 @@ fn is_ty_const_destruct<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>
|
||||
ocx.register_obligations(impl_src.nested_obligations());
|
||||
ocx.select_all_or_error().is_empty()
|
||||
}
|
||||
|
||||
!ty.needs_drop(tcx, ConstCx::new(tcx, body).param_env)
|
||||
}
|
||||
|
@ -99,4 +99,5 @@ fn drop(&mut self) {
|
||||
}
|
||||
|
||||
// Lint this, since it can be dropped in const contexts
|
||||
// FIXME(effects)
|
||||
fn d(this: D) {}
|
||||
|
@ -89,11 +89,5 @@ LL | | 46
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: this could be a `const fn`
|
||||
--> $DIR/could_be_const.rs:102:1
|
||||
|
|
||||
LL | fn d(this: D) {}
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user