Commit Graph

69191 Commits

Author SHA1 Message Date
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
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
bors
525b81d570 Auto merge of #45734 - kennytm:ci-fix-centos-broken-link, r=alexcrichton
ci: Fix broken link in `build-powerpc64le-toolchain.sh`

r? @rust-lang/infra

This is just an emergency fix to keep bors running for another week. I think the numbers will be broken soon. Can we verify if this statement is still true later?

> First, download the CentOS7 glibc.ppc64le and relevant header files.
> (upstream ppc64le support wasn't added until 2.19, which el7 backported.)
2017-11-03 12:30:09 +00:00
kennytm
1f95c6de3c
Fix broken link in build-powerpc64le-toolchain.sh 2017-11-03 15:53:36 +08:00
Zack M. Davis
085ec6d528 unreachable-pub lint for pub items not reachable from crate root
This is with deepest thanks to Vadim Petrochenkov for thorough review, and
resolves #45521.
2017-11-02 20:50:17 -07:00
bors
9f3b09116b Auto merge of #45484 - oli-obk:lint_names, r=nikomatsakis
Report lint names in json diagnostics

This allows tools like `rustfix` to have whitelists for what to automatically apply and what not.
2017-11-03 00:42:11 +00:00
bors
e340996ff5 Auto merge of #45409 - tamird:suggest-match-default-bindings, r=nikomatsakis
typeck: suggest use of match_default_bindings feature

Fixes #45383.
Updates #42640.

r? @nikomatsakis
cc @tschottdorf

This needs a UI test, but thought I'd get some early feedback.
2017-11-02 16:28:16 +00:00
bors
5ce3d482e2 Auto merge of #45647 - nrc:rls-bugs, r=eddyb
save-analysis: support unions

r? @eddyb
2017-11-02 12:34:13 +00:00
Oliver Schneider
6ae440e048
Make the difference between lint codes and error codes explicit 2017-11-02 10:19:41 +01:00
Oliver Schneider
88fb4c4fda
Report lint names in json diagnostics 2017-11-02 10:19:41 +01:00
bors
a7d98c7837 Auto merge of #45630 - joshleeb:iss35241, r=estebank
Improve display of error E0308

Ref. Forgetting to call a variant constructor causes a confusing error message #35241.

This PR modifies [`note_type_err`](b7041bfab3/src/librustc/infer/error_reporting/mod.rs (L669-L674)) to display a `help` message when a `TyFnPtr` or `TyFnDef` are found and the return type, of the function or function pointer, is the same as the type that is expected.

The output of compiling

```rust
struct Foo(u32);

fn test() -> Foo { Foo }

fn main() {}
```

is now

```bash
$ rustc src/test/ui/issue-35241.rs
error[E0308]: mismatched types
  --> src/test/ui/issue-35241.rs:13:20
   |
13 | fn test() -> Foo { Foo }
   |              ---   ^^^ expected struct `Foo`, found fn item
   |              |
   |              expected `Foo` because of return type
   |
   = help: did you mean `Foo { /* fields */ }`?
   = note: expected type `Foo`
              found type `fn(u32) -> Foo {Foo::{{constructor}}}`

error: aborting due to previous error
```
2017-11-02 08:30:03 +00:00
bors
2379faa933 Auto merge of #45468 - Xanewok:crate-source, r=nrc
Emit crate disambiguators in save-analysis data

Needed for https://github.com/nrc/rls-analysis/issues/93.
Blocked by https://github.com/nrc/rls-data/pull/11. (For now, this pulls my branch [rls-data/crate-source](https://github.com/Xanewok/rls-data/tree/crate-source))

This will allow to disambiguate different crates types/versions when indexing resulting save-analysis data (most importantly allow to support bin+lib and different crate versions).

r? @nrc
2017-11-02 03:36:50 +00:00
bors
d5b69d4670 Auto merge of #45306 - whitequark:ref_slice, r=alexcrichton
Bring back slice::ref_slice as slice::from_ref.

These functions were deprecated and removed in 1.5, but such simple
functionality shouldn't require using unsafe code, and it isn't
cluttering libstd too much.

The original removal was quite contentious (see #27774), since then
we've had precedent for including such nuggets of functionality (see rust-lang/rfcs#1789),
and @nikomatsakis has provided a lot of use cases in https://github.com/rust-lang/rfcs/pull/1789#issuecomment-314640034.
Hence this PR.

I'm not too sure what to do with stability, feel free to correct me.
It seems pointless to go through stabilization for these functions though.

cc @aturon
2017-11-02 00:06:16 +00:00
whitequark
1cc88be2eb De-stabilize core::slice::{from_ref, from_ref_mut}. 2017-11-01 22:21:29 +00:00
bors
2be4cc0402 Auto merge of #45538 - nikomatsakis:nll-liveness, r=pnkfelix
enable non-lexical lifetimes in the MIR borrow checker

This PR, joint work with @spastorino, fills out the NLL infrastructure and integrates it with the borrow checker. **Don't get too excited:** it includes still a number of hacks (the subtyping code is particularly hacky). However, it *does* kinda' work. =)

The final commit demonstrates this by including a test that -- with both the AST borrowck and MIR borrowck -- reports an error by default. But if you pass `-Znll`, you only get an error from the AST borrowck, demonstrating that the integration succeeds:

```
struct MyStruct {
    field: String
}

fn main() {
    let mut my_struct = MyStruct { field: format!("Hello") };

    let value = &my_struct.field;
    if value.is_empty() {
        my_struct.field.push_str("Hello, world!");
        //~^ ERROR cannot borrow (Ast)
    }
}
```
2017-11-01 18:14:13 +00:00
bors
a3f990dc08 Auto merge of #45472 - michaelwoerister:incr-comp-caching-base, r=nikomatsakis
incr.comp.: Implement compiler diagnostic persistence.

This PR implements storing and loading diagnostics that the compiler generates and thus allows for emitting warnings during incremental compilation without actually re-evaluating the thing the warning originally came from. It also lays some groundwork for storing and loading type information and MIR in the incr. comp. cache.

~~It is still work in progress:~~
- ~~There's still some documentation to be added.~~
- ~~The way anonymous queries are handled might lead to duplicated emissions of warnings. Not sure if there is a better way or how frequent such duplication would be in practice.~~

Diagnostic message duplication is addressed separately in #45519.

r? @nikomatsakis
2017-11-01 14:28:11 +00:00
bors
2f581cf9d6 Auto merge of #45435 - eddyb:binop-subtype-lhs, r=nikomatsakis
rustc_typeck: use subtyping on the LHS of binops.

Fixes #45425.

r? @nikomatsakis
2017-11-01 09:40:15 +00:00
bors
740286657a Auto merge of #45674 - kennytm:rollup, r=kennytm
Rollup of 14 pull requests

- Successful merges: #45450, #45579, #45602, #45619, #45624, #45644, #45646, #45648, #45649, #45650, #45652, #45660, #45664, #45671
- Failed merges:
2017-11-01 07:04:17 +00:00
kennytm
028455082e Rollup merge of #45671 - est31:master, r=alexcrichton
Tidy: track rustc_const_unstable feature gates as well

This is important for the unstable book stub generation.
2017-11-01 13:32:21 +08:00
kennytm
e2554b36fc Rollup merge of #45664 - mbrubeck:docs, r=estebank
Fix incorrect error type in Read::byte docs

None
2017-11-01 13:32:20 +08:00
kennytm
0ec40c1704 Rollup merge of #45660 - Cldfire:suggest-rename-import, r=estebank
Suggest renaming import if names clash

Closes https://github.com/rust-lang/rust/issues/32354.

The output for the example in the issue looks like this:

```
~/p/local-rust-dev-testing ❯❯❯ cargo +local-s1 build
   Compiling local-rust-dev-testing v0.1.0 (file:///home/cldfire/programming_projects/local-rust-dev-testing)
error[E0252]: the name `ConstructorExtension` is defined multiple times
  --> src/main.rs:49:5
   |
48 | use extension1::ConstructorExtension;
   |     -------------------------------- previous import of the trait `ConstructorExtension` here
49 | use extension2::ConstructorExtension;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ConstructorExtension` reimported here
   |
   = note: `ConstructorExtension` must be defined only once in the type namespace of this module
help: You can use `as` to change the binding name of the import
   |
49 | use extension2::ConstructorExtension as OtherConstructorExtension;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

...
```

This is my first PR that touches the compiler in any way, so if there's something else I need to do here (e.g. add a test), please let me know :).
2017-11-01 13:32:19 +08:00
kennytm
63ad1293cc Rollup merge of #45652 - malbarbo:x32-2, r=alexcrichton
More fixes for x86_64-unknown-linux-gnux32

This update libc (all libc testing are passing) and fixes NR_GETRANDOM.

Fix all but one run-pass test (lto-unwind.rs, see https://github.com/rust-lang/rust/issues/45416)
2017-11-01 13:32:18 +08:00
kennytm
2d53d94c3b Rollup merge of #45650 - michaelwoerister:per-crate-type-symbol-threshold, r=alexcrichton
Take crate-type into account when generating symbol export lists (linker version scripts)

r? @alexcrichton
cc https://github.com/rust-lang/rust/issues/45613
2017-11-01 13:32:17 +08:00
kennytm
57b4658a2b Rollup merge of #45649 - tbu-:pr_doc_bufread_eof, r=estebank
Add a hint what `BufRead` functions do on EOF
2017-11-01 13:32:16 +08:00
kennytm
e9b5c86c03 Rollup merge of #45648 - tbu-:pr_doc_unix_ext, r=estebank
Update doc comment for the Unix extension module

It was a bit outdated, claimed to be able to do less than it actually
could.
2017-11-01 13:32:15 +08:00
kennytm
cf0fe06bb9 Rollup merge of #45646 - sinkuu:dead-code-alias-in-pat, r=arielb1
Count type aliases used in patterns as usage by dead_code lint

Fixes #45614.
2017-11-01 13:32:14 +08:00
kennytm
26af3e1c4e Rollup merge of #45644 - zackmdavis:edit_disallowed_inner_attr_note, r=estebank
edit and fix bad spacing of inner-attribute-not-allowed note

This multiline string literal was missing a backslash, leaving an awkward
newline and 35 spaces in the middle of the message.

But while we're here, the existing message seems kind of long in comparison to
similar notes: to cut it down, we excise the mentions of doc comments, which
seems sensible because we know that this erroneous attribute is not a doc
comment (notice the `is_sugared_doc: false` at the end of the function; if it
had been a doc comment, that error would get set in the `token::DocComment`
match branch of `parse_outer_attributes`).
2017-11-01 13:32:13 +08:00
kennytm
28b18790f7 Rollup merge of #45624 - glaubitz:bootstrap-sparc64, r=kennytm
bootstrap: Add missing cputype matching for sparc64

Trying to configure rust natively on sparc64-unknown-linux-gnu currently fails with:

```
root@deb4g:/local_scratch/glaubitz/rust/rust# ./configure --host=sparc64-unknown-linux-gnu --enable-local-rust --local-rust-root=/usr/local
configure: processing command line
configure:
configure: build.host           := ['sparc64-unknown-linux-gnu']
configure: build.rustc          := /usr/local/bin/rustc
configure: build.cargo          := /usr/local/bin/cargo
configure: build.rustc          := /usr/local/bin/rustc
configure: build.cargo          := /usr/local/bin/cargo
configure: build.configure-args := ['--host=sparc64-unknown-linux-gnu', '--enable ...
unknown cpu type: sparc64
root@deb4g:/local_scratch/glaubitz/rust/rust#
```

This is trivially fixed by defining sparc64 as a valid cputype.
2017-11-01 13:32:12 +08:00
kennytm
18fa54f835 Rollup merge of #45619 - mneumann:fix-bootstrap-dragonfly, r=alexcrichton
Support Dragonfly when building Openssl
2017-11-01 13:32:11 +08:00
kennytm
e01dcf4b75 Rollup merge of #45602 - petrochenkov:ospan, r=michaelwoerister
Optimize some span operations

Do not decode span data twice/thrice/etc unnecessarily.
Applied to stable hashing and all methods in `impl Span`.

Follow up to https://github.com/rust-lang/rust/pull/44646
r? @michaelwoerister
2017-11-01 13:32:10 +08:00
kennytm
59c9d03af8 Rollup merge of #45579 - leodasvacas:document-that-call-can-be-adt-constructor, r=estebank
Document that call expressions also represent ADT constructors.

This is a rather obscure part of the language.
2017-11-01 13:32:09 +08:00
kennytm
07df45d363 Rollup merge of #45450 - GuillaumeGomez:overlap-link, r=QuietMisdreavus
Fix title heading overlap in rust doc

Fixes #45158.

To be noted that this margin only appears when a title is the first element.

<img width="1440" alt="screen shot 2017-10-22 at 16 08 44" src="https://user-images.githubusercontent.com/3050060/31862746-6411070e-b743-11e7-9a75-4159e1f7f1d6.png">

r? @rust-lang/docs
2017-11-01 13:32:08 +08:00
bors
31bbe57c79 Auto merge of #45267 - oconnor663:rwlock_send, r=alexcrichton
remove the `T: Sync` requirement for `RwLock<T>: Send`

That requirement makes sense for containers like `Arc` that don't
uniquely own their contents, but `RwLock` is not one of those.

This restriction was added in 380d23b5d4, but it's not clear why. @hniksic
and I [were discussing this on reddit](https://www.reddit.com/r/rust/comments/763o7r/blog_posts_introducing_lockfree_rust_comparing/dobcvbm/). I might be totally wrong about this change being sound, but I'm super curious to find out :)
2017-11-01 04:32:15 +00:00
bors
fc3e12a03c Auto merge of #45187 - GuillaumeGomez:doc-ui-improvement, r=QuietMisdreavus
Improve sidebar rendering and add methods list

I suppose it can be reviewed as is, but this is just the first step of a more global plan.

cc @rust-lang/docs @nical

And a screenshot of course:

<img width="1440" alt="screen shot 2017-10-10 at 23 38 45" src="https://user-images.githubusercontent.com/3050060/31412170-657beaf6-ae14-11e7-9f01-1e562a034595.png">
2017-11-01 01:45:58 +00:00
Igor Matuszewski
b4ffedee67 Update rls so it compiles with #45468 2017-11-01 00:48:26 +01:00