Skip to content

Clippy fixes and others #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions src/generate/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,18 @@ impl<Pat: PartialEq> RuleWithNamedFields<Pat> {
.collect();
for (field, paths) in &self.fields {
for path in paths {
if path.len() == 0 {
return None;
}
if path.len() == 1 {
if variants[path[0]].name != "" {
return None;
match path[..] {
[] => return None,
[variant] if variants[variant].name != "" => return None,
[variant] => variants[variant].name = field,
// FIXME: use [variant, rest @ ..] when possible.
_ => {
variants[path[0]]
.fields
.entry(&field[..])
.or_insert_with(OrderSet::new)
.insert(path[1..].to_vec());
}
variants[path[0]].name = field;
} else {
variants[path[0]]
.fields
.entry(&field[..])
.or_insert_with(OrderSet::new)
.insert(path[1..].to_vec());
}
}
}
Expand Down Expand Up @@ -711,17 +709,12 @@ impl<Pat: Ord + Hash + RustInputPat> Rule<Pat> {
Thunk::new(move |cont| match (self, rc_self_and_rules) {
(Rule::Empty, _) => cont,
(Rule::Eat(pat), _) => {
// HACK(eddyb) remove extra variables post-NLL
let pat = pat.rust_matcher();
let cont = check(quote!(let Some(_range) = p.input_consume_left(_range, #pat)))
.apply(cont);
cont
check(quote!(let Some(_range) = p.input_consume_left(_range, #pat))).apply(cont)
}
(Rule::NegativeLookahead(pat), _) => {
// HACK(eddyb) remove extra variables post-NLL
let pat = pat.rust_matcher();
let cont = check(quote!(p.input_consume_left(_range, #pat).is_none())).apply(cont);
cont
check(quote!(p.input_consume_left(_range, #pat).is_none())).apply(cont)
}
(Rule::Call(r), _) => call(Rc::new(CodeLabel::NamedRule(r.clone()))).apply(cont),
(Rule::Concat([left, right]), None) => {
Expand Down
6 changes: 2 additions & 4 deletions src/generate/src.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,8 @@ impl Src {
};
if new_line {
frag.lines.push(Line::default());
} else {
if !frag.last().is_empty() {
frag.push(Elem::Char(' ', Spacing::Alone));
}
} else if !frag.last().is_empty() {
frag.push(Elem::Char(' ', Spacing::Alone));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/indexing_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ unsafe impl Contiguous for Str {
self.0.as_ptr()
}
fn end(&self) -> *const Self::Item {
unsafe { self.begin().offset(self.0.len() as isize) }
unsafe { self.begin().add(self.0.len()) }
}
fn as_slice(&self) -> &[Self::Item] {
self.0.as_bytes()
Expand Down
5 changes: 3 additions & 2 deletions src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl fmt::Debug for LineColumn {
impl LineColumn {
fn count(prefix: &str) -> Self {
let (line, column) = prefix
.split("\n")
.split('\n')
.enumerate()
.last()
.map_or((0, 0), |(i, s)| (i, s.chars().count()));
Expand Down Expand Up @@ -407,7 +407,8 @@ impl<'i, C: CodeLabel> Threads<'i, C> {
let old = self.seen.iter().rev().next().cloned();
if let Some(old) = old {
// TODO also check end point for proper "t.range includes old.range".
if !t.range.contains(old.range.start()).is_some() {
let new_includes_old = t.range.contains(old.range.start()).is_some();
if !new_includes_old {
self.seen.remove(&old);
continue;
}
Expand Down