Skip to content

Commit d24f627

Browse files
committed
nits
1 parent bf0863a commit d24f627

File tree

13 files changed

+76
-50
lines changed

13 files changed

+76
-50
lines changed

examples/rewrite.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use std::fs::File;
44
use std::io::BufReader;
55
use std::path::Path;
6-
use xml::reader::{ParserConfig, Result};
76
use xml::EmitterConfig;
7+
use xml::reader::{ParserConfig, Result};
88

99
fn main() -> Result<(), Box<dyn std::error::Error>> {
1010
let arg = std::env::args_os().nth(1);

src/analyze.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use std::fs::File;
55
use std::io::{self, BufReader, Read};
66
use std::{cmp, env};
77

8-
use xml::reader::XmlEvent;
98
use xml::ParserConfig;
9+
use xml::reader::XmlEvent;
1010

1111
fn main() -> Result<(), Box<dyn std::error::Error>> {
1212
let mut file;
@@ -67,7 +67,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
6767
XmlEvent::EndElement { .. } => {
6868
depth -= 1;
6969
},
70-
};
70+
}
7171
}
7272

7373
namespaces.remove(xml::namespace::NS_EMPTY_URI);

src/namespace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! Contains namespace manipulation types and functions.
22
33
use std::borrow::Cow;
4+
use std::collections::HashSet;
45
use std::collections::btree_map::Iter as Entries;
56
use std::collections::btree_map::{BTreeMap, Entry};
6-
use std::collections::HashSet;
77
use std::iter::{Map, Rev};
88
use std::slice::Iter;
99

src/reader.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ impl<'r> EventReader<&'r [u8]> {
175175
/// A convenience method to create an `XmlReader` from a string slice.
176176
#[inline]
177177
#[must_use]
178+
#[allow(clippy::should_implement_trait)]
178179
pub fn from_str(source: &'r str) -> Self {
179180
EventReader::new(source.as_bytes())
180181
}

src/reader/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::reader::lexer::Token;
21
use crate::Encoding;
2+
use crate::reader::lexer::Token;
33

44
use std::borrow::Cow;
55
use std::error::Error as _;

src/reader/parser.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ impl PullParser {
398398
}
399399

400400
#[cold]
401+
#[allow(clippy::needless_pass_by_value)]
401402
fn error(&self, e: SyntaxError) -> Result {
402403
Err(Error {
403404
pos: self.lexer.position(),
@@ -465,17 +466,20 @@ impl PullParser {
465466
}
466467

467468
#[inline]
469+
#[allow(clippy::wrong_self_convention)]
468470
fn into_state(&mut self, st: State, ev: Option<Result>) -> Option<Result> {
469471
self.st = st;
470472
ev
471473
}
472474

473475
#[inline]
476+
#[allow(clippy::wrong_self_convention)]
474477
fn into_state_continue(&mut self, st: State) -> Option<Result> {
475478
self.into_state(st, None)
476479
}
477480

478481
#[inline]
482+
#[allow(clippy::wrong_self_convention)]
479483
fn into_state_emit(&mut self, st: State, ev: Result) -> Option<Result> {
480484
self.into_state(st, Some(ev))
481485
}

src/reader/parser/inside_comment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ impl PullParser {
99
match t {
1010
Token::CommentEnd if self.config.c.ignore_comments => {
1111
self.into_state_continue(State::OutsideTag)
12-
}
12+
},
1313

1414
Token::CommentEnd => {
1515
let data = self.take_buf();

src/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,13 @@ mod tests {
289289
match CharReader::new().next_char_from(&mut bytes).unwrap_err() {
290290
super::CharReadError::UnexpectedEof => {},
291291
e => panic!("Unexpected result: {e:?}")
292-
};
292+
}
293293

294294
let mut bytes: &[u8] = b"\xff\x9f\x98\x32"; // invalid code point
295295
match CharReader::new().next_char_from(&mut bytes).unwrap_err() {
296296
super::CharReadError::Utf8(_) => {},
297297
e => panic!("Unexpected result: {e:?}")
298-
};
298+
}
299299

300300
// error during read
301301
struct ErrorReader;

src/writer/emitter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl Emitter {
169169
self.indent_level += 1;
170170
}
171171

172-
fn before_end_element<W: Write>(&mut self, target: &mut W) -> Result<()> {
172+
fn before_end_element<W: Write>(&self, target: &mut W) -> Result<()> {
173173
if self.config.perform_indent && self.indent_level > 0 && self.wrote_markup() &&
174174
!self.wrote_text() {
175175
let indent_level = self.indent_level;

tests/event_reader.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use std::fmt;
44
use std::fs::File;
5-
use std::io::{stderr, BufRead, BufReader, Write};
5+
use std::io::{BufRead, BufReader, Write, stderr};
66
use std::path::Path;
77
use xml::reader::ParserConfig2;
88

@@ -940,12 +940,11 @@ fn skip() {
940940
assert_eq!(Ok(XmlEvent::EndElement{ name: OwnedName::local("a".to_string()) }), reader.next());
941941
assert_eq!(Ok(XmlEvent::EndDocument), reader.next());
942942
break 'outer;
943-
} else {
944-
// Should never see the "c" element, since it should be skipped!
945-
assert_ne!(name.local_name, "c");
946-
// Should never see the "d" element, since it should be skipped!
947-
assert_ne!(name.local_name, "d");
948943
}
944+
// Should never see the "c" element, since it should be skipped!
945+
assert_ne!(name.local_name, "c");
946+
// Should never see the "d" element, since it should be skipped!
947+
assert_ne!(name.local_name, "d");
949948
}
950949
XmlEvent::EndElement { name, .. } => {
951950
// Should never see the "c" element, since it should be skipped!
@@ -966,7 +965,7 @@ fn skip() {
966965

967966
struct Name<'a>(&'a OwnedName);
968967

969-
impl<'a> fmt::Display for Name<'a> {
968+
impl fmt::Display for Name<'_> {
970969
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
971970
if let Some(ref namespace) = self.0.namespace {
972971
write!(f, "{{{namespace}}}")?;
@@ -982,7 +981,7 @@ impl<'a> fmt::Display for Name<'a> {
982981

983982
struct Event<'a>(&'a Result<XmlEvent>);
984983

985-
impl<'a> fmt::Display for Event<'a> {
984+
impl fmt::Display for Event<'_> {
986985
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
987986
let empty = String::new();
988987
match *self.0 {

0 commit comments

Comments
 (0)