Skip to content

Fails to build on Nightly #1963

Closed
Closed
@antonok-edm

Description

@antonok-edm

Hopefully no action required here, but I wanted to give a heads up that bat currently doesn't build on 1.59 (Nightly). I've filed a report of the (minimized) regression here (now being tracked within rust-lang/rust#90904).

The error is as follows:

error[E0277]: cannot add `&()` to `usize`
  --> src/line_range.rs:56:37
   |
56 |                     new_range.lower + more_lines
   |                                     ^ no implementation for `usize + &()`
   |
   = help: the trait `Add<&()>` is not implemented for `usize`

error[E0277]: the trait bound `(): FromStr` is not satisfied
    --> src/line_range.rs:54:26
     |
54   |                         .parse()
     |                          ^^^^^ the trait `FromStr` is not implemented for `()`
     |
note: required by a bound in `core::str::<impl str>::parse`
    --> /home/antonok/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/str/mod.rs:2247:21
     |
2247 |     pub fn parse<F: FromStr>(&self) -> Result<F, F::Err> {
     |                     ^^^^^^^ required by this bound in `core::str::<impl str>::parse`

And in case anyone urgently needs to build on Nightly, this tiny patch should do the trick:

diff --git a/src/line_range.rs b/src/line_range.rs
index ccd998f..5e4e74c 100644
--- a/src/line_range.rs
+++ b/src/line_range.rs
@@ -50,7 +50,7 @@ impl LineRange {
                 let first_byte = line_numbers[1].bytes().next();
 
                 new_range.upper = if first_byte == Some(b'+') {
-                    let more_lines = &line_numbers[1][1..]
+                    let more_lines: &usize = &line_numbers[1][1..]
                         .parse()
                         .map_err(|_| "Invalid character after +")?;
                     new_range.lower + more_lines

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions