Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into rustup
Browse files Browse the repository at this point in the history
  • Loading branch information
flip1995 committed Oct 18, 2024
2 parents c512a22 + dae1be9 commit 224d1e3
Show file tree
Hide file tree
Showing 186 changed files with 4,078 additions and 1,768 deletions.
2 changes: 1 addition & 1 deletion .github/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ rm -rf out/master/ || exit 0
echo "Making the docs for master"
mkdir out/master/
cp util/gh-pages/index.html out/master
cp util/gh-pages/theme.js out/master
cp util/gh-pages/script.js out/master
cp util/gh-pages/lints.json out/master
cp util/gh-pages/style.css out/master

if [[ -n $TAG_NAME ]]; then
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ out

# gh pages docs
util/gh-pages/lints.json
util/gh-pages/index.html

# rustfmt backups
*.rs.bk
Expand Down
42 changes: 40 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,46 @@ document.

## Unreleased / Beta / In Rust Nightly

[b794b8e0...master](https://github.com/rust-lang/rust-clippy/compare/b794b8e0...master)
[0f8eabd6...master](https://github.com/rust-lang/rust-clippy/compare/0f8eabd6...master)

## Rust 1.82

Current stable, released 2024-10-17

[View all 108 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2024-07-11T20%3A12%3A07Z..2024-08-24T20%3A55%3A35Z+base%3Amaster)

### New Lints

* Added [`too_long_first_doc_paragraph`] to `nursery`
[#12993](https://github.com/rust-lang/rust-clippy/pull/12993)
* Added [`unused_result_ok`] to `restriction`
[#12150](https://github.com/rust-lang/rust-clippy/pull/12150)
* Added [`pathbuf_init_then_push`] to `restriction`
[#11700](https://github.com/rust-lang/rust-clippy/pull/11700)

### Enhancements

* [`explicit_iter_loop`]: Now respects the `msrv` configuration
[#13288](https://github.com/rust-lang/rust-clippy/pull/13288)
* [`assigning_clones`]: No longer lints in test code
[#13273](https://github.com/rust-lang/rust-clippy/pull/13273)
* [`inconsistent_struct_constructor`]: Lint attributes now work on the struct definition
[#13211](https://github.com/rust-lang/rust-clippy/pull/13211)
* [`set_contains_or_insert`]: Now also checks for `BTreeSet`
[#13053](https://github.com/rust-lang/rust-clippy/pull/13053)
* [`doc_markdown`]: Added the following identifiers to [`doc-valid-idents`]: AccessKit,
CoreFoundation, CoreGraphics, CoreText, Direct2D, Direct3D, DirectWrite, PostScript,
OpenAL, OpenType, WebRTC, WebSocket, WebTransport, NetBSD, and OpenBSD
[#13093](https://github.com/rust-lang/rust-clippy/pull/13093)

### ICE Fixes

* [`uninit_vec`]
[rust#128720](https://github.com/rust-lang/rust/pull/128720)

## Rust 1.81

Current stable, released 2024-09-05
Released 2024-09-05

### New Lints

Expand Down Expand Up @@ -5621,6 +5656,7 @@ Released 2018-09-13
[`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map
[`manual_flatten`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten
[`manual_hash_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_hash_one
[`manual_ignore_case_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ignore_case_cmp
[`manual_inspect`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect
[`manual_instant_elapsed`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_instant_elapsed
[`manual_is_ascii_check`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check
Expand Down Expand Up @@ -5874,6 +5910,7 @@ Released 2018-09-13
[`ref_option`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_option
[`ref_option_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_option_ref
[`ref_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#ref_patterns
[`regex_creation_in_loops`]: https://rust-lang.github.io/rust-clippy/master/index.html#regex_creation_in_loops
[`regex_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#regex_macro
[`renamed_function_params`]: https://rust-lang.github.io/rust-clippy/master/index.html#renamed_function_params
[`repeat_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#repeat_once
Expand Down Expand Up @@ -6027,6 +6064,7 @@ Released 2018-09-13
[`unnecessary_get_then_check`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
[`unnecessary_join`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_join
[`unnecessary_lazy_evaluations`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_lazy_evaluations
[`unnecessary_literal_bound`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_bound
[`unnecessary_literal_unwrap`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_literal_unwrap
[`unnecessary_map_on_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_on_constructor
[`unnecessary_min_or_max`]: https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_min_or_max
Expand Down
13 changes: 11 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ path = "src/driver.rs"
[dependencies]
clippy_config = { path = "clippy_config" }
clippy_lints = { path = "clippy_lints" }
rustc_tools_util = "0.3.0"
rustc_tools_util = "0.4.0"
tempfile = { version = "3.3", optional = true }
termize = "0.1"
color-print = "0.3.4"
Expand All @@ -39,6 +39,8 @@ toml = "0.7.3"
walkdir = "2.3"
filetime = "0.2.9"
itertools = "0.12"
pulldown-cmark = "0.11"
rinja = { version = "0.3", default-features = false, features = ["config"] }

# UI test dependencies
clippy_utils = { path = "clippy_utils" }
Expand All @@ -50,7 +52,7 @@ parking_lot = "0.12"
tokio = { version = "1", features = ["io-util"] }

[build-dependencies]
rustc_tools_util = "0.3.0"
rustc_tools_util = "0.4.0"

[features]
integration = ["tempfile"]
Expand All @@ -67,3 +69,10 @@ harness = false
[[test]]
name = "dogfood"
harness = false

# quine-mc_cluskey makes up a significant part of the runtime in dogfood
# due to the number of conditions in the clippy_lints crate
# and enabling optimizations for that specific dependency helps a bit
# without increasing total build times.
[profile.dev.package.quine-mc_cluskey]
opt-level = 3
2 changes: 1 addition & 1 deletion book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ arithmetic-side-effects-allowed-unary = ["SomeType", "AnotherType"]
## `array-size-threshold`
The maximum allowed size for arrays on the stack

**Default Value:** `512000`
**Default Value:** `16384`

---
**Affected lints:**
Expand Down
26 changes: 25 additions & 1 deletion clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,30 @@ impl ConfError {
}
}

// Remove code tags and code behind '# 's, as they are not needed for the lint docs and --explain
pub fn sanitize_explanation(raw_docs: &str) -> String {
// Remove tags and hidden code:
let mut explanation = String::with_capacity(128);
let mut in_code = false;
for line in raw_docs.lines().map(str::trim) {
if let Some(lang) = line.strip_prefix("```") {
let tag = lang.split_once(',').map_or(lang, |(left, _)| left);
if !in_code && matches!(tag, "" | "rust" | "ignore" | "should_panic" | "no_run" | "compile_fail") {
explanation += "```rust\n";
} else {
explanation += line;
explanation.push('\n');
}
in_code = !in_code;
} else if !(in_code && line.starts_with("# ")) {
explanation += line;
explanation.push('\n');
}
}

explanation
}

macro_rules! wrap_option {
() => {
None
Expand Down Expand Up @@ -366,7 +390,7 @@ define_Conf! {
arithmetic_side_effects_allowed_unary: Vec<String> = <_>::default(),
/// The maximum allowed size for arrays on the stack
#[lints(large_const_arrays, large_stack_arrays)]
array_size_threshold: u64 = 512_000,
array_size_threshold: u64 = 16 * 1024,
/// Suppress lints whenever the suggested change would cause breakage for other crates.
#[lints(
box_collection,
Expand Down
2 changes: 1 addition & 1 deletion clippy_config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ mod metadata;
pub mod msrvs;
pub mod types;

pub use conf::{Conf, get_configuration_metadata, lookup_conf_file};
pub use conf::{Conf, get_configuration_metadata, lookup_conf_file, sanitize_explanation};
pub use metadata::ClippyConfiguration;
3 changes: 1 addition & 2 deletions clippy_config/src/msrvs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ macro_rules! msrv_aliases {

// names may refer to stabilized feature flags or library items
msrv_aliases! {
1,83,0 { CONST_EXTERN_FN }
1,83,0 { CONST_FLOAT_BITS_CONV }
1,83,0 { CONST_EXTERN_FN, CONST_FLOAT_BITS_CONV, CONST_FLOAT_CLASSIFY }
1,82,0 { IS_NONE_OR }
1,81,0 { LINT_REASONS_STABILIZATION }
1,80,0 { BOX_INTO_ITER}
Expand Down
2 changes: 1 addition & 1 deletion clippy_dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ aho-corasick = "1.0"
clap = { version = "4.4", features = ["derive"] }
indoc = "1.0"
itertools = "0.12"
opener = "0.6"
opener = "0.7"
shell-escape = "0.1"
walkdir = "2.3"

Expand Down
28 changes: 14 additions & 14 deletions clippy_dev/src/new_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,13 @@ pub(crate) fn get_stabilization_version() -> String {

fn get_test_file_contents(lint_name: &str, msrv: bool) -> String {
let mut test = formatdoc!(
r#"
r"
#![warn(clippy::{lint_name})]
fn main() {{
// test code goes here
}}
"#
"
);

if msrv {
Expand Down Expand Up @@ -272,31 +272,31 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {

result.push_str(&if enable_msrv {
formatdoc!(
r#"
r"
use clippy_config::msrvs::{{self, Msrv}};
use clippy_config::Conf;
{pass_import}
use rustc_lint::{{{context_import}, {pass_type}, LintContext}};
use rustc_session::impl_lint_pass;
"#
"
)
} else {
formatdoc!(
r#"
r"
{pass_import}
use rustc_lint::{{{context_import}, {pass_type}}};
use rustc_session::declare_lint_pass;
"#
"
)
});

let _: fmt::Result = writeln!(result, "{}", get_lint_declaration(&name_upper, category));

result.push_str(&if enable_msrv {
formatdoc!(
r#"
r"
pub struct {name_camel} {{
msrv: Msrv,
}}
Expand All @@ -315,15 +315,15 @@ fn get_lint_file_contents(lint: &LintData<'_>, enable_msrv: bool) -> String {
// TODO: Add MSRV level to `clippy_config/src/msrvs.rs` if needed.
// TODO: Update msrv config comment in `clippy_config/src/conf.rs`
"#
"
)
} else {
formatdoc!(
r#"
r"
declare_lint_pass!({name_camel} => [{name_upper}]);
impl {pass_type}{pass_lifetimes} for {name_camel} {{}}
"#
"
)
});

Expand Down Expand Up @@ -416,7 +416,7 @@ fn create_lint_for_ty(lint: &LintData<'_>, enable_msrv: bool, ty: &str) -> io::R
} else {
let _: fmt::Result = writedoc!(
lint_file_contents,
r#"
r"
use rustc_lint::{{{context_import}, LintContext}};
use super::{name_upper};
Expand All @@ -425,7 +425,7 @@ fn create_lint_for_ty(lint: &LintData<'_>, enable_msrv: bool, ty: &str) -> io::R
pub(super) fn check(cx: &{context_import}{pass_lifetimes}) {{
todo!();
}}
"#
"
);
}

Expand Down Expand Up @@ -470,7 +470,7 @@ fn setup_mod_file(path: &Path, lint: &LintData<'_>) -> io::Result<&'static str>
});

// Find both the last lint declaration (declare_clippy_lint!) and the lint pass impl
while let Some(LintDeclSearchResult { content, .. }) = iter.find(|result| result.token == TokenKind::Ident) {
while let Some(LintDeclSearchResult { content, .. }) = iter.find(|result| result.token_kind == TokenKind::Ident) {
let mut iter = iter
.by_ref()
.filter(|t| !matches!(t.token_kind, TokenKind::Whitespace | TokenKind::LineComment { .. }));
Expand All @@ -480,7 +480,7 @@ fn setup_mod_file(path: &Path, lint: &LintData<'_>) -> io::Result<&'static str>
// matches `!{`
match_tokens!(iter, Bang OpenBrace);
if let Some(LintDeclSearchResult { range, .. }) =
iter.find(|result| result.token == TokenKind::CloseBrace)
iter.find(|result| result.token_kind == TokenKind::CloseBrace)
{
last_decl_curly_offset = Some(range.end);
}
Expand Down
4 changes: 3 additions & 1 deletion clippy_dev/src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ pub fn run(port: u16, lint: Option<String>) -> ! {
});

loop {
if mtime("util/gh-pages/lints.json") < mtime("clippy_lints/src") {
let index_time = mtime("util/gh-pages/index.html");

if index_time < mtime("clippy_lints/src") || index_time < mtime("util/gh-pages/index_template.html") {
Command::new(env::var("CARGO").unwrap_or("cargo".into()))
.arg("collect-metadata")
.spawn()
Expand Down
1 change: 0 additions & 1 deletion clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ arrayvec = { version = "0.7", default-features = false }
cargo_metadata = "0.18"
clippy_config = { path = "../clippy_config" }
clippy_utils = { path = "../clippy_utils" }
declare_clippy_lint = { path = "../declare_clippy_lint" }
itertools = "0.12"
quine-mc_cluskey = "0.2"
regex-syntax = "0.8"
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/box_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl LateLintPass<'_> for BoxDefault {
// And the call is that of a `Box` method
&& path_def_id(cx, ty).map_or(false, |id| Some(id) == cx.tcx.lang_items().owned_box())
// And the single argument to the call is another function call
// This is the `T::default()` of `Box::new(T::default())`
// This is the `T::default()` (or default equivalent) of `Box::new(T::default())`
&& let ExprKind::Call(arg_path, _) = arg.kind
// And we are not in a foreign crate's macro
&& !in_external_macro(cx.sess(), expr.span)
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/byte_char_slices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl EarlyLintPass for ByteCharSlice {
"can be more succinctly written as a byte str",
"try",
format!("b\"{slice}\""),
Applicability::MaybeIncorrect,
Applicability::MachineApplicable,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/casts/cast_abs_to_unsigned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(super) fn check(
if msrv.meets(msrvs::UNSIGNED_ABS)
&& let ty::Int(from) = cast_from.kind()
&& let ty::Uint(to) = cast_to.kind()
&& let ExprKind::MethodCall(method_path, receiver, ..) = cast_expr.kind
&& let ExprKind::MethodCall(method_path, receiver, [], _) = cast_expr.kind
&& method_path.ident.name.as_str() == "abs"
{
let span = if from.bit_width() == to.bit_width() {
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/casts/cast_ptr_alignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
cx.typeck_results().expr_ty(expr),
);
lint_cast_ptr_alignment(cx, expr, cast_from, cast_to);
} else if let ExprKind::MethodCall(method_path, self_arg, ..) = &expr.kind {
} else if let ExprKind::MethodCall(method_path, self_arg, [], _) = &expr.kind {
if method_path.ident.name == sym!(cast)
&& let Some(generic_args) = method_path.args
&& let [GenericArg::Type(cast_to)] = generic_args.args
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/create_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ declare_lint_pass!(CreateDir => [CREATE_DIR]);

impl LateLintPass<'_> for CreateDir {
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
if let ExprKind::Call(func, [arg, ..]) = expr.kind
if let ExprKind::Call(func, [arg]) = expr.kind
&& let ExprKind::Path(ref path) = func.kind
&& let Some(def_id) = cx.qpath_res(path, func.hir_id).opt_def_id()
&& cx.tcx.is_diagnostic_item(sym::fs_create_dir, def_id)
Expand Down
Loading

0 comments on commit 224d1e3

Please sign in to comment.