Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 0 additions & 5 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 8 deletions
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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()

0 commit comments

Comments
 (0)