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

compiler error E0505 example compiles with 2018 edition #58586

Closed
gurgalex opened this issue Feb 20, 2019 · 4 comments · Fixed by #58644
Closed

compiler error E0505 example compiles with 2018 edition #58586

gurgalex opened this issue Feb 20, 2019 · 4 comments · Fixed by #58644
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools

Comments

@gurgalex
Copy link
Contributor

gurgalex commented Feb 20, 2019

Taken from https://doc.rust-lang.org
Erroneous code compiles fine for E0505

A possible way to trigger E0505 in the 2018 edition

Rust version 1.32 on playground

@gurgalex
Copy link
Contributor Author

Where are the error code examples in the repo?

@gurgalex gurgalex changed the title compiler error E505 example compiles with 2018 edition compiler error E0505 example compiles with 2018 edition Feb 20, 2019
@hellow554
Copy link
Contributor

E0505: r##"
A value was moved out while it was still borrowed.
Erroneous code example:
```compile_fail,E0505
struct Value {}
fn eat(val: Value) {}
fn main() {
let x = Value{};
{
let _ref_to_val: &Value = &x;
eat(x);
}
}
```

@Centril Centril added the A-diagnostics Area: Messages for errors, warnings, and lints label Feb 20, 2019
@estebank estebank added A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools and removed A-diagnostics Area: Messages for errors, warnings, and lints labels Feb 20, 2019
@gurgalex
Copy link
Contributor Author

gurgalex commented Feb 20, 2019

Which part do I need to build for rustc --explain E0505 to reflect changes in rust/src/librustc_mir/diagnostics.rs?

@zackmdavis
Copy link
Member

I think a stage 1 build should be fine? ./x.py build -i --stage 1 src/libtest

Centril added a commit to Centril/rust that referenced this issue Feb 22, 2019
…n, r=matthewjasper

Fixes rust-lang#58586: Make E0505 erronous example fail for the 2018 edition

The original example worked for 2015, but not the 2018 edition of Rust.

Borrowing the moved value after ownership is transferred seems required for 2018.

[this](rust-lang/rust@rust-lang:f66e469...gurgalex:b2a02c8#diff-4ca866aea4a6efecd732f1975faaad88R1564) line though is correct for 2018, but not for the 2015 edition.

Fix rust-lang#58586
Centril added a commit to Centril/rust that referenced this issue Feb 22, 2019
…n, r=matthewjasper

Fixes rust-lang#58586: Make E0505 erronous example fail for the 2018 edition

The original example worked for 2015, but not the 2018 edition of Rust.

Borrowing the moved value after ownership is transferred seems required for 2018.

[this](rust-lang/rust@rust-lang:f66e469...gurgalex:b2a02c8#diff-4ca866aea4a6efecd732f1975faaad88R1564) line though is correct for 2018, but not for the 2015 edition.

Fix rust-lang#58586
bors added a commit that referenced this issue Feb 22, 2019
Rollup of 17 pull requests

Successful merges:

 - #57656 (Deprecate the unstable Vec::resize_default)
 - #58059 (deprecate before_exec in favor of unsafe pre_exec)
 - #58064 (override `VecDeque::try_rfold`, also update iterator)
 - #58198 (Suggest removing parentheses surrounding lifetimes)
 - #58431 (fix overlapping references in BTree)
 - #58555 (Add a note about 2018e if someone uses `try {` in 2015e)
 - #58588 (remove a bit of dead code)
 - #58589 (cleanup macro after 2018 transition)
 - #58591 (Dedup a rustdoc diagnostic construction)
 - #58600 (fix small documentation typo)
 - #58601 (Search for target_triple.json only if builtin target not found)
 - #58606 (Docs: put Future trait into spotlight)
 - #58607 (Fixes #58586: Make E0505 erronous example fail for the 2018 edition)
 - #58615 (miri: explain why we use static alignment in ref-to-place conversion)
 - #58620 (introduce benchmarks of BTreeSet.intersection)
 - #58621 (Update miri links)
 - #58632 (Make std feature list sorted)

Failed merges:

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants