Skip to content
This repository was archived by the owner on Nov 24, 2023. It is now read-only.

Commit 6d4f793

Browse files
authored
Merge pull request #179 from alexcrichton/gh-actions
Switch from Travis/AppVeyor to Github Actions
2 parents c26abc0 + ba81441 commit 6d4f793

File tree

7 files changed

+59
-45
lines changed

7 files changed

+59
-45
lines changed

.appveyor.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: CI
2+
on: [push, pull_request]
3+
4+
jobs:
5+
test:
6+
name: Test
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
os: [ubuntu-latest, windows-latest]
11+
steps:
12+
- uses: actions/checkout@master
13+
- name: Install Rust (rustup)
14+
run: rustup update nightly --no-self-update && rustup default nightly
15+
if: matrix.os != 'macos-latest'
16+
shell: bash
17+
- name: Install Rust (macos)
18+
run: |
19+
curl https://sh.rustup.rs | sh -s -- -y
20+
echo ::add-path::$HOME/.cargo/bin
21+
if: matrix.os == 'macos-latest'
22+
- run: cargo test --all
23+
- run: cargo test --all -- --ignored
24+
25+
rustfmt:
26+
name: Rustfmt
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@master
30+
- name: Install Rust
31+
run: rustup update stable && rustup default stable && rustup component add rustfmt
32+
- run: cargo fmt -- --check

.travis.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/fix-json.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
use rustfix;
32

43
use failure::Error;

src/lib.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ pub struct Replacement {
9494

9595
fn parse_snippet(span: &DiagnosticSpan) -> Option<Snippet> {
9696
// unindent the snippet
97-
let indent = span.text
97+
let indent = span
98+
.text
9899
.iter()
99100
.map(|line| {
100-
let indent = line.text
101+
let indent = line
102+
.text
101103
.chars()
102104
.take_while(|&c| char::is_whitespace(c))
103105
.count();
@@ -127,7 +129,11 @@ fn parse_snippet(span: &DiagnosticSpan) -> Option<Snippet> {
127129

128130
if span.text.len() > 1 {
129131
body.push('\n');
130-
body.push_str(&last_slice[indent..last_tail_index].iter().collect::<String>());
132+
body.push_str(
133+
&last_slice[indent..last_tail_index]
134+
.iter()
135+
.collect::<String>(),
136+
);
131137
}
132138
tail.push_str(&last_slice[last_tail_index..].iter().collect::<String>());
133139
Some(Snippet {
@@ -150,7 +156,10 @@ fn parse_snippet(span: &DiagnosticSpan) -> Option<Snippet> {
150156
fn collect_span(span: &DiagnosticSpan) -> Option<Replacement> {
151157
let snippet = parse_snippet(span)?;
152158
let replacement = span.suggested_replacement.clone()?;
153-
Some(Replacement { snippet, replacement })
159+
Some(Replacement {
160+
snippet,
161+
replacement,
162+
})
154163
}
155164

156165
pub fn collect_suggestions<S: ::std::hash::BuildHasher>(
@@ -184,8 +193,8 @@ pub fn collect_suggestions<S: ::std::hash::BuildHasher>(
184193
.spans
185194
.iter()
186195
.filter(|span| {
187-
use crate::Filter::*;
188196
use crate::diagnostics::Applicability::*;
197+
use crate::Filter::*;
189198

190199
match (filter, &span.suggestion_applicability) {
191200
(MachineApplicableOnly, Some(MachineApplicable)) => true,

src/replace.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ impl Data {
4343
pub fn new(data: &[u8]) -> Self {
4444
Data {
4545
original: data.into(),
46-
parts: vec![
47-
Span {
48-
data: State::Initial,
49-
start: 0,
50-
end: data.len().saturating_sub(1),
51-
},
52-
],
46+
parts: vec![Span {
47+
data: State::Initial,
48+
start: 0,
49+
end: data.len().saturating_sub(1),
50+
}],
5351
}
5452
}
5553

@@ -105,15 +103,17 @@ impl Data {
105103
// the whole chunk. As an optimization and without loss of generality we
106104
// don't add empty parts.
107105
let new_parts = {
108-
let index_of_part_to_split = self.parts
106+
let index_of_part_to_split = self
107+
.parts
109108
.iter()
110109
.position(|p| {
111110
!p.data.is_inserted() && p.start <= from && p.end >= up_to_and_including
112111
})
113112
.ok_or_else(|| {
114113
use log::Level::Debug;
115114
if log_enabled!(Debug) {
116-
let slices = self.parts
115+
let slices = self
116+
.parts
117117
.iter()
118118
.map(|p| {
119119
(
@@ -154,7 +154,7 @@ impl Data {
154154
if part_to_split.start == from && part_to_split.end == up_to_and_including {
155155
if let State::Replaced(ref replacement) = part_to_split.data {
156156
if &**replacement == data {
157-
return Ok(())
157+
return Ok(());
158158
}
159159
}
160160
}

tests/parse_and_replace.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ use env_logger;
66
extern crate log;
77
use rustfix;
88

9-
109
#[macro_use]
1110
extern crate failure;
1211

13-
1412
use std::collections::HashSet;
15-
use std::ffi::OsString;
1613
use std::env;
14+
use std::ffi::OsString;
1715
use std::fs;
1816
use std::path::{Path, PathBuf};
1917
use std::process::Output;
@@ -123,7 +121,8 @@ fn diff(expected: &str, actual: &str) -> String {
123121
write!(
124122
&mut res,
125123
"differences found (+ == actual, - == expected):\n"
126-
).unwrap();
124+
)
125+
.unwrap();
127126
different = true;
128127
}
129128
for diff in diff.lines() {

0 commit comments

Comments
 (0)