]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #4198 - matthiaskrgr:rustup_8, r=flip1995
authorbors <bors@rust-lang.org>
Wed, 12 Jun 2019 09:29:00 +0000 (09:29 +0000)
committerbors <bors@rust-lang.org>
Wed, 12 Jun 2019 09:29:00 +0000 (09:29 +0000)
rustup

changelog: none

cc @lzutao

r? @phansch

clippy_lints/src/format.rs
clippy_lints/src/non_copy_const.rs
clippy_lints/src/types.rs
clippy_lints/src/utils/diagnostics.rs
clippy_lints/src/utils/mod.rs
clippy_lints/src/utils/sugg.rs
clippy_lints/src/write.rs

index 2eaa1ac45647497aa16e8a35586965f409c52555..aed1142d9aea1fc395fa66bf749da4a397fb8e6e 100644 (file)
@@ -92,7 +92,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
     }
 }
 
-fn span_useless_format<'a, 'tcx: 'a, T: LintContext<'tcx>>(cx: &'a T, span: Span, help: &str, mut sugg: String) {
+fn span_useless_format<T: LintContext>(cx: &T, span: Span, help: &str, mut sugg: String) {
     let to_replace = span.source_callsite();
 
     // The callsite span contains the statement semicolon for some reason.
index 2652e5e75d33de8f3ec68437f1f79b65066bb356..5aaa279941e7bed214355be480c21cb9938cf390 100644 (file)
@@ -12,7 +12,7 @@
 use rustc::{declare_lint_pass, declare_tool_lint};
 use rustc_errors::Applicability;
 use rustc_typeck::hir_ty_to_ty;
-use syntax_pos::{Span, DUMMY_SP};
+use syntax_pos::{InnerSpan, Span, DUMMY_SP};
 
 use crate::utils::{in_constant, in_macro_or_desugar, is_copy, span_lint_and_then};
 
@@ -123,7 +123,7 @@ fn verify_ty_bound<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>, source: S
         }
         match source {
             Source::Item { .. } => {
-                let const_kw_span = span.from_inner_byte_pos(0, 5);
+                let const_kw_span = span.from_inner(InnerSpan::new(0, 5));
                 db.span_suggestion(
                     const_kw_span,
                     "make this a static item",
index 7b41bea4ff4bea2e5c190a3a435df7b4e6c44fdc..a1bcc43d8ba277ed0b1d23bda3664d6a4b421811 100644 (file)
@@ -1120,7 +1120,7 @@ fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
             if let ExprKind::Lit(ref lit) = ex.node {
                 use syntax::ast::{LitIntType, LitKind};
                 if let LitKind::Int(n, _) = lit.node {
-                    if cast_to.is_fp() {
+                    if cast_to.is_floating_point() {
                         let from_nbits = 128 - n.leading_zeros();
                         let to_nbits = fp_ty_mantissa_nbits(cast_to);
                         if from_nbits != 0 && to_nbits != 0 && from_nbits <= to_nbits {
index 5be0a67c64d0b2c435e9d7b60c33d6b767ec9b01..6210cebfe9a0385710cf526f1bf9e19a58c59e86 100644 (file)
@@ -48,7 +48,7 @@ fn docs_link(&mut self, lint: &'static Lint) {
 /// 17 |     std::mem::forget(seven);
 ///    |     ^^^^^^^^^^^^^^^^^^^^^^^
 /// ```
-pub fn span_lint<'a, T: LintContext<'a>>(cx: &T, lint: &'static Lint, sp: impl Into<MultiSpan>, msg: &str) {
+pub fn span_lint<T: LintContext>(cx: &T, lint: &'static Lint, sp: impl Into<MultiSpan>, msg: &str) {
     DiagnosticWrapper(cx.struct_span_lint(lint, sp, msg)).docs_link(lint);
 }
 
@@ -70,13 +70,7 @@ pub fn span_lint<'a, T: LintContext<'a>>(cx: &T, lint: &'static Lint, sp: impl I
 ///    |
 ///    = help: Consider using `std::f64::NAN` if you would like a constant representing NaN
 /// ```
-pub fn span_help_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(
-    cx: &'a T,
-    lint: &'static Lint,
-    span: Span,
-    msg: &str,
-    help: &str,
-) {
+pub fn span_help_and_lint<'a, T: LintContext>(cx: &'a T, lint: &'static Lint, span: Span, msg: &str, help: &str) {
     let mut db = DiagnosticWrapper(cx.struct_span_lint(lint, span, msg));
     db.0.help(help);
     db.docs_link(lint);
@@ -103,7 +97,7 @@ pub fn span_help_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(
 /// 10 |     forget(&SomeStruct);
 ///    |            ^^^^^^^^^^^
 /// ```
-pub fn span_note_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(
+pub fn span_note_and_lint<'a, T: LintContext>(
     cx: &'a T,
     lint: &'static Lint,
     span: Span,
@@ -120,13 +114,8 @@ pub fn span_note_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(
     db.docs_link(lint);
 }
 
-pub fn span_lint_and_then<'a, 'tcx: 'a, T: LintContext<'tcx>, F>(
-    cx: &'a T,
-    lint: &'static Lint,
-    sp: Span,
-    msg: &str,
-    f: F,
-) where
+pub fn span_lint_and_then<'a, T: LintContext, F>(cx: &'a T, lint: &'static Lint, sp: Span, msg: &str, f: F)
+where
     F: for<'b> FnOnce(&mut DiagnosticBuilder<'b>),
 {
     let mut db = DiagnosticWrapper(cx.struct_span_lint(lint, sp, msg));
@@ -166,7 +155,7 @@ pub fn span_lint_hir_and_then(
 ///     |
 ///     = note: `-D fold-any` implied by `-D warnings`
 /// ```
-pub fn span_lint_and_sugg<'a, 'tcx: 'a, T: LintContext<'tcx>>(
+pub fn span_lint_and_sugg<'a, T: LintContext>(
     cx: &'a T,
     lint: &'static Lint,
     sp: Span,
index 5fa5eeaae768da5ae531cf902fb5b0f89be9cb70..ae5c430f133fb387cd1b3193e2d2faa5e4a5cdb0 100644 (file)
@@ -114,7 +114,7 @@ pub fn in_macro(span: Span) -> bool {
 // sources that the user has no control over.
 // For some reason these attributes don't have any expansion info on them, so
 // we have to check it this way until there is a better way.
-pub fn is_present_in_source<'a, T: LintContext<'a>>(cx: &T, span: Span) -> bool {
+pub fn is_present_in_source<T: LintContext>(cx: &T, span: Span) -> bool {
     if let Some(snippet) = snippet_opt(cx, span) {
         if snippet.is_empty() {
             return false;
@@ -455,7 +455,7 @@ pub fn contains_name(name: Name, expr: &Expr) -> bool {
 /// ```rust,ignore
 /// snippet(cx, expr.span, "..")
 /// ```
-pub fn snippet<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
+pub fn snippet<'a, T: LintContext>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
     snippet_opt(cx, span).map_or_else(|| Cow::Borrowed(default), From::from)
 }
 
@@ -465,7 +465,7 @@ pub fn snippet<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &'a str)
 /// - If the span is inside a macro, change the applicability level to `MaybeIncorrect`.
 /// - If the default value is used and the applicability level is `MachineApplicable`, change it to
 /// `HasPlaceholders`
-pub fn snippet_with_applicability<'a, 'b, T: LintContext<'b>>(
+pub fn snippet_with_applicability<'a, T: LintContext>(
     cx: &T,
     span: Span,
     default: &'a str,
@@ -487,12 +487,12 @@ pub fn snippet_with_applicability<'a, 'b, T: LintContext<'b>>(
 
 /// Same as `snippet`, but should only be used when it's clear that the input span is
 /// not a macro argument.
-pub fn snippet_with_macro_callsite<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
+pub fn snippet_with_macro_callsite<'a, T: LintContext>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
     snippet(cx, span.source_callsite(), default)
 }
 
 /// Converts a span to a code snippet. Returns `None` if not available.
-pub fn snippet_opt<'a, T: LintContext<'a>>(cx: &T, span: Span) -> Option<String> {
+pub fn snippet_opt<T: LintContext>(cx: &T, span: Span) -> Option<String> {
     cx.sess().source_map().span_to_snippet(span).ok()
 }
 
@@ -506,14 +506,14 @@ pub fn snippet_opt<'a, T: LintContext<'a>>(cx: &T, span: Span) -> Option<String>
 /// ```rust,ignore
 /// snippet_block(cx, expr.span, "..")
 /// ```
-pub fn snippet_block<'a, 'b, T: LintContext<'b>>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
+pub fn snippet_block<'a, T: LintContext>(cx: &T, span: Span, default: &'a str) -> Cow<'a, str> {
     let snip = snippet(cx, span, default);
     trim_multiline(snip, true)
 }
 
 /// Same as `snippet_block`, but adapts the applicability level by the rules of
 /// `snippet_with_applicabiliy`.
-pub fn snippet_block_with_applicability<'a, 'b, T: LintContext<'b>>(
+pub fn snippet_block_with_applicability<'a, T: LintContext>(
     cx: &T,
     span: Span,
     default: &'a str,
@@ -524,7 +524,7 @@ pub fn snippet_block_with_applicability<'a, 'b, T: LintContext<'b>>(
 }
 
 /// Returns a new Span that covers the full last line of the given Span
-pub fn last_line_of_span<'a, T: LintContext<'a>>(cx: &T, span: Span) -> Span {
+pub fn last_line_of_span<T: LintContext>(cx: &T, span: Span) -> Span {
     let source_map_and_line = cx.sess().source_map().lookup_line(span.lo()).unwrap();
     let line_no = source_map_and_line.line;
     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 {
 
 /// Like `snippet_block`, but add braces if the expr is not an `ExprKind::Block`.
 /// Also takes an `Option<String>` which can be put inside the braces.
-pub fn expr_block<'a, 'b, T: LintContext<'b>>(
-    cx: &T,
-    expr: &Expr,
-    option: Option<String>,
-    default: &'a str,
-) -> Cow<'a, str> {
+pub fn expr_block<'a, T: LintContext>(cx: &T, expr: &Expr, option: Option<String>, default: &'a str) -> Cow<'a, str> {
     let code = snippet_block(cx, expr.span, default);
     let string = option.unwrap_or_default();
     if in_macro_or_desugar(expr.span) {
index ec79b0616e3b180e2b3820dd9c2b2ee348b3bae3..70286dc95a3bcb6ff3c00755ebcbfcfd78eeccd3 100644 (file)
@@ -480,7 +480,7 @@ fn astbinop2assignop(op: ast::BinOp) -> AssocOp {
 
 /// Returns the indentation before `span` if there are nothing but `[ \t]`
 /// before it on its line.
-fn indentation<'a, T: LintContext<'a>>(cx: &T, span: Span) -> Option<String> {
+fn indentation<T: LintContext>(cx: &T, span: Span) -> Option<String> {
     let lo = cx.sess().source_map().lookup_char_pos(span.lo());
     if let Some(line) = lo.file.get_line(lo.line - 1 /* line numbers in `Loc` are 1-based */) {
         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> {
 }
 
 /// Convenience extension trait for `DiagnosticBuilder`.
-pub trait DiagnosticBuilderExt<'a, T: LintContext<'a>> {
+pub trait DiagnosticBuilderExt<'a, T: LintContext> {
     /// Suggests to add an attribute to an item.
     ///
     /// Correctly handles indentation of the attribute and item.
@@ -546,7 +546,7 @@ fn suggest_item_with_attr<D: Display + ?Sized>(
     fn suggest_remove_item(&mut self, cx: &T, item: Span, msg: &str, applicability: Applicability);
 }
 
-impl<'a, 'b, 'c, T: LintContext<'c>> DiagnosticBuilderExt<'c, T> for rustc_errors::DiagnosticBuilder<'b> {
+impl<'a, 'b, 'c, T: LintContext> DiagnosticBuilderExt<'c, T> for rustc_errors::DiagnosticBuilder<'b> {
     fn suggest_item_with_attr<D: Display + ?Sized>(
         &mut self,
         cx: &T,
index b55d0d94019855313a146e81494962f0b5e348d7..869e532eea6a1b6f4fe30a7f26729c169362d860 100644 (file)
@@ -6,7 +6,7 @@
 use syntax::ast::*;
 use syntax::parse::{parser, token};
 use syntax::tokenstream::TokenStream;
-use syntax_pos::{symbol::Symbol, BytePos, Span};
+use syntax_pos::{BytePos, Span};
 
 declare_clippy_lint! {
     /// **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
                             match arg.position {
                                 ArgumentImplicitlyIs(_) | ArgumentIs(_) => {},
                                 ArgumentNamed(name) => {
-                                    if *p == Symbol::intern(name) {
+                                    if *p == name {
                                         seen = true;
                                         all_simple &= arg.format == SIMPLE;
                                     }