Skip to content

Commit 51d49c1

Browse files
authored
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

Diff for: .github/driver.sh

+3-3
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)

Diff for: book/src/usage.md

+4-5
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

Diff for: clippy_lints/src/box_default.rs

+11-6
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 {

Diff for: clippy_lints/src/casts/as_pointer_underscore.rs

+1-1
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,

Diff for: clippy_lints/src/casts/as_underscore.rs

+1-1
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() {

Diff for: clippy_lints/src/casts/cast_lossless.rs

+1-1
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",

Diff for: clippy_lints/src/casts/cast_ptr_alignment.rs

+1-1
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);

Diff for: clippy_lints/src/casts/ptr_as_ptr.rs

+2-2
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!(

Diff for: clippy_lints/src/casts/ref_as_ptr.rs

+2-2
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!(

Diff for: clippy_lints/src/casts/unnecessary_cast.rs

+1-1
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

Diff for: clippy_lints/src/casts/zero_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn check(cx: &LateContext<'_>, expr: &Expr<'_>, from: &Expr<'_>, to: &Ty<'_>
1818
Mutability::Not => ("`0 as *const _` detected", "ptr::null"),
1919
};
2020

21-
let sugg = if let TyKind::Infer = mut_ty.ty.kind {
21+
let sugg = if let TyKind::Infer(()) = mut_ty.ty.kind {
2222
format!("{std_or_core}::{sugg_fn}()")
2323
} else if let Some(mut_ty_snip) = mut_ty.ty.span.get_source_text(cx) {
2424
format!("{std_or_core}::{sugg_fn}::<{mut_ty_snip}>()")

Diff for: clippy_lints/src/declared_lints.rs

-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,6 @@ pub static LINTS: &[&crate::LintInfo] = &[
512512
crate::misc::USED_UNDERSCORE_BINDING_INFO,
513513
crate::misc::USED_UNDERSCORE_ITEMS_INFO,
514514
crate::misc_early::BUILTIN_TYPE_SHADOW_INFO,
515-
crate::misc_early::DOUBLE_NEG_INFO,
516515
crate::misc_early::DUPLICATE_UNDERSCORE_ARGUMENT_INFO,
517516
crate::misc_early::MIXED_CASE_HEX_LITERALS_INFO,
518517
crate::misc_early::REDUNDANT_AT_REST_PATTERN_INFO,

Diff for: clippy_lints/src/default_numeric_fallback.rs

+19-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ use clippy_utils::numeric_literal;
33
use clippy_utils::source::snippet_opt;
44
use rustc_ast::ast::{LitFloatType, LitIntType, LitKind};
55
use rustc_errors::Applicability;
6-
use rustc_hir::intravisit::{Visitor, walk_expr, walk_stmt};
7-
use rustc_hir::{Block, Body, ConstContext, Expr, ExprKind, FnRetTy, HirId, Lit, Stmt, StmtKind, StructTailExpr};
6+
use rustc_hir::intravisit::{Visitor, walk_expr, walk_pat, walk_stmt};
7+
use rustc_hir::{
8+
Block, Body, ConstContext, Expr, ExprKind, FnRetTy, HirId, Lit, Pat, PatExpr, PatExprKind, PatKind, Stmt, StmtKind,
9+
StructTailExpr,
10+
};
811
use rustc_lint::{LateContext, LateLintPass, LintContext};
912
use rustc_middle::lint::in_external_macro;
1013
use rustc_middle::ty::{self, FloatTy, IntTy, PolyFnSig, Ty};
@@ -219,6 +222,20 @@ impl<'tcx> Visitor<'tcx> for NumericFallbackVisitor<'_, 'tcx> {
219222
walk_expr(self, expr);
220223
}
221224

225+
fn visit_pat(&mut self, pat: &'tcx Pat<'_>) {
226+
if let PatKind::Expr(&PatExpr {
227+
hir_id,
228+
kind: PatExprKind::Lit { lit, .. },
229+
..
230+
}) = pat.kind
231+
{
232+
let ty = self.cx.typeck_results().node_type(hir_id);
233+
self.check_lit(lit, ty, hir_id);
234+
return;
235+
}
236+
walk_pat(self, pat);
237+
}
238+
222239
fn visit_stmt(&mut self, stmt: &'tcx Stmt<'_>) {
223240
match stmt.kind {
224241
// we cannot check the exact type since it's a hir::Ty which does not implement `is_numeric`

Diff for: clippy_lints/src/deprecated_lints.rs

+2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ declare_with_version! { RENAMED(RENAMED_VERSION): &[(&str, &str)] = &[
129129
("clippy::clone_double_ref", "suspicious_double_ref_op"),
130130
#[clippy::version = ""]
131131
("clippy::cmp_nan", "invalid_nan_comparisons"),
132+
#[clippy::version = "1.86.0"]
133+
("clippy::double_neg", "double_negations"),
132134
#[clippy::version = ""]
133135
("clippy::drop_bounds", "drop_bounds"),
134136
#[clippy::version = ""]

Diff for: clippy_lints/src/dereference.rs

+13-19
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ use rustc_ast::util::parser::ExprPrecedence;
1111
use rustc_data_structures::fx::FxIndexMap;
1212
use rustc_errors::Applicability;
1313
use rustc_hir::def_id::DefId;
14-
use rustc_hir::intravisit::{Visitor, walk_ty};
14+
use rustc_hir::intravisit::{InferKind, Visitor, VisitorExt, walk_ty};
1515
use rustc_hir::{
16-
self as hir, BindingMode, Body, BodyId, BorrowKind, Expr, ExprKind, HirId, MatchSource, Mutability, Node, Pat,
17-
PatKind, Path, QPath, TyKind, UnOp,
16+
self as hir, AmbigArg, BindingMode, Body, BodyId, BorrowKind, Expr, ExprKind, HirId, MatchSource, Mutability, Node,
17+
Pat, PatKind, Path, QPath, TyKind, UnOp,
1818
};
1919
use rustc_lint::{LateContext, LateLintPass};
2020
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
@@ -796,7 +796,7 @@ impl TyCoercionStability {
796796
if let Some(args) = path.args
797797
&& args.args.iter().any(|arg| match arg {
798798
hir::GenericArg::Infer(_) => true,
799-
hir::GenericArg::Type(ty) => ty_contains_infer(ty),
799+
hir::GenericArg::Type(ty) => ty_contains_infer(ty.as_unambig_ty()),
800800
_ => false,
801801
})
802802
{
@@ -815,7 +815,7 @@ impl TyCoercionStability {
815815
| TyKind::Path(_) => Self::Deref,
816816
TyKind::OpaqueDef(..)
817817
| TyKind::TraitAscription(..)
818-
| TyKind::Infer
818+
| TyKind::Infer(())
819819
| TyKind::Typeof(..)
820820
| TyKind::TraitObject(..)
821821
| TyKind::InferDelegation(..)
@@ -889,29 +889,23 @@ impl TyCoercionStability {
889889
fn ty_contains_infer(ty: &hir::Ty<'_>) -> bool {
890890
struct V(bool);
891891
impl Visitor<'_> for V {
892-
fn visit_ty(&mut self, ty: &hir::Ty<'_>) {
893-
if self.0
894-
|| matches!(
895-
ty.kind,
896-
TyKind::OpaqueDef(..) | TyKind::Infer | TyKind::Typeof(_) | TyKind::Err(_)
897-
)
898-
{
892+
fn visit_infer(&mut self, inf_id: HirId, _inf_span: Span, kind: InferKind<'_>) -> Self::Result {
893+
if let InferKind::Ty(_) | InferKind::Ambig(_) = kind {
899894
self.0 = true;
900-
} else {
901-
walk_ty(self, ty);
902895
}
896+
self.visit_id(inf_id);
903897
}
904898

905-
fn visit_generic_arg(&mut self, arg: &hir::GenericArg<'_>) {
906-
if self.0 || matches!(arg, hir::GenericArg::Infer(_)) {
899+
fn visit_ty(&mut self, ty: &hir::Ty<'_, AmbigArg>) {
900+
if self.0 || matches!(ty.kind, TyKind::OpaqueDef(..) | TyKind::Typeof(_) | TyKind::Err(_)) {
907901
self.0 = true;
908-
} else if let hir::GenericArg::Type(ty) = arg {
909-
self.visit_ty(ty);
902+
} else {
903+
walk_ty(self, ty);
910904
}
911905
}
912906
}
913907
let mut v = V(false);
914-
v.visit_ty(ty);
908+
v.visit_ty_unambig(ty);
915909
v.0
916910
}
917911

Diff for: clippy_lints/src/derive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ impl<'tcx> Visitor<'tcx> for UnsafeVisitor<'_, 'tcx> {
419419
id: LocalDefId,
420420
) -> Self::Result {
421421
if let Some(header) = kind.header()
422-
&& header.safety.is_unsafe()
422+
&& header.is_unsafe()
423423
{
424424
ControlFlow::Break(())
425425
} else {

Diff for: clippy_lints/src/disallowed_macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_data_structures::fx::FxHashSet;
66
use rustc_errors::Diag;
77
use rustc_hir::def_id::DefIdMap;
88
use rustc_hir::{
9-
Expr, ExprKind, ForeignItem, HirId, ImplItem, Item, ItemKind, OwnerId, Pat, Path, Stmt, TraitItem, Ty,
9+
AmbigArg, Expr, ExprKind, ForeignItem, HirId, ImplItem, Item, ItemKind, OwnerId, Pat, Path, Stmt, TraitItem, Ty,
1010
};
1111
use rustc_lint::{LateContext, LateLintPass};
1212
use rustc_middle::ty::TyCtxt;
@@ -140,7 +140,7 @@ impl LateLintPass<'_> for DisallowedMacros {
140140
self.check(cx, stmt.span, None);
141141
}
142142

143-
fn check_ty(&mut self, cx: &LateContext<'_>, ty: &Ty<'_>) {
143+
fn check_ty(&mut self, cx: &LateContext<'_>, ty: &Ty<'_, AmbigArg>) {
144144
self.check(cx, ty.span, None);
145145
}
146146

Diff for: clippy_lints/src/disallowed_types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
33
use rustc_data_structures::fx::FxHashMap;
44
use rustc_hir::def::Res;
55
use rustc_hir::def_id::DefIdMap;
6-
use rustc_hir::{Item, ItemKind, PolyTraitRef, PrimTy, Ty, TyKind, UseKind};
6+
use rustc_hir::{AmbigArg, Item, ItemKind, PolyTraitRef, PrimTy, Ty, TyKind, UseKind};
77
use rustc_lint::{LateContext, LateLintPass};
88
use rustc_middle::ty::TyCtxt;
99
use rustc_session::impl_lint_pass;
@@ -108,7 +108,7 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedTypes {
108108
}
109109
}
110110

111-
fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx Ty<'tcx>) {
111+
fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx Ty<'tcx, AmbigArg>) {
112112
if let TyKind::Path(path) = &ty.kind {
113113
self.check_res_emit(cx, &cx.qpath_res(path, ty.hir_id), ty.span);
114114
}

Diff for: clippy_lints/src/doc/missing_headers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn check(
3232
}
3333

3434
let span = cx.tcx.def_span(owner_id);
35-
match (headers.safety, sig.header.safety) {
35+
match (headers.safety, sig.header.safety()) {
3636
(false, Safety::Unsafe) => span_lint(
3737
cx,
3838
MISSING_SAFETY_DOC,

Diff for: clippy_lints/src/equatable_if_let.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn unary_pattern(pat: &Pat<'_>) -> bool {
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),
5858
PatKind::Ref(x, _) | PatKind::Box(x) | PatKind::Deref(x) | PatKind::Guard(x, _) => unary_pattern(x),
59-
PatKind::Path(_) | PatKind::Lit(_) => true,
59+
PatKind::Path(_) | PatKind::Expr(_) => true,
6060
}
6161
}
6262

Diff for: clippy_lints/src/eta_reduction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
9393
#[allow(clippy::too_many_lines)]
9494
fn check_closure<'tcx>(cx: &LateContext<'tcx>, outer_receiver: Option<&Expr<'tcx>>, expr: &Expr<'tcx>) {
9595
let body = if let ExprKind::Closure(c) = expr.kind
96-
&& c.fn_decl.inputs.iter().all(|ty| matches!(ty.kind, TyKind::Infer))
96+
&& c.fn_decl.inputs.iter().all(|ty| matches!(ty.kind, TyKind::Infer(())))
9797
&& matches!(c.fn_decl.output, FnRetTy::DefaultReturn(_))
9898
&& !expr.span.from_expansion()
9999
{

Diff for: clippy_lints/src/extra_unused_type_parameters.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then};
33
use clippy_utils::{is_from_proc_macro, trait_ref_of_method};
44
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
55
use rustc_errors::Applicability;
6-
use rustc_hir::intravisit::{Visitor, walk_impl_item, walk_item, walk_param_bound, walk_ty};
6+
use rustc_hir::intravisit::{Visitor, walk_impl_item, walk_item, walk_param_bound, walk_ty, walk_unambig_ty};
77
use rustc_hir::{
8-
BodyId, ExprKind, GenericBound, GenericParam, GenericParamKind, Generics, ImplItem, ImplItemKind, Item, ItemKind,
9-
PredicateOrigin, Ty, WherePredicate, WherePredicateKind,
8+
AmbigArg, BodyId, ExprKind, GenericBound, GenericParam, GenericParamKind, Generics, ImplItem, ImplItemKind, Item,
9+
ItemKind, PredicateOrigin, Ty, WherePredicate, WherePredicateKind,
1010
};
1111
use rustc_lint::{LateContext, LateLintPass, LintContext};
1212
use rustc_middle::hir::nested_filter;
@@ -196,7 +196,7 @@ fn bound_to_trait_def_id(bound: &GenericBound<'_>) -> Option<LocalDefId> {
196196
impl<'tcx> Visitor<'tcx> for TypeWalker<'_, 'tcx> {
197197
type NestedFilter = nested_filter::OnlyBodies;
198198

199-
fn visit_ty(&mut self, t: &'tcx Ty<'tcx>) {
199+
fn visit_ty(&mut self, t: &'tcx Ty<'tcx, AmbigArg>) {
200200
if let Some((def_id, _)) = t.peel_refs().as_generic_param() {
201201
self.ty_params.remove(&def_id);
202202
} else {
@@ -234,7 +234,7 @@ impl<'tcx> Visitor<'tcx> for TypeWalker<'_, 'tcx> {
234234
// type, any params we find nested inside of it are being used as concrete types,
235235
// and can therefore can be considered used. So, we're fine to walk the left-hand
236236
// side of the where bound.
237-
walk_ty(self, predicate.bounded_ty);
237+
walk_unambig_ty(self, predicate.bounded_ty);
238238
}
239239
for bound in predicate.bounds {
240240
walk_param_bound(self, bound);

Diff for: clippy_lints/src/from_over_into.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ impl<'tcx> LateLintPass<'tcx> for FromOverInto {
103103
"replace the `Into` implementation with `From<{}>`",
104104
middle_trait_ref.self_ty()
105105
);
106-
if let Some(suggestions) = convert_to_from(cx, into_trait_seg, target_ty, self_ty, impl_item_ref) {
106+
if let Some(suggestions) =
107+
convert_to_from(cx, into_trait_seg, target_ty.as_unambig_ty(), self_ty, impl_item_ref)
108+
{
107109
diag.multipart_suggestion(message, suggestions, Applicability::MachineApplicable);
108110
} else {
109111
diag.help(message);

0 commit comments

Comments
 (0)