Teach rustc about DW_AT_noreturn and a few more DIFlags
We achieve two small things with this PR:
1. We provide definitions for a few additional llvm debuginfo flags
1. We _use_ one of these new flags, `FlagNoReturn`, and add it to debuginfo for functions with the never return type (`!`).
Fix type inhabitedness check for arrays
Arrays of uninhabited types were considered to also be uninhabited if
their length had not been evaluated, causing unsoundness.
Fixes#47563.
r? @eddyb
Add ./x.py check src/{libstd,libtest,librustc}
This currently only supports a limited subset of the full compilation,
but is likely 90% of what people will want and is possible without
building a full compiler (and also building LLVM). In theory, this means
that contributors who don't want to build LLVM now have an easy way to
compile locally, though running tests won't work.
Fix no_integrated_as option to work with new codegen architecture.
Old implementation called the assembler once per crate, but we need to call
it for each object file instead, because a single crate can now have more
than one object file.
This patch fixes issue #45836 (Can't compile core for msp430 in release mode)
This change can be tested on x86_64 using
```sh
export RUSTFLAGS="-C no_integrated_as -C save_temps"
```
r? @alexcrichton
cc @japaric
rustc_trans: ignore trailing padding larger than 8 bytes.
Fixes#45662 by ignoring a missing second register component, as it could be entirely padding.
rustc_trans: take into account primitives larger than 8 bytes.
Fixes#38763 by marking all "eightbytes" covered by a primitive appropriately, not just the first.
Add CGU size heuristic for partitioning
This addresses the concern of #47316 by estimating CGU size based on
the size of its MIR. Looking at the size estimate differences for a
small selection of crates, this heuristic produces different orderings,
which should more accurately reflect optimisation time. (Fixes #47316.)
r? @michaelwoerister
Fix spans in unused import lint for nested groups
This fixes an inconsistency for empty nested groups, and adds a test for all the possible cases of the lint.
```
warning: unused imports: `*`, `Foo`, `baz::{}`, `foobar::*`
--> test.rs:16:11
|
16 | use foo::{Foo, bar::{baz::{}, foobar::*}, *};
| ^^^ ^^^^^^^ ^^^^^^^^^ ^
|
= note: #[warn(unused_imports)] on by default
warning: unused import: `*`
--> test.rs:17:24
|
17 | use foo::bar::baz::{*, *};
| ^
warning: unused import: `use foo::{};`
--> test.rs:18:1
|
18 | use foo::{};
| ^^^^^^^^^^^^
```
cc #44494
Fix into() cast paren check precedence
As discussed in #47699 the logic for determining if an expression needs parenthesis when suggesting an `.into()` cast is incorrect. Two broken examples from nightly are:
```
error[E0308]: mismatched types
--> main.rs:4:10
|
4 | test(foo as i8);
| ^^^^^^^^^ expected i32, found i8
help: you can cast an `i8` to `i32`, which will sign-extend the source value
|
4 | test(foo as i8.into());
|
```
```
error[E0308]: mismatched types
--> main.rs:4:10
|
4 | test(*foo);
| ^^^^ expected i32, found i8
help: you can cast an `i8` to `i32`, which will sign-extend the source value
|
4 | test(*foo.into());
|
```
As suggested by @petrochenkov switch the precedence check to `PREC_POSTFIX`. This catches both `as` and unary operators. Fixes#47699.
r? @petrochenkov
Remove workarounds for cc 1.0.3.
Now that the Rust codebase depends on cc 1.0.4, there is no longer any
need to specify a compiler for CloudABI manually. Cargo will
automatically call into the right compiler executable.
Remove broken redundant backtrace hint
When the compiler driver panics it attempts to show a hint about using `RUST_BACKTRACE`. However, the logic is currently reversed to the hint is only shown if `RUST_BACKTRACE` is **already** set:
```shell
> RUST_BACKTRACE=1 rustc /dev/null --crate-type proc-macro
error: internal compiler error: unexpected panic
...
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'attempt to subtract with overflow', librustc_errors/emitter.rs:287:49
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
> RUST_BACKTRACE=0 rustc /dev/null --crate-type proc-macro
error: internal compiler error: unexpected panic
...
thread 'rustc' panicked at 'attempt to subtract with overflow', librustc_errors/emitter.rs:287:49
note: Run with `RUST_BACKTRACE=1` for a backtrace.
```
As the `panic` itself already has a working `RUST_BACKTRACE` hint just remove the broken duplicate hint entirely.
On missing method do not suggest private traits
When encountering a method call for an ADT that doesn't have any
implementation of it, we search for traits that could be implemented
that do have that method. Filter out private non-local traits that would
not be able to be implemented.
This doesn't account for public traits that are in a private scope, but
works as a first approximation and is a more correct behavior than the
current one.
Fix#45781.
Makes the constructors of Duration const fns.
This affects `Duration::new`, `Duration::from_secs`, `Duration::from_millis`, `Duration::from_micros`, and `Duration::from_nanos`.
As discussed in #47699 the logic for determining if an expression needs
parenthesis when suggesting an `.into()` cast is incorrect. Two broken
examples from nightly are:
```
error[E0308]: mismatched types
--> main.rs:4:10
|
4 | test(foo as i8);
| ^^^^^^^^^ expected i32, found i8
help: you can cast an `i8` to `i32`, which will sign-extend the source value
|
4 | test(foo as i8.into());
|
```
```
error[E0308]: mismatched types
--> main.rs:4:10
|
4 | test(*foo);
| ^^^^ expected i32, found i8
help: you can cast an `i8` to `i32`, which will sign-extend the source value
|
4 | test(*foo.into());
|
```
As suggested by @petrochenkov switch the precedence check to
PREC_POSTFIX. This catches both `as` and unary operators. Fixes#47699.
Now that the Rust codebase depends on cc 1.0.4, there is no longer any
need to specify a compiler for CloudABI manually. Cargo will
automatically call into the right compiler executable.
Make core::ops::Place an unsafe trait
Consumers of `Place` would reasonably expect that the `pointer` function returns a valid pointer to memory that can actually be written to.
This currently only supports a limited subset of the full compilation,
but is likely 90% of what people will want and is possible without
building a full compiler (i.e., running LLVM). In theory, this means
that contributors who don't want to build LLVM now have an easy way to
compile locally, though running tests won't work.
Immovable generators
This adds support for immovable generators which allow you to borrow local values inside generator across suspension points. These are declared using a `static` keyword:
```rust
let mut generator = static || {
let local = &Vec::new();
yield;
local.push(0i8);
};
generator.resume();
// ERROR moving the generator after it has resumed would invalidate the interior reference
// drop(generator);
```
Region inference is no longer affected by the types stored in generators so the regions inside should be similar to other code (and unaffected by the presence of `yield` expressions). The borrow checker is extended to pick up the slack so interior references still result in errors for movable generators. This fixes#44197, #45259 and #45093.
This PR depends on [PR #44917 (immovable types)](https://github.com/rust-lang/rust/pull/44917), I suggest potential reviewers ignore the first commit as it adds immovable types.
Fix spurious warning on empty proc macro crates
While attempting to reproduce rust-lang/rust#47086 I noticed the following warning:
```shell
> rustc /dev/null --crate-type proc-macro
warning: unused variable: `registrar`
--> /dev/null:0:1
```
As there are no macros to register the automatically generated registrar function for the crate has no body. As a result its `registrar` argument is unused triggering the above warning.
The warning is confusing and not easily actionable by the developer. It could also be triggered legitimately by e.g. having all of the macros in a crate #[cfg]'ed out.
Fix by naming the generated argument `_registrar` inside `mk_registrar()`. This suppresses the unused variable warning.
When the compiler driver panics it attempts to show a hint about using
`RUST_BACKTRACE`. However, the logic is currently reversed to the hint
is only shown if `RUST_BACKTRACE` is *already* set:
```shell
> RUST_BACKTRACE=1 rustc /dev/null --crate-type proc-macro
error: internal compiler error: unexpected panic
...
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'attempt to subtract with overflow', librustc_errors/emitter.rs:287:49
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
> RUST_BACKTRACE=0 rustc /dev/null --crate-type proc-macro
error: internal compiler error: unexpected panic
...
thread 'rustc' panicked at 'attempt to subtract with overflow', librustc_errors/emitter.rs:287:49
note: Run with `RUST_BACKTRACE=1` for a backtrace.
```
As the `panic` itself already has a working `RUST_BACKTRACE` hint just
remove the broken duplicate hint entirely.
LLVM5: Update DW_OP_plus to DW_OP_plus_uconst
LLVM <= 4.0 used a non-standard interpretation of `DW_OP_plus`. In the
DWARF standard, this adds two items on the expressions stack. LLVM's
behavior was more like DWARF's `DW_OP_plus_uconst` -- adding a constant
that follows the op. The patch series starting with [D33892] switched
to the standard DWARF interpretation, so we need to follow.
[D33892]: https://reviews.llvm.org/D33892Fixes#47464
r? @eddyb
Make liballoc_jemalloc work on CloudABI.
The automated builds for CloudABI in dist-various-2 don't use
--disable-jemalloc, even though my original container image did. Instead
of setting that flag, let's go the extra mile of making jemalloc work.
CloudABI's C library already uses jemalloc and now exposes the API
extensions used by us.
This makes the CloudABI dist work out of the box.