Skip to content

Commit c950602

Browse files
authored
Rustup (#15148)
r? @ghost changelog: none
2 parents 8050e59 + 32fcff8 commit c950602

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+277
-213
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.89"
3+
version = "0.1.90"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"
@@ -59,6 +59,7 @@ rustc_tools_util = { path = "rustc_tools_util", version = "0.4.2" }
5959
[features]
6060
integration = ["dep:tempfile"]
6161
internal = ["dep:clippy_lints_internal", "dep:tempfile"]
62+
jemalloc = []
6263

6364
[package.metadata.rust-analyzer]
6465
# This package uses #[feature(rustc_private)]

clippy_config/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_config"
3-
version = "0.1.89"
3+
version = "0.1.90"
44
edition = "2024"
55
publish = false
66

clippy_dev/src/update_lints.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,17 +386,13 @@ pub fn read_deprecated_lints() -> (Vec<DeprecatedLint>, Vec<RenamedLint>) {
386386

387387
/// Removes the line splices and surrounding quotes from a string literal
388388
fn parse_str_lit(s: &str) -> String {
389-
let (s, mode) = if let Some(s) = s.strip_prefix("r") {
390-
(s.trim_matches('#'), rustc_literal_escaper::Mode::RawStr)
391-
} else {
392-
(s, rustc_literal_escaper::Mode::Str)
393-
};
389+
let s = s.strip_prefix("r").unwrap_or(s).trim_matches('#');
394390
let s = s
395391
.strip_prefix('"')
396392
.and_then(|s| s.strip_suffix('"'))
397393
.unwrap_or_else(|| panic!("expected quoted string, found `{s}`"));
398394
let mut res = String::with_capacity(s.len());
399-
rustc_literal_escaper::unescape_unicode(s, mode, &mut |_, ch| {
395+
rustc_literal_escaper::unescape_str(s, &mut |_, ch| {
400396
if let Ok(ch) = ch {
401397
res.push(ch);
402398
}

clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.89"
3+
version = "0.1.90"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"
Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
use super::INLINE_ALWAYS;
2-
use super::utils::is_word;
32
use clippy_utils::diagnostics::span_lint;
3+
use rustc_attr_data_structures::{AttributeKind, InlineAttr, find_attr};
44
use rustc_hir::Attribute;
55
use rustc_lint::LateContext;
6+
use rustc_span::Span;
67
use rustc_span::symbol::Symbol;
7-
use rustc_span::{Span, sym};
88

99
pub(super) fn check(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribute]) {
1010
if span.from_expansion() {
1111
return;
1212
}
1313

14-
for attr in attrs {
15-
if let Some(values) = attr.meta_item_list() {
16-
if values.len() != 1 || !attr.has_name(sym::inline) {
17-
continue;
18-
}
19-
if is_word(&values[0], sym::always) {
20-
span_lint(
21-
cx,
22-
INLINE_ALWAYS,
23-
attr.span(),
24-
format!("you have declared `#[inline(always)]` on `{name}`. This is usually a bad idea"),
25-
);
26-
}
27-
}
14+
if let Some(span) = find_attr!(attrs, AttributeKind::Inline(InlineAttr::Always, span) => *span) {
15+
span_lint(
16+
cx,
17+
INLINE_ALWAYS,
18+
span,
19+
format!("you have declared `#[inline(always)]` on `{name}`. This is usually a bad idea"),
20+
);
2821
}
2922
}

clippy_lints/src/bool_assert_comparison.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn is_impl_not_trait_with_bool_out<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -
5656
.and_then(|trait_id| {
5757
cx.tcx.associated_items(trait_id).find_by_ident_and_kind(
5858
cx.tcx,
59-
Ident::from_str("Output"),
59+
Ident::with_dummy_span(sym::Output),
6060
ty::AssocTag::Type,
6161
trait_id,
6262
)

clippy_lints/src/casts/manual_dangling_ptr.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
22
use clippy_utils::source::SpanRangeExt;
3-
use clippy_utils::{expr_or_init, path_def_id, paths, std_or_core};
3+
use clippy_utils::{expr_or_init, is_path_diagnostic_item, std_or_core, sym};
44
use rustc_ast::LitKind;
55
use rustc_errors::Applicability;
66
use rustc_hir::{Expr, ExprKind, GenericArg, Mutability, QPath, Ty, TyKind};
@@ -53,8 +53,7 @@ fn is_expr_const_aligned(cx: &LateContext<'_>, expr: &Expr<'_>, to: &Ty<'_>) ->
5353

5454
fn is_align_of_call(cx: &LateContext<'_>, fun: &Expr<'_>, to: &Ty<'_>) -> bool {
5555
if let ExprKind::Path(QPath::Resolved(_, path)) = fun.kind
56-
&& let Some(fun_id) = path_def_id(cx, fun)
57-
&& paths::ALIGN_OF.matches(cx, fun_id)
56+
&& is_path_diagnostic_item(cx, fun, sym::mem_align_of)
5857
&& let Some(args) = path.segments.last().and_then(|seg| seg.args)
5958
&& let [GenericArg::Type(generic_ty)] = args.args
6059
{

clippy_lints/src/casts/unnecessary_cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ pub(super) fn check<'tcx>(
185185
Node::Expr(parent) if is_borrow_expr(cx, parent) && !is_in_allowed_macro(cx, parent) => {
186186
MaybeParenOrBlock::Block
187187
},
188-
Node::Expr(parent) if cast_expr.precedence() < parent.precedence() => MaybeParenOrBlock::Paren,
188+
Node::Expr(parent) if cx.precedence(cast_expr) < cx.precedence(parent) => MaybeParenOrBlock::Paren,
189189
_ => MaybeParenOrBlock::Nothing,
190190
};
191191

clippy_lints/src/coerce_container_to_any.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ declare_clippy_lint! {
4242
/// ```
4343
#[clippy::version = "1.88.0"]
4444
pub COERCE_CONTAINER_TO_ANY,
45-
suspicious,
45+
nursery,
4646
"coercing to `&dyn Any` when dereferencing could produce a `dyn Any` without coercion is usually not intended"
4747
}
4848
declare_lint_pass!(CoerceContainerToAny => [COERCE_CONTAINER_TO_ANY]);

clippy_lints/src/dereference.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ fn report<'tcx>(
972972
"&"
973973
};
974974

975-
let expr_str = if !expr_is_macro_call && is_ufcs && expr.precedence() < ExprPrecedence::Prefix {
975+
let expr_str = if !expr_is_macro_call && is_ufcs && cx.precedence(expr) < ExprPrecedence::Prefix {
976976
Cow::Owned(format!("({expr_str})"))
977977
} else {
978978
expr_str
@@ -1015,10 +1015,10 @@ fn report<'tcx>(
10151015
Node::Expr(e) => match e.kind {
10161016
ExprKind::Call(callee, _) if callee.hir_id != data.first_expr.hir_id => false,
10171017
ExprKind::Call(..) => {
1018-
expr.precedence() < ExprPrecedence::Unambiguous
1018+
cx.precedence(expr) < ExprPrecedence::Unambiguous
10191019
|| matches!(expr.kind, ExprKind::Field(..))
10201020
},
1021-
_ => expr.precedence() < e.precedence(),
1021+
_ => cx.precedence(expr) < cx.precedence(e),
10221022
},
10231023
_ => false,
10241024
};
@@ -1066,7 +1066,7 @@ fn report<'tcx>(
10661066
Mutability::Not => "&",
10671067
Mutability::Mut => "&mut ",
10681068
};
1069-
(prefix, expr.precedence() < ExprPrecedence::Prefix)
1069+
(prefix, cx.precedence(expr) < ExprPrecedence::Prefix)
10701070
},
10711071
None if !ty.is_ref() && data.adjusted_ty.is_ref() => ("&", false),
10721072
_ => ("", false),
@@ -1172,7 +1172,7 @@ impl<'tcx> Dereferencing<'tcx> {
11721172
},
11731173
Some(parent) if !parent.span.from_expansion() => {
11741174
// Double reference might be needed at this point.
1175-
if parent.precedence() == ExprPrecedence::Unambiguous {
1175+
if cx.precedence(parent) == ExprPrecedence::Unambiguous {
11761176
// Parentheses would be needed here, don't lint.
11771177
*outer_pat = None;
11781178
} else {

0 commit comments

Comments
 (0)