Skip to content
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

Ch5/ch5-impossible-add.rs can not compile #64

Open
ghost opened this issue Dec 15, 2021 · 2 comments · May be fixed by #66
Open

Ch5/ch5-impossible-add.rs can not compile #64

ghost opened this issue Dec 15, 2021 · 2 comments · May be fixed by #66

Comments

@ghost
Copy link

ghost commented Dec 15, 2021

#[allow(arithmetic_overflow)]    <1>

fn main() {
  let (a, b) = (200, 200);
  let c: u8 = a + b;             <2>
  println!("200 + 200 = {}", c);
}

In this source code, there are two marks <1>/<2> the author might forget to comment, making the rustc reject to compile it

dcroote added a commit to dcroote/code that referenced this issue Dec 20, 2021
@dcroote dcroote linked a pull request Dec 20, 2021 that will close this issue
@ewenmcneill
Copy link

ewenmcneill commented Jan 6, 2023

FTR, there's also an additional problem in the book text (or the naming of the file in the repo). The book says:

Look in ch5/ ch5-impossible-addition.rs for the source code for this listing

but the actual file is called:

ewen@basadi:~/misc/src/rust/rust-in-action/code/ch5$ ls ch5*impossible*rs
ch5-impossible-add.rs
ewen@basadi:~/misc/src/rust/rust-in-action/code/ch5$ 

Ie, one has the suffix "-addition", and one has the suffix "-add"; the meaning is similar, but anyone cut'n'pasting filenames to look for will be confused. (It's probably easier to rename the file in the repo to match the book text. ETA: The second half of page 141, of the PDF version, uses the name matching the repo; so maybe it's just the "look in" reference that introduces it which has the wrong name.)

Anyway I can confirm properly commenting out the book reference markers does allow the example to compile.

Ewen

CC: @timClicks

@timClicks
Copy link
Contributor

Oh good catch! I will get that fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants