This repository was archived by the owner on Nov 24, 2023. It is now read-only.
File tree 7 files changed +59
-45
lines changed 7 files changed +59
-45
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
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
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
-
2
1
use rustfix;
3
2
4
3
use failure:: Error ;
Original file line number Diff line number Diff line change @@ -94,10 +94,12 @@ pub struct Replacement {
94
94
95
95
fn parse_snippet ( span : & DiagnosticSpan ) -> Option < Snippet > {
96
96
// unindent the snippet
97
- let indent = span. text
97
+ let indent = span
98
+ . text
98
99
. iter ( )
99
100
. map ( |line| {
100
- let indent = line. text
101
+ let indent = line
102
+ . text
101
103
. chars ( )
102
104
. take_while ( |& c| char:: is_whitespace ( c) )
103
105
. count ( ) ;
@@ -127,7 +129,11 @@ fn parse_snippet(span: &DiagnosticSpan) -> Option<Snippet> {
127
129
128
130
if span. text . len ( ) > 1 {
129
131
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
+ ) ;
131
137
}
132
138
tail. push_str ( & last_slice[ last_tail_index..] . iter ( ) . collect :: < String > ( ) ) ;
133
139
Some ( Snippet {
@@ -150,7 +156,10 @@ fn parse_snippet(span: &DiagnosticSpan) -> Option<Snippet> {
150
156
fn collect_span ( span : & DiagnosticSpan ) -> Option < Replacement > {
151
157
let snippet = parse_snippet ( span) ?;
152
158
let replacement = span. suggested_replacement . clone ( ) ?;
153
- Some ( Replacement { snippet, replacement } )
159
+ Some ( Replacement {
160
+ snippet,
161
+ replacement,
162
+ } )
154
163
}
155
164
156
165
pub fn collect_suggestions < S : :: std:: hash:: BuildHasher > (
@@ -184,8 +193,8 @@ pub fn collect_suggestions<S: ::std::hash::BuildHasher>(
184
193
. spans
185
194
. iter ( )
186
195
. filter ( |span| {
187
- use crate :: Filter :: * ;
188
196
use crate :: diagnostics:: Applicability :: * ;
197
+ use crate :: Filter :: * ;
189
198
190
199
match ( filter, & span. suggestion_applicability ) {
191
200
( MachineApplicableOnly , Some ( MachineApplicable ) ) => true ,
Original file line number Diff line number Diff line change @@ -43,13 +43,11 @@ impl Data {
43
43
pub fn new ( data : & [ u8 ] ) -> Self {
44
44
Data {
45
45
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
+ } ] ,
53
51
}
54
52
}
55
53
@@ -105,15 +103,17 @@ impl Data {
105
103
// the whole chunk. As an optimization and without loss of generality we
106
104
// don't add empty parts.
107
105
let new_parts = {
108
- let index_of_part_to_split = self . parts
106
+ let index_of_part_to_split = self
107
+ . parts
109
108
. iter ( )
110
109
. position ( |p| {
111
110
!p. data . is_inserted ( ) && p. start <= from && p. end >= up_to_and_including
112
111
} )
113
112
. ok_or_else ( || {
114
113
use log:: Level :: Debug ;
115
114
if log_enabled ! ( Debug ) {
116
- let slices = self . parts
115
+ let slices = self
116
+ . parts
117
117
. iter ( )
118
118
. map ( |p| {
119
119
(
@@ -154,7 +154,7 @@ impl Data {
154
154
if part_to_split. start == from && part_to_split. end == up_to_and_including {
155
155
if let State :: Replaced ( ref replacement) = part_to_split. data {
156
156
if & * * replacement == data {
157
- return Ok ( ( ) )
157
+ return Ok ( ( ) ) ;
158
158
}
159
159
}
160
160
}
Original file line number Diff line number Diff line change @@ -6,14 +6,12 @@ use env_logger;
6
6
extern crate log;
7
7
use rustfix;
8
8
9
-
10
9
#[ macro_use]
11
10
extern crate failure;
12
11
13
-
14
12
use std:: collections:: HashSet ;
15
- use std:: ffi:: OsString ;
16
13
use std:: env;
14
+ use std:: ffi:: OsString ;
17
15
use std:: fs;
18
16
use std:: path:: { Path , PathBuf } ;
19
17
use std:: process:: Output ;
@@ -123,7 +121,8 @@ fn diff(expected: &str, actual: &str) -> String {
123
121
write ! (
124
122
& mut res,
125
123
"differences found (+ == actual, - == expected):\n "
126
- ) . unwrap ( ) ;
124
+ )
125
+ . unwrap ( ) ;
127
126
different = true ;
128
127
}
129
128
for diff in diff. lines ( ) {
You can’t perform that action at this time.
0 commit comments