summaryrefslogtreecommitdiff
path: root/crates/tor-consdiff/src
Commit message (Collapse)AuthorAgeFilesLines
* tor-consdiff: Apply comment suggestionClara Engler2026-03-251-2/+3
| | | Co-authored-by: Ian Jackson
* tor-consdiff: Prevent dotlines with WS tailClara Engler2026-03-251-4/+18
| | | | | | | | This commit modifies the dotline check to prevent generating lines that consist of a single dot followed by an arbitrary amount of whitespace, such as `.`, `. `, `. \t `, but not `. \t foo`. It also adjusts the tests appropriately.
* tor-consdiff: Rename `.lno` to `.lno_for_error`Clara Engler2026-03-251-2/+2
|
* tor-consdiff: Prevent dotlines properlyClara Engler2026-03-251-1/+19
| | | | | | | As pointed out by Diziet, our implementation does not reject dotlines properly, due to our use of `trim_end()`. This commit fixes this, by just checking for `line == ".\n"`. This is fine because we ensure Unix line endings now anyways.
* tor-consdiff: Enforce Unix line endingsClara Engler2026-03-252-10/+10
| | | | | | | | | | This commit changes the consdiff generation to enforce Unix line endings and reject all other ones, including Windows line endings as well as no line endings. In other words, it checks for `\n` while forbidding `\r\n`. It also renames the relevant error variant to reflect this change better.
* tor-consdiff: Justify our use of peek'ingClara Engler2026-03-251-0/+3
| | | | This is done to only get the first directory-signature.
* tor-consdiff: Refactor result compositionClara Engler2026-03-251-11/+17
| | | | | | This commit refactors the result composition by simply looping over every line and checking whether it ends with a newline AND does not consist of a single dot.
* tor-consdiff: Use named variants for lno errorsClara Engler2026-03-252-10/+16
| | | | | | This commit changes the error variants that contain a line number to a named variant with a field `lno: usize` to make it semantically clear, that it is a line number.
* tor-consdiff: Use derive_more for HunkType's DisplayClara Engler2026-03-251-13/+5
|
* tor-consdiff: Use usize::try_fromClara Engler2026-03-251-2/+5
|
* tor-consdiff: Fix clippy warningsClara Engler2026-03-251-2/+2
|
* tor-consdiff: Test with CRLFClara Engler2026-03-251-0/+10
| | | | | Now that we no longer use .lines(), everything should work fine with CRLF -- and it does. :-)
* tor-consdiff: Remove manual line splitsClara Engler2026-03-252-19/+35
| | | | | | | | | This commit removes all manual line splits in the consdiff generation. Instead, it now simply uses the primitives offered by imara-diff to access the lines in the input itself. Meanwhile, it also adds a check for missing newlines/assertions that all lines are actually terminated by \n.
* tor-consdiff: Cut signature using byte offsetsClara Engler2026-03-251-30/+36
| | | | | This commit replaces the use of lines with byte offsets for cutting of the signatures.
* tor-consdiff: Use same rng in testClara Engler2026-03-251-2/+3
|
* tor-consdiff: Compile-time assertion for 32-bitClara Engler2026-03-251-0/+3
| | | | | This commit adds a compile time assertion that a u32 can always be safely casted into a usize.
* tor-consdiff: Return error for dotlineClara Engler2026-03-252-16/+47
| | | | | This commit adds a check that prevents gen_cons_diff from computing a diff with a single dot line.
* tor-consdiff: Refactor gen_ed_diffClara Engler2026-03-251-28/+63
| | | | | | This commit refactors gen_ed_diff to have less code duplication by not matching upon the hunk type once but by splitting it into two different matches for the header and the body.
* tor-consdiff: Failed applies are a BugClara Engler2026-03-252-6/+12
| | | | | | Mark a failed apply from a consensus diff we generate as a bug as this should not happen. We must obviously always accept the consensus diffs we produce.
* tor-consdiff: Replace `+=` with `std::fmt`Clara Engler2026-03-251-20/+36
| | | | | This commit replaces repeated `result += &format!(...)` cruft with `write!` calls and multi-line strings.
* tor-consdiff: Constify directory-signature literalClara Engler2026-03-251-3/+10
| | | | | This commit moves "directory-signature" and "directory-signature " into semantically meaningful constants.
* tor-consdiff: Replace names with custom wordlistClara Engler2026-03-251-7/+29
| | | | | | | This commit replaces the names crate with a simple hardcoded wordlist of length 20, obtained from my systems wordlist. Reason for that being that names triggers a cargo-audit failure.
* tor-consdiff: Add consdiff generation algorithmClara Engler2026-03-252-0/+187
| | | | | | | | This commit implements support for the consensus diff generation. Unlike CTor, it does not use its own custom algorithm but rather uses an implementation of Myers' algorithm from the `imara-diff` crate, which is pretty performant and comparable to size and run time to CTor, while being much simpler in the interfacing code.
* Allow clippy::collapsible_if to triggerGabriela Moldovan2026-02-161-0/+1
| | | | | | | | | `clippy::collapsible_if` started triggering after bumping the MSRV to 1.88. Since this triggers from a lot of places, and since there even are a couple of instances where we explicitly allow `clippy::collapsible_ifs`, I've opened #2342 for deciding what to do about it.
* maint/add_warning: Run script to add new warningGabriela Moldovan2026-01-271-0/+1
| | | | This adds the lint to all our crates.
* Fix name of clippy lint to unchecked_time_subtraction (2)Ian Jackson2025-11-061-2/+2
| | | | Run maint/add_warning
* Remove "doc_auto_cfg" incantation from all crates.Nick Mathewson2025-09-291-1/+1
| | | | This feature has been removed from nightly, in favor of doc_cfg.
* Switch Cargo.toml files to edition 2024.Nick Mathewson2025-08-071-33/+47
| | | | | | | | | | | | | | 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.
* Update code for Edition 2024Nick Mathewson2025-08-071-1/+1
| | | | | | | | | | | | | | | | | | 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.
* Temporarily suppress mismatched_lifetime_syntaxes.Gabriela Moldovan2025-07-071-0/+1
| | | | See #2060.
* tor-consdiff: Replaced an old MSRV TODO with a link to why it shouldn't be donehashcatHitman2025-04-231-2/+3
| | | | | | | | | - After spending quite a while trying to figure out why the tests kept failing after making the change, I eventually stumbled upon the netdoc syntax specification, which helpfully informs me that newlines MUST be ignored and discarded. Switching to using [`str::split_inclusive`] would either require extra lines to workaround and recreate the current expected behavior or changing the spec and correcting the tests to align with the new expected behavior.
* tor-consdiff: standardized MSRV TODOhashcatHitman2025-04-161-2/+1
| | | | | | | | - Part of a series of commits aimed at replacing all MSRV-related TODOs with a standardized format, which should be easier to find when the MSRV is bumped. For this one in particular, we actually do already meet the MSRV specified, but I want to check on the implementation details to see if this is still desired, since the TODO is 4 years old.
* clippy: deny `mod_module_files`Steven Engler2025-01-061-0/+1
| | | | | | Denies 'mod.rs' files for consistency. https://rust-lang.github.io/rust-clippy/master/index.html#mod_module_files
* add_warnings, *: Allow clippy::needless_lifetimesNick Mathewson2024-12-031-0/+1
| | | | | | | | In 1.83, this warning triggers on many of our crates. We're thinking of fixing them all, but for now, we're going to disable the warning. This is part of #1765.
* tor-consdiff: Avoid cfg(fuzzing).Nick Mathewson2024-05-071-4/+4
| | | | | This now generates an error (per #1395), and everything we used it for is also available as a feature.
* Re-run maint/add_warning.Nick Mathewson2024-05-061-2/+2
| | | | This commit is automatically generated.
* Use uXX::MAX in place of std::uXX::MAXNick Mathewson2024-04-221-2/+2
| | | | | | The old code produced a warning from clippy nightly; we may as well update to use the new associated consts. (They've been there since Rust 1.4x.)
* Run maint/add_warning.Nick Mathewson2024-03-131-0/+1
|
* Fix typo in error messageTobias Stoeckmann2024-03-061-1/+1
|
* Fix typos in doc commentsTobias Stoeckmann2024-03-061-2/+2
|
* deny clippy::unchecked_duration_subtractiontrinity-1686a2024-02-291-0/+1
|
* Run maint/add_warning to add lint block everywhereIan Jackson2023-08-231-0/+1
|
* Run add_warnings on all files.Nick Mathewson2023-08-041-2/+2
|
* Run maint/add_warning to actually apply new lint allowsIan Jackson2023-07-101-0/+2
|
* Run add_warning to remove `missing_panics_doc` deny.Nick Mathewson2023-07-061-1/+0
| | | | Closes #950.
* lints: Run maint/add_warning to actually apply new lintsIan Jackson2023-06-211-0/+2
|
* Allow clippy::unchecked_duration_subtraction in testsNick Mathewson2023-01-271-0/+1
| | | | | This panics on error, and we're fine with a panic on misbehavior in tests.
* Disable clippy::unlinlined-format-argsNick Mathewson2023-01-271-0/+1
| | | | | | | | This warning kind of snuck up on us! (See #748) For now, let's disable it. (I've cleaned it up in a couple of examples, since those are meant to be more idiomatic and user-facing.) Closes #748.
* test lint blocks: Add many many automaticallyIan Jackson2022-12-121-0/+8
| | | | | This is precisely the result of running the rune in maint/adhoc-add-lint-blocks.
* Run add_warnings.Nick Mathewson2022-11-031-0/+1
|