Skip to content

Commit f342ea6

Browse files
committed
Auto merge of #4198 - matthiaskrgr:rustup_8, r=flip1995
rustup changelog: none cc @lzutao r? @phansch
2 parents ba1702a + 7c91fb8 commit f342ea6

File tree

7 files changed

+24
-40
lines changed

7 files changed

+24
-40
lines changed

clippy_lints/src/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UselessFormat {
9292
}
9393
}
9494

95-
fn span_useless_format<'a, 'tcx: 'a, T: LintContext<'tcx>>(cx: &'a T, span: Span, help: &str, mut sugg: String) {
95+
fn span_useless_format<T: LintContext>(cx: &T, span: Span, help: &str, mut sugg: String) {
9696
let to_replace = span.source_callsite();
9797

9898
// The callsite span contains the statement semicolon for some reason.

clippy_lints/src/non_copy_const.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc::ty::{Ty, TypeFlags};
1212
use rustc::{declare_lint_pass, declare_tool_lint};
1313
use rustc_errors::Applicability;
1414
use rustc_typeck::hir_ty_to_ty;
15-
use syntax_pos::{Span, DUMMY_SP};
15+
use syntax_pos::{InnerSpan, Span, DUMMY_SP};
1616

1717
use crate::utils::{in_constant, in_macro_or_desugar, is_copy, span_lint_and_then};
1818

@@ -123,7 +123,7 @@ fn verify_ty_bound<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>, source: S
123123
}
124124
match source {
125125
Source::Item { .. } => {
126-
let const_kw_span = span.from_inner_byte_pos(0, 5);
126+
let const_kw_span = span.from_inner(InnerSpan::new(0, 5));
127127
db.span_suggestion(
128128
const_kw_span,
129129
"make this a static item",

clippy_lints/src/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Casts {
11201120
if let ExprKind::Lit(ref lit) = ex.node {
11211121
use syntax::ast::{LitIntType, LitKind};
11221122
if let LitKind::Int(n, _) = lit.node {
1123-
if cast_to.is_fp() {
1123+
if cast_to.is_floating_point() {
11241124
let from_nbits = 128 - n.leading_zeros();
11251125
let to_nbits = fp_ty_mantissa_nbits(cast_to);
11261126
if from_nbits != 0 && to_nbits != 0 && from_nbits <= to_nbits {

clippy_lints/src/utils/diagnostics.rs

+6-17
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'a> DiagnosticWrapper<'a> {
4848
/// 17 | std::mem::forget(seven);
4949
/// | ^^^^^^^^^^^^^^^^^^^^^^^
5050
/// ```
51-
pub fn span_lint<'a, T: LintContext<'a>>(cx: &T, lint: &'static Lint, sp: impl Into<MultiSpan>, msg: &str) {
51+
pub fn span_lint<T: LintContext>(cx: &T, lint: &'static Lint, sp: impl Into<MultiSpan>, msg: &str) {
5252
DiagnosticWrapper(cx.struct_span_lint(lint, sp, msg)).docs_link(lint);
5353
}
5454

@@ -70,13 +70,7 @@ pub fn span_lint<'a, T: LintContext<'a>>(cx: &T, lint: &'static Lint, sp: impl I
7070
/// |
7171
/// = help: Consider using `std::f64::NAN` if you would like a constant representing NaN
7272
/// ```
73-
pub fn span_help_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(
74-
cx: &'a T,
75-
lint: &'static Lint,
76-
span: Span,
77-
msg: &str,
78-
help: &str,
79-
) {
73+
pub fn span_help_and_lint<'a, T: LintContext>(cx: &'a T, lint: &'static Lint, span: Span, msg: &str, help: &str) {
8074
let mut db = DiagnosticWrapper(cx.struct_span_lint(lint, span, msg));
8175
db.0.help(help);
8276
db.docs_link(lint);
@@ -103,7 +97,7 @@ pub fn span_help_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(
10397
/// 10 | forget(&SomeStruct);
10498
/// | ^^^^^^^^^^^
10599
/// ```
106-
pub fn span_note_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(
100+
pub fn span_note_and_lint<'a, T: LintContext>(
107101
cx: &'a T,
108102
lint: &'static Lint,
109103
span: Span,
@@ -120,13 +114,8 @@ pub fn span_note_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(
120114
db.docs_link(lint);
121115
}
122116

123-
pub fn span_lint_and_then<'a, 'tcx: 'a, T: LintContext<'tcx>, F>(
124-
cx: &'a T,
125-
lint: &'static Lint,
126-
sp: Span,
127-
msg: &str,
128-
f: F,
129-
) where
117+
pub fn span_lint_and_then<'a, T: LintContext, F>(cx: &'a T, lint: &'static Lint, sp: Span, msg: &str, f: F)
118+
where
130119
F: for<'b> FnOnce(&mut DiagnosticBuilder<'b>),
131120
{
132121
let mut db = DiagnosticWrapper(cx.struct_span_lint(lint, sp, msg));
@@ -166,7 +155,7 @@ pub fn span_lint_hir_and_then(
166155
/// |
167156
/// = note: `-D fold-any` implied by `-D warnings`
168157
/// ```
169-
pub fn span_lint_and_sugg<'a, 'tcx: 'a, T: LintContext<'tcx>>(
158+
pub fn span_lint_and_sugg<'a, T: LintContext>(
170159
cx: &'a T,
171160
lint: &'static Lint,
172161
sp: Span,

clippy_lints/src/utils/mod.rs

+9-14
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub fn in_macro(span: Span) -> bool {
114114
// sources that the user has no control over.
115115
// For some reason these attributes don't have any expansion info on them, so
116116
// we have to check it this way until there is a better way.
117-
pub fn is_present_in_source<'a, T: LintContext<'a>>(cx: &T, span: Span) -> bool {
117+
pub fn is_present_in_source<T: LintContext>(cx: &T, span: Span) -> bool {
118118
if let Some(snippet) = snippet_opt(cx, span) {
119119
if snippet.is_empty() {
120120
return false;
@@ -455,7 +455,7 @@ pub fn contains_name(name: Name, expr: &Expr) -> bool {
455455
/// ```rust,ignore
456456
/// snippet(cx, expr.span, "..")
457457
/// ```
458-
pub fn snippet<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
458+
pub fn snippet<'a, T: LintContext>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
459459
snippet_opt(cx, span).map_or_else(|| Cow::Borrowed(default), From::from)
460460
}
461461

@@ -465,7 +465,7 @@ pub fn snippet<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &'a str)
465465
/// - If the span is inside a macro, change the applicability level to `MaybeIncorrect`.
466466
/// - If the default value is used and the applicability level is `MachineApplicable`, change it to
467467
/// `HasPlaceholders`
468-
pub fn snippet_with_applicability<'a, 'b, T: LintContext<'b>>(
468+
pub fn snippet_with_applicability<'a, T: LintContext>(
469469
cx: &T,
470470
span: Span,
471471
default: &'a str,
@@ -487,12 +487,12 @@ pub fn snippet_with_applicability<'a, 'b, T: LintContext<'b>>(
487487

488488
/// Same as `snippet`, but should only be used when it's clear that the input span is
489489
/// not a macro argument.
490-
pub fn snippet_with_macro_callsite<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
490+
pub fn snippet_with_macro_callsite<'a, T: LintContext>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
491491
snippet(cx, span.source_callsite(), default)
492492
}
493493

494494
/// Converts a span to a code snippet. Returns `None` if not available.
495-
pub fn snippet_opt<'a, T: LintContext<'a>>(cx: &T, span: Span) -> Option<String> {
495+
pub fn snippet_opt<T: LintContext>(cx: &T, span: Span) -> Option<String> {
496496
cx.sess().source_map().span_to_snippet(span).ok()
497497
}
498498

@@ -506,14 +506,14 @@ pub fn snippet_opt<'a, T: LintContext<'a>>(cx: &T, span: Span) -> Option<String>
506506
/// ```rust,ignore
507507
/// snippet_block(cx, expr.span, "..")
508508
/// ```
509-
pub fn snippet_block<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
509+
pub fn snippet_block<'a, T: LintContext>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
510510
let snip = snippet(cx, span, default);
511511
trim_multiline(snip, true)
512512
}
513513

514514
/// Same as `snippet_block`, but adapts the applicability level by the rules of
515515
/// `snippet_with_applicabiliy`.
516-
pub fn snippet_block_with_applicability<'a, 'b, T: LintContext<'b>>(
516+
pub fn snippet_block_with_applicability<'a, T: LintContext>(
517517
cx: &T,
518518
span: Span,
519519
default: &'a str,
@@ -524,7 +524,7 @@ pub fn snippet_block_with_applicability<'a, 'b, T: LintContext<'b>>(
524524
}
525525

526526
/// Returns a new Span that covers the full last line of the given Span
527-
pub fn last_line_of_span<'a, T: LintContext<'a>>(cx: &T, span: Span) -> Span {
527+
pub fn last_line_of_span<T: LintContext>(cx: &T, span: Span) -> Span {
528528
let source_map_and_line = cx.sess().source_map().lookup_line(span.lo()).unwrap();
529529
let line_no = source_map_and_line.line;
530530
let line_start = &source_map_and_line.sf.lines[line_no];
@@ -533,12 +533,7 @@ pub fn last_line_of_span<'a, T: LintContext<'a>>(cx: &T, span: Span) -> Span {
533533

534534
/// Like `snippet_block`, but add braces if the expr is not an `ExprKind::Block`.
535535
/// Also takes an `Option<String>` which can be put inside the braces.
536-
pub fn expr_block<'a, 'b, T: LintContext<'b>>(
537-
cx: &T,
538-
expr: &Expr,
539-
option: Option<String>,
540-
default: &'a str,
541-
) -> Cow<'a, str> {
536+
pub fn expr_block<'a, T: LintContext>(cx: &T, expr: &Expr, option: Option<String>, default: &'a str) -> Cow<'a, str> {
542537
let code = snippet_block(cx, expr.span, default);
543538
let string = option.unwrap_or_default();
544539
if in_macro_or_desugar(expr.span) {

clippy_lints/src/utils/sugg.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ fn astbinop2assignop(op: ast::BinOp) -> AssocOp {
480480

481481
/// Returns the indentation before `span` if there are nothing but `[ \t]`
482482
/// before it on its line.
483-
fn indentation<'a, T: LintContext<'a>>(cx: &T, span: Span) -> Option<String> {
483+
fn indentation<T: LintContext>(cx: &T, span: Span) -> Option<String> {
484484
let lo = cx.sess().source_map().lookup_char_pos(span.lo());
485485
if let Some(line) = lo.file.get_line(lo.line - 1 /* line numbers in `Loc` are 1-based */) {
486486
if let Some((pos, _)) = line.char_indices().find(|&(_, c)| c != ' ' && c != '\t') {
@@ -499,7 +499,7 @@ fn indentation<'a, T: LintContext<'a>>(cx: &T, span: Span) -> Option<String> {
499499
}
500500

501501
/// Convenience extension trait for `DiagnosticBuilder`.
502-
pub trait DiagnosticBuilderExt<'a, T: LintContext<'a>> {
502+
pub trait DiagnosticBuilderExt<'a, T: LintContext> {
503503
/// Suggests to add an attribute to an item.
504504
///
505505
/// Correctly handles indentation of the attribute and item.
@@ -546,7 +546,7 @@ pub trait DiagnosticBuilderExt<'a, T: LintContext<'a>> {
546546
fn suggest_remove_item(&mut self, cx: &T, item: Span, msg: &str, applicability: Applicability);
547547
}
548548

549-
impl<'a, 'b, 'c, T: LintContext<'c>> DiagnosticBuilderExt<'c, T> for rustc_errors::DiagnosticBuilder<'b> {
549+
impl<'a, 'b, 'c, T: LintContext> DiagnosticBuilderExt<'c, T> for rustc_errors::DiagnosticBuilder<'b> {
550550
fn suggest_item_with_attr<D: Display + ?Sized>(
551551
&mut self,
552552
cx: &T,

clippy_lints/src/write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::borrow::Cow;
66
use syntax::ast::*;
77
use syntax::parse::{parser, token};
88
use syntax::tokenstream::TokenStream;
9-
use syntax_pos::{symbol::Symbol, BytePos, Span};
9+
use syntax_pos::{BytePos, Span};
1010

1111
declare_clippy_lint! {
1212
/// **What it does:** This lint warns when you use `println!("")` to
@@ -418,7 +418,7 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &TokenStream, is_write: bool) -> (O
418418
match arg.position {
419419
ArgumentImplicitlyIs(_) | ArgumentIs(_) => {},
420420
ArgumentNamed(name) => {
421-
if *p == Symbol::intern(name) {
421+
if *p == name {
422422
seen = true;
423423
all_simple &= arg.format == SIMPLE;
424424
}

0 commit comments

Comments
 (0)