Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Dec 20, 2022
1 parent cd3d38a commit c6477eb
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
13 changes: 12 additions & 1 deletion tests/ui/needless_borrow.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// run-rustfix
#![feature(lint_reasons)]
#![feature(custom_inner_attributes, lint_reasons, rustc_private)]
#![allow(
unused,
clippy::uninlined_format_args,
Expand Down Expand Up @@ -491,3 +491,14 @@ mod issue_9782_method_variant {
S.foo::<&[u8; 100]>(&a);
}
}

extern crate rustc_lint;
extern crate rustc_span;

#[allow(dead_code)]
mod span_lint {
use rustc_lint::{LateContext, Lint, LintContext};
fn foo(cx: &LateContext<'_>, lint: &'static Lint) {
cx.struct_span_lint(lint, rustc_span::Span::default(), "", |diag| diag.note(&String::new()));
}
}
13 changes: 12 additions & 1 deletion tests/ui/needless_borrow.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// run-rustfix
#![feature(lint_reasons)]
#![feature(custom_inner_attributes, lint_reasons, rustc_private)]
#![allow(
unused,
clippy::uninlined_format_args,
Expand Down Expand Up @@ -491,3 +491,14 @@ mod issue_9782_method_variant {
S.foo::<&[u8; 100]>(&a);
}
}

extern crate rustc_lint;
extern crate rustc_span;

#[allow(dead_code)]
mod span_lint {
use rustc_lint::{LateContext, Lint, LintContext};
fn foo(cx: &LateContext<'_>, lint: &'static Lint) {
cx.struct_span_lint(lint, rustc_span::Span::default(), "", |diag| diag.note(&String::new()));
}
}
6 changes: 6 additions & 0 deletions tests/ui/redundant_clone.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,9 @@ fn false_negative_5707() {
let _z = x.clone(); // pr 7346 can't lint on `x`
drop(y);
}

#[allow(unused, clippy::manual_retain)]
fn possible_borrower_improvements() {
let mut s = String::from("foobar");
s = s.chars().filter(|&c| c != 'o').to_owned().collect();
}
6 changes: 6 additions & 0 deletions tests/ui/redundant_clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,9 @@ fn false_negative_5707() {
let _z = x.clone(); // pr 7346 can't lint on `x`
drop(y);
}

#[allow(unused, clippy::manual_retain)]
fn possible_borrower_improvements() {
let mut s = String::from("foobar");
s = s.chars().filter(|&c| c != 'o').to_owned().collect();
}

0 comments on commit c6477eb

Please sign in to comment.