Commit Graph

18503 Commits

Author SHA1 Message Date
Mazdak Farrokhzad
647eda17e8
Rollup merge of #66457 - cjgillot:just_hashstable, r=Zoxc
Just derive Hashstable in librustc

Split out of #66279

r? @Zoxc
2019-11-20 18:32:07 +01:00
Mazdak Farrokhzad
e32397a754
Rollup merge of #66060 - traxys:test_65401, r=michaelwoerister
Making ICEs and test them in incremental

This adds:
 - A way to make the compiler ICE
 - A way to check for ICE in `cfail` tests with `should-ice`
 - A regression test for issue #65401

I am not sure the attribute added `should-ice` is the best for this job
2019-11-20 18:32:04 +01:00
Mazdak Farrokhzad
1346557ba1
Rollup merge of #66532 - cuviper:dwarf-aranges, r=michaelwoerister
Generate DWARF address ranges for faster lookups

This adds a new option `-Zgenerate-arange-section`, enabled by default,
corresponding to LLVM's `-generate-arange-section`. This creates a
`.debug_aranges` section with DWARF address ranges, which some tools
depend on to optimize address lookups (elfutils [22288], [25173]).

This only has effect when debuginfo is enabled, and the additional data
is small compared to the other debug sections. For example, libstd.so
with full debuginfo is about 11MB, with just 61kB in aranges.

[22288]: https://sourceware.org/bugzilla/show_bug.cgi?id=22288
[25173]: https://sourceware.org/bugzilla/show_bug.cgi?id=25173

Closes #45246.
r? @michaelwoerister
2019-11-20 12:58:32 +01:00
bors
f50d6ea348 Auto merge of #66104 - yodaldevoid:generic-arg-disambiguation, r=petrochenkov
Generic arg disambiguation

Using the tactic suggested by @petrochenkov in https://github.com/rust-lang/rust/issues/60804#issuecomment-516769465 and on [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/generic.20argument.20disambiguation), this change checks type arguments to see if they are really incorrectly-parsed const arguments.

it should be noted that `segments.len() == 1 && segments[0].arg.is_none()` was reduced to `segments.len() == 1` as suggested by @petrochenkov in [zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/generic.20argument.20disambiguation/near/177848002). This change allowed a few more existing tests to have their braces removed.

There are a couple of "problems" with these changes that I should note. First, there was a regression in the error messages found in "src/test/ui/privacy-ns1.rs" and "src/test/ui/privacy-ns1.rs". Second, some braces were unable to be removed from "src/test/ui/const-generics/fn-const-param-infer.rs". Those on line 24 caused the statement to stop equating when removed, and those on line 20 cause a statement that should not equate to produce no error when removed.

I have not looked further into any of these issues yet, though I would be willing to look into them before landing this. I simply wanted to get some other eyes on this before going further.

Fixes #60804

cc @varkor @jplatte
2019-11-20 03:07:39 +00:00
Camille GILLOT
4da5fe7fdb Fix derive syntax. 2019-11-19 20:48:08 +01:00
Camille GILLOT
7db84e8504 Fix project syntax. 2019-11-19 20:48:06 +01:00
Camille GILLOT
e1522fa183 Derive HashStable more. 2019-11-19 20:47:57 +01:00
Camille GILLOT
781866f3a9 More HashStable. 2019-11-19 20:47:31 +01:00
Camille GILLOT
c4bc3f05f5 More HashStable. 2019-11-19 20:40:28 +01:00
Camille GILLOT
e00ebd725f Derive HashStable in librustc. 2019-11-19 20:32:35 +01:00
Josh Stone
4c2f1c802c Mark -Zgenerate-arange-section as TRACKED 2019-11-19 09:13:10 -08:00
bors
618b01f9fa Auto merge of #66454 - cjgillot:lift, r=Zoxc
Derive Lift using a proc-macro

Based on #66384

r? @Zoxc
2019-11-19 15:24:09 +00:00
Mazdak Farrokhzad
0ddd298a45
Rollup merge of #66536 - nnethercote:mv-QueryResult, r=Centril
Move the definition of `QueryResult` into `plumbing.rs`.

Because it's the only file that uses it, and removes the need for importing it.

r? @Centril
2019-11-19 13:10:24 +01:00
Mazdak Farrokhzad
ee535a0f95
Rollup merge of #66431 - Aaron1011:fix/opaque-type-infer, r=varkor
Fix 'type annotations needed' error with opaque types

Related: #66426

This commit adds handling for opaque types during inference variable
fallback. Type variables generated from the instantiation of opaque
types now fallback to the opaque type itself.

Normally, the type variable for an instantiated opaque type is either
unified with the concrete type, or with the opaque type itself (e.g when
a function returns an opaque type by calling another function).

However, it's possible for the type variable to be left completely
unconstrained. This can occur in code like this:

```rust
pub type Foo = impl Copy;
fn produce() -> Option<Foo> {
    None
}
```

Here, we'll instantatiate the `Foo` in `Option<Foo>` to a fresh type
variable, but we will never unify it with anything due to the fact
that we return a `None`.

This results in the error message:
```
type annotations needed: cannot resolve `_: std::marker::Copy
```

pointing at `pub type Foo = impl Copy`.

This message is not only confusing, it's incorrect. When an opaque type
inference variable is completely unconstrained, we can always fall back
to using the opaque type itself. This effectively turns that particular
use of the opaque type into a non-defining use, even if it appears in a
defining scope.
2019-11-19 13:10:17 +01:00
Mazdak Farrokhzad
0b0d683805
Rollup merge of #66239 - estebank:suggest-async-closure-call, r=Centril
Suggest calling async closure when needed

When using an async closure as a value in a place that expects a future,
suggest calling the closure.

Fix #65923.
2019-11-19 13:10:14 +01:00
Nicholas Nethercote
c84fae13e5 Move the definition of QueryResult into plumbing.rs.
Because it's the only file that uses it, and removes the need for
importing it.
2019-11-19 17:23:44 +11:00
Josh Stone
a5d624d32c Generate DWARF address ranges for faster lookups
This adds a new option `-Zgenerate-arange-section`, enabled by default,
corresponding to LLVM's `-generate-arange-section`. This creates a
`.debug_aranges` section with DWARF address ranges, which some tools
depend on to optimize address lookups (elfutils [22288], [25173]).

This only has effect when debuginfo is enabled, and the additional data
is small compared to the other debug sections. For example, libstd.so
with full debuginfo is about 11MB, with just 61kB in aranges.

[22288]: https://sourceware.org/bugzilla/show_bug.cgi?id=22288
[25173]: https://sourceware.org/bugzilla/show_bug.cgi?id=25173

Closes #45246.
2019-11-18 15:05:01 -08:00
Gabriel Smith
fb6cfde5ba rustc: lowering: Lower type args as const args when resolved in value
namespace
2019-11-18 17:23:22 -05:00
Gabriel Smith
128ca7415f rustc: hir: Add method to check validity of a Res/Def in a namespace 2019-11-18 17:01:48 -05:00
Esteban Küber
614da98454 review comments 2019-11-18 11:46:14 -08:00
Aaron Hill
f87177b1c5
Replace bool with new FallbackMode enum 2019-11-18 14:01:37 -05:00
Aaron Hill
0e2ccaaa3e
Fix 'type annotations needed' error with opaque types
Related: #66426

This commit adds handling for opaque types during inference variable
fallback. Type variables generated from the instantiatino of opaque
types now fallback to the opque type itself.

Normally, the type variable for an instantiated opaque type is either
unified with the concrete type, or with the opaque type itself (e.g when
a function returns an opaque type by calling another function).

However, it's possible for the type variable to be left completely
unconstrained. This can occur in code like this:

```rust
pub type Foo = impl Copy;
fn produce() -> Option<Foo> {
    None
}
```

Here, we'll instantatiate the `Foo` in `Option<Foo>` to a fresh type
variable, but we will never unify it with anything due to the fact
that we return a `None`.

This results in the error message:

`type annotations needed: cannot resolve `_: std::marker::Copy``

pointing at `pub type Foo = impl Copy`.

This message is not only confusing, it's incorrect. When an opaque type
inference variable is completely unconstrained, we can always fall back
to using the opaque type itself. This effectively turns that particular
use of the opaque type into a non-defining use, even if it appears in a
defining scope.
2019-11-18 14:01:36 -05:00
Camille GILLOT
35cba9eb0b Retire EnumLiftImpl. 2019-11-18 08:41:28 +01:00
Camille GILLOT
033d1df19b Retire BraceStructLiftImpl. 2019-11-18 08:41:28 +01:00
bors
361791bb5f Auto merge of #65456 - estebank:trait-bound-borrow, r=matthewjasper
Suggest borrowing when it would satisfy an unmet trait bound

When there are multiple implementors for the same trait that is present
in an unmet binding, modify the E0277 error to refer to the parent
obligation and verify whether borrowing the argument being passed in
would satisfy the unmet bound. If it would, suggest it.

Fix #56368.
2019-11-18 00:05:38 +00:00
bors
0f0c640e0e Auto merge of #66385 - ecstatic-morse:check-only-pass2, r=eddyb
Make dataflow-based const qualification the canonical one

For over a month, dataflow-based const qualification has been running in parallel with `qualify_consts` to check the bodies of `const` and `static`s. This PR removes the old qualification pass completely in favor of the dataflow-based one.

**edit:**
This PR also stops checking `QUALIF_ERROR_BIT` during promotion. This check appears to no longer serve a purpose now that the CTFE engine is more robust.

As a side-effect, this resolves #66167.

r? @eddyb
2019-11-17 18:38:15 +00:00
bors
d8014582b8 Auto merge of #66384 - cjgillot:typefoldable, r=Zoxc
Derive TypeFoldable using a proc-macro

A new proc macro is added in librustc_macros.
It is used to derive TypeFoldable inside librustc and librustc_traits.

For now, the macro uses the `'tcx` lifetime implicitly, and does not allow for a more robust selection of the adequate lifetime.

The Clone-based TypeFoldable implementations are not migrated.

Closes #65674
2019-11-17 15:25:10 +00:00
Yuki Okushi
6e6c46c694
Rollup merge of #66456 - Centril:driver-codes, r=Mark-Simulacrum
Move `DIAGNOSTICS` usage to `rustc_driver`

Remove `rustc_interface`'s dependency on `rustc_error_codes` and centralize all usages of `DIAGNOSTICS` in `rustc_driver`. Once we remove all references to `rustc_error_codes` in all other crates but `rustc_driver`, this should allow for incremental recompilation of the compiler to be smoother when tweaking error codes. This works towards https://github.com/rust-lang/rust/issues/66210#issuecomment-551862528.

(May include traces of minor drive-by cleanup.)

r? @Mark-Simulacrum
2019-11-17 13:36:18 +09:00
Yuki Okushi
54998d1b3f
Rollup merge of #66344 - petrochenkov:noregattr, r=matthewjasper
rustc_plugin: Remove `Registry::register_attribute`

Legacy plugins cannot register inert attributes anymore.

The preferred replacement is to use `register_tool` ([tracking issue](https://github.com/rust-lang/rust/issues/66079)).
```rust
#![register_tool(servo)]

#[servo::must_root]
struct S;
```

The more direct replacement is `register_attribute` ([tracking issue](https://github.com/rust-lang/rust/issues/66080))
```rust
#![register_attr(must_root)]

#[must_root]
struct S;
```
, but it requires registering each attribute individually rather than registering the tool once, and is more likely to be removed rather than stabilized.
2019-11-17 13:36:13 +09:00
Esteban Küber
d7efa5bd6a review comments 2019-11-16 17:10:13 -08:00
Esteban Küber
0487f0c0c3 Suggest calling async closure when needed
When using an async closure as a value in a place that expects a future,
suggest calling the closure.

Fix #65923.
2019-11-16 16:24:00 -08:00
Esteban Küber
2fe8371268 review comments and fix rebase 2019-11-16 16:12:22 -08:00
Esteban Küber
7a2f3ee73f Account for rustc_on_unimplemented 2019-11-16 13:23:19 -08:00
Esteban Küber
0f7f2346a6 Remove unnecessary note 2019-11-16 13:23:19 -08:00
Esteban Küber
970503b2e1 Modify primary label message to be inline with error message 2019-11-16 13:23:19 -08:00
Esteban Küber
f57413b717 Suggest borrowing when it would satisfy an unmet trait bound
When there are multiple implementors for the same trait that is present
in an unmet binding, modify the E0277 error to refer to the parent
obligation and verify whether borrowing the argument being passed in
would satisfy the unmet bound. If it would, suggest it.
2019-11-16 13:23:19 -08:00
Esteban Küber
405a3dd91c Tweak code formatting 2019-11-16 13:23:19 -08:00
Vadim Petrochenkov
00bc449602 ast: Keep string literals in ABIs precisely 2019-11-16 21:21:37 +03:00
Vadim Petrochenkov
266f547127 ast: Keep extern qualifiers in functions more precisely 2019-11-16 21:21:37 +03:00
Vadim Petrochenkov
8575743793 rustc_plugin: Remove Registry::register_attribute 2019-11-16 18:50:23 +03:00
bors
9b0214d9c5 Auto merge of #66255 - ehuss:update-cc, r=alexcrichton
Update cc, git2, num_cpus.

This updates the `cc` crate, bringing in better parallel building support. Also updates `git2` which enables the parallel feature. (Note: I don't expect it will have a significant impact on build time, but seems good to update anyways.)

The main thorn is that `cc` gained knowledge about RISC-V architectures (https://github.com/alexcrichton/cc-rs/pull/428, https://github.com/alexcrichton/cc-rs/pull/429, https://github.com/alexcrichton/cc-rs/pull/430), but the builders on CI do not have the riscv C compiler installed. This means that bootstraps' cc detection was finding a C compiler that isn't installed, and fails.

The solution here is to override the cc detection to `false`. The C compiler isn't actually used on riscv platforms. AFAIK, the only location would be compiler_builtins, and it currently forces C support off (a533ae9c5a/build.rs (L49-L55)).

Other possible solutions:
- Add the override in cc_detect for riscv (or any "no-C" platform like wasm32 and nvptx)
- Install and use the appropriate c compiler. I tried this the `g++-riscv64-linux-gnu` package, but it failed missing some header file.

Closes #66232
2019-11-16 07:26:57 +00:00
Mazdak Farrokhzad
8444e1628c move DIAGNOSTICS usage to rustc_driver 2019-11-16 02:32:33 +01:00
Dylan MacKenzie
ea95e94f51 Fix nits from review 2019-11-15 10:33:52 -08:00
Dylan MacKenzie
056edc0d48 Use a bespoke type for the result of mir_const_qualif 2019-11-15 10:33:52 -08:00
Dylan MacKenzie
9a2e53a7b3 Remove -Z flag for suppressing validation mismatch ICE 2019-11-15 10:33:52 -08:00
Mazdak Farrokhzad
ae0c8b5f09
Rollup merge of #66427 - Mark-Simulacrum:errors-json, r=Centril
Move the JSON error emitter to librustc_errors

This is done both as a cleanup (it makes little sense for this emitter to be in libsyntax), but also as part of broader work to decouple Session from librustc itself.

Along the way, this also moves SourceMap to syntax_pos, which is also nice for the above reasons, as well as allowing dropping the SourceMapper trait from code. This had the unfortunate side-effect of moving `FatalError` to rustc_data_structures (it's needed in syntax_pos, due to SourceMap, but putting it there feels somehow worse).
2019-11-15 18:02:02 +01:00
Mark Rousskov
c31a8754e3 Move JSON emitter to rustc_errors 2019-11-15 08:45:49 -05:00
Tyler Mandry
d99026e891
Rollup merge of #66435 - JohnTitor:fix-spelling, r=Centril
Correct `const_in_array_repeat_expressions` feature name

Fixes #66433

r? @estebank
2019-11-15 14:44:50 +01:00
Tyler Mandry
c5bb2ec0dd
Rollup merge of #66197 - Centril:transparent-ast, r=varkor
Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering

We currently have a hack in the form of `ast::{ItemKind, ImplItemKind}::OpaqueTy` which is constructed literally when you write `type Alias = impl Trait;` but not e.g. `type Alias = Vec<impl Trait>;`. Per https://github.com/rust-lang/rfcs/pull/2515, this needs to change to allow `impl Trait` in nested positions.  This PR achieves this change for the syntactic aspect but not the semantic one, which will require changes in lowering and def collection. In the interim, `TyKind::opaque_top_hack` is introduced to avoid knock-on changes in lowering, collection, and resolve. These hacks can then be removed and fixed one by one until the desired semantics are supported.

r? @varkor
2019-11-15 14:44:47 +01:00
Yuki Okushi
e4d5f0596d
Rollup merge of #66410 - RalfJung:miri-machine-max, r=oli-obk
miri: helper methods for max values of machine's usize/isize

We recently wanted this in Miri.

r? @oli-obk
2019-11-15 18:36:31 +09:00