Skip to content

Commit 9725c4a

Browse files
committed
Auto merge of rust-lang#12632 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents 5a9e9b0 + bb023e9 commit 9725c4a

File tree

128 files changed

+417
-376
lines changed

Some content is hidden

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

128 files changed

+417
-376
lines changed

book/src/development/type_checking.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ Here the HIR sees the types without "thinking" about them, it knows that the fun
118118
an `u32`. As far as `hir::Ty` is concerned those might be different types. But at the `ty::Ty` level the compiler
119119
understands that they're the same type, in-depth lifetimes, etc...
120120

121-
To get from a `hir::Ty` to a `ty::Ty`, you can use the [`hir_ty_to_ty`][hir_ty_to_ty] function outside of bodies or
121+
To get from a `hir::Ty` to a `ty::Ty`, you can use the [`lower_ty`][lower_ty] function outside of bodies or
122122
the [`TypeckResults::node_type()`][node_type] method inside of bodies.
123123

124-
> **Warning**: Don't use `hir_ty_to_ty` inside of bodies, because this can cause ICEs.
124+
> **Warning**: Don't use `lower_ty` inside of bodies, because this can cause ICEs.
125125
126126
## Creating Types programmatically
127127

@@ -162,6 +162,6 @@ in this chapter:
162162
[Ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Ty.html
163163
[TyKind]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_type_ir/ty_kind/enum.TyKind.html
164164
[TypeckResults]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TypeckResults.html
165-
[middle_ty]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_middle/ty/struct.Ty.html
166-
[hir_ty]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_hir/struct.Ty.html
167-
[hir_ty_to_ty]: https://doc.rust-lang.org/beta/nightly-rustc/rustc_hir_analysis/fn.hir_ty_to_ty.html
165+
[middle_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.Ty.html
166+
[hir_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/struct.Ty.html
167+
[lower_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/fn.lower_ty.html

clippy_config/src/conf.rs

-5
Original file line numberDiff line numberDiff line change
@@ -856,11 +856,6 @@ mod tests {
856856
}
857857
}
858858

859-
assert!(
860-
names.remove("allow-one-hash-in-raw-strings"),
861-
"remove this when #11481 is fixed"
862-
);
863-
864859
assert!(
865860
names.is_empty(),
866861
"Configuration variable lacks test: {names:?}\nAdd a test to `tests/ui-toml`"

clippy_config/src/msrvs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ impl Msrv {
143143
None
144144
}
145145

146-
pub fn enter_lint_attrs(&mut self, sess: &Session, attrs: &[Attribute]) {
146+
pub fn check_attributes(&mut self, sess: &Session, attrs: &[Attribute]) {
147147
if let Some(version) = Self::parse_attr(sess, attrs) {
148148
self.stack.push(version);
149149
}
150150
}
151151

152-
pub fn exit_lint_attrs(&mut self, sess: &Session, attrs: &[Attribute]) {
152+
pub fn check_attributes_post(&mut self, sess: &Session, attrs: &[Attribute]) {
153153
if Self::parse_attr(sess, attrs).is_some() {
154154
self.stack.pop();
155155
}

clippy_lints/src/assigning_clones.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fn is_ok_to_suggest<'tcx>(cx: &LateContext<'tcx>, lhs: &Expr<'tcx>, call: &CallC
163163
// TODO: This check currently bails if the local variable has no initializer.
164164
// That is overly conservative - the lint should fire even if there was no initializer,
165165
// but the variable has been initialized before `lhs` was evaluated.
166-
if let Some(Node::Local(local)) = cx.tcx.hir().parent_id_iter(local).next().map(|p| cx.tcx.hir_node(p))
166+
if let Some(Node::LetStmt(local)) = cx.tcx.hir().parent_id_iter(local).next().map(|p| cx.tcx.hir_node(p))
167167
&& local.init.is_none()
168168
{
169169
return false;

clippy_lints/src/attrs/duplicated_attributes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ fn emit_if_duplicated(
2525
}
2626
}
2727

28-
#[allow(clippy::needless_return)]
2928
fn check_duplicated_attr(
3029
cx: &EarlyContext<'_>,
3130
attr: &MetaItem,
@@ -49,7 +48,8 @@ fn check_duplicated_attr(
4948
// FIXME: We don't correctly check `cfg`s for now, so if it's more complex than just a one
5049
// level `cfg`, we leave.
5150
return;
52-
} else if let Some(value) = attr.value_str() {
51+
}
52+
if let Some(value) = attr.value_str() {
5353
emit_if_duplicated(cx, attr, attr_paths, format!("{}:{name}={value}", parent.join(":")));
5454
} else if let Some(sub_attrs) = attr.meta_item_list() {
5555
parent.push(name.as_str().to_string());

clippy_lints/src/box_default.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clippy_utils::{is_default_equivalent, path_def_id};
55
use rustc_errors::Applicability;
66
use rustc_hir::def::Res;
77
use rustc_hir::intravisit::{walk_ty, Visitor};
8-
use rustc_hir::{Block, Expr, ExprKind, Local, Node, QPath, Ty, TyKind};
8+
use rustc_hir::{Block, Expr, ExprKind, LetStmt, Node, QPath, Ty, TyKind};
99
use rustc_lint::{LateContext, LateLintPass, LintContext};
1010
use rustc_middle::lint::in_external_macro;
1111
use rustc_session::declare_lint_pass;
@@ -102,7 +102,7 @@ impl<'tcx> Visitor<'tcx> for InferVisitor {
102102

103103
fn given_type(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
104104
match cx.tcx.parent_hir_node(expr.hir_id) {
105-
Node::Local(Local { ty: Some(ty), .. }) => {
105+
Node::LetStmt(LetStmt { ty: Some(ty), .. }) => {
106106
let mut v = InferVisitor::default();
107107
v.visit_ty(ty);
108108
!v.0

clippy_lints/src/casts/as_ptr_cast_mut.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@ use rustc_errors::Applicability;
44
use rustc_hir::{Expr, ExprKind};
55
use rustc_lint::LateContext;
66
use rustc_middle::mir::Mutability;
7-
use rustc_middle::ty::{self, Ty, TypeAndMut};
7+
use rustc_middle::ty::{self, Ty};
88

99
use super::AS_PTR_CAST_MUT;
1010

1111
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_to: Ty<'_>) {
12-
if let ty::RawPtr(TypeAndMut {
13-
mutbl: Mutability::Mut,
14-
ty: ptrty,
15-
}) = cast_to.kind()
16-
&& let ty::RawPtr(TypeAndMut {
17-
mutbl: Mutability::Not, ..
18-
}) = cx.typeck_results().node_type(cast_expr.hir_id).kind()
12+
if let ty::RawPtr(ptrty, Mutability::Mut) = cast_to.kind()
13+
&& let ty::RawPtr(_, Mutability::Not) = cx.typeck_results().node_type(cast_expr.hir_id).kind()
1914
&& let ExprKind::MethodCall(method_name, receiver, [], _) = cast_expr.peel_blocks().kind
2015
&& method_name.ident.name == rustc_span::sym::as_ptr
2116
&& let Some(as_ptr_did) = cx

clippy_lints/src/casts/cast_ptr_alignment.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
3333
}
3434

3535
fn lint_cast_ptr_alignment<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>, cast_from: Ty<'tcx>, cast_to: Ty<'tcx>) {
36-
if let ty::RawPtr(from_ptr_ty) = &cast_from.kind()
37-
&& let ty::RawPtr(to_ptr_ty) = &cast_to.kind()
38-
&& let Ok(from_layout) = cx.layout_of(from_ptr_ty.ty)
39-
&& let Ok(to_layout) = cx.layout_of(to_ptr_ty.ty)
36+
if let ty::RawPtr(from_ptr_ty, _) = *cast_from.kind()
37+
&& let ty::RawPtr(to_ptr_ty, _) = *cast_to.kind()
38+
&& let Ok(from_layout) = cx.layout_of(from_ptr_ty)
39+
&& let Ok(to_layout) = cx.layout_of(to_ptr_ty)
4040
&& from_layout.align.abi < to_layout.align.abi
4141
// with c_void, we inherently need to trust the user
42-
&& !is_c_void(cx, from_ptr_ty.ty)
42+
&& !is_c_void(cx, from_ptr_ty)
4343
// when casting from a ZST, we don't know enough to properly lint
4444
&& !from_layout.is_zst()
4545
&& !is_used_as_unaligned(cx, expr)

clippy_lints/src/casts/cast_slice_different_sizes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn is_child_of_cast(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
8787
/// the type is one of those slices
8888
fn get_raw_slice_ty_mut(ty: Ty<'_>) -> Option<TypeAndMut<'_>> {
8989
match ty.kind() {
90-
ty::RawPtr(TypeAndMut { ty: slice_ty, mutbl }) => match slice_ty.kind() {
90+
ty::RawPtr(slice_ty, mutbl) => match slice_ty.kind() {
9191
ty::Slice(ty) => Some(TypeAndMut { ty: *ty, mutbl: *mutbl }),
9292
_ => None,
9393
},

clippy_lints/src/casts/cast_slice_from_raw_parts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ fn raw_parts_kind(cx: &LateContext<'_>, did: DefId) -> Option<RawPartsKind> {
2525

2626
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_to: Ty<'_>, msrv: &Msrv) {
2727
if msrv.meets(msrvs::PTR_SLICE_RAW_PARTS)
28-
&& let ty::RawPtr(ptrty) = cast_to.kind()
29-
&& let ty::Slice(_) = ptrty.ty.kind()
28+
&& let ty::RawPtr(ptrty, _) = cast_to.kind()
29+
&& let ty::Slice(_) = ptrty.kind()
3030
&& let ExprKind::Call(fun, [ptr_arg, len_arg]) = cast_expr.peel_blocks().kind
3131
&& let ExprKind::Path(ref qpath) = fun.kind
3232
&& let Some(fun_def_id) = cx.qpath_res(qpath, fun.hir_id).opt_def_id()

clippy_lints/src/casts/ptr_as_ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_errors::Applicability;
66
use rustc_hir::{Expr, ExprKind, Mutability, QPath, TyKind};
77
use rustc_hir_pretty::qpath_to_string;
88
use rustc_lint::LateContext;
9-
use rustc_middle::ty::{self, TypeAndMut};
9+
use rustc_middle::ty;
1010
use rustc_span::sym;
1111

1212
use super::PTR_AS_PTR;
@@ -33,8 +33,8 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: &Msrv) {
3333

3434
if let ExprKind::Cast(cast_expr, cast_to_hir_ty) = expr.kind
3535
&& let (cast_from, cast_to) = (cx.typeck_results().expr_ty(cast_expr), cx.typeck_results().expr_ty(expr))
36-
&& let ty::RawPtr(TypeAndMut { mutbl: from_mutbl, .. }) = cast_from.kind()
37-
&& let ty::RawPtr(TypeAndMut { ty: to_pointee_ty, mutbl: to_mutbl }) = cast_to.kind()
36+
&& let ty::RawPtr(_, from_mutbl) = cast_from.kind()
37+
&& let ty::RawPtr(to_pointee_ty, to_mutbl) = cast_to.kind()
3838
&& matches!((from_mutbl, to_mutbl),
3939
(Mutability::Not, Mutability::Not) | (Mutability::Mut, Mutability::Mut))
4040
// The `U` in `pointer::cast` have to be `Sized`

clippy_lints/src/casts/ptr_cast_constness.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::sugg::Sugg;
44
use rustc_errors::Applicability;
55
use rustc_hir::{Expr, Mutability};
66
use rustc_lint::LateContext;
7-
use rustc_middle::ty::{self, Ty, TypeAndMut};
7+
use rustc_middle::ty::{self, Ty};
88

99
use super::PTR_CAST_CONSTNESS;
1010

@@ -17,14 +17,8 @@ pub(super) fn check<'tcx>(
1717
msrv: &Msrv,
1818
) {
1919
if msrv.meets(msrvs::POINTER_CAST_CONSTNESS)
20-
&& let ty::RawPtr(TypeAndMut {
21-
mutbl: from_mutbl,
22-
ty: from_ty,
23-
}) = cast_from.kind()
24-
&& let ty::RawPtr(TypeAndMut {
25-
mutbl: to_mutbl,
26-
ty: to_ty,
27-
}) = cast_to.kind()
20+
&& let ty::RawPtr(from_ty, from_mutbl) = cast_from.kind()
21+
&& let ty::RawPtr(to_ty, to_mutbl) = cast_to.kind()
2822
&& matches!(
2923
(from_mutbl, to_mutbl),
3024
(Mutability::Not, Mutability::Mut) | (Mutability::Mut, Mutability::Not)

clippy_lints/src/casts/ref_as_ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use clippy_utils::{expr_use_ctxt, is_no_std_crate, ExprUseNode};
55
use rustc_errors::Applicability;
66
use rustc_hir::{Expr, Mutability, Ty, TyKind};
77
use rustc_lint::LateContext;
8-
use rustc_middle::ty::{self, TypeAndMut};
8+
use rustc_middle::ty;
99

1010
use super::REF_AS_PTR;
1111

@@ -21,10 +21,10 @@ pub(super) fn check<'tcx>(
2121
);
2222

2323
if matches!(cast_from.kind(), ty::Ref(..))
24-
&& let ty::RawPtr(TypeAndMut { mutbl: to_mutbl, .. }) = cast_to.kind()
24+
&& let ty::RawPtr(_, to_mutbl) = cast_to.kind()
2525
&& let Some(use_cx) = expr_use_ctxt(cx, expr)
2626
// TODO: only block the lint if `cast_expr` is a temporary
27-
&& !matches!(use_cx.node, ExprUseNode::Local(_) | ExprUseNode::ConstStatic(_))
27+
&& !matches!(use_cx.node, ExprUseNode::LetStmt(_) | ExprUseNode::ConstStatic(_))
2828
{
2929
let core_or_std = if is_no_std_crate(cx) { "core" } else { "std" };
3030
let fn_name = match to_mutbl {

clippy_lints/src/casts/unnecessary_cast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub(super) fn check<'tcx>(
6666
&& let QPath::Resolved(None, Path { res, .. }) = qpath
6767
&& let Res::Local(hir_id) = res
6868
&& let parent = cx.tcx.parent_hir_node(*hir_id)
69-
&& let Node::Local(local) = parent
69+
&& let Node::LetStmt(local) = parent
7070
{
7171
if let Some(ty) = local.ty
7272
&& let TyKind::Path(qpath) = ty.kind
@@ -275,7 +275,7 @@ fn is_cast_from_ty_alias<'tcx>(cx: &LateContext<'tcx>, expr: impl Visitable<'tcx
275275
}
276276
// Local usage
277277
} else if let Res::Local(hir_id) = res
278-
&& let Node::Local(l) = cx.tcx.parent_hir_node(hir_id)
278+
&& let Node::LetStmt(l) = cx.tcx.parent_hir_node(hir_id)
279279
{
280280
if let Some(e) = l.init
281281
&& is_cast_from_ty_alias(cx, e, cast_from)

clippy_lints/src/cognitive_complexity.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ impl<'tcx> LateLintPass<'tcx> for CognitiveComplexity {
158158
}
159159
}
160160

161-
fn enter_lint_attrs(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
161+
fn check_attributes(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
162162
self.limit.push_attrs(cx.sess(), attrs, "cognitive_complexity");
163163
}
164-
fn exit_lint_attrs(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
164+
fn check_attributes_post(&mut self, cx: &LateContext<'tcx>, attrs: &'tcx [Attribute]) {
165165
self.limit.pop_attrs(cx.sess(), attrs, "cognitive_complexity");
166166
}
167167
}

clippy_lints/src/collection_is_never_read.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::ty::{is_type_diagnostic_item, is_type_lang_item};
33
use clippy_utils::visitors::for_each_expr_with_closures;
44
use clippy_utils::{get_enclosing_block, path_to_local_id};
55
use core::ops::ControlFlow;
6-
use rustc_hir::{Block, ExprKind, HirId, LangItem, Local, Node, PatKind};
6+
use rustc_hir::{Block, ExprKind, HirId, LangItem, LetStmt, Node, PatKind};
77
use rustc_lint::{LateContext, LateLintPass};
88
use rustc_session::declare_lint_pass;
99
use rustc_span::symbol::sym;
@@ -58,7 +58,7 @@ static COLLECTIONS: [Symbol; 9] = [
5858
];
5959

6060
impl<'tcx> LateLintPass<'tcx> for CollectionIsNeverRead {
61-
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx Local<'tcx>) {
61+
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx LetStmt<'tcx>) {
6262
// Look for local variables whose type is a container. Search surrounding bock for read access.
6363
if match_acceptable_type(cx, local, &COLLECTIONS)
6464
&& let PatKind::Binding(_, local_id, _, _) = local.pat.kind
@@ -70,7 +70,7 @@ impl<'tcx> LateLintPass<'tcx> for CollectionIsNeverRead {
7070
}
7171
}
7272

73-
fn match_acceptable_type(cx: &LateContext<'_>, local: &Local<'_>, collections: &[Symbol]) -> bool {
73+
fn match_acceptable_type(cx: &LateContext<'_>, local: &LetStmt<'_>, collections: &[Symbol]) -> bool {
7474
let ty = cx.typeck_results().pat_ty(local.pat);
7575
collections.iter().any(|&sym| is_type_diagnostic_item(cx, ty, sym))
7676
// String type is a lang item but not a diagnostic item for now so we need a separate check

clippy_lints/src/derive.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use rustc_lint::{LateContext, LateLintPass};
1111
use rustc_middle::hir::nested_filter;
1212
use rustc_middle::traits::Reveal;
1313
use rustc_middle::ty::{
14-
self, ClauseKind, GenericArgKind, GenericParamDefKind, ImplPolarity, ParamEnv, ToPredicate, TraitPredicate, Ty,
15-
TyCtxt,
14+
self, ClauseKind, GenericArgKind, GenericParamDefKind, ParamEnv, ToPredicate, TraitPredicate, Ty, TyCtxt,
1615
};
1716
use rustc_session::declare_lint_pass;
1817
use rustc_span::def_id::LocalDefId;
@@ -502,7 +501,7 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
502501
params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| {
503502
ClauseKind::Trait(TraitPredicate {
504503
trait_ref: ty::TraitRef::new(tcx, eq_trait_id, [tcx.mk_param_from_def(param)]),
505-
polarity: ImplPolarity::Positive,
504+
polarity: ty::PredicatePolarity::Positive,
506505
})
507506
.to_predicate(tcx)
508507
}),

clippy_lints/src/equatable_if_let.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn unary_pattern(pat: &Pat<'_>) -> bool {
5555
| PatKind::Err(_) => false,
5656
PatKind::Struct(_, a, etc) => !etc && a.iter().all(|x| unary_pattern(x.pat)),
5757
PatKind::Tuple(a, etc) | PatKind::TupleStruct(_, a, etc) => etc.as_opt_usize().is_none() && array_rec(a),
58-
PatKind::Ref(x, _) | PatKind::Box(x) => unary_pattern(x),
58+
PatKind::Ref(x, _) | PatKind::Box(x) | PatKind::Deref(x) => unary_pattern(x),
5959
PatKind::Path(_) | PatKind::Lit(_) => true,
6060
}
6161
}

clippy_lints/src/eta_reduction.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use rustc_hir::{BindingAnnotation, Expr, ExprKind, FnRetTy, Param, PatKind, QPat
99
use rustc_infer::infer::TyCtxtInferExt;
1010
use rustc_lint::{LateContext, LateLintPass};
1111
use rustc_middle::ty::{
12-
self, Binder, ClosureArgs, ClosureKind, FnSig, GenericArg, GenericArgKind, ImplPolarity, List, Region, RegionKind,
13-
Ty, TypeVisitableExt, TypeckResults,
12+
self, Binder, ClosureArgs, ClosureKind, FnSig, GenericArg, GenericArgKind, List, Region, RegionKind, Ty,
13+
TypeVisitableExt, TypeckResults,
1414
};
1515
use rustc_session::declare_lint_pass;
1616
use rustc_span::symbol::sym;
@@ -173,7 +173,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
173173
if let Ok((ClosureKind::FnMut, _)) = cx.tcx.infer_ctxt().build().type_implements_fn_trait(
174174
cx.param_env,
175175
Binder::bind_with_vars(callee_ty_adjusted, List::empty()),
176-
ImplPolarity::Positive,
176+
ty::PredicatePolarity::Positive,
177177
) && path_to_local(callee).map_or(false, |l| {
178178
local_used_in(cx, l, args) || local_used_after_expr(cx, l, expr)
179179
}) {

clippy_lints/src/float_literal.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
8383
LitFloatType::Unsuffixed => None,
8484
};
8585
let (is_whole, is_inf, mut float_str) = match fty {
86-
FloatTy::F16 => unimplemented!("f16_f128"),
86+
FloatTy::F16 | FloatTy::F128 => {
87+
// FIXME(f16_f128): do a check like the others when parsing is available
88+
return;
89+
},
8790
FloatTy::F32 => {
8891
let value = sym_str.parse::<f32>().unwrap();
8992

@@ -94,7 +97,6 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
9497

9598
(value.fract() == 0.0, value.is_infinite(), formatter.format(value))
9699
},
97-
FloatTy::F128 => unimplemented!("f16_f128"),
98100
};
99101

100102
if is_inf {
@@ -139,10 +141,11 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
139141
#[must_use]
140142
fn max_digits(fty: FloatTy) -> u32 {
141143
match fty {
142-
FloatTy::F16 => unimplemented!("f16_f128"),
144+
// FIXME(f16_f128): replace the magic numbers once `{f16,f128}::DIGITS` are available
145+
FloatTy::F16 => 3,
143146
FloatTy::F32 => f32::DIGITS,
144147
FloatTy::F64 => f64::DIGITS,
145-
FloatTy::F128 => unimplemented!("f16_f128"),
148+
FloatTy::F128 => 33,
146149
}
147150
}
148151

clippy_lints/src/from_raw_with_void_ptr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::ty::is_c_void;
44
use rustc_hir::def_id::DefId;
55
use rustc_hir::{Expr, ExprKind, QPath};
66
use rustc_lint::{LateContext, LateLintPass};
7-
use rustc_middle::ty::{RawPtr, TypeAndMut};
7+
use rustc_middle::ty::RawPtr;
88
use rustc_session::declare_lint_pass;
99
use rustc_span::sym;
1010

@@ -44,7 +44,7 @@ impl LateLintPass<'_> for FromRawWithVoidPtr {
4444
&& seg.ident.name == sym!(from_raw)
4545
&& let Some(type_str) = path_def_id(cx, ty).and_then(|id| def_id_matches_type(cx, id))
4646
&& let arg_kind = cx.typeck_results().expr_ty(arg).kind()
47-
&& let RawPtr(TypeAndMut { ty, .. }) = arg_kind
47+
&& let RawPtr(ty, _) = arg_kind
4848
&& is_c_void(cx, *ty)
4949
{
5050
let msg = format!("creating a `{type_str}` from a void raw pointer");

clippy_lints/src/functions/misnamed_getters.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ pub fn check_fn(cx: &LateContext<'_>, kind: FnKind<'_>, decl: &FnDecl<'_>, body:
2424
let name = ident.name.as_str();
2525

2626
let name = match decl.implicit_self {
27-
ImplicitSelfKind::MutRef => {
27+
ImplicitSelfKind::RefMut => {
2828
let Some(name) = name.strip_suffix("_mut") else {
2929
return;
3030
};
3131
name
3232
},
33-
ImplicitSelfKind::Imm | ImplicitSelfKind::Mut | ImplicitSelfKind::ImmRef => name,
33+
ImplicitSelfKind::Imm | ImplicitSelfKind::Mut | ImplicitSelfKind::RefImm => name,
3434
ImplicitSelfKind::None => return,
3535
};
3636

0 commit comments

Comments
 (0)