Skip to content

Commit 64befe5

Browse files
committed
Auto merge of #5377 - matthiaskrgr:rustup_38, r=flip1995
rustup changelog: none
2 parents 2ff568d + 0982097 commit 64befe5

12 files changed

+40
-28
lines changed

clippy_lints/src/derive.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ fn check_hash_peq<'a, 'tcx>(
9494
if_chain! {
9595
if match_path(&trait_ref.path, &paths::HASH);
9696
if let Some(peq_trait_def_id) = cx.tcx.lang_items().eq_trait();
97-
if !&trait_ref.trait_def_id().is_local();
97+
if let Some(def_id) = &trait_ref.trait_def_id();
98+
if !def_id.is_local();
9899
then {
99100
// Look for the PartialEq implementations for `ty`
100101
cx.tcx.for_each_relevant_impl(peq_trait_def_id, ty, |impl_id| {

clippy_lints/src/if_let_some_result.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::utils::{match_type, method_chain_args, paths, snippet_with_applicability, span_lint_and_sugg};
22
use if_chain::if_chain;
33
use rustc_errors::Applicability;
4-
use rustc_hir::{print, Expr, ExprKind, MatchSource, PatKind, QPath};
4+
use rustc_hir::{Expr, ExprKind, MatchSource, PatKind, QPath};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_session::{declare_lint_pass, declare_tool_lint};
77

@@ -46,7 +46,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for OkIfLet {
4646
if let PatKind::TupleStruct(QPath::Resolved(_, ref x), ref y, _) = body[0].pat.kind; //get operation
4747
if method_chain_args(op, &["ok"]).is_some(); //test to see if using ok() methoduse std::marker::Sized;
4848
let is_result_type = match_type(cx, cx.tables.expr_ty(&result_types[0]), &paths::RESULT);
49-
if print::to_string(print::NO_ANN, |s| s.print_path(x, false)) == "Some" && is_result_type;
49+
if rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_path(x, false)) == "Some" && is_result_type;
5050

5151
then {
5252
let mut applicability = Applicability::MachineApplicable;

clippy_lints/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ extern crate rustc_errors;
3434
#[allow(unused_extern_crates)]
3535
extern crate rustc_hir;
3636
#[allow(unused_extern_crates)]
37+
extern crate rustc_hir_pretty;
38+
#[allow(unused_extern_crates)]
3739
extern crate rustc_index;
3840
#[allow(unused_extern_crates)]
3941
extern crate rustc_infer;

clippy_lints/src/loops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
720720
ExprKind::Struct(_, _, None)
721721
| ExprKind::Yield(_, _)
722722
| ExprKind::Closure(_, _, _, _, _)
723-
| ExprKind::InlineAsm(_)
723+
| ExprKind::LlvmInlineAsm(_)
724724
| ExprKind::Path(_)
725725
| ExprKind::Lit(_)
726726
| ExprKind::Err => NeverLoopResult::Otherwise,

clippy_lints/src/matches.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use rustc_ast::ast::LitKind;
1515
use rustc_errors::Applicability;
1616
use rustc_hir::def::CtorKind;
1717
use rustc_hir::{
18-
print, Arm, BindingAnnotation, Block, BorrowKind, Expr, ExprKind, Local, MatchSource, Mutability, Node, Pat,
19-
PatKind, QPath, RangeEnd,
18+
Arm, BindingAnnotation, Block, BorrowKind, Expr, ExprKind, Local, MatchSource, Mutability, Node, Pat, PatKind,
19+
QPath, RangeEnd,
2020
};
2121
use rustc_lint::{LateContext, LateLintPass, LintContext};
2222
use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -536,10 +536,12 @@ fn check_single_match_opt_like(
536536
if !inner.iter().all(is_wild) {
537537
return;
538538
}
539-
print::to_string(print::NO_ANN, |s| s.print_qpath(path, false))
539+
rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_qpath(path, false))
540540
},
541541
PatKind::Binding(BindingAnnotation::Unannotated, .., ident, None) => ident.to_string(),
542-
PatKind::Path(ref path) => print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)),
542+
PatKind::Path(ref path) => {
543+
rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_qpath(path, false))
544+
},
543545
_ => return,
544546
};
545547

@@ -638,7 +640,7 @@ fn check_wild_err_arm(cx: &LateContext<'_, '_>, ex: &Expr<'_>, arms: &[Arm<'_>])
638640
if match_type(cx, ex_ty, &paths::RESULT) {
639641
for arm in arms {
640642
if let PatKind::TupleStruct(ref path, ref inner, _) = arm.pat.kind {
641-
let path_str = print::to_string(print::NO_ANN, |s| s.print_qpath(path, false));
643+
let path_str = rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_qpath(path, false));
642644
if path_str == "Err" {
643645
let mut matching_wild = inner.iter().any(is_wild);
644646
let mut ident_bind_name = String::from("_");

clippy_lints/src/mut_reference.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::utils::span_lint;
22
use rustc::ty::subst::Subst;
33
use rustc::ty::{self, Ty};
4-
use rustc_hir::{print, BorrowKind, Expr, ExprKind, Mutability};
4+
use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_session::{declare_lint_pass, declare_tool_lint};
77

@@ -34,7 +34,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
3434
cx,
3535
arguments,
3636
cx.tables.expr_ty(fn_expr),
37-
&print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)),
37+
&rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_qpath(path, false)),
3838
);
3939
}
4040
},

clippy_lints/src/redundant_clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use rustc_hir::intravisit::FnKind;
1414
use rustc_hir::{def_id, Body, FnDecl, HirId};
1515
use rustc_index::bit_set::{BitSet, HybridBitSet};
1616
use rustc_lint::{LateContext, LateLintPass};
17-
use rustc_mir::dataflow::generic::{Analysis, AnalysisDomain, GenKill, GenKillAnalysis, ResultsCursor};
1817
use rustc_mir::dataflow::BottomValue;
18+
use rustc_mir::dataflow::{Analysis, AnalysisDomain, GenKill, GenKillAnalysis, ResultsCursor};
1919
use rustc_session::{declare_lint_pass, declare_tool_lint};
2020
use rustc_span::source_map::{BytePos, Span};
2121
use std::convert::TryFrom;

clippy_lints/src/trait_bounds.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
use crate::utils::{in_macro, snippet, span_lint_and_help, SpanlessHash};
1+
use crate::utils::{in_macro, snippet, snippet_with_applicability, span_lint_and_help, SpanlessHash};
22
use rustc_data_structures::fx::FxHashMap;
3+
use rustc_errors::Applicability;
34
use rustc_hir::{GenericBound, Generics, WherePredicate};
45
use rustc_lint::{LateContext, LateLintPass};
56
use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -41,6 +42,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TraitBounds {
4142
hasher.finish()
4243
};
4344
let mut map = FxHashMap::default();
45+
let mut applicability = Applicability::MaybeIncorrect;
4446
for bound in gen.where_clause.predicates {
4547
if let WherePredicate::BoundPredicate(ref p) = bound {
4648
let h = hash(&p.bounded_ty);
@@ -52,13 +54,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TraitBounds {
5254
for b in v.iter() {
5355
if let GenericBound::Trait(ref poly_trait_ref, _) = b {
5456
let path = &poly_trait_ref.trait_ref.path;
55-
hint_string.push_str(&format!(" {} +", path));
57+
hint_string.push_str(&format!(
58+
" {} +",
59+
snippet_with_applicability(cx, path.span, "..", &mut applicability)
60+
));
5661
}
5762
}
5863
for b in p.bounds.iter() {
5964
if let GenericBound::Trait(ref poly_trait_ref, _) = b {
6065
let path = &poly_trait_ref.trait_ref.path;
61-
hint_string.push_str(&format!(" {} +", path));
66+
hint_string.push_str(&format!(
67+
" {} +",
68+
snippet_with_applicability(cx, path.span, "..", &mut applicability)
69+
));
6270
}
6371
}
6472
hint_string.truncate(hint_string.len() - 2);

clippy_lints/src/utils/author.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,9 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
468468
println!("Ret(None) = {};", current);
469469
}
470470
},
471-
ExprKind::InlineAsm(_) => {
472-
println!("InlineAsm(_) = {};", current);
473-
println!(" // unimplemented: `ExprKind::InlineAsm` is not further destructured at the moment");
471+
ExprKind::LlvmInlineAsm(_) => {
472+
println!("LlvmInlineAsm(_) = {};", current);
473+
println!(" // unimplemented: `ExprKind::LlvmInlineAsm` is not further destructured at the moment");
474474
},
475475
ExprKind::Struct(ref path, ref fields, ref opt_base) => {
476476
let path_pat = self.next("path");

clippy_lints/src/utils/hir_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
474474
self.hash_expr(a);
475475
self.hash_expr(i);
476476
},
477-
ExprKind::InlineAsm(..) | ExprKind::Err => {},
477+
ExprKind::LlvmInlineAsm(..) | ExprKind::Err => {},
478478
ExprKind::Lit(ref l) => {
479479
l.node.hash(&mut self.s);
480480
},

clippy_lints/src/utils/inspector.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
use crate::utils::get_attr;
44
use rustc_ast::ast::Attribute;
55
use rustc_hir as hir;
6-
use rustc_hir::print;
76
use rustc_lint::{LateContext, LateLintPass, LintContext};
87
use rustc_session::Session;
98
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -50,7 +49,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DeepCodeInspector {
5049
hir::VisibilityKind::Crate(_) => println!("visible crate wide"),
5150
hir::VisibilityKind::Restricted { ref path, .. } => println!(
5251
"visible in module `{}`",
53-
print::to_string(print::NO_ANN, |s| s.print_path(path, false))
52+
rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_path(path, false))
5453
),
5554
hir::VisibilityKind::Inherited => println!("visibility inherited from outer item"),
5655
}
@@ -283,10 +282,10 @@ fn print_expr(cx: &LateContext<'_, '_>, expr: &hir::Expr<'_>, indent: usize) {
283282
print_expr(cx, e, indent + 1);
284283
}
285284
},
286-
hir::ExprKind::InlineAsm(ref asm) => {
285+
hir::ExprKind::LlvmInlineAsm(ref asm) => {
287286
let inputs = &asm.inputs_exprs;
288287
let outputs = &asm.outputs_exprs;
289-
println!("{}InlineAsm", ind);
288+
println!("{}LlvmInlineAsm", ind);
290289
println!("{}inputs:", ind);
291290
for e in inputs.iter() {
292291
print_expr(cx, e, indent + 1);
@@ -333,7 +332,7 @@ fn print_item(cx: &LateContext<'_, '_>, item: &hir::Item<'_>) {
333332
hir::VisibilityKind::Crate(_) => println!("visible crate wide"),
334333
hir::VisibilityKind::Restricted { ref path, .. } => println!(
335334
"visible in module `{}`",
336-
print::to_string(print::NO_ANN, |s| s.print_path(path, false))
335+
rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_path(path, false))
337336
),
338337
hir::VisibilityKind::Inherited => println!("visibility inherited from outer item"),
339338
}
@@ -427,7 +426,7 @@ fn print_pat(cx: &LateContext<'_, '_>, pat: &hir::Pat<'_>, indent: usize) {
427426
println!(
428427
"{}name: {}",
429428
ind,
430-
print::to_string(print::NO_ANN, |s| s.print_qpath(path, false))
429+
rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_qpath(path, false))
431430
);
432431
println!("{}ignore leftover fields: {}", ind, ignore);
433432
println!("{}fields:", ind);
@@ -444,7 +443,7 @@ fn print_pat(cx: &LateContext<'_, '_>, pat: &hir::Pat<'_>, indent: usize) {
444443
println!(
445444
"{}path: {}",
446445
ind,
447-
print::to_string(print::NO_ANN, |s| s.print_qpath(path, false))
446+
rustc_hir_pretty::to_string(rustc_hir_pretty::NO_ANN, |s| s.print_qpath(path, false))
448447
);
449448
if let Some(dot_position) = opt_dots_position {
450449
println!("{}dot position: {}", ind, dot_position);

clippy_lints/src/utils/sugg.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'a> Sugg<'a> {
108108
| hir::ExprKind::Call(..)
109109
| hir::ExprKind::Field(..)
110110
| hir::ExprKind::Index(..)
111-
| hir::ExprKind::InlineAsm(..)
111+
| hir::ExprKind::LlvmInlineAsm(..)
112112
| hir::ExprKind::Lit(..)
113113
| hir::ExprKind::Loop(..)
114114
| hir::ExprKind::MethodCall(..)
@@ -150,7 +150,7 @@ impl<'a> Sugg<'a> {
150150
| ast::ExprKind::Field(..)
151151
| ast::ExprKind::ForLoop(..)
152152
| ast::ExprKind::Index(..)
153-
| ast::ExprKind::InlineAsm(..)
153+
| ast::ExprKind::LlvmInlineAsm(..)
154154
| ast::ExprKind::Lit(..)
155155
| ast::ExprKind::Loop(..)
156156
| ast::ExprKind::MacCall(..)

0 commit comments

Comments
 (0)