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

editions support for mdbook test #812

Closed
vorner opened this issue Nov 3, 2018 · 6 comments · Fixed by #1086
Closed

editions support for mdbook test #812

vorner opened this issue Nov 3, 2018 · 6 comments · Fixed by #1086
Labels
A-Configuration Area: Configuration A-Documentation Area: Documentation A-Tests Area: `mbdook test` related tests

Comments

@vorner
Copy link

vorner commented Nov 3, 2018

Hello

I can't find a way to turn on the 2018 edition in mdbook test. I guess this is more of a documentation issue, because after all, there's the 2018 edition of The Book, so it must work somehow. But some kind of option somewhere or explanation how to do that in docs would be nice.

@steveklabnik
Copy link
Member

steveklabnik commented Nov 3, 2018 via email

@tkaitchuck
Copy link

It would be useful to have a config option to set a default. That would avoid having to type it every time, and prevent the loss of syntax highlighting within the IDE.

@kpp
Copy link
Contributor

kpp commented Nov 17, 2019

@steveklabnik Looks like edition2018 is ignored by rustdoc.

src/chapter_1.md:

# Chapter 1

```edition2018
async fn hello() {}
fn main() {
    assert_eq!(1, 2);
}
```
$ rustdoc --test src/chapter_1.md 

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

However with:

```rust
async fn hello() {}
fn main() {
    assert_eq!(1, 2);
}
```

Works as expected:

$ rustdoc --edition 2018 --test src/chapter_1.md 

running 1 test
test src/chapter_1.md - Chapter_1 (line 4) ... FAILED

failures:

---- src/chapter_1.md - Chapter_1 (line 4) stdout ----
Test executable failed (exit code 101).

stderr:
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `1`,
 right: `2`', src/chapter_1.md:4:5

@ehuss
Copy link
Contributor

ehuss commented Nov 17, 2019

Yea, this was just recently discovered. There is a PR (rust-lang/rust#66238) to fix that.

@kpp
Copy link
Contributor

kpp commented Nov 17, 2019

How about adding edition=2018 option to mdbook config?

Books will have to replace ```rust with ```edition2018 everywhere to make it work, but it would be useful to change it in config only.

@ehuss
Copy link
Contributor

ehuss commented Nov 17, 2019

How about adding edition=2018 option to mdbook config?

There was a recent PR to add that (#1086), but it had a problem so had to be reverted. I'm looking at fixing it, but I wanted to change how the config was defined. It's near the top of my list, so hopefully soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Configuration Area: Configuration A-Documentation Area: Documentation A-Tests Area: `mbdook test` related tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants