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

Commit

Permalink
Merge pull request #179 from alexcrichton/gh-actions
Browse files Browse the repository at this point in the history
Switch from Travis/AppVeyor to Github Actions
  • Loading branch information
pietroalbini authored Oct 29, 2019
2 parents c26abc0 + ba81441 commit 6d4f793
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 45 deletions.
16 changes: 0 additions & 16 deletions .appveyor.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI
on: [push, pull_request]

jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@master
- name: Install Rust (rustup)
run: rustup update nightly --no-self-update && rustup default nightly
if: matrix.os != 'macos-latest'
shell: bash
- name: Install Rust (macos)
run: |
curl https://sh.rustup.rs | sh -s -- -y
echo ::add-path::$HOME/.cargo/bin
if: matrix.os == 'macos-latest'
- run: cargo test --all
- run: cargo test --all -- --ignored

rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
- run: cargo fmt -- --check
9 changes: 0 additions & 9 deletions .travis.yml

This file was deleted.

1 change: 0 additions & 1 deletion examples/fix-json.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

use rustfix;

use failure::Error;
Expand Down
19 changes: 14 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ pub struct Replacement {

fn parse_snippet(span: &DiagnosticSpan) -> Option<Snippet> {
// unindent the snippet
let indent = span.text
let indent = span
.text
.iter()
.map(|line| {
let indent = line.text
let indent = line
.text
.chars()
.take_while(|&c| char::is_whitespace(c))
.count();
Expand Down Expand Up @@ -127,7 +129,11 @@ fn parse_snippet(span: &DiagnosticSpan) -> Option<Snippet> {

if span.text.len() > 1 {
body.push('\n');
body.push_str(&last_slice[indent..last_tail_index].iter().collect::<String>());
body.push_str(
&last_slice[indent..last_tail_index]
.iter()
.collect::<String>(),
);
}
tail.push_str(&last_slice[last_tail_index..].iter().collect::<String>());
Some(Snippet {
Expand All @@ -150,7 +156,10 @@ fn parse_snippet(span: &DiagnosticSpan) -> Option<Snippet> {
fn collect_span(span: &DiagnosticSpan) -> Option<Replacement> {
let snippet = parse_snippet(span)?;
let replacement = span.suggested_replacement.clone()?;
Some(Replacement { snippet, replacement })
Some(Replacement {
snippet,
replacement,
})
}

pub fn collect_suggestions<S: ::std::hash::BuildHasher>(
Expand Down Expand Up @@ -184,8 +193,8 @@ pub fn collect_suggestions<S: ::std::hash::BuildHasher>(
.spans
.iter()
.filter(|span| {
use crate::Filter::*;
use crate::diagnostics::Applicability::*;
use crate::Filter::*;

match (filter, &span.suggestion_applicability) {
(MachineApplicableOnly, Some(MachineApplicable)) => true,
Expand Down
20 changes: 10 additions & 10 deletions src/replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ impl Data {
pub fn new(data: &[u8]) -> Self {
Data {
original: data.into(),
parts: vec![
Span {
data: State::Initial,
start: 0,
end: data.len().saturating_sub(1),
},
],
parts: vec![Span {
data: State::Initial,
start: 0,
end: data.len().saturating_sub(1),
}],
}
}

Expand Down Expand Up @@ -105,15 +103,17 @@ impl Data {
// the whole chunk. As an optimization and without loss of generality we
// don't add empty parts.
let new_parts = {
let index_of_part_to_split = self.parts
let index_of_part_to_split = self
.parts
.iter()
.position(|p| {
!p.data.is_inserted() && p.start <= from && p.end >= up_to_and_including
})
.ok_or_else(|| {
use log::Level::Debug;
if log_enabled!(Debug) {
let slices = self.parts
let slices = self
.parts
.iter()
.map(|p| {
(
Expand Down Expand Up @@ -154,7 +154,7 @@ impl Data {
if part_to_split.start == from && part_to_split.end == up_to_and_including {
if let State::Replaced(ref replacement) = part_to_split.data {
if &**replacement == data {
return Ok(())
return Ok(());
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions tests/parse_and_replace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ use env_logger;
extern crate log;
use rustfix;


#[macro_use]
extern crate failure;


use std::collections::HashSet;
use std::ffi::OsString;
use std::env;
use std::ffi::OsString;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Output;
Expand Down Expand Up @@ -123,7 +121,8 @@ fn diff(expected: &str, actual: &str) -> String {
write!(
&mut res,
"differences found (+ == actual, - == expected):\n"
).unwrap();
)
.unwrap();
different = true;
}
for diff in diff.lines() {
Expand Down

0 comments on commit 6d4f793

Please sign in to comment.