* refactor: Run rustfix
* fix: Accept `dyn Trait` as a type
Rust has started warning about trait objects without dyn on nightly.
* fix: Accept Fn(A, B) -> Type as a type
* Fixup `dyn Trait` and `dyn Fn()` in tests
* Remove `clone` calls from `Copy` types
This commit fixes code that triggered the clippy::clone_on_copy lint.
* Remove redundant field names in struct literals
This commit fixes code that triggered the clippy::redundant_field_names
lint.
* Remove unneeded `return` statements
This commit fixes code that triggered the clippy::needless_return lint.
* Remove unnecessary double parentheses
This commit fixes code that triggered the clippy::double_parens lint.
* Replace `while let` loops with `for` loops
This commit fixes code that triggered the clippy::while_let_on_iterator
lint.
* Remove needless if-else statement
This commit fixes code that triggered the clippy::needless_bool lint.
* Remove empty string from `writeln!` invocations
This commit fixes code that triggered the clippy::writeln_empty_string
lint.
* Remove redundant closures
This commit fixes code that triggered the clippy::redundant_closure
lint.
* Replace length comparisons with `is_empty`
This commit fixes code that triggered the clippy::len_zero lint.
* Remove 'static lifetime param on consts
This commit fixes code that triggered the clippy::const_static_lifetime
lint.
* Replace useless invocations of `format!`
This commit fixes code that triggered the clippy::useless_format lint.
* Remove needless lifetime params from functions
This commit fixes code that triggered the clippy::needless_lifetimes
and clippy::extra_unused_lifetimes lints.
* Replace wildcard field matches with `..`
This commit fixes code that triggered the clippy::unneeded_field_pattern
lint.
* Replace `<char> as u8` with byte literals
This commit fixes code that triggered the clippy::char_lit_as_u8 lint.
* Fix clippy warnings related to iterators
This commit fixes code that triggered the clippy lints:
- for_kv_map
- into_iter_on_ref
- filter_next
- iter_cloned_collect
- unnecessary_fold
* Fix clippy warnings related to references
This commit fixes code that triggered the clippy lints:
- match_ref_pats
- trivially_copy_pass_by_ref
- prt_arg
- toplevel_ref_arg
- op_ref
* Simplify `if` statements
This commit fixes code triggering the clippy lints:
- collapsible_if
- if_same_then_else
* Fix misc clippy warnings
This commit fixes code triggering the clippy lints:
- write_with_newline
- inconsistent_digit_grouping
- range_plus_one
- or_fun_call
- assign_op_pattern
- assertions_on_constants
Now that our minimum supported Rust version is 1.31.0, we can make the
switch from `String::trim_left` (deprecated since 1.33.0) to
`String::trim_start`.
This also lets us get rid of the `allow(deprecated)` introduced as a
workaround for issue #428.
* Ignore trailing commas in `ExpectedDebug`
rust-lang/rust/pull/59076 changed the multiline Debug representation to
always include a trailing comma. This change currently breaks our tests
on beta and nightly, since we use this Debug representation to compare
expected parsing output.
We cannot simply add the trailing commas to the expected output strings,
since that would break on older rustc versions we support. Instead, this
commit makes it so that all trailing commas are stripped before the
comparison.
This workaround can be removed once rust-lang/rust/pull/59076 reaches
our minimum supported rustc version.
* Bump minimum Rust version to 1.31.0
That's required by the current version rustc-demangle, which is a
dependency of mdbook.
* Replace all uses of `try!` with `?`
The `?` operator was added to replace the `try!` macro and should be
used in modern Rust code. `try` is also a reserved keyword in Rust 2018,
so this change prepares for a possible edition switch too.
* Ignore trailing commas in `ExpectedDebug`
rust-lang/rust/pull/59076 changed the multiline Debug representation to
always include a trailing comma. This change currently breaks our tests
on beta and nightly, since we use this Debug representation to compare
expected parsing output.
We cannot simply add the trailing commas to the expected output strings,
since that would break on older rustc versions we support. Instead, this
commit makes it so that all trailing commas are stripped before the
comparison.
This workaround can be removed once rust-lang/rust/pull/59076 reaches
our minimum supported rustc version.
* Bump minimum Rust version to 1.31.0
That's required by the current version rustc-demangle, which is a
dependency of mdbook.
* Split apart UnrecognizedEOF error variant from UnrecognizedToken
* Factor out fmt_expected function
* Initial attempt at fixing codegen
- Match on lookahead when returning error
- Use last fixed symbol as location of UnrecognizedEOF
- Use `Default::default()` when there are no fixed symbols (?)
* Initial implementation of finding latest optional location
* Fix UnrecognizedToken errors in `Some` test cases
* Fix UnrecognizedEOF test cases
* Fix parentheses around pattern error for 1.26 compatibility
* Add basic test for UnrecognizedEOF (and hopefully trigger Travis build)
* Fix emitted indentation and use travis_wait when testing
On Rust 1.33, the current generated code emits a warning because hidden lifetime parameters in types are deprecated. This occurs in the `impl Display for Token`, and happens because `fmt::Formatter` has a lifetime parameter.
This PR adds an explicit lifetime parameter `'f` to the generated code, so it will work on all supported versions of Rust.
In gluon's parser I have a lalrpop symbol type that ends up at 400Kb
which is expensive to copy around. By moving the `push` call into each
reduction instead we make it easier for LLVM to elide memcpys and I
observed a reduction in memcpy uses from 27% to 18% of of the total
parse time.