Skip to content

Commit aeee0f0

Browse files
committed
Remove wrong lifetime from LintContext
1 parent ba1702a commit aeee0f0

File tree

4 files changed

+19
-24
lines changed

4 files changed

+19
-24
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<'a, 'tcx: 'a, T: LintContext>(cx: &'a 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/utils/diagnostics.rs

+6-11
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<'a, 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,7 +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>>(
73+
pub fn span_help_and_lint<'a, 'tcx: 'a, T: LintContext>(
7474
cx: &'a T,
7575
lint: &'static Lint,
7676
span: Span,
@@ -103,7 +103,7 @@ pub fn span_help_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(
103103
/// 10 | forget(&SomeStruct);
104104
/// | ^^^^^^^^^^^
105105
/// ```
106-
pub fn span_note_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(
106+
pub fn span_note_and_lint<'a, 'tcx: 'a, T: LintContext>(
107107
cx: &'a T,
108108
lint: &'static Lint,
109109
span: Span,
@@ -120,13 +120,8 @@ pub fn span_note_and_lint<'a, 'tcx: 'a, T: LintContext<'tcx>>(
120120
db.docs_link(lint);
121121
}
122122

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
123+
pub fn span_lint_and_then<'a, 'tcx: 'a, T: LintContext, F>(cx: &'a T, lint: &'static Lint, sp: Span, msg: &str, f: F)
124+
where
130125
F: for<'b> FnOnce(&mut DiagnosticBuilder<'b>),
131126
{
132127
let mut db = DiagnosticWrapper(cx.struct_span_lint(lint, sp, msg));
@@ -166,7 +161,7 @@ pub fn span_lint_hir_and_then(
166161
/// |
167162
/// = note: `-D fold-any` implied by `-D warnings`
168163
/// ```
169-
pub fn span_lint_and_sugg<'a, 'tcx: 'a, T: LintContext<'tcx>>(
164+
pub fn span_lint_and_sugg<'a, 'tcx: 'a, T: LintContext>(
170165
cx: &'a T,
171166
lint: &'static Lint,
172167
sp: Span,

clippy_lints/src/utils/mod.rs

+9-9
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<'a, 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, 'b, 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, 'b, 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, 'b, 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<'a, 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, 'b, 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, 'b, 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<'a, 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,7 +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>>(
536+
pub fn expr_block<'a, 'b, T: LintContext>(
537537
cx: &T,
538538
expr: &Expr,
539539
option: Option<String>,

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<'a, 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,

0 commit comments

Comments
 (0)