]> git.lizzy.rs Git - rust.git/log
rust.git
6 years agoDisplay all emission types in error msg if user inputs invalid option.
Corey Farwell [Sun, 5 Nov 2017 14:20:59 +0000 (09:20 -0500)]
Display all emission types in error msg if user inputs invalid option.

before:

```
> rustc --emit foo
error: unknown emission type: `foo`
```

after:

```
> rustc --emit foo
error: unknown emission type: `foo` - expected one of: `llvm-bc`, `asm`, `llvm-ir`, `mir`, `obj`, `metadata`, `link`, `dep-info`
```

6 years agoAuto merge of #45754 - scottmcm:checked-npot, r=dtolnay
bors [Sun, 5 Nov 2017 09:11:45 +0000 (09:11 +0000)]
Auto merge of #45754 - scottmcm:checked-npot, r=dtolnay

Fix #18604: next_power_of_two should panic on overflow

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

Is it possible to write a test for this?  My experiments showed `x.py test` running in release mode, so my attempt at a `#[should_panic]` didn't work.

6 years agoAuto merge of #45748 - petrochenkov:short, r=alexcrichton
bors [Sun, 5 Nov 2017 06:42:17 +0000 (06:42 +0000)]
Auto merge of #45748 - petrochenkov:short, r=alexcrichton

Shorten paths to auxiliary files created by tests

I'm hitting issues with long file paths to object files created by the test suite, similar to https://github.com/rust-lang/rust/issues/45103#issuecomment-335622075.

If we look at the object file path in https://github.com/rust-lang/rust/issues/45103 we can see that the patch contains of few components:
```
specialization-cross-crate-defaults.stage2-x86_64-pc-windows-gnu.run-pass.libaux\specialization_cross_crate_defaults.specialization_cross_crate_defaults0.rust-cgu.o
```
=>

1. specialization-cross-crate-defaults // test name, required
2. stage2 // stage disambiguator, required
3. x86_64-pc-windows-gnu // target disambiguator, required
4. run-pass // mode disambiguator, rarely required
5. libaux // suffix, can be shortened
6. specialization_cross_crate_defaults // required, there may be several libraries in the directory
7. specialization_cross_crate_defaults0 // codegen unit name, can be shortened?
8. rust-cgu // suffix, can be shortened?
9. o // object file extension

This patch addresses items `4`, `5` and `8`.
`libaux` is shortened to `aux`, `rust-cgu` is shortened to `rcgu`, mode disambiguator is omitted unless it's necessary (for pretty-printing and debuginfo tests, see https://github.com/rust-lang/rust/pull/24537/commits/38d26d811a44ba93637c84ce77a58af88c47f0ac)

I haven't touched names of codegen units though (`specialization_cross_crate_defaults0`).
Is it useful for them to have descriptive names including the crate name, as opposed to just `0` or `cgu0` or something?

6 years agoAuto merge of #45710 - alexcrichton:std-symbols, r=michaelwoerister
bors [Sun, 5 Nov 2017 04:02:07 +0000 (04:02 +0000)]
Auto merge of #45710 - alexcrichton:std-symbols, r=michaelwoerister

rustc: Handle some libstd symbole exports better

Right now symbol exports, particularly in a cdylib, are handled by
assuming that `pub extern` combined with `#[no_mangle]` means "export
this". This isn't actually what we want for some symbols that the
standard library uses to implement itself, for example symbols related
to allocation. Additionally other special symbols like
`rust_eh_personallity` have no need to be exported from cdylib crate
types (only needed in dylib crate types).

This commit updates how rustc handles these special symbols by adding to
the hardcoded logic of symbols like `rust_eh_personallity` but also
adding a new attribute, `#[rustc_std_internal_symbol]`, which forces the
export level to be considered the same as all other Rust functions
instead of looking like a C function.

The eventual goal here is to prevent functions like `__rdl_alloc` from
showing up as part of a Rust cdylib as it's just an internal
implementation detail. This then further allows such symbols to get gc'd
by the linker when creating a cdylib.

6 years agorustc: Handle some libstd symbole exports better
Alex Crichton [Wed, 1 Nov 2017 20:16:36 +0000 (13:16 -0700)]
rustc: Handle some libstd symbole exports better

Right now symbol exports, particularly in a cdylib, are handled by
assuming that `pub extern` combined with `#[no_mangle]` means "export
this". This isn't actually what we want for some symbols that the
standard library uses to implement itself, for example symbols related
to allocation. Additionally other special symbols like
`rust_eh_personallity` have no need to be exported from cdylib crate
types (only needed in dylib crate types).

This commit updates how rustc handles these special symbols by adding to
the hardcoded logic of symbols like `rust_eh_personallity` but also
adding a new attribute, `#[rustc_std_internal_symbol]`, which forces the
export level to be considered the same as all other Rust functions
instead of looking like a C function.

The eventual goal here is to prevent functions like `__rdl_alloc` from
showing up as part of a Rust cdylib as it's just an internal
implementation detail. This then further allows such symbols to get gc'd
by the linker when creating a cdylib.

6 years agoUse Add::add for overflow checks instead of [rustc_inherit_overflow_checks]
Scott McMurray [Sun, 5 Nov 2017 00:10:51 +0000 (17:10 -0700)]
Use Add::add for overflow checks instead of [rustc_inherit_overflow_checks]

6 years agoAuto merge of #45711 - tirr-c:unicode-span, r=estebank
bors [Sat, 4 Nov 2017 23:09:19 +0000 (23:09 +0000)]
Auto merge of #45711 - tirr-c:unicode-span, r=estebank

Display spans correctly when there are zero-width or wide characters

Hopefully...
* fixes #45211
* fixes #8706

---

Before:
```
error: invalid width `7` for integer literal
  --> unicode_2.rs:12:25
   |
12 |     let _ = ("a̐éö̲", 0u7);
   |                         ^^^
   |
   = help: valid widths are 8, 16, 32, 64 and 128

error: invalid width `42` for integer literal
  --> unicode_2.rs:13:20
   |
13 |     let _ = ("아あ", 1i42);
   |                    ^^^^
   |
   = help: valid widths are 8, 16, 32, 64 and 128

error: aborting due to 2 previous errors
```

After:
```
error: invalid width `7` for integer literal
  --> unicode_2.rs:12:25
   |
12 |     let _ = ("a̐éö̲", 0u7);
   |                     ^^^
   |
   = help: valid widths are 8, 16, 32, 64 and 128

error: invalid width `42` for integer literal
  --> unicode_2.rs:13:20
   |
13 |     let _ = ("아あ", 1i42);
   |                      ^^^^
   |
   = help: valid widths are 8, 16, 32, 64 and 128

error: aborting due to 2 previous errors
```

Spans might display incorrectly on the browser.

r? @estebank

6 years agoAuto merge of #45394 - davidtwco:rfc-2008, r=petrochenkov
bors [Sat, 4 Nov 2017 18:07:07 +0000 (18:07 +0000)]
Auto merge of #45394 - davidtwco:rfc-2008, r=petrochenkov

RFC 2008: Future-proofing enums/structs with #[non_exhaustive] attribute

This work-in-progress pull request contains my changes to implement [RFC 2008](https://github.com/rust-lang/rfcs/pull/2008). The related tracking issue is #44109.

As of writing, enum-related functionality is not included and there are some issues related to tuple/unit structs. Enum related tests are currently ignored.

WIP PR requested by @nikomatsakis [in Gitter](https://gitter.im/rust-impl-period/WG-compiler-middle?at=59e90e6297cedeb0482ade3e).

6 years agoIgnoring pretty print for test due to #37199
David Wood [Sat, 4 Nov 2017 18:01:35 +0000 (18:01 +0000)]
Ignoring pretty print for test due to #37199

6 years agoAuto merge of #45709 - nrc:rls-bugs-2, r=eddyb
bors [Sat, 4 Nov 2017 15:30:20 +0000 (15:30 +0000)]
Auto merge of #45709 - nrc:rls-bugs-2, r=eddyb

Fix a bunch of minor save-analysis bugs

r? @eddyb

6 years agoAuto merge of #45617 - GuillaumeGomez:search-fixes, r=QuietMisdreavus
bors [Sat, 4 Nov 2017 12:54:34 +0000 (12:54 +0000)]
Auto merge of #45617 - GuillaumeGomez:search-fixes, r=QuietMisdreavus

Search fixes

Fixes #45608.

r? @QuietMisdreavus

6 years agoAuto merge of #45605 - Nashenas88:derive-newtype, r=nikomatsakis
bors [Sat, 4 Nov 2017 10:24:20 +0000 (10:24 +0000)]
Auto merge of #45605 - Nashenas88:derive-newtype, r=nikomatsakis

Add derive and doc comment capabilities to newtype_index macro

This moves `RustcDecodable` and `RustcEncodable` out of the macro definition and into the macro uses. They were conflicting with `CrateNum`'s impls of `serialize::UseSpecializedEncodable` and `serialize::UseSpecializedDecodable`, and now it's not :). `CrateNum` is now defined with the `newtype_index` macro. I also added support for doc comments on constant definitions and allowed a type to remove the pub specification on the tuple param (otherwise a LOT of code would refuse to compile for `CrateNum`). I was getting dozens of errors like this if `CrateNum` was defined as `pub struct CrateNum(pub u32)`:
```
error[E0530]: match bindings cannot shadow tuple structs
   --> src/librustc/dep_graph/dep_node.rs:624:25
    |
63  | use hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX};
    |                   -------- a tuple struct `CrateNum` is imported here
...
624 |     [] MissingLangItems(CrateNum),
    |                         ^^^^^^^^ cannot be named the same as a tuple struct
```

I also cleaned up the formatting of the macro bodies as they were getting impossibly long. Should I go back and fix the matching rules to this style too?

I also want to see what the test results look like because `CrateNum` used to just derive `Debug`, but the `newtype_index` macro has a custom implementation. This might require further pushes.

Feel free to bikeshed on the macro language, I have no preference here.

6 years agoAuto merge of #45755 - kennytm:rollup, r=kennytm
bors [Sat, 4 Nov 2017 06:59:29 +0000 (06:59 +0000)]
Auto merge of #45755 - kennytm:rollup, r=kennytm

Rollup of 9 pull requests

- Successful merges: #45548, #45610, #45639, #45669, #45681, #45718, #45722, #45739, #45746
- Failed merges:

6 years agoRollup merge of #45746 - GuillaumeGomez:methods-doc-test, r=steveklabnik
kennytm [Sat, 4 Nov 2017 05:49:33 +0000 (13:49 +0800)]
Rollup merge of #45746 - GuillaumeGomez:methods-doc-test, r=steveklabnik

Add tests for methods listing in rust docs

r? @rust-lang/docs

6 years agoRollup merge of #45739 - rkarp:master, r=petrochenkov
kennytm [Sat, 4 Nov 2017 05:49:33 +0000 (13:49 +0800)]
Rollup merge of #45739 - rkarp:master, r=petrochenkov

Fix libstd compile error for windows-gnu targets without `backtrace`

This is basically an addition to #44979. Compiling `libstd` still fails when targeting `windows-gnu` with `panic = "abort"` because the items in the `...c::gnu` module are not used. They are only referenced from `backtrace_gnu.rs`, which is indirectly feature gated behind `backtrace` [here](https://github.com/rust-lang/rust/blob/9f3b09116b742b2606dc5f36f9145e0c89e4010b/src/libstd/sys/windows/mod.rs#L23).

6 years agoRollup merge of #45722 - mikhail-m1:improve-mir-opt-error-output, r=alexcrichton
kennytm [Sat, 4 Nov 2017 05:49:32 +0000 (13:49 +0800)]
Rollup merge of #45722 - mikhail-m1:improve-mir-opt-error-output, r=alexcrichton

improve compiletest output for errors from mir-opt tests

improvement:
1. Report filename against general cannot open error
2. Report current MIR block

6 years agoRollup merge of #45718 - Ljzn:patch-2, r=BurntSushi
kennytm [Sat, 4 Nov 2017 05:49:31 +0000 (13:49 +0800)]
Rollup merge of #45718 - Ljzn:patch-2, r=BurntSushi

Fix typo

`accomodate` -> `accommodate`

6 years agoRollup merge of #45681 - Ljzn:patch-1, r=kennytm
kennytm [Sat, 4 Nov 2017 05:49:30 +0000 (13:49 +0800)]
Rollup merge of #45681 - Ljzn:patch-1, r=kennytm

Fix typo.

6 years agoRollup merge of #45669 - cardoe:metadata, r=kennytm
kennytm [Sat, 4 Nov 2017 05:49:29 +0000 (13:49 +0800)]
Rollup merge of #45669 - cardoe:metadata, r=kennytm

add Cargo metadata to libstd

Add license and repository metadata to libstd

6 years agoRollup merge of #45639 - LaurentMazare:master, r=petrochenkov
kennytm [Sat, 4 Nov 2017 05:49:28 +0000 (13:49 +0800)]
Rollup merge of #45639 - LaurentMazare:master, r=petrochenkov

Add a nicer error message for missing  in for loop, fixes #40782.

As suggested by @estebank in issue #40782, this works in the same way as #42578: if the in keyword is missing, we continue parsing the expression and if this works correctly an adapted error message is produced. Otherwise we return the old error.

A specific test case has also been added.
This is my first PR on rust-lang/rust so any feedback is very welcome.

6 years agoRollup merge of #45610 - strake:atomic_from, r=nagisa
kennytm [Sat, 4 Nov 2017 05:49:27 +0000 (13:49 +0800)]
Rollup merge of #45610 - strake:atomic_from, r=nagisa

impl From<T> for AtomicT

6 years agoRollup merge of #45548 - ratmice:master, r=oli-obk
kennytm [Sat, 4 Nov 2017 05:49:26 +0000 (13:49 +0800)]
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.

6 years agoAdd overflow tests for next_power_of_two
Scott McMurray [Sat, 4 Nov 2017 05:33:34 +0000 (22:33 -0700)]
Add overflow tests for next_power_of_two

6 years agoFix #18604: next_power_of_two should panic on overflow
Scott McMurray [Sat, 4 Nov 2017 04:48:33 +0000 (21:48 -0700)]
Fix #18604: next_power_of_two should panic on overflow

6 years agoAuto merge of #45514 - gnzlbg:jemalloc_realloc2, r=sfackler
bors [Sat, 4 Nov 2017 04:28:13 +0000 (04:28 +0000)]
Auto merge of #45514 - gnzlbg:jemalloc_realloc2, r=sfackler

[jemalloc] set correct excess in realloc_excess

6 years agoAuto merge of #45384 - mikhail-m1:mir_add_false_edges_terminator_kind, r=arielb1
bors [Sat, 4 Nov 2017 00:09:14 +0000 (00:09 +0000)]
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.

6 years agoShorten paths to auxiliary files created by tests
Vadim Petrochenkov [Fri, 3 Nov 2017 19:41:15 +0000 (22:41 +0300)]
Shorten paths to auxiliary files created by tests

6 years agoAdded page to unstable book.
David Wood [Fri, 3 Nov 2017 19:18:11 +0000 (19:18 +0000)]
Added page to unstable book.

6 years agoImplemented RFC 2008 for enums (not including variants) and structs.
David Wood [Fri, 3 Nov 2017 19:17:54 +0000 (19:17 +0000)]
Implemented RFC 2008 for enums (not including variants) and structs.

6 years agoAdded tests for RFC 2008.
David Wood [Fri, 3 Nov 2017 19:15:15 +0000 (19:15 +0000)]
Added tests for RFC 2008.

6 years agoAdded feature gate for RFC 2008.
David Wood [Fri, 3 Nov 2017 19:14:39 +0000 (19:14 +0000)]
Added feature gate for RFC 2008.

6 years agoAuto merge of #45247 - leodasvacas:implement-auto-trait-syntax, r=nikomatsakis
bors [Fri, 3 Nov 2017 19:07:45 +0000 (19:07 +0000)]
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

6 years agoFix unsafe auto trait pretty print.
leonardo.yvens [Fri, 3 Nov 2017 18:13:02 +0000 (16:13 -0200)]
Fix unsafe auto trait pretty print.

It was being printed wrong as auto unsafe trait

6 years agoUpdate pretty test for auto trait syntax.
leonardo.yvens [Thu, 2 Nov 2017 18:33:09 +0000 (16:33 -0200)]
Update pretty test for auto trait syntax.

6 years agorustfmt is broken which makes rls broken
leonardo.yvens [Thu, 2 Nov 2017 01:10:36 +0000 (23:10 -0200)]
rustfmt is broken which makes rls broken

6 years agofix rebase conflict
leonardo.yvens [Wed, 1 Nov 2017 11:47:18 +0000 (09:47 -0200)]
fix rebase conflict

6 years agoRename `trait_has_auto_impl` to `trait_is_auto`
leonardo.yvens [Mon, 16 Oct 2017 19:33:45 +0000 (17:33 -0200)]
Rename `trait_has_auto_impl` to `trait_is_auto`

6 years agoupdate unstable book and error example
leonardo.yvens [Sun, 15 Oct 2017 19:58:25 +0000 (17:58 -0200)]
update unstable book and error example

6 years agoParse auto traits the same as traits.
leonardo.yvens [Sun, 15 Oct 2017 18:03:03 +0000 (16:03 -0200)]
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.

6 years agoFix tests and rebase conflict
leonardo.yvens [Sat, 14 Oct 2017 22:14:31 +0000 (19:14 -0300)]
Fix tests and rebase conflict

6 years agoauto trait future compatibility lint
leonardo.yvens [Sat, 14 Oct 2017 21:23:50 +0000 (18:23 -0300)]
auto trait future compatibility lint

6 years agoFinish DefaultImpl -> AutoImpl rename.
leonardo.yvens [Fri, 13 Oct 2017 16:58:46 +0000 (13:58 -0300)]
Finish DefaultImpl -> AutoImpl rename.

Forgot this ones.

6 years agoAdd tests for `auto trait`, fix parsing bug
leonardo.yvens [Thu, 12 Oct 2017 22:00:30 +0000 (19:00 -0300)]
Add tests for `auto trait`, fix parsing bug

Now we can do the well formedness checks in the parser, yay!

6 years agoFeature gate `auto trait` and ignore it in rustdoc
leonardo.yvens [Thu, 12 Oct 2017 18:36:18 +0000 (15:36 -0300)]
Feature gate `auto trait` and ignore it in rustdoc

6 years agoTeach typeck about `auto trait`
leonardo.yvens [Thu, 12 Oct 2017 14:18:55 +0000 (11:18 -0300)]
Teach typeck about `auto trait`

6 years agoadd `auto` keyword, parse `auto trait`, lower to HIR
leonardo.yvens [Thu, 12 Oct 2017 12:51:31 +0000 (09:51 -0300)]
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.

6 years ago[Syntax Breaking] Rename DefaultImpl to AutoImpl
leonardo.yvens [Mon, 9 Oct 2017 16:59:20 +0000 (13:59 -0300)]
[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`.

6 years agoissue #45357 set clippy build condition to extended.
matt rice [Sun, 29 Oct 2017 16:10:07 +0000 (09:10 -0700)]
issue #45357 set clippy build condition to extended.

6 years agoAdd tests for methods listing in rust docs
Guillaume Gomez [Fri, 3 Nov 2017 17:39:00 +0000 (18:39 +0100)]
Add tests for methods listing in rust docs

6 years ago[jemalloc] set correct excess in alloc_excess
gnzlbg [Fri, 3 Nov 2017 16:44:58 +0000 (17:44 +0100)]
[jemalloc] set correct excess in alloc_excess

6 years agoAuto merge of #45569 - zackmdavis:unexported_pub_lint, r=petrochenkov
bors [Fri, 3 Nov 2017 16:28:24 +0000 (16:28 +0000)]
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

6 years agoFix std compile error for windows-gnu targets without `backtrace` feature
Rolf Karp [Fri, 3 Nov 2017 14:21:05 +0000 (15:21 +0100)]
Fix std compile error for windows-gnu targets without `backtrace` feature

6 years agoAuto merge of #45734 - kennytm:ci-fix-centos-broken-link, r=alexcrichton
bors [Fri, 3 Nov 2017 12:30:09 +0000 (12:30 +0000)]
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.)

6 years agoFix broken link in `build-powerpc64le-toolchain.sh`
kennytm [Fri, 3 Nov 2017 07:53:36 +0000 (15:53 +0800)]
Fix broken link in `build-powerpc64le-toolchain.sh`

6 years agounreachable-pub lint for `pub` items not reachable from crate root
Zack M. Davis [Fri, 3 Nov 2017 03:50:17 +0000 (20:50 -0700)]
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.

6 years agoAuto merge of #45484 - oli-obk:lint_names, r=nikomatsakis
bors [Fri, 3 Nov 2017 00:42:11 +0000 (00:42 +0000)]
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.

6 years agoDisplay spans correctly when there are non-half-width characters
Wonwoo Choi [Thu, 2 Nov 2017 01:25:54 +0000 (10:25 +0900)]
Display spans correctly when there are non-half-width characters

6 years agoreplace Add by tuple
Mikhail Modin [Thu, 2 Nov 2017 17:25:38 +0000 (20:25 +0300)]
replace Add by tuple

6 years agoAuto merge of #45409 - tamird:suggest-match-default-bindings, r=nikomatsakis
bors [Thu, 2 Nov 2017 16:28:16 +0000 (16:28 +0000)]
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.

6 years agoimprove compiletest output for errors from mir-opt tests
Mikhail Modin [Thu, 2 Nov 2017 13:41:40 +0000 (16:41 +0300)]
improve compiletest output for errors from mir-opt tests

6 years agoAuto merge of #45647 - nrc:rls-bugs, r=eddyb
bors [Thu, 2 Nov 2017 12:34:13 +0000 (12:34 +0000)]
Auto merge of #45647 - nrc:rls-bugs, r=eddyb

save-analysis: support unions

r? @eddyb

6 years agoFix typo
Lance John [Thu, 2 Nov 2017 12:07:22 +0000 (20:07 +0800)]
Fix typo

`accomodate` -> `accommodate`

6 years agoMake the difference between lint codes and error codes explicit
Oliver Schneider [Fri, 27 Oct 2017 06:21:22 +0000 (08:21 +0200)]
Make the difference between lint codes and error codes explicit

6 years agoReport lint names in json diagnostics
Oliver Schneider [Tue, 24 Oct 2017 06:37:41 +0000 (08:37 +0200)]
Report lint names in json diagnostics

6 years agoAuto merge of #45630 - joshleeb:iss35241, r=estebank
bors [Thu, 2 Nov 2017 08:30:03 +0000 (08:30 +0000)]
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`](https://github.com/rust-lang/rust/blob/b7041bfab3a83702a8026fb7a18d8ea7d54cc648/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
```

6 years agochange mir stage in test
Mikhail Modin [Thu, 2 Nov 2017 07:21:36 +0000 (10:21 +0300)]
change mir stage in test

6 years agoadd one more sample
Mikhail Modin [Wed, 1 Nov 2017 13:21:30 +0000 (16:21 +0300)]
add one more sample

6 years agofix pre binding false edges
Mikhail Modin [Tue, 31 Oct 2017 15:02:14 +0000 (18:02 +0300)]
fix pre binding false edges

6 years agofix opt-mir test and remove false edge if no guard
Mikhail Modin [Tue, 31 Oct 2017 10:50:04 +0000 (13:50 +0300)]
fix opt-mir test and remove false edge if no guard

6 years agoadd TerminatorKind::FalseEdges and use it in matches
Mikhail Modin [Fri, 13 Oct 2017 13:36:15 +0000 (16:36 +0300)]
add TerminatorKind::FalseEdges and use it in matches

6 years agoAuto merge of #45468 - Xanewok:crate-source, r=nrc
bors [Thu, 2 Nov 2017 03:36:50 +0000 (03:36 +0000)]
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

6 years agosave-analysis: fix issue with sub-exprs in for loops
Nick Cameron [Thu, 2 Nov 2017 01:35:39 +0000 (14:35 +1300)]
save-analysis: fix issue with sub-exprs in for loops

Fixes https://github.com/nrc/rls-analysis/issues/78

6 years agonewindex_type macro: make index private by default and allow pub through config
Paul Daniel Faria [Thu, 2 Nov 2017 01:25:37 +0000 (21:25 -0400)]
newindex_type macro: make index private by default and allow pub through config

6 years agonewtype_index: Support simpler serializable override, custom derive, and fix mir_opt...
Paul Daniel Faria [Wed, 1 Nov 2017 03:14:13 +0000 (23:14 -0400)]
newtype_index: Support simpler serializable override, custom derive, and fix mir_opt tests

6 years agoClean up macro argument matches so they satisfy tidy checks
Paul Daniel Faria [Sun, 29 Oct 2017 15:09:54 +0000 (11:09 -0400)]
Clean up macro argument matches so they satisfy tidy checks

6 years agoAdd derive and doc comment capabilities to newtype_index macro
Paul Daniel Faria [Sun, 29 Oct 2017 04:13:49 +0000 (00:13 -0400)]
Add derive and doc comment capabilities to newtype_index macro

6 years agoAuto merge of #45306 - whitequark:ref_slice, r=alexcrichton
bors [Thu, 2 Nov 2017 00:06:16 +0000 (00:06 +0000)]
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

6 years agoRemove the redundant span_label.
laurent [Wed, 1 Nov 2017 23:43:32 +0000 (23:43 +0000)]
Remove the redundant span_label.

6 years agosave-analysis: corrects reference for tuple struct and unit struct literals
Nick Cameron [Wed, 1 Nov 2017 22:28:13 +0000 (11:28 +1300)]
save-analysis: corrects reference for tuple struct and unit struct literals

Fixes https://github.com/nrc/rls-analysis/issues/77

6 years agoDe-stabilize core::slice::{from_ref, from_ref_mut}.
whitequark [Wed, 1 Nov 2017 21:56:17 +0000 (21:56 +0000)]
De-stabilize core::slice::{from_ref, from_ref_mut}.

6 years agosave-analysis: handle types in turbofish
Nick Cameron [Wed, 1 Nov 2017 20:22:44 +0000 (09:22 +1300)]
save-analysis: handle types in turbofish

fixes https://github.com/nrc/rls-analysis/issues/52

6 years agosave-analysis: handle function types in bounds
Nick Cameron [Wed, 1 Nov 2017 04:59:06 +0000 (17:59 +1300)]
save-analysis: handle function types in bounds

This special cases the function type sugar in paths and deals with traits bounds as just the path parts. That required refactoring the path collector to distinguish between variable decls and references in patterns, basically just to please the borrow checker.

cc https://github.com/nrc/rls-analysis/issues/37

6 years agoAuto merge of #45538 - nikomatsakis:nll-liveness, r=pnkfelix
bors [Wed, 1 Nov 2017 18:14:13 +0000 (18:14 +0000)]
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)
    }
}
```

6 years agoAuto merge of #45472 - michaelwoerister:incr-comp-caching-base, r=nikomatsakis
bors [Wed, 1 Nov 2017 14:28:11 +0000 (14:28 +0000)]
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

6 years agoFix typo.
Lance John [Wed, 1 Nov 2017 13:02:08 +0000 (21:02 +0800)]
Fix typo.

6 years agoRemove duplicated results in the search
Guillaume Gomez [Sun, 29 Oct 2017 17:22:13 +0000 (18:22 +0100)]
Remove duplicated results in the search

6 years agofix function not appearing in first tab when appearing in another one. Thanks to...
Guillaume Gomez [Sun, 29 Oct 2017 12:42:34 +0000 (13:42 +0100)]
fix function not appearing in first tab when appearing in another one. Thanks to @Seeker14491 for this one!

6 years agoBe more flexible when looking for something by using levenshtein method
Guillaume Gomez [Sun, 29 Oct 2017 12:39:11 +0000 (13:39 +0100)]
Be more flexible when looking for something by using levenshtein method

6 years agoBetter check for returned value
Guillaume Gomez [Sun, 29 Oct 2017 12:29:07 +0000 (13:29 +0100)]
Better check for returned value

6 years agoKeep displaying good information when query is made
Guillaume Gomez [Sun, 29 Oct 2017 12:21:18 +0000 (13:21 +0100)]
Keep displaying good information when query is made

6 years agoAuto merge of #45435 - eddyb:binop-subtype-lhs, r=nikomatsakis
bors [Wed, 1 Nov 2017 09:40:15 +0000 (09:40 +0000)]
Auto merge of #45435 - eddyb:binop-subtype-lhs, r=nikomatsakis

rustc_typeck: use subtyping on the LHS of binops.

Fixes #45425.

r? @nikomatsakis

6 years agoAuto merge of #45674 - kennytm:rollup, r=kennytm
bors [Wed, 1 Nov 2017 07:04:17 +0000 (07:04 +0000)]
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:

6 years agoPreserve original formatting.
laurent [Wed, 1 Nov 2017 06:46:58 +0000 (06:46 +0000)]
Preserve original formatting.

6 years agoRemove the parser snapshot hack.
laurent [Wed, 1 Nov 2017 06:45:34 +0000 (06:45 +0000)]
Remove the parser snapshot hack.

6 years agoRollup merge of #45671 - est31:master, r=alexcrichton
kennytm [Wed, 1 Nov 2017 05:32:21 +0000 (13:32 +0800)]
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.

6 years agoRollup merge of #45664 - mbrubeck:docs, r=estebank
kennytm [Wed, 1 Nov 2017 05:32:20 +0000 (13:32 +0800)]
Rollup merge of #45664 - mbrubeck:docs, r=estebank

Fix incorrect error type in Read::byte docs

None

6 years agoRollup merge of #45660 - Cldfire:suggest-rename-import, r=estebank
kennytm [Wed, 1 Nov 2017 05:32:19 +0000 (13:32 +0800)]
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 :).

6 years agoRollup merge of #45652 - malbarbo:x32-2, r=alexcrichton
kennytm [Wed, 1 Nov 2017 05:32:18 +0000 (13:32 +0800)]
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)

6 years agoRollup merge of #45650 - michaelwoerister:per-crate-type-symbol-threshold, r=alexcrichton
kennytm [Wed, 1 Nov 2017 05:32:17 +0000 (13:32 +0800)]
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

6 years agoRollup merge of #45649 - tbu-:pr_doc_bufread_eof, r=estebank
kennytm [Wed, 1 Nov 2017 05:32:16 +0000 (13:32 +0800)]
Rollup merge of #45649 - tbu-:pr_doc_bufread_eof, r=estebank

Add a hint what `BufRead` functions do on EOF