David Wood [Thu, 4 Oct 2018 19:48:50 +0000 (21:48 +0200)]
Improve message for closure returning a closure.
Now when a `FnMut` closure is returning a closure that contains a
reference to a captured variable, we provide an error that makes it more
clear what is happening.
bors [Tue, 9 Oct 2018 07:22:14 +0000 (07:22 +0000)]
Auto merge of #54798 - matthewjasper:free-region-closure-errors, r=nikomatsakis
[NLL] Improve closure region bound errors
Previously, we would report free region errors that originate from closure with the span of the closure and a "closure body requires ..." message. This is now updated to use a reason and span from inside the closure.
Tom Tromey [Tue, 2 Oct 2018 16:13:30 +0000 (10:13 -0600)]
Run debuginfo tests against rust-enabled lldb, when possible
If the rust-enabled lldb was built, then use it when running the
debuginfo tests. Updating the lldb submodule was necessary as this
needed a way to differentiate the rust-enabled lldb, so I added a line
to the --version output.
This adds compiletest commands to differentiate between the
rust-enabled and non-rust-enabled lldb, as is already done for gdb. A
new "rust-lldb" header directive is also added, but not used in this
patch; I plan to use it in #54004.
Added text explaining the (new) relative roles of `optimize`+`debug`
and to briefly touch on the theory of debugging rustc versus the
practice of such.
David Wood [Thu, 4 Oct 2018 20:40:17 +0000 (22:40 +0200)]
Move errors specify "dereference of raw pointer".
Previously, move errors involving the dereference of a raw pointer would
say "borrowed content". This commit changes it to say "dereference of
raw pointer".
Zack M. Davis [Mon, 8 Oct 2018 02:28:37 +0000 (19:28 -0700)]
in which rightward drift is opposed
Thanks to reviewers Tyler Mandry (for pointing out that this is
ridiculous and we need a helper function), Niko Matsakis (for pointing
out that the span-calculation code only has a couple free variables),
and Esteban Küber (for pointing out `get_generics`).
David Wood [Fri, 5 Oct 2018 21:31:33 +0000 (23:31 +0200)]
Update logic to search for casts.
This commit updates the captured trait object search logic to look for
unsized casts to boxed types rather than for functions that returned
trait objects.
bors [Sun, 7 Oct 2018 03:07:16 +0000 (03:07 +0000)]
Auto merge of #54451 - alexcrichton:no-mangle-extern-linkage, r=michaelwoerister
rustc: Allow `#[no_mangle]` anywhere in a crate
This commit updates the compiler to allow the `#[no_mangle]` (and
`#[export_name]` attributes) to be located anywhere within a crate.
These attributes are unconditionally processed, causing the compiler to
always generate an exported symbol with the appropriate name.
After some discussion on #54135 it was found that not a great reason
this hasn't been allowed already, and it seems to match the behavior
that many expect! Previously the compiler would only export a
`#[no_mangle]` symbol if it were *publicly reachable*, meaning that it
itself is `pub` and it's otherwise publicly reachable from the root of
the crate. This new definition is that `#[no_mangle]` *is always
reachable*, no matter where it is in a crate or whether it has `pub` or
not.
This should make it much easier to declare an exported symbol with a
known and unique name, even when it's an internal implementation detail
of the crate itself. Note that these symbols will persist beyond LTO as
well, always making their way to the linker.
Along the way this commit removes the `private_no_mangle_functions` lint
(also for statics) as there's no longer any need to lint these
situations. Furthermore a good number of tests were updated now that
symbol visibility has been changed.
bors [Sun, 7 Oct 2018 00:28:26 +0000 (00:28 +0000)]
Auto merge of #54782 - pnkfelix:issue-54556-semi-on-tail-diagnostic, r=nikomatsakis
NLL: temps in block tail expression diagnostic
This change adds a diagnostic that explains when temporaries in a block tail expression live longer than block local variables that they borrow, and attempts to suggest turning the tail expresion into a statement (either by adding a semicolon at the end, when its result value is clearly unused, or by introducing a `let`-binding for the result value and then returning that).
Alex Crichton [Fri, 21 Sep 2018 22:58:11 +0000 (15:58 -0700)]
rustc: Allow `#[no_mangle]` anywhere in a crate
This commit updates the compiler to allow the `#[no_mangle]` (and
`#[export_name]` attributes) to be located anywhere within a crate.
These attributes are unconditionally processed, causing the compiler to
always generate an exported symbol with the appropriate name.
After some discussion on #54135 it was found that not a great reason
this hasn't been allowed already, and it seems to match the behavior
that many expect! Previously the compiler would only export a
`#[no_mangle]` symbol if it were *publicly reachable*, meaning that it
itself is `pub` and it's otherwise publicly reachable from the root of
the crate. This new definition is that `#[no_mangle]` *is always
reachable*, no matter where it is in a crate or whether it has `pub` or
not.
This should make it much easier to declare an exported symbol with a
known and unique name, even when it's an internal implementation detail
of the crate itself. Note that these symbols will persist beyond LTO as
well, always making their way to the linker.
Along the way this commit removes the `private_no_mangle_functions` lint
(also for statics) as there's no longer any need to lint these
situations. Furthermore a good number of tests were updated now that
symbol visibility has been changed.
bors [Sat, 6 Oct 2018 10:44:11 +0000 (10:44 +0000)]
Auto merge of #54766 - alexcrichton:wasm-all-symbols, r=michaelwoerister
wasm: Explicitly export all symbols with LLD
This commit fixes an oddity on the wasm target where LTO can produce
working executables but plain old optimizations doesn't. The compiler
already knows what set of symbols it would like to export, but LLD only
discovers this list transitively through symbol visibilities. LLD may
not, however, always find all the symbols that we'd like to export.
For example if you depend on an rlib with a `#[no_mangle]` symbol, then
if you don't actually use anything from the rlib then the symbol won't
appear in the final artifact! It will appear, however, with LTO. This
commit attempts to rectify this situation by ensuring that all symbols
rustc would otherwise preserve through LTO are also preserved through
the linking process with LLD by default.
bors [Sat, 6 Oct 2018 00:44:11 +0000 (00:44 +0000)]
Auto merge of #54859 - pietroalbini:rollup, r=pietroalbini
Rollup of 11 pull requests
Successful merges:
- #54078 (Expand the documentation for the `std::sync` module)
- #54717 (Cleanup rustc/ty part 1)
- #54781 (Add examples to `TyKind::FnDef` and `TyKind::FnPtr` docs)
- #54787 (Only warn about unused `mut` in user-written code)
- #54804 (add suggestion for inverted function parameters)
- #54812 (Regression test for #32382.)
- #54833 (make `Parser::parse_foreign_item()` return a foreign item or error)
- #54834 (rustdoc: overflow:auto doesn't work nicely on small screens)
- #54838 (Fix typo in src/libsyntax/parse/parser.rs)
- #54851 (Fix a regression in 1.30 by reverting #53564)
- #54853 (Remove unneccessary error from test, revealing NLL error.)
Pietro Albini [Fri, 5 Oct 2018 20:33:21 +0000 (22:33 +0200)]
Rollup merge of #54851 - alexcrichton:revert-optimize, r=sfackler
Fix a regression in 1.30 by reverting #53564
Investigation on #54477 revealed https://github.com/rust-lang/rust/pull/53564 as the culprit in the regression for that crate. I've reproduced the regression with the [detailed test cases provided](https://github.com/rust-lang/rust/issues/54477#issuecomment-427398456). While we figure out how to fix the regression this commit reverts the current culprit.
Pietro Albini [Fri, 5 Oct 2018 20:33:17 +0000 (22:33 +0200)]
Rollup merge of #54833 - abonander:issue-54441, r=petrochenkov
make `Parser::parse_foreign_item()` return a foreign item or error
Fixes `Parser::parse_foreign_item()` to follow the convention of `parse_trait_item()` and `parse_impl_item()` in that it *must* parse an item or return an error, and then the caller is responsible for detecting the closing delimiter.
This prevents it from looping endlessly on an unexpected token in `ext/expand.rs` where it was also leaking memory by continually pushing to `Parser::expected_tokens` via `Parser::check_keyword()`.