Skip to content

internal: Add clippy to CI #16413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
- name: Switch to stable toolchain
run: |
rustup update --no-self-update stable
rustup component add --toolchain stable rust-src
rustup component add --toolchain stable rust-src clippy
rustup default stable

- name: Run analysis-stats on rust-analyzer
Expand All @@ -103,6 +103,10 @@ jobs:
RUSTC_BOOTSTRAP: 1
run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps $(rustc --print sysroot)/lib/rustlib/src/rust/library/std

- name: clippy
if: matrix.os == 'ubuntu-latest'
run: cargo clippy --all-targets

# Weird targets to catch non-portable code
rust-cross:
if: github.repository == 'rust-lang/rust-analyzer'
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-expand/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl Attr {
let (path, input) = tt.split_at(path_end);
let path = Interned::new(ModPath::from_tt(db, path)?);

let input = match input.get(0) {
let input = match input.first() {
Some(tt::TokenTree::Subtree(tree)) => {
Some(Interned::new(AttrInput::TokenTree(Box::new(tree.clone()))))
}
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-expand/src/mod_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ fn convert_path(
ast::PathSegmentKind::SuperKw => {
let mut deg = 1;
let mut next_segment = None;
while let Some(segment) = segments.next() {
for segment in segments.by_ref() {
match segment.kind()? {
ast::PathSegmentKind::SuperKw => deg += 1,
ast::PathSegmentKind::Name(name) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl<'p> MatchCheckCtx<'p> {
ctor = Or;
// Collect here because `Arena::alloc_extend` panics on reentrancy.
let subpats: SmallVec<[_; 2]> =
pats.into_iter().map(|pat| self.lower_pat(pat)).collect();
pats.iter().map(|pat| self.lower_pat(pat)).collect();
fields = self.pattern_arena.alloc_extend(subpats);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-ty/src/mir/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1715,7 +1715,7 @@ impl Evaluator<'_> {
let v: Cow<'_, [u8]> = if size != v.len() {
// Handle self enum
if size == 16 && v.len() < 16 {
Cow::Owned(pad16(&v, false).to_vec())
Cow::Owned(pad16(v, false).to_vec())
} else if size < 16 && v.len() == 16 {
Cow::Borrowed(&v[0..size])
} else {
Expand Down
2 changes: 1 addition & 1 deletion crates/hir/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ fn modpath_from_str(link: &str) -> Option<ModPath> {
"self" => PathKind::Super(0),
"super" => {
let mut deg = 1;
while let Some(segment) = parts.next() {
for segment in parts.by_ref() {
if segment == "super" {
deg += 1;
} else {
Expand Down
10 changes: 5 additions & 5 deletions crates/proc-macro-srv/proc-macro-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ fn main() {
let mut artifact_path = None;
for message in Message::parse_stream(output.stdout.as_slice()) {
if let Message::CompilerArtifact(artifact) = message.unwrap() {
if artifact.target.kind.contains(&"proc-macro".to_string()) {
if artifact.package_id.repr.starts_with(&repr) || artifact.package_id.repr == pkgid
{
artifact_path = Some(PathBuf::from(&artifact.filenames[0]));
}
if artifact.target.kind.contains(&"proc-macro".to_string())
&& (artifact.package_id.repr.starts_with(&repr)
|| artifact.package_id.repr == pkgid)
{
artifact_path = Some(PathBuf::from(&artifact.filenames[0]));
}
}
}
Expand Down