Auto merge of #13540 - GnomedDev:create-dir-single-arg, r=y21

Check MethodCall/Call arg count earlier or at all

This gets rid of a bunch of possible panic spots, as well as bailing out earlier for optimisation reasons.

I started doing this because I saw that a significant amount of time was being spent in the `create_dir` restriction lint when running clippy with `perf`, but this also helps with robustness.

changelog: none
This commit is contained in:
bors 2024-10-13 13:34:48 +00:00
commit 236751d093
59 changed files with 127 additions and 149 deletions

View file

@ -484,10 +484,9 @@ impl<'tcx> ConstEvalCtxt<'tcx> {
}),
ExprKind::If(cond, then, ref otherwise) => self.ifthenelse(cond, then, *otherwise),
ExprKind::Binary(op, left, right) => self.binop(op, left, right),
ExprKind::Call(callee, args) => {
ExprKind::Call(callee, []) => {
// We only handle a few const functions for now.
if args.is_empty()
&& let ExprKind::Path(qpath) = &callee.kind
if let ExprKind::Path(qpath) = &callee.kind
&& let Some(did) = self.typeck.qpath_res(qpath, callee.hir_id).opt_def_id()
{
match self.tcx.get_diagnostic_name(did) {