| Commit message (Collapse) | Author | Age | Files | Lines |
| | |
|
| |
|
|
|
|
|
|
| |
This commit adds #[allow(clippy::string_slice)] to all functions in the
code where string slices are used, alongside a TODO comment.
We do this add the function header to have it consistent, as things like
expression based allow's are still experimental.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
This commit executes maint/add_warning with the just added change to
deny string slices except in tests.
I recommend auditing this by checking out the previous commit followed
by running the script yourself and then verifying that the diff is
identical to this commit.
This commit makes cargo clippy fail. We will add exceptions in the next
commit.
|
| |
|
|
| |
As per #2492.
|
| | |
|
| |
|
|
|
| |
As per
https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/3471#note_3288716
|
| | |
|
| |
|
|
|
| |
My planned encoding derive macro is not going to use `decl_keyword!`
but will need to call `NetdocEncoder::item`.
|
| | |
|
| |
|
|
|
|
|
|
|
| |
NetdocEncoder::item uses it this way. Presumably it is right at
least in those cases where this method is called.
The only implementor of this trait right now is the output from
`decl_keyword!` in the old parser, which is (generally) expected to be
the actual keyword.
|
| |
|
|
|
|
|
| |
We're going to introduce facilities for encoding more generally, and
we'll want a way to enable them.
Instead, have a separate feature for *encoding* documents.
|
| |
|
|
| |
Run maint/add_warning
|
| |
|
|
|
|
|
| |
The methods in ParseRouterStatus can now be inherent.
This starts a cascade of unused stuff, and stuff which doesn't need to
be pub any more.
|
| |
|
|
| |
The new parser is going to reuse this.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
First, run
```
git grep -l "^edition =" |
xargs perl -i -pe 's/^edition *=.*/edition = "2024"/;'
```
Second, manually verify that all Cargo.toml files have changed,
and nothing else has changed.
Third, run cargo fmt again.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
1. Run cargo fix --edition
2. Selectively revert the "if let"->"match" changes.
These changes are meant to protect us from the lifetime changes
for "if let" bindings in Rust 2024.
But we're not actually relying on the old lifetime rules
anywhere, and the match syntax here is quite ugly.
3. Automatically revert `$pat:expr_2021` to `$pat:expr`.
(We don't actually want to restrict the expression syntax
that our macros accept).
Done with
`git grep -l expr_2021 | xargs perl -i -pe 's/expr_2021/expr/g;'`
4. Run cargo fmt.
|
| |
|
|
| |
Part of proposal 360.
|
| |
|
|
|
| |
Previously it didn't include end-of-line space, even though the docs
said it did.
|
| | |
|
| |
|
|
|
|
| |
- Replaced `once_cell::sync::Lazy` with `std::sync::LazyLock`.
Signed-off-by: hashcatHitman <[email protected]>
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
```text
warning: length comparison to one
--> crates/tor-netdoc/src/parse/tokenize.rs:470:12
|
470 | if args.len() >= 1 {
| ^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!args.is_empty()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#len_zero
note: the lint level is defined here
--> crates/tor-netdoc/src/lib.rs:9:9
|
9 | #![warn(clippy::all)]
| ^^^^^^^^^^^
= note: `#[warn(clippy::len_zero)]` implied by `#[warn(clippy::all)]`
```
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Per <https://spec.torproject.org/dir-spec/netdoc.html>,
our netdocs never have a BOM, and never have internal NULs.
This makes Arti reject such documents.
For arguments on why it's okay to increase parser strictness,
see the (forthcoming) proposal 356 at torspec!342,
and see older discussion at torspec#296.
Closes #1739.
|
| |
|
|
|
|
|
| |
I'm about to make our parsers reject some strings at construction
time, so it makes sense to have these functions become fallible.
This is a breaking change.
|
| |
|
|
|
|
| |
Looks like a copy/paste error.
Co-authored-by: Micah Elizabeth Scott <[email protected]>
|
| |
|
|
|
|
|
| |
This warning suggests using `[a,b]` as a Pattern
when it sees a search for `|ch| ch == a || ch == b`.
(All of our supported rust versions allow this kind of Pattern.)
|
| | |
|
| |
|
|
|
| |
FTR I don't think agree with clippy on this question, but then I often
don't.
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
| |
`ParseErrorKind` was renamed to `NetdocErrorKind`, so we need to
rename this acccessor too.
Signed-off-by: Gabriela Moldovan <[email protected]>
|
| |
|
|
|
|
|
|
|
|
|
| |
`ParseErrorSource` was originally meant to represent a parsing error,
this enum has since gained some variants that aren't really parsing
related (`Signature`, `CertSignature`, `UntimelyDescriptor`).
Since this error type is now used for general-purpose netdoc errors,
let's rename `ParseError{Kind, Source}` to `NetdocError{Kind, Source}`.
Signed-off-by: Gabriela Moldovan <[email protected]>
|
| |
|
|
| |
Fixes #756
|
| | |
|
| |
|
|
| |
Nothing uses these now; the NetDocReader is simply an iterator, itself.
|
| | |
|
| |
|
|
| |
This simplifies the return type!
|
| |
|
|
| |
This will simplify things at many call sites.
|
| |
|
|
| |
This is the last use of PauseAt.
|
| |
|
|
|
|
| |
There's a blanket impl of Itertor for &mut impl Iterator, so this
isn't necessary, and it prevents us passing iterators by value
producing syntactic vinegar.
|
| |
|
|
|
| |
This makes things easier to read. We're about to add another
site (albeit, temporarily).
|
| |
|
|
|
| |
This gets rid of a lot of manual boolean state variable iterator
stuff.
|
| |
|
|
|
| |
This will avoids some hairy borrowck disasters when we try to use
iterator adapters.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Now we require that, for all `SectionRules`, either the caller say
how to handle unrecognized tokens (using `.add(UNRECOGNIZED...)`),
or that they explicitly reject unrecognized tokens (using
`reject_unrecognized`()`.)
This solution uses an assert!() rather than an Error to indicate
failure. I say that's fine, since
1. This is a crate-internal API.
2. We never dynamically construct SectionRules according to
different behavior: they are always prefabricated in a fixed
code block. Thus, if we test a parser at all, we will make
sure that its SectionRules are well-formed.
I considered and explicitly rejected a solution where the builder
had to be finalized with separate methods `build_strict()` or
`build_tolerant()`: It's too easy IMO for the caller to forget what
these call means.
Prevents further recurrences of #752.
Closes #752.
|
| |
|
|
| |
No new behavior yet.
|
| |
|
|
|
| |
This is dead code when
cargo +stable clippy -p tor-netdir --all-features --all-targets
|
| |
|
|
|
| |
This panics on error, and we're fine with a panic on misbehavior in
tests.
|
| |
|
|
|
| |
Clippy now warns about these; I'm not sure how these warnings snuck
up on us.
|
| | |
|