Commit Graph

69504 Commits

Author SHA1 Message Date
kennytm
9ca6ee0299 Rollup merge of #45548 - ratmice:master, r=oli-obk
issue #45357 don't build clippy stage 1

#45357
Wasn't sure top_stage was the right thing, but seemed to go ahead building clippy stage 2.
2017-11-04 13:49:26 +08:00
Scott McMurray
1b19e64324 Add overflow tests for next_power_of_two 2017-11-03 22:33:34 -07:00
Scott McMurray
15ea3d80da Fix #18604: next_power_of_two should panic on overflow 2017-11-03 21:48:33 -07:00
bors
a4541525d5 Auto merge of #45514 - gnzlbg:jemalloc_realloc2, r=sfackler
[jemalloc] set correct excess in realloc_excess
2017-11-04 04:28:13 +00:00
Esteban Küber
9dc7abe06d Detect = -> : typo in let bindings
When encountering a let binding type error, attempt to parse as
initializer instead. If successful, it is likely just a typo:

```rust
fn main() {
    let x: Vec::with_capacity(10);
}
```

```
error: expected type, found `10`
 --> file.rs:3:31
  |
3 |     let x: Vec::with_capacity(10, 20);
  |         --                    ^^
  |         ||
  |         |help: did you mean assign here?: `=`
  |         while parsing the type for `x`
```
2017-11-03 17:39:16 -07:00
Vadim Petrochenkov
765076faab Give better help for identifier patterns failing exhaustiveness check 2017-11-04 03:09:47 +03:00
Vadim Petrochenkov
3386757923 Move some tests to UI 2017-11-04 03:09:47 +03:00
Vadim Petrochenkov
db0be32fec resolve: Use same rules for disambiguating fresh bindings in match and let 2017-11-04 03:09:47 +03:00
bors
95a401609f Auto merge of #45384 - mikhail-m1:mir_add_false_edges_terminator_kind, r=arielb1
add TerminatorKind::FalseEdges and use it in matches

impl #45184 and fixes #45043 right way.

False edges unexpectedly affects uninitialized variables analysis in MIR borrowck.
2017-11-04 00:09:14 +00:00
Lukas Kalbertodt
259c125267 Mark several ascii methods as unstable again
We don't want to stabilize them now already. The goal of this set of
commits is just to add inherent methods to the four types. Stabilizing
all of those methods can be done later.
2017-11-03 21:28:04 +01:00
Lukas Kalbertodt
da57580736 Remove unused AsciiExt imports and fix tests related to ascii methods
Many AsciiExt imports have become useless thanks to the inherent ascii
methods added in the last commits. These were removed. In some places, I
fully specified the ascii method being called to enforce usage of the
AsciiExt trait. Note that some imports are not removed but tagged with
a `#[cfg(stage0)]` attribute. This is necessary, because certain ascii
methods are not yet available in stage0. All those imports will be
removed later.

Additionally, failing tests were fixed. The test suite should exit
successfully now.
2017-11-03 21:27:40 +01:00
Lukas Kalbertodt
1916e3c4aa Copy AsciiExt methods to str directly
This is done in order to deprecate AsciiExt eventually. Note that
this commit contains a bunch of `cfg(stage0)` statements. This is
due to a new compiler feature this commit depends on: the
`slice_u8` lang item. Once this lang item is available in the
stage0 compiler, all those cfg flags (and more) can be removed.
2017-11-03 21:27:40 +01:00
Lukas Kalbertodt
5a1d11a733 Copy AsciiExt methods to [u8] directly
This is done in order to deprecate AsciiExt eventually. Note that
this commit contains a bunch of `cfg(stage0)` statements. This is
due to a new compiler feature I am using: the `slice_u8` lang item.
Once this lang item is available in the stage0 compiler, all those
cfg flags (and more) can be removed.
2017-11-03 21:27:40 +01:00
Simon Sapin
9e441c76f7 Add a lang item to allow impl [u8] {…} in the standard library 2017-11-03 21:27:40 +01:00
Lukas Kalbertodt
8a4fa742a1 Fix lists in doc comments for ascii methods of u8 and char 2017-11-03 21:27:40 +01:00
Lukas Kalbertodt
f373916cb5 Add missing space in match arm 2017-11-03 21:27:40 +01:00
Lukas Kalbertodt
3b13b66351 Tweak documentation for u8::eq_ignore_ascii_case() 2017-11-03 21:27:40 +01:00
Lukas Kalbertodt
a5277622c5 Remove examples in doc-comments of AsciiExt methods
The doc comments were incorrect before: since the inherent ascii methods
shadow the `AsciiExt` methods, the examples didn't use the `AsciiExt` at
all. Since the trait will be deprecated soon anyway, the easiest solution
was to remove the examples and already mention that the methods will be
deprecated in the near future.
2017-11-03 21:27:40 +01:00
Lukas Kalbertodt
6f5556854e Use direct implementation on u8/char to implement AsciiExt
The methods were copied to u8/char, so we can just use it in
AsciiExt impls to avoid duplicate code.
2017-11-03 21:27:40 +01:00
Lukas Kalbertodt
d425f8d226 Copy AsciiExt methods to char directly
This is done in order to deprecate AsciiExt eventually.
2017-11-03 21:27:40 +01:00
Lukas Kalbertodt
5061c9fecb Revert signature of eq_ignore_ascii_case() to original
Since the methods on u8 directly will shadow the AsciiExt methods,
we cannot change the signature without breaking everything. It
would have been nice to take `u8` as argument instead of `&u8`, but
we cannot break stuff! So this commit reverts it to the original
`&u8` version.
2017-11-03 21:27:40 +01:00
Lukas Kalbertodt
04070d1148 Make ascii methods on u8 insta-stable
Those methods will shadow the methods of `AsciiExt`, so if we don't
make them insta-stable, everyone will hitting stability errors. It
is fine adding those as stable, because they are just being moved
around [according to sfackler][1].

OPEN QUESTION: this commit also stabilizes the `AsciiExt` methods
that were previously feature gated by the `ascii_ctype` feature.
Maybe we don't want to stablilize those yet.

[1]: https://github.com/rust-lang/rust/pull/44042#issuecomment-329939279
2017-11-03 21:27:40 +01:00
Lukas Kalbertodt
d3f2be4bd8 Add all methods of AsciiExt to u8 directly
This is the first step in order to deprecate AsciiExt. Since
this is a WIP commit, there is still some code duplication (notably
the static arrays) that will be removed later.
2017-11-03 21:27:17 +01:00
Vadim Petrochenkov
d588f9338d Shorten paths to auxiliary files created by tests 2017-11-03 22:41:15 +03:00
David Wood
d3babe5eaa
Added page to unstable book. 2017-11-03 19:36:19 +00:00
David Wood
059eccb07f
Implemented RFC 2008 for enums (not including variants) and structs. 2017-11-03 19:36:18 +00:00
David Wood
6c19ebe128
Added tests for RFC 2008. 2017-11-03 19:36:18 +00:00
David Wood
d51ea538e4
Added feature gate for RFC 2008. 2017-11-03 19:36:17 +00:00
bors
2278506f68 Auto merge of #45247 - leodasvacas:implement-auto-trait-syntax, r=nikomatsakis
[Syntax] Implement auto trait syntax

Implements `auto trait Send {}` as a substitute for `trait Send {} impl Send for .. {}`.

See the [internals thread](https://internals.rust-lang.org/t/pre-rfc-renaming-oibits-and-changing-their-declaration-syntax/3086) for motivation. Part of #13231.

The first commit is just a rename moving from "default trait" to "auto trait". The rest is parser->AST->HIR work and making it the same as the current syntax for everything below HIR. It's under the `optin_builtin_traits` feature gate.

When can we remove the old syntax? Do we need to wait for a new `stage0`? We also need to formally decide for the new form (even if the keyword is not settled yet).

Observations:
- If you `auto trait Auto {}` and then `impl Auto for .. {}` that's accepted even if it's redundant.
- The new syntax is simpler internally which will allow for a net removal of code, for example well-formedness checks are effectively moved to the parser.
- Rustfmt and clippy are broken, need to fix those.
- Rustdoc just ignores it for now.

ping @petrochenkov @nikomatsakis
2017-11-03 19:07:45 +00:00
leonardo.yvens
5190abb941 Fix unsafe auto trait pretty print.
It was being printed wrong as auto unsafe trait
2017-11-03 16:13:23 -02:00
leonardo.yvens
ca26f01dd1 Update pretty test for auto trait syntax. 2017-11-03 16:13:22 -02:00
leonardo.yvens
3241f4583b rustfmt is broken which makes rls broken 2017-11-03 16:13:22 -02:00
leonardo.yvens
5e74353981 fix rebase conflict 2017-11-03 16:13:22 -02:00
leonardo.yvens
27efe126e0 Rename trait_has_auto_impl to trait_is_auto 2017-11-03 16:13:22 -02:00
leonardo.yvens
94b07a91bc update unstable book and error example 2017-11-03 16:13:22 -02:00
leonardo.yvens
97de8cae6e Parse auto traits the same as traits.
This moves the well formedness checks to the AST validation pass. Tests
were adjusted.

The auto keyword should be back-compat now.
2017-11-03 16:13:22 -02:00
leonardo.yvens
9d181ac2de Fix tests and rebase conflict 2017-11-03 16:13:21 -02:00
leonardo.yvens
8b586e68b5 auto trait future compatibility lint 2017-11-03 16:13:21 -02:00
leonardo.yvens
0d1b79a01a Finish DefaultImpl -> AutoImpl rename.
Forgot this ones.
2017-11-03 16:13:21 -02:00
leonardo.yvens
acf50ee236 Add tests for auto trait, fix parsing bug
Now we can do the well formedness checks in the parser, yay!
2017-11-03 16:13:21 -02:00
leonardo.yvens
37dfc0c598 Feature gate auto trait and ignore it in rustdoc 2017-11-03 16:13:21 -02:00
leonardo.yvens
00be060daf Teach typeck about auto trait 2017-11-03 16:13:20 -02:00
leonardo.yvens
1f4b630899 add auto keyword, parse auto trait, lower to HIR
Adds an `IsAuto` field to `ItemTrait` which flags if the trait was
declared as an `auto trait`.

Auto traits cannot have generics nor super traits.
2017-11-03 16:13:20 -02:00
leonardo.yvens
06506bb751 [Syntax Breaking] Rename DefaultImpl to AutoImpl
DefaultImpl is a highly confusing name for what we now call auto impls,
as in `impl Send for ..`. The name auto impl is not formally decided
but for sanity anything is better than `DefaultImpl` which refers
neither to `default impl` nor to `impl Default`.
2017-11-03 16:13:20 -02:00
matt rice
aa9d0aae99 issue #45357 set clippy build condition to extended. 2017-11-03 10:52:36 -07:00
Guillaume Gomez
765153e6a4 Add tests for methods listing in rust docs 2017-11-03 18:39:00 +01:00
gnzlbg
549ab77e23 [jemalloc] set correct excess in alloc_excess 2017-11-03 17:44:58 +01:00
bors
59d484575a Auto merge of #45569 - zackmdavis:unexported_pub_lint, r=petrochenkov
`unreachable-pub` lint (as authorized by RFC 2126)

To whom it may concern:

RFC 2126 commissions the creation of a lint for `pub` items that are not visible from crate root (#45521). We understand (but seek confirmation from more knowledgable compiler elders) that this can be implemented by linting HIR items that are _not_ ~~`cx.access_levels.is_exported`~~ `cx.access_levels.is_reachable` but have a `vis` (-ibility) field of `hir::Visibility::Public`.

The lint, tentatively called ~~`unexported-pub`~~ `unreachable-pub` (with the understanding that much could be written on the merits of various names, as it is said of the colors of bicycle-sheds), suggests `crate` as a replacement for `pub` if the `crate_visibility_modifier` feature is enabled (see #45388), and `pub(crate)` otherwise. We also use help messaging to suggest the other potential fix of exporting the item; feedback is desired as to whether this may be confusing or could be worded better.

As a preview of what respecting the proposed lint would look like (and to generate confirmatory evidence that this implementation doesn't issue false positives), ~~we take its suggestions for `libcore`~~ (save one, which is deferred to another pull request because it brings up an unrelated technical matter). I remain your obedient servant.

![unexported_pub](https://user-images.githubusercontent.com/1076988/32089794-fbd02420-baa0-11e7-87e5-3ec01f18924a.png)

r? @petrochenkov
2017-11-03 16:28:24 +00:00
Oliver Schneider
e5c1d512e7
Update config.rs 2017-11-03 16:32:03 +01:00
Oliver Schneider
443332afaf
Refactor internal suggestion API 2017-11-03 16:30:04 +01:00