diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 9cc3e39726bd..c827a7f3d528 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -648,10 +648,10 @@ impl EarlyLintPass for AnonymousParameters { cx.struct_span_lint(ANONYMOUS_PARAMETERS, arg.pat.span, |lint| { let ty_snip = cx.sess.source_map().span_to_snippet(arg.ty.span); - let (ty_snip, appl) = if let Ok(snip) = ty_snip { - (snip, Applicability::MachineApplicable) + let (ty_snip, appl) = if let Ok(ref snip) = ty_snip { + (snip.as_str(), Applicability::MachineApplicable) } else { - ("".to_owned(), Applicability::HasPlaceholders) + ("", Applicability::HasPlaceholders) }; lint.build( @@ -1132,17 +1132,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds { let mut suggested_changing_assoc_types = false; // There must not be a where clause if !type_alias_generics.where_clause.predicates.is_empty() { - let spans: Vec<_> = type_alias_generics - .where_clause - .predicates - .iter() - .map(|pred| pred.span()) - .collect(); - cx.struct_span_lint( + cx.lint( TYPE_ALIAS_BOUNDS, - spans, |lint| { let mut err = lint.build("where clauses are not enforced in type aliases"); + let spans: Vec<_> = type_alias_generics + .where_clause + .predicates + .iter() + .map(|pred| pred.span()) + .collect(); + err.set_span(spans); err.span_suggestion( type_alias_generics.where_clause.span_for_predicates_or_empty_place(), "the clause will not be checked when the type alias is used, and should be removed", diff --git a/src/librustc_lint/context.rs b/src/librustc_lint/context.rs index f3cbd3f1c9ef..8e8beefa72f1 100644 --- a/src/librustc_lint/context.rs +++ b/src/librustc_lint/context.rs @@ -571,6 +571,8 @@ pub trait LintContext: Sized { }); } + // FIXME: These methods should not take an Into -- instead, callers should need to + // set the span in their `decorate` function (preferably using set_span). fn lookup>( &self, lint: &'static Lint, diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs index d45ea10dfbf5..8c58f2ba4c07 100644 --- a/src/librustc_lint/nonstandard_style.rs +++ b/src/librustc_lint/nonstandard_style.rs @@ -225,9 +225,8 @@ impl NonSnakeCase { let name = &ident.name.as_str(); if !is_snake_case(name) { - let sc = NonSnakeCase::to_snake_case(name); - cx.struct_span_lint(NON_SNAKE_CASE, ident.span, |lint| { + let sc = NonSnakeCase::to_snake_case(name); let msg = format!("{} `{}` should have a snake case name", sort, name); let mut err = lint.build(&msg); // We have a valid span in almost all cases, but we don't have one when linting a crate