Commit Graph

3188 Commits

Author SHA1 Message Date
bors
b2d6ea98b0 Auto merge of #54810 - 1aim:unused-impl-trait, r=oli-obk
Fix dead code lint for functions using impl Trait

Fixes https://github.com/rust-lang/rust/issues/54754

This is a minimal fix that doesn't add any new queries or touches unnecessary code. Please nominate for beta backport if wanted.
2018-10-07 19:30:24 +00:00
bors
0ee045ea09 Auto merge of #54835 - oli-obk:mögen_konstante_funktionen_doch_bitte_endlich_stabil_sein, r=Centril
Stabilize `min_const_fn`

tracking issue: #53555

r? @Centril
2018-10-07 13:37:07 +00:00
bors
5a6f122126 Auto merge of #54813 - petrochenkov:uilocale, r=alexcrichton
Fix two UI tests with locale-dependent output

Closes https://github.com/rust-lang/rust/issues/54719
2018-10-07 11:10:39 +00:00
bors
987a50bab3 Auto merge of #54823 - euclio:needs-test, r=alexcrichton
Add tests for some E-needstest issues

Fixes #28134.
Fixes #24338.
Fixes #29743.
2018-10-07 08:32:19 +00:00
bors
13429136b8 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.

Closes #54135
2018-10-07 03:07:16 +00:00
bors
dbecb7a644 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).

Fix #54556
2018-10-07 00:28:26 +00:00
Alex Crichton
d7d7045374 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.

Closes #54135
2018-10-06 13:57:30 -07:00
Pietro Albini
51334c96b3
Rollup merge of #54853 - davidtwco:issue-52663-missing-lifetime-suggestion-test, r=nikomatsakis
Remove unneccessary error from test, revealing NLL error.

Part of #52663.

Removes unnecessary type mismatch error from test that was hiding
borrow check error from NLL stderr.

r? @nikomatsakis
2018-10-05 22:33:22 +02:00
Pietro Albini
a95a6e287a
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()`.

closes #54441

r? @petrochenkov
cc @dtolnay
2018-10-05 22:33:17 +02:00
Pietro Albini
08af25fb27
Rollup merge of #54812 - pnkfelix:issue-32382-index-assoc-type-with-lifetime, r=nikomatsakis
Regression test for #32382.
2018-10-05 22:33:16 +02:00
Pietro Albini
ee745d6abf
Rollup merge of #54804 - euclio:inverted-parameters, r=estebank
add suggestion for inverted function parameters

Fixes #54065.
2018-10-05 22:33:15 +02:00
Pietro Albini
3810657ae3
Rollup merge of #54787 - varkor:unused-mut-in-desugaring, r=nikomatsakis
Only warn about unused `mut` in user-written code

Fixes https://github.com/rust-lang/rust/issues/54586.

r? @pnkfelix
cc @blitzerr
2018-10-05 22:33:13 +02:00
David Wood
c07b712d2c
Simplify test.
Removes unnecessary type mismatch error from test that was hiding
borrow check error from NLL stderr.
2018-10-05 18:35:23 +02:00
bors
2155f27b64 Auto merge of #54741 - oli-obk:impl_trait_hierarchy, r=cramertj
Nest the `impl Trait` existential item inside the return type

fixes #54045

r? @cramertj
2018-10-05 15:32:19 +00:00
Andy Russell
f5db411410
add suggestion for inverted function parameters
Fixes #54065.
2018-10-05 10:33:19 -04:00
bors
60c846046e Auto merge of #54336 - petrochenkov:preuni, r=alexcrichton
resolve: Some refactorings in preparation for uniform paths 2.0

The main result is that in-scope resolution performed during macro expansion / import resolution is now consolidated in a single function (`fn early_resolve_ident_in_lexical_scope`), which can now be used for resolving first import segments as well when uniform paths are enabled.

r? @ghost
2018-10-05 12:52:53 +00:00
Felix S. Klock II
056cfffd1b Unit tests for issue #54556. Some were also taken from issues #21114, #46413. 2018-10-05 12:04:53 +02:00
Felix S. Klock II
37f1003121 Updates to .stderr output in ui tests from earlier changes. 2018-10-05 12:04:53 +02:00
Austin Bonander
9da428dad8 make Parser::parse_foreign_item() return a foreign item or error
closes #54441
2018-10-05 02:47:57 -07:00
Oliver Schneider
ec74d3533a Stabilize min_const_fn 2018-10-05 10:36:14 +02:00
Vadim Petrochenkov
0d8e9cd4df Reapply the macro_rules disambiguation changes from master 2018-10-05 11:46:12 +04:00
Vadim Petrochenkov
050bd32958 resolve: Merge resolution for macro_rules into the common early in-scope resolution function
`fn resolve_legacy_scope`/`fn resolve_lexical_macro_path_segment` -> `fn early_resolve_ident_in_lexical_scope`
2018-10-05 11:40:40 +04:00
bors
61f5ca7d64 Auto merge of #54703 - davidtwco:issue-52086, r=nikomatsakis
error message when trying to move from an Rc or Arc is ungreat

Fixes #52086.

r? @nikomatsakis
2018-10-05 07:40:36 +00:00
Vadim Petrochenkov
a7cce470b6 Fix two UI tests with locale-dependent output 2018-10-05 11:37:48 +04:00
Andy Russell
0501ee23d5
add test for #29743 2018-10-04 15:50:23 -04:00
Andy Russell
e15e86b843
add test for #24338 2018-10-04 15:50:01 -04:00
Andy Russell
1ab1b1e6f8
add test for #28134 2018-10-04 15:49:29 -04:00
bors
a57f1c9c95 Auto merge of #54666 - matthewjasper:mir-function-spans, r=pnkfelix
[NLL] Improve "borrow later used here" messages

* In the case of two conflicting borrows, the later used message says which borrow it's referring to
* If the later use is a function call (from the users point of view) say that the later use is for the call. Point just to the function.

r? @pnkfelix
Closes #48643
2018-10-04 16:34:27 +00:00
Jonas Schievink
e24f4d57b0 Convert conservative_impl_trait.rs to compile-pass 2018-10-04 14:57:31 +02:00
Jonas Schievink
31d5878a05 Convert issue-49556.rs to compile-pass 2018-10-04 14:55:40 +02:00
Jonas Schievink
7e5a13163e Convert issue-49376.rs to compile-pass 2018-10-04 14:53:16 +02:00
Jonas Schievink
12cabc824b Convert existential-minimal.rs to compile-pass 2018-10-04 14:51:26 +02:00
Jonas Schievink
62e9a09cfb Convert impl-trait/issue-42479.rs to compile-pass 2018-10-04 14:47:46 +02:00
Jonas Schievink
3c46da8c82 Fix dead code lint for functions using impl Trait 2018-10-04 14:14:14 +02:00
Felix S. Klock II
594655bafa Regression test for #32382. 2018-10-04 13:03:24 +02:00
Pietro Albini
71aded852f
Rollup merge of #54795 - euclio:ifmt-bad-arg, r=estebank
remove padding from multiline format string label

Fixes #53836.
2018-10-04 12:20:17 +02:00
Pietro Albini
cbc9477bda
Rollup merge of #54780 - scalexm:dup-predicates, r=nikomatsakis
Remove duplicate predicates in `explicit_predicates_of`

I took a more brutal approach than described in #52187. I could have used the `linked_hash_map` crate but this seems overkill, especially as we need a vec storage in the end.

r? @nikomatsakis
2018-10-04 12:20:13 +02:00
bors
088fc7384c Auto merge of #53851 - oli-obk:local_promotion, r=eddyb
Limit the promotion of const fns to the libstd and the `rustc_promotable` attribute

There are so many questions around promoting const fn calls... it seems saner to try to limit automatic promotion to const fns which were explicitly opted in for promotion.

I added the attribute to all public stable const fns that were already promotable (e.g. not Cell::new) in order to not cause any breakage

r? @eddyb

cc @nikomatsakis
2018-10-04 06:48:13 +00:00
bors
c67ea54d44 Auto merge of #54624 - arielb1:evaluate-outlives, r=nikomatsakis
handle outlives predicates in trait evaluation

This handles higher-ranked outlives predicates in trait evaluation the same way they are handled in projection.

Fixes #54302. I think this is a more correct fix than #54401 because it fixes the root case in evaluation instead of making evaluation used in less cases. However, we might want to go to a direction closer to @nikomatsakis's solution with Chalk.

r? @nikomatsakis
2018-10-04 03:08:22 +00:00
bors
d0787284da Auto merge of #54447 - KiChjang:issue-54331, r=nikomatsakis
Lower type ascriptions to HAIR and MIR

Fixes #54331.

r? @nikomatsakis
2018-10-04 00:26:00 +00:00
bors
4bf883b5e7 Auto merge of #54391 - davidtwco:issue-54230, r=petrochenkov
suggest `crate::...` for "local" paths in 2018

Fixes #54230.

This commit adds suggestions for unresolved imports in the cases where
there could be a missing `crate::`, `super::`, `self::` or a missing
external crate name before an import.

r? @nikomatsakis
2018-10-03 21:46:21 +00:00
Matthew Jasper
bc4f9b848d Clearer later use messages for calls
Give a special message when the later use is from a call. Use the span
of the callee instead of the whole expression. For conflicting borrow
messages say that the later use is of the first borrow.
2018-10-03 20:32:38 +01:00
Andy Russell
b14dc69ee8
remove padding from multiline format string label
Fixes #53836.
2018-10-03 14:29:39 -04:00
bors
5597ee8a64 Auto merge of #54605 - petrochenkov:mambig, r=alexcrichton
resolve: Disambiguate a subset of conflicts "macro_rules" vs "macro name in module"

Currently if macro name may refer to both a `macro_rules` macro definition and a macro defined/imported into module we conservatively report an ambiguity error.
Unfortunately, these errors became a source of regressions when macro modularization was enabled - see issue https://github.com/rust-lang/rust/issues/54472.

This PR disambiguates such conflicts in favor of `macro_rules` if both the `macro_rules` item and in-module macro name are defined in the same normal (named) module and `macro_rules` is closer in scope to the point of use (see the tests for examples).
This is a subset of more general approach described in https://github.com/rust-lang/rust/issues/54472#issuecomment-424666659.
The subset is enough to fix all the regressions from https://github.com/rust-lang/rust/issues/54472, but it can be extended to apply to all "macro_rules" vs "macro name in module" conflicts in the future.

To give an analogy, this is equivalent to scoping rules for `let` variables and items defined in blocks (`macro_rules` behaves like "`let` at module level" in general).
```rust
{ // beginning of the block
    use xxx::m; // (1)

    // Starting from the beginning of the block and until here m!() refers to (1)
    macro_rules! m { ... } // (2)
    // Starting from here and until the end of the block m!() refers to (2)
} // end of the block
```
More complex examples with `use` and `macro_rules` from different modules still report ambiguity errors, even if equivalent examples with `let` are legal.

Fixes https://github.com/rust-lang/rust/issues/54472 (stable-to-beta regression)
2018-10-03 18:12:22 +00:00
varkor
113141b6f5 Only warn about unused mut in user-written code 2018-10-03 14:14:11 +01:00
David Wood
9d408e0511
Update tests to demonstrate 2015 behaviour.
Adds a test to demonstrate behaviour of suggestions in the
2015 edition.
2018-10-03 14:43:58 +02:00
David Wood
29e2376ac7
Add suggestions for unresolved imports.
This commit adds suggestions for unresolved imports in the cases where
there could be a missing `crate::`, `super::`, `self::` or a missing
external crate name before an import.
2018-10-03 14:43:57 +02:00
Vadim Petrochenkov
078fc52cbc resolve: Prefer macro_rules definitions to in-module macro definitions in some cases 2018-10-03 16:12:39 +04:00
scalexm
8327976890 Remove duplicate predicates in explicit_predicates_of
Fixes #52187.
2018-10-03 13:57:47 +02:00
bors
6ddab3e078 Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
NLL fails to suggest "try removing `&mut` here"

Fixes #51191.

This PR adds ``try removing `&mut` here`` suggestions to functions where a mutable borrow is being taken of a `&mut self` or a `self: &mut Self`. This PR also enables the suggestion for adding a `mut` pattern to by-value implicit self arguments without `mut` patterns already.

r? @nikomatsakis
2018-10-03 10:49:27 +00:00