Skip to content

Commit 0e6c1e5

Browse files
committed
Fix ambiguous assert_eq uses
These uses of assert_eq will be broken by changes to how the prelude handles macros: rust-lang/rust#139493.
1 parent 3cfd2fe commit 0e6c1e5

File tree

2 files changed

+46
-36
lines changed

2 files changed

+46
-36
lines changed

gcode/src/gcode.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ impl<A: Buffer<Word>> GCode<A> {
9898
}
9999

100100
/// The overall category this [`GCode`] belongs to.
101-
pub fn mnemonic(&self) -> Mnemonic { self.mnemonic }
101+
pub fn mnemonic(&self) -> Mnemonic {
102+
self.mnemonic
103+
}
102104

103105
/// The integral part of a command number (i.e. the `12` in `G12.3`).
104106
pub fn major_number(&self) -> u32 {
@@ -115,10 +117,14 @@ impl<A: Buffer<Word>> GCode<A> {
115117
}
116118

117119
/// The arguments attached to this [`GCode`].
118-
pub fn arguments(&self) -> &[Word] { self.arguments.as_slice() }
120+
pub fn arguments(&self) -> &[Word] {
121+
self.arguments.as_slice()
122+
}
119123

120124
/// Where the [`GCode`] was found in its source text.
121-
pub fn span(&self) -> Span { self.span }
125+
pub fn span(&self) -> Span {
126+
self.span
127+
}
122128

123129
/// Add an argument to the list of arguments attached to this [`GCode`].
124130
pub fn push_argument(
@@ -252,7 +258,7 @@ mod tests {
252258
span: Span::default(),
253259
};
254260

255-
assert_eq!(code.major_number(), 90);
261+
pretty_assertions::assert_eq!(code.major_number(), 90);
256262
}
257263

258264
#[test]
@@ -265,7 +271,7 @@ mod tests {
265271
span: Span::default(),
266272
};
267273

268-
assert_eq!(code.minor_number(), i);
274+
pretty_assertions::assert_eq!(code.minor_number(), i);
269275
}
270276
}
271277

@@ -290,9 +296,9 @@ mod tests {
290296
})
291297
.unwrap();
292298

293-
assert_eq!(code.value_for('X'), Some(10.0));
294-
assert_eq!(code.value_for('x'), Some(10.0));
295-
assert_eq!(code.value_for('Y'), Some(-3.5));
296-
assert_eq!(code.value_for('Z'), None);
299+
pretty_assertions::assert_eq!(code.value_for('X'), Some(10.0));
300+
pretty_assertions::assert_eq!(code.value_for('x'), Some(10.0));
301+
pretty_assertions::assert_eq!(code.value_for('Y'), Some(-3.5));
302+
pretty_assertions::assert_eq!(code.value_for('Z'), None);
297303
}
298304
}

gcode/src/parser.rs

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,19 @@ impl<'input, C, B> Parser<'input, C, B> {
5151
}
5252

5353
impl<'input, B> From<&'input str> for Parser<'input, Nop, B> {
54-
fn from(src: &'input str) -> Self { Parser::new(src, Nop) }
54+
fn from(src: &'input str) -> Self {
55+
Parser::new(src, Nop)
56+
}
5557
}
5658

5759
impl<'input, C: Callbacks, B: Buffers<'input>> Iterator
5860
for Parser<'input, C, B>
5961
{
6062
type Item = Line<'input, B>;
6163

62-
fn next(&mut self) -> Option<Self::Item> { self.lines.next() }
64+
fn next(&mut self) -> Option<Self::Item> {
65+
self.lines.next()
66+
}
6367
}
6468

6569
#[derive(Debug)]
@@ -306,32 +310,32 @@ mod tests {
306310
let src = "(this is a comment)";
307311
let got: Vec<_> = parse(src).collect();
308312

309-
assert_eq!(got.len(), 1);
313+
pretty_assertions::assert_eq!(got.len(), 1);
310314
let line = &got[0];
311-
assert_eq!(line.comments().len(), 1);
312-
assert_eq!(line.gcodes().len(), 0);
313-
assert_eq!(line.span(), Span::new(0, src.len(), 0));
315+
pretty_assertions::assert_eq!(line.comments().len(), 1);
316+
pretty_assertions::assert_eq!(line.gcodes().len(), 0);
317+
pretty_assertions::assert_eq!(line.span(), Span::new(0, src.len(), 0));
314318
}
315319

316320
#[test]
317321
fn line_numbers() {
318322
let src = "N42";
319323
let got: Vec<_> = parse(src).collect();
320324

321-
assert_eq!(got.len(), 1);
325+
pretty_assertions::assert_eq!(got.len(), 1);
322326
let line = &got[0];
323-
assert_eq!(line.comments().len(), 0);
324-
assert_eq!(line.gcodes().len(), 0);
327+
pretty_assertions::assert_eq!(line.comments().len(), 0);
328+
pretty_assertions::assert_eq!(line.gcodes().len(), 0);
325329
let span = Span::new(0, src.len(), 0);
326-
assert_eq!(
330+
pretty_assertions::assert_eq!(
327331
line.line_number(),
328332
Some(Word {
329333
letter: 'N',
330334
value: 42.0,
331335
span
332336
})
333337
);
334-
assert_eq!(line.span(), span);
338+
pretty_assertions::assert_eq!(line.span(), span);
335339
}
336340

337341
#[test]
@@ -346,25 +350,25 @@ mod tests {
346350
)
347351
.collect();
348352

349-
assert_eq!(got.len(), 1);
353+
pretty_assertions::assert_eq!(got.len(), 1);
350354
assert!(got[0].line_number().is_none());
351355
let unexpected_line_number = unexpected_line_number.lock().unwrap();
352-
assert_eq!(unexpected_line_number.len(), 1);
353-
assert_eq!(unexpected_line_number[0].0, 42.0);
356+
pretty_assertions::assert_eq!(unexpected_line_number.len(), 1);
357+
pretty_assertions::assert_eq!(unexpected_line_number[0].0, 42.0);
354358
}
355359

356360
#[test]
357361
fn parse_g90() {
358362
let src = "G90";
359363
let got: Vec<_> = parse(src).collect();
360364

361-
assert_eq!(got.len(), 1);
365+
pretty_assertions::assert_eq!(got.len(), 1);
362366
let line = &got[0];
363-
assert_eq!(line.gcodes().len(), 1);
367+
pretty_assertions::assert_eq!(line.gcodes().len(), 1);
364368
let g90 = &line.gcodes()[0];
365-
assert_eq!(g90.major_number(), 90);
366-
assert_eq!(g90.minor_number(), 0);
367-
assert_eq!(g90.arguments().len(), 0);
369+
pretty_assertions::assert_eq!(g90.major_number(), 90);
370+
pretty_assertions::assert_eq!(g90.minor_number(), 0);
371+
pretty_assertions::assert_eq!(g90.arguments().len(), 0);
368372
}
369373

370374
#[test]
@@ -385,11 +389,11 @@ mod tests {
385389

386390
let got: Vec<_> = parse(src).collect();
387391

388-
assert_eq!(got.len(), 1);
392+
pretty_assertions::assert_eq!(got.len(), 1);
389393
let line = &got[0];
390-
assert_eq!(line.gcodes().len(), 1);
394+
pretty_assertions::assert_eq!(line.gcodes().len(), 1);
391395
let g01 = &line.gcodes()[0];
392-
assert_eq!(g01, &should_be);
396+
pretty_assertions::assert_eq!(g01, &should_be);
393397
}
394398

395399
#[test]
@@ -398,10 +402,10 @@ mod tests {
398402

399403
let got: Vec<_> = parse(src).collect();
400404

401-
assert_eq!(got.len(), 2);
402-
assert_eq!(got[0].gcodes().len(), 4);
403-
assert_eq!(got[0].comments().len(), 1);
404-
assert_eq!(got[1].gcodes().len(), 1);
405+
pretty_assertions::assert_eq!(got.len(), 2);
406+
pretty_assertions::assert_eq!(got[0].gcodes().len(), 4);
407+
pretty_assertions::assert_eq!(got[0].comments().len(), 1);
408+
pretty_assertions::assert_eq!(got[1].gcodes().len(), 1);
405409
}
406410

407411
/// I wasn't sure if the `#[derive(Serialize)]` would work given we use
@@ -434,6 +438,6 @@ mod tests {
434438

435439
let got: Vec<_> = crate::parse(src).collect();
436440

437-
assert_eq!(got, expected);
441+
pretty_assertions::assert_eq!(got, expected);
438442
}
439443
}

0 commit comments

Comments
 (0)