Skip to content

Commit 55019ea

Browse files
committed
Rebase and merge
1 parent 60fe9c2 commit 55019ea

File tree

6 files changed

+22
-46
lines changed

6 files changed

+22
-46
lines changed

compiler/rustc_lint/src/levels.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn lint_expectations(tcx: TyCtxt<'_>, (): ()) -> Vec<(LintExpectationId, LintExp
143143
builder.provider.expectations
144144
}
145145

146-
pub fn lints_that_dont_need_to_run(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LintId> {
146+
fn lints_that_dont_need_to_run(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LintId> {
147147
let store = unerased_lint_store(&tcx.sess);
148148

149149
let dont_need_to_run: FxIndexSet<LintId> = store

compiler/rustc_lint/src/unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ pub(crate) struct UnusedParens {
10271027
}
10281028

10291029
impl Default for UnusedParens {
1030-
pub(crate) fn default() -> Self {
1030+
fn default() -> Self {
10311031
Self { with_self_ty_parens: false, parens_in_cast_in_lt: Vec::new() }
10321032
}
10331033
}

src/tools/clippy/clippy_lints/src/cognitive_complexity.rs

+16-40
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,18 @@ use clippy_utils::source::{IntoSpan, SpanRangeExt};
44
use clippy_utils::ty::is_type_diagnostic_item;
55
use clippy_utils::visitors::for_each_expr_without_closures;
66
use clippy_utils::{get_async_fn_body, is_async_fn, LimitStack};
7-
use rustc_lint::{Level::Allow, Lint};
87
use core::ops::ControlFlow;
98
use rustc_ast::ast::Attribute;
109
use rustc_hir::intravisit::FnKind;
1110
use rustc_hir::{Body, Expr, ExprKind, FnDecl};
12-
use rustc_lint::{LateContext, LateLintPass, LintContext};
11+
use rustc_lint::Level::Allow;
12+
use rustc_lint::{LateContext, LateLintPass, Lint, LintContext};
1313
use rustc_session::impl_lint_pass;
1414
use rustc_span::def_id::LocalDefId;
1515
use rustc_span::{sym, Span};
1616

1717
use crate::LintInfo;
1818

19-
// declare_clippy_lint! {
20-
// /// ### What it does
21-
// /// Checks for methods with high cognitive complexity.
22-
// ///
23-
// /// ### Why is this bad?
24-
// /// Methods of high cognitive complexity tend to be hard to
25-
// /// both read and maintain. Also LLVM will tend to optimize small methods better.
26-
// ///
27-
// /// ### Known problems
28-
// /// Sometimes it's hard to find a way to reduce the
29-
// /// complexity.
30-
// ///
31-
// /// ### Example
32-
// /// You'll see it when you get the warning.
33-
// #[clippy::version = "1.35.0"]
34-
// pub COGNITIVE_COMPLEXITY,
35-
// nursery,
36-
// "functions that should be split up into multiple functions"
37-
// }
38-
39-
// Recursive expansion of declare_clippy_lint! macro
40-
// ==================================================
41-
42-
#[doc = " ### What it does"]
43-
#[doc = " Checks for methods with high cognitive complexity."]
44-
#[doc = ""]
45-
#[doc = " ### Why is this bad?"]
46-
#[doc = " Methods of high cognitive complexity tend to be hard to"]
47-
#[doc = " both read and maintain. Also LLVM will tend to optimize small methods better."]
48-
#[doc = ""]
49-
#[doc = " ### Known problems"]
50-
#[doc = " Sometimes it\'s hard to find a way to reduce the"]
51-
#[doc = " complexity."]
52-
#[doc = ""]
53-
#[doc = " ### Example"]
54-
#[doc = " You\'ll see it when you get the warning."]
55-
#[clippy::version = "1.35.0"]
5619
pub static COGNITIVE_COMPLEXITY: &Lint = &Lint {
5720
name: &"clippy::COGNITIVE_COMPLEXITY",
5821
default_level: Allow,
@@ -68,7 +31,20 @@ pub static COGNITIVE_COMPLEXITY: &Lint = &Lint {
6831
pub(crate) static COGNITIVE_COMPLEXITY_INFO: &'static LintInfo = &LintInfo {
6932
lint: &COGNITIVE_COMPLEXITY,
7033
category: crate::LintCategory::Nursery,
71-
explanation: "### What it does\nChecks for methods with high cognitive complexity.\n\n### Why is this bad?\nMethods of high cognitive complexity tend to be hard to\nboth read and maintain. Also LLVM will tend to optimize small methods better.\n\n### Known problems\nSometimes it's hard to find a way to reduce the\ncomplexity.\n\n### Example\nYou'll see it when you get the warning.\n",
34+
explanation: r"### What it does
35+
Checks for methods with high cognitive complexity.
36+
37+
### Why is this bad?
38+
Methods of high cognitive complexity tend to be hard to both read and maintain.
39+
Also LLVM will tend to optimize small methods better.
40+
41+
### Known problems
42+
Sometimes it's hard to find a way to reduce the complexity.
43+
44+
### Example
45+
You'll see it when you get the warning.",
46+
version: Some("1.35.0"),
47+
location: "#L0",
7248
};
7349

7450
pub struct CognitiveComplexity {

src/tools/clippy/clippy_lints/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ extern crate declare_clippy_lint;
6767
mod utils;
6868

6969
pub mod ctfe; // VERY important lint (rust#125116)
70-
mod declared_lints;
70+
pub mod declared_lints;
7171
pub mod deprecated_lints;
7272

7373
// begin lints modules, do not remove this comment, it’s used in `update_lints`

src/tools/clippy/tests/ui/indexing_slicing_index.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ fn main() {
6262
x[const { idx4() }];
6363
// This should be linted, since `suppress-restriction-lint-in-const` default is false.
6464
const { &ARR[idx()] };
65-
// ~^ ERROR: indexing may panic
65+
//~^ ERROR: indexing may panic
6666
// This should be linted, since `suppress-restriction-lint-in-const` default is false.
6767
const { &ARR[idx4()] };
68-
// ~^ ERROR: indexing may panic
68+
//~^ ERROR: indexing may panic
6969

7070
let y = &x;
7171
// Ok, referencing shouldn't affect this lint. See the issue 6021

src/tools/clippy/tests/ui/string_slice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::borrow::Cow;
22

3-
#![warn(clippy::string_slice)]
3+
#[warn(clippy::string_slice)]
44
#[allow(clippy::no_effect)]
55

66
fn main() {

0 commit comments

Comments
 (0)