Skip to content

Commit ce83d8d

Browse files
committed
Revert "Avoid or_fun_call for const_fn with no args"
This reverts commit 5d66bd7.
1 parent 3e294b2 commit ce83d8d

File tree

3 files changed

+0
-25
lines changed

3 files changed

+0
-25
lines changed

clippy_lints/src/utils/mod.rs

-9
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use rustc_lint::{LateContext, Level, Lint, LintContext};
4646
use rustc_middle::hir::map::Map;
4747
use rustc_middle::ty::subst::{GenericArg, GenericArgKind};
4848
use rustc_middle::ty::{self, layout::IntegerExt, Ty, TyCtxt, TypeFoldable};
49-
use rustc_mir::const_eval;
5049
use rustc_span::hygiene::{ExpnKind, MacroKind};
5150
use rustc_span::source_map::original_sp;
5251
use rustc_span::symbol::{self, kw, Symbol};
@@ -883,19 +882,11 @@ pub fn is_copy<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool {
883882

884883
/// Checks if an expression is constructing a tuple-like enum variant or struct
885884
pub fn is_ctor_or_promotable_const_function(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
886-
fn has_no_arguments(cx: &LateContext<'_>, def_id: DefId) -> bool {
887-
cx.tcx.fn_sig(def_id).skip_binder().inputs().is_empty()
888-
}
889-
890885
if let ExprKind::Call(ref fun, _) = expr.kind {
891886
if let ExprKind::Path(ref qp) = fun.kind {
892887
let res = cx.qpath_res(qp, fun.hir_id);
893888
return match res {
894889
def::Res::Def(DefKind::Variant | DefKind::Ctor(..), ..) => true,
895-
// FIXME: check the constness of the arguments, see https://github.com/rust-lang/rust-clippy/pull/5682#issuecomment-638681210
896-
def::Res::Def(DefKind::Fn, def_id) if has_no_arguments(cx, def_id) => {
897-
const_eval::is_const_fn(cx.tcx, def_id)
898-
},
899890
def::Res::Def(_, def_id) => cx.tcx.is_promotable_const_fn(def_id),
900891
_ => false,
901892
};

tests/ui/or_fun_call.fixed

-8
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,4 @@ fn f() -> Option<()> {
116116
Some(())
117117
}
118118

119-
// Issue 5886 - const fn (with no arguments)
120-
pub fn skip_const_fn_with_no_args() {
121-
const fn foo() -> Option<i32> {
122-
Some(42)
123-
}
124-
let _ = None.or(foo());
125-
}
126-
127119
fn main() {}

tests/ui/or_fun_call.rs

-8
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,4 @@ fn f() -> Option<()> {
116116
Some(())
117117
}
118118

119-
// Issue 5886 - const fn (with no arguments)
120-
pub fn skip_const_fn_with_no_args() {
121-
const fn foo() -> Option<i32> {
122-
Some(42)
123-
}
124-
let _ = None.or(foo());
125-
}
126-
127119
fn main() {}

0 commit comments

Comments
 (0)