Skip to content

Commit 51d49c1

Browse files
authored
Rustup (#14080)
r? @ghost changelog: none
2 parents 25509e7 + 336a259 commit 51d49c1

File tree

129 files changed

+639
-724
lines changed

Some content is hidden

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

129 files changed

+639
-724
lines changed

.github/driver.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ unset CARGO_MANIFEST_DIR
4747

4848
# Run a lint and make sure it produces the expected output. It's also expected to exit with code 1
4949
# FIXME: How to match the clippy invocation in compile-test.rs?
50-
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/double_neg.rs 2>double_neg.stderr && exit 1
51-
sed -e "/= help: for/d" double_neg.stderr > normalized.stderr
52-
diff -u normalized.stderr tests/ui/double_neg.stderr
50+
./target/debug/clippy-driver -Dwarnings -Aunused -Zui-testing --emit metadata --crate-type bin tests/ui/string_to_string.rs 2>string_to_string.stderr && exit 1
51+
sed -e "/= help: for/d" string_to_string.stderr > normalized.stderr
52+
diff -u normalized.stderr tests/ui/string_to_string.stderr
5353

5454
# make sure "clippy-driver --rustc --arg" and "rustc --arg" behave the same
5555
SYSROOT=$(rustc --print sysroot)

book/src/usage.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ You can configure lint levels on the command line by adding
3333
`-A/W/D clippy::lint_name` like this:
3434

3535
```bash
36-
cargo clippy -- -Aclippy::style -Wclippy::double_neg -Dclippy::perf
36+
cargo clippy -- -Aclippy::style -Wclippy::box_default -Dclippy::perf
3737
```
3838

3939
For [CI] all warnings can be elevated to errors which will in turn fail
@@ -101,11 +101,10 @@ You can configure lint levels in source code the same way you can configure
101101
```rust,ignore
102102
#![allow(clippy::style)]
103103
104-
#[warn(clippy::double_neg)]
104+
#[warn(clippy::box_default)]
105105
fn main() {
106-
let x = 1;
107-
let y = --x;
108-
// ^^ warning: double negation
106+
let _ = Box::<String>::new(Default::default());
107+
// ^ warning: `Box::new(_)` of default value
109108
}
110109
```
111110

clippy_lints/src/box_default.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use clippy_utils::ty::expr_sig;
44
use clippy_utils::{is_default_equivalent, path_def_id};
55
use rustc_errors::Applicability;
66
use rustc_hir::def::Res;
7-
use rustc_hir::intravisit::{Visitor, walk_ty};
8-
use rustc_hir::{Block, Expr, ExprKind, LetStmt, Node, QPath, Ty, TyKind};
7+
use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt, walk_ty};
8+
use rustc_hir::{AmbigArg, Block, Expr, ExprKind, HirId, 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;
12-
use rustc_span::sym;
12+
use rustc_span::{Span, sym};
1313

1414
declare_clippy_lint! {
1515
/// ### What it does
@@ -92,8 +92,13 @@ fn is_local_vec_expn(cx: &LateContext<'_>, expr: &Expr<'_>, ref_expr: &Expr<'_>)
9292
struct InferVisitor(bool);
9393

9494
impl Visitor<'_> for InferVisitor {
95-
fn visit_ty(&mut self, t: &Ty<'_>) {
96-
self.0 |= matches!(t.kind, TyKind::Infer | TyKind::OpaqueDef(..) | TyKind::TraitObject(..));
95+
fn visit_infer(&mut self, inf_id: HirId, _inf_span: Span, _kind: InferKind<'_>) -> Self::Result {
96+
self.0 = true;
97+
self.visit_id(inf_id);
98+
}
99+
100+
fn visit_ty(&mut self, t: &Ty<'_, AmbigArg>) {
101+
self.0 |= matches!(t.kind, TyKind::OpaqueDef(..) | TyKind::TraitObject(..));
97102
if !self.0 {
98103
walk_ty(self, t);
99104
}
@@ -104,7 +109,7 @@ fn given_type(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
104109
match cx.tcx.parent_hir_node(expr.hir_id) {
105110
Node::LetStmt(LetStmt { ty: Some(ty), .. }) => {
106111
let mut v = InferVisitor::default();
107-
v.visit_ty(ty);
112+
v.visit_ty_unambig(ty);
108113
!v.0
109114
},
110115
Node::Expr(Expr {

clippy_lints/src/casts/as_pointer_underscore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_middle::ty::Ty;
44

55
pub fn check<'tcx>(cx: &LateContext<'tcx>, ty_into: Ty<'_>, cast_to_hir: &'tcx rustc_hir::Ty<'tcx>) {
66
if let rustc_hir::TyKind::Ptr(rustc_hir::MutTy { ty, .. }) = cast_to_hir.kind
7-
&& matches!(ty.kind, rustc_hir::TyKind::Infer)
7+
&& matches!(ty.kind, rustc_hir::TyKind::Infer(()))
88
{
99
clippy_utils::diagnostics::span_lint_and_sugg(
1010
cx,

clippy_lints/src/casts/as_underscore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_middle::ty;
77
use super::AS_UNDERSCORE;
88

99
pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, ty: &'tcx Ty<'_>) {
10-
if matches!(ty.kind, TyKind::Infer) {
10+
if matches!(ty.kind, TyKind::Infer(())) {
1111
span_lint_and_then(cx, AS_UNDERSCORE, expr.span, "using `as _` conversion", |diag| {
1212
let ty_resolved = cx.typeck_results().expr_ty(expr);
1313
if let ty::Error(_) = ty_resolved.kind() {

clippy_lints/src/casts/cast_lossless.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub(super) fn check(
3838
return;
3939
};
4040
match cast_to_hir.kind {
41-
TyKind::Infer => {
41+
TyKind::Infer(()) => {
4242
diag.span_suggestion_verbose(
4343
expr.span,
4444
"use `Into::into` instead",

clippy_lints/src/casts/cast_ptr_alignment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
2424
&& let Some(generic_args) = method_path.args
2525
&& let [GenericArg::Type(cast_to)] = generic_args.args
2626
// There probably is no obvious reason to do this, just to be consistent with `as` cases.
27-
&& !is_hir_ty_cfg_dependant(cx, cast_to)
27+
&& !is_hir_ty_cfg_dependant(cx, cast_to.as_unambig_ty())
2828
{
2929
let (cast_from, cast_to) = (cx.typeck_results().expr_ty(self_arg), cx.typeck_results().expr_ty(expr));
3030
lint_cast_ptr_alignment(cx, expr, cast_from, cast_to);

clippy_lints/src/casts/ptr_as_ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, msrv: &Msrv) {
4343
{
4444
let mut app = Applicability::MachineApplicable;
4545
let turbofish = match &cast_to_hir_ty.kind {
46-
TyKind::Infer => String::new(),
46+
TyKind::Infer(()) => String::new(),
4747
TyKind::Ptr(mut_ty) => {
48-
if matches!(mut_ty.ty.kind, TyKind::Infer) {
48+
if matches!(mut_ty.ty.kind, TyKind::Infer(())) {
4949
String::new()
5050
} else {
5151
format!(

clippy_lints/src/casts/ref_as_ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ pub(super) fn check<'tcx>(
3434

3535
let mut app = Applicability::MachineApplicable;
3636
let turbofish = match &cast_to_hir_ty.kind {
37-
TyKind::Infer => String::new(),
37+
TyKind::Infer(()) => String::new(),
3838
TyKind::Ptr(mut_ty) => {
39-
if matches!(mut_ty.ty.kind, TyKind::Infer) {
39+
if matches!(mut_ty.ty.kind, TyKind::Infer(())) {
4040
String::new()
4141
} else {
4242
format!(

clippy_lints/src/casts/unnecessary_cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub(super) fn check<'tcx>(
4343
}
4444
},
4545
// Ignore `p as *const _`
46-
TyKind::Infer => return false,
46+
TyKind::Infer(()) => return false,
4747
_ => {},
4848
}
4949

0 commit comments

Comments
 (0)