Commit graph

3722 commits

Author SHA1 Message Date
b-naber
da2cf9b9d1 substitutions in trait predicates 2021-02-04 16:35:52 +01:00
b-naber
760a6654fb lowering of generic args in AssocTyConstraint 2021-02-04 16:20:58 +01:00
b-naber
16af7bf3d9 hir pretty printing 2021-02-04 16:20:57 +01:00
b-naber
fdaf603102 add generic args to hir::TypeBinding 2021-02-04 16:20:56 +01:00
Mara Bos
24e0940169 Stabilize feature(iterator_fold_self): Iterator::reduce 2021-02-04 11:31:11 +01:00
Mara Bos
5c056ed2f5 Rename Iterator::fold_first to reduce. 2021-02-04 11:30:42 +01:00
bjorn3
da536554a0 Use is_local instead of as_local 2021-02-04 11:17:01 +01:00
Ryan Levick
cdfc52fbd6 Try fast_reject::simplify_type in coherence before doing full check
Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
Co-authored-by: Ryan Levick <me@ryanlevick.com>
2021-02-04 10:45:17 +01:00
Camelid
253a970c3d Miscellaneous small diagnostics cleanup 2021-02-03 22:09:37 -08:00
Tyson Nottingham
29711d8c96 rustc_codegen_ssa: tune codegen scheduling to reduce memory usage
For better throughput during parallel processing by LLVM, we used to sort
CGUs largest to smallest. This would lead to better thread utilization
by, for example, preventing a large CGU from being processed last and
having only one LLVM thread working while the rest remained idle.

However, this strategy would lead to high memory usage, as it meant the
LLVM-IR for all of the largest CGUs would be resident in memory at once.

Instead, we can compromise by ordering CGUs such that the largest and
smallest are first, second largest and smallest are next, etc. If there
are large size variations, this can reduce memory usage significantly.
2021-02-03 18:55:05 -08:00
klensy
60cca83975 faster spans 2021-02-04 04:54:23 +03:00
Bastian Kauschke
031cce8cfc add relaxed_struct_unsize feature gate 2021-02-04 00:00:41 +01:00
Bastian Kauschke
50e394a05e relax adt unsizing requirements 2021-02-04 00:00:28 +01:00
Mara Bos
34d5ac25c5 Make panic/assert calls in rustc compatible with Rust 2021. 2021-02-03 22:42:53 +01:00
Mara Bos
a616f8267e Add lint for panic!(123) which is not accepted in Rust 2021.
This extends the `panic_fmt` lint to warn for all cases where the first
argument cannot be interpreted as a format string, as will happen in
Rust 2021.

It suggests to add `"{}", ` to format the message as a string. In the
case of `std::panic!()`, it also suggests the recently stabilized
`std::panic::panic_any()` function as an alternative.

It renames the lint to `non_fmt_panic` to match the lint naming
guidelines.
2021-02-03 22:42:53 +01:00
Esteban Küber
3b5d018ebb Handle Spans for byte and raw strings and add more detail 2021-02-03 13:34:28 -08:00
Mara Bos
89882388d9 Revert stabilizing integer::BITS. 2021-02-03 22:23:58 +01:00
bors
e708cbd91c Auto merge of #81717 - Aaron1011:fix/closure-diag, r=estebank
Fix panic when emitting diagnostic for closure mutable binding error

Fixes #81700

The upvar borrow kind may be `ty::BorrowKind::UniqueImmBorrow`, which is
still a mutable borrow for the purposes of this diagnostic code.
2021-02-03 20:53:08 +00:00
bors
120b2a704a Auto merge of #81718 - m-ou-se:rollup-3ftbymt, r=m-ou-se
Rollup of 5 pull requests

Successful merges:

 - #80394 (make const_err a future incompat lint)
 - #81532 (Remove incorrect `delay_span_bug`)
 - #81692 (Update clippy)
 - #81715 (Reduce tab formatting assertions to debug only)
 - #81716 (Fix non-existent-field ICE for generic fields.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-03 18:01:37 +00:00
Mara Bos
46174188e8
Rollup merge of #81716 - m-ou-se:fix-ice, r=eddyb
Fix non-existent-field ICE for generic fields.

I mentioned this ICE in a chat and it took about 3 milliseconds before `@eddyb` found the problem and said this change would fix it. :)

This also changes one the field types in the related test to one that triggered the ICE.

Fixes #81627.
Fixes #81672.
Fixes #81709.

Cc https://github.com/rust-lang/rust/pull/81480 `@b-naber` `@estebank.`
2021-02-03 18:51:18 +01:00
Mara Bos
65b3c0caf0
Rollup merge of #81715 - jryans:tab-handling-ice-81614, r=estebank
Reduce tab formatting assertions to debug only

The tab replacement for diagnostics added in #79757 included a few assertions to ensure all tab characters are handled appropriately. We've started getting reports of these assertions firing (#81614). Since it's only a cosmetic issue, this downgrades the assertions to debug only, so we at least continue compiling even if the diagnostics might be a tad wonky.

Minimizes the impact of #81614
2021-02-03 18:51:17 +01:00
Mara Bos
66959448e6
Rollup merge of #81532 - estebank:ice-ice-baby, r=pnkfelix
Remove incorrect `delay_span_bug`

The following code is supposed to compile

```rust
use std::ops::BitOr;

pub trait IntWrapper {
    type InternalStorage;
}

impl<T> BitOr for dyn IntWrapper<InternalStorage = T>
where
    Self: Sized,
    T: BitOr + BitOr<Output = T>,
{
    type Output = Self;
    fn bitor(self, _other: Self) -> Self {
        todo!()
    }
}
```

Before this change it would ICE. In #70998 the removed logic was added
to provide better suggestions, and the `delay_span_bug` guard was added
to  protect against a potential logic error when returning traits. As it
happens, there are cases, like the one above, where traits can indeed be
returned, so valid code was being rejected.

Fix (but not close) #80207.
2021-02-03 18:51:14 +01:00
Mara Bos
00dabfbd28
Rollup merge of #80394 - RalfJung:const-err-future, r=oli-obk
make const_err a future incompat lint

This is the first step for https://github.com/rust-lang/rust/issues/71800: make const_err a future-incompat lint. I also rewrote the const_err lint description as the old one seemed wrong.

This has the unfortunate side-effect of making const-eval error even more verbose by making the const_err message longer without fixing the redundancy caused by additionally emitting an error on each use site of the constant. We cannot fix that redundancy until const_err is a *hard* error (at that point the error-on-use-site can be turned into a `delay_span_bug!` for uses of monomorphic consts, and into a nicely rendered error for [lazily / post-monomorhization evaluated] associated consts).

~~The one annoying effect of this PR is that `let _x = &(1/(1-1));` now also shows the future-incompat warning, even though of course we will *not* make this a hard error. We'll instead (hopefully) stop promoting it -- see https://github.com/rust-lang/rfcs/pull/3027. The only way I see to avoid the future-incompat warning is to use a different lint for "failure to evaluate promoted".~~

Cc `@rust-lang/wg-const-eval`
2021-02-03 18:51:12 +01:00
Mara Bos
68cc12ab71 Fix non-existent-field ICE for generic fields.
Co-authored-by: eddyb <eddyb@lyken.rs>
2021-02-03 18:36:48 +01:00
Aaron Hill
bc84e21107
Fix panic when emitting diagnostic for closure mutable binding error
Fixes #81700

The upvar borrow kind may be `ty::BorrowKind::UniqueImmBorrow`, which is
still a mutable borrow for the purposes of this diagnostic code.
2021-02-03 12:36:24 -05:00
J. Ryan Stinnett
18f6cc6c5d Reduce tab formatting assertions to debug only
The tab replacement for diagnostics added in #79757 included a few assertions to
ensure all tab characters are handled appropriately. We've started getting
reports of these assertions firing (#81614). Since it's only a cosmetic issue,
this downgrades the assertions to debug only, so we at least continue compiling
even if the diagnostics might be a tad wonky.

Fixes #81614
2021-02-03 17:17:15 +00:00
Esteban Küber
ede0a71b9e Remove incorrect delay_span_bug
The following code is supposed to compile

```rust
use std::ops::BitOr;

pub trait IntWrapper {
    type InternalStorage;
}

impl<T> BitOr for dyn IntWrapper<InternalStorage = T>
where
    Self: Sized,
    T: BitOr + BitOr<Output = T>,
{
    type Output = Self;
    fn bitor(self, _other: Self) -> Self {
        todo!()
    }
}
```

Before this change it would ICE. In #70998 the removed logic was added
to provide better suggestions, and the `delay_span_bug` guard was added
to  protect against a potential logic error when returning traits. As it
happens, there are cases, like the one above, where traits can indeed be
returned, so valid code was being rejected.

Fix #80207.
2021-02-03 08:52:57 -08:00
Joshua Nelson
82914a5031 Add more information to the error code for 'crate not found'
This comes up a lot when bootstrapping.
2021-02-03 11:51:42 -05:00
bors
186f7ae5b0 Auto merge of #81294 - pnkfelix:issue-81211-use-ufcs-in-derive-debug, r=oli-obk
Use ufcs in derive(Debug)

Cc #81211.

(Arguably this *is* the fix for it.)
2021-02-03 15:12:19 +00:00
Ralf Jung
8477d352ac make const_err a future incompat lint 2021-02-03 15:45:43 +01:00
Cameron Steffen
fba747a06e Refactor out PrimitiveTypeTable 2021-02-03 08:32:23 -06:00
Camille GILLOT
0658d8c097 Address review. 2021-02-03 14:29:18 +01:00
bors
6ad11e2e25 Auto merge of #81699 - jethrogb:fix-81531, r=petrochenkov
Really fix early lints inside an async desugaring

Fixes #81531

cc `@Aaron1011`

r? `@petrochenkov`
2021-02-03 11:42:09 +00:00
Jethro Beekman
37cb9d30fa Really fix early lints inside an async desugaring 2021-02-03 10:05:58 +01:00
bors
b593389edb Auto merge of #81346 - hug-dev:nonsecure-call-abi, r=jonas-schievink
Add a new ABI to support cmse_nonsecure_call

This adds support for the `cmse_nonsecure_call` feature to be able to perform non-secure function call.

See the discussion on Zulip [here](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Support.20for.20callsite.20attributes/near/223054928).

This is a followup to #75810 which added `cmse_nonsecure_entry`. As for that PR, I assume that the changes are small enough to not have to go through a RFC but I don't mind doing one if needed 😃
I did not yet create a tracking issue, but if most of it is fine, I can create one and update the various files accordingly (they refer to the other tracking issue now).

On the Zulip chat, I believe `@jonas-schievink` volunteered to be a reviewer 💯
2021-02-03 06:00:43 +00:00
kadmin
6e6608d8b5 Add additional benchmarks to bit_set 2021-02-02 23:31:30 +00:00
Niko Matsakis
b6b897b02c introduce future-compatibility warning for forbidden lint groups
We used to ignore `forbid(group)` scenarios completely. This changed
in #78864, but that led to a number of regressions (#80988, #81218).

This PR introduces a future compatibility warning for the case where
a group is forbidden but then an individual lint within that group
is allowed. We now issue a FCW when we see the "allow", but permit
it to take effect.
2021-02-02 18:21:37 -05:00
bors
d95d4f0189 Auto merge of #81678 - jackh726:rollup-3nerni4, r=jackh726
Rollup of 14 pull requests

Successful merges:

 - #80593 (Upgrade Chalk)
 - #81260 (Add .editorconfig)
 - #81455 (Add AArch64 big-endian and ILP32 targets)
 - #81517 (Remove remnants of the santizer runtime crates from bootstrap)
 - #81530 (sys: use `process::abort()` instead of `arch::wasm32::unreachable()`)
 - #81544 (Add better diagnostic for unbounded Abst. Const)
 - #81588 (Add doc aliases for "delete")
 - #81603 (rustbuild: Don't build compiler twice for error-index-generator.)
 - #81634 (Add long explanation e0521)
 - #81636 (Directly use `Option<&[T]>` instead of converting from `Option<&Vec<T>>` later on)
 - #81647 (Fix bug with assert!() calling the wrong edition of panic!().)
 - #81655 (Improve wording of suggestion about accessing field)
 - #81665 (Fix out of date `Scalar` documentation)
 - #81671 (Add more associated type tests)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-02-02 23:15:22 +00:00
Jack Huey
70d16d506c
Rollup merge of #81665 - jacob-hughes:mir_doc_fix, r=estebank
Fix out of date `Scalar` documentation

Scalars can represent integers up to `u128`, but the docs state otherwise.
2021-02-02 16:01:49 -05:00
Jack Huey
7edb3ad39b
Rollup merge of #81655 - matsujika:suggest-accessing-field-rewording, r=estebank
Improve wording of suggestion about accessing field

Follow-up to #81504

The compiler at this moment suggests "you might have meant to use field `b` of type `B`", sounding like it's type `B` which has the field `b`.
r? ```@estebank```
2021-02-02 16:01:48 -05:00
Jack Huey
7f2eeb10c7
Rollup merge of #81647 - m-ou-se:assert-2021-fix, r=petrochenkov
Fix bug with assert!() calling the wrong edition of panic!().

The span of `panic!` produced by the `assert` macro did not carry the right edition. This changes `assert` to call the right version.

Also adds tests for the 2021 edition of panic and assert, that would've caught this.
2021-02-02 16:01:46 -05:00
Jack Huey
86e23cc9f1
Rollup merge of #81636 - LingMan:slice_not_vec, r=petrochenkov
Directly use `Option<&[T]>` instead of converting from `Option<&Vec<T>>` later on

```@rustbot``` modify labels +C-cleanup +T-compiler
2021-02-02 16:01:45 -05:00
Jack Huey
fd4f4adede
Rollup merge of #81634 - jesusprubio:jesusprubio/add-long-explanation-e0521, r=GuillaumeGomez
Add long explanation e0521

Helps with #61137
2021-02-02 16:01:44 -05:00
Jack Huey
3aed8b17a8
Rollup merge of #81544 - JulianKnodt:sat_where, r=lcnr
Add better diagnostic for unbounded Abst. Const

~~In the case where a generic abst. const requires a trivial where bound: `where TypeWithConst<const_fn(N)>: ,`,
instead of requiring a where bound, just check that only consts are being substituted in to skip over where check.~~

~~This is pretty sketchy, but I think it works. Presumably, if there is checking for type bounds added later, it can first check nested requirements, and see if they're satisfied by the current `ParamEnv`.~~

Changed the diagnostic to add a better example, which is more practical than what was previously proposed.

r? ```@lcnr```
2021-02-02 16:01:39 -05:00
Jack Huey
399c0a8e52
Rollup merge of #81455 - Amanieu:aarch64_ilp32, r=sanxiyn
Add AArch64 big-endian and ILP32 targets

This PR adds 3 new AArch64 targets:
- `aarch64_be-unknown-linux-gnu`
- `aarch64-unknown-linux-gnu_ilp32`
- `aarch64_be-unknown-linux-gnu_ilp32`

It also fixes some ABI issues on big-endian ARM and AArch64.
2021-02-02 16:01:35 -05:00
Jack Huey
c1623a2ee7
Rollup merge of #80593 - jackh726:chalk-upgrade, r=nikomatsakis
Upgrade Chalk

~~Blocked on rust-lang/chalk#670~~
~~Now blocked on rust-lang/chalk#680 and release~~

In addition to the straight upgrade, I also tried to fix some tests by properly returning variables and max universes in the solution. Unfortunately, this actually triggers the same perf problem that rustc traits code runs into in `canonicalizer`. Not sure what the root cause of this problem is, or why it's supposed to be solved in chalk.

r? ```@nikomatsakis```
2021-02-02 16:01:32 -05:00
bors
368275062f Auto merge of #81541 - Aaron1011:early-lint-async-fn, r=petrochenkov
Fix early lints inside an async desugaring

Fixes #81531

When we buffer an early lint for a macro invocation,
we need to determine which NodeId to take the lint level from.
Currently, we use the NodeId of the closest def parent. However, if
the macro invocation is inside the desugared closure from an `async fn`
or async closure, that NodeId does not actually exist in the AST.

This commit uses the parent of a desugared closure when computing
`lint_node_id`, which is something that actually exists in the AST (an
`async fn` or async closure).
2021-02-02 20:27:09 +00:00
Aaron Hill
a74b2fb946
Fix early lints inside an async desugaring
Fixes #81531

When we buffer an early lint for a macro invocation,
we need to determine which NodeId to take the lint level from.
Currently, we use the `NodeId` of the closest def parent. However, if
the macro invocation is inside the desugared closure from an `async fn`
or async closure, that `NodeId` does not actually exist in the AST.

This commit explicitly calls `check_lint` for the `NodeId`s of closures
desugared from async expressions, ensuring that we do not miss any
buffered lints.
2021-02-02 13:57:46 -05:00
Jack Huey
a0622d60e0 Update Chalk 2021-02-02 12:37:22 -05:00
bors
3182375e06 Auto merge of #81405 - bugadani:ast, r=cjgillot
Box the biggest ast::ItemKind variants

This PR is a different approach on https://github.com/rust-lang/rust/pull/81400, aiming to save memory in humongous ASTs.

The three affected item kind enums are:
 - `ast::ItemKind` (208 -> 112 bytes)
 - `ast::AssocItemKind` (176 -> 72 bytes)
 - `ast::ForeignItemKind` (176 -> 72 bytes)
2021-02-02 17:34:08 +00:00
kadmin
65256717f2 Add better diagnostic for missing where clause
Previously, it's not clear what exactly should be added in the suggested where clause,
so this adds an example to demonstrate.
2021-02-02 17:01:53 +00:00
Jake Hughes
07c4eeb836 Fix out of date Scalar documentation
Scalars can represent integers up to u128, but the docs state otherwise.
2021-02-02 16:15:32 +00:00
bjorn3
fbe109a2fc Avoid a hir access inside get_static 2021-02-02 16:36:54 +01:00
bors
b81f5811f9 Auto merge of #80843 - Mark-Simulacrum:fmt-bump, r=petrochenkov
Bump rustfmt version
2021-02-02 14:52:53 +00:00
Mark Rousskov
d5b760ba62 Bump rustfmt version
Also switches on formatting of the mir build module
2021-02-02 09:09:52 -05:00
Hugues de Valon
ce9818f2b7 Add a new ABI to support cmse_nonsecure_call
This commit adds a new ABI to be selected via `extern
"C-cmse-nonsecure-call"` on function pointers in order for the compiler to
apply the corresponding cmse_nonsecure_call callsite attribute.
For Armv8-M targets supporting TrustZone-M, this will perform a
non-secure function call by saving, clearing and calling a non-secure
function pointer using the BLXNS instruction.

See the page on the unstable book for details.

Signed-off-by: Hugues de Valon <hugues.devalon@arm.com>
2021-02-02 13:04:31 +00:00
Jonas Schievink
73f859e912
Rollup merge of #81631 - LingMan:rem_var, r=davidtwco
Remove unneeded `mut` variable

`arg_elide` gets initialized, immediately cloned, and only written to after that.
The last reading access was removed back in
7704762604
2021-02-02 12:15:08 +01:00
Jonas Schievink
285524f8da
Rollup merge of #81609 - Julian-Wollersberger:no-query-categories, r=davidtwco
Remove the remains of query categories

Back in October 2020 in #77830 ``@cjgillot`` removed the query categories information from the profiler, but the actual definitions which query was in which category remained, although unused.
Here I clean that up, to simplify the query definitions even further.

It's unfortunate that this loses all the context for `git blame`, ~~but I'm working on moving those query definitions into `rustc_query_system`, which will lose that context anyway.~~ EDIT: Might not work out.

The functional changes are in the first commit. The second one only changes the indentation.
2021-02-02 12:15:04 +01:00
Jonas Schievink
255e0764c0
Rollup merge of #81608 - Aaron1011:macro-res-parse-err, r=davidtwco
Improve handling of spans around macro result parse errors

Fixes #81543

After we expand a macro, we try to parse the resulting tokens as a AST
node. This commit makes several improvements to how we handle spans when
an error occurs:

* Only ovewrite the original `Span` if it's a dummy span. This preserves
  a more-specific span if one is available.
* Use `self.prev_token` instead of `self.token` when emitting an error
  message after encountering EOF, since an EOF token always has a dummy
  span
* Make `SourceMap::next_point` leave dummy spans unused. A dummy span
  does not have a logical 'next point', since it's a zero-length span.
  Re-using the span span preserves its 'dummy-ness' for other checks
2021-02-02 12:15:02 +01:00
Jonas Schievink
efec2bbbce
Rollup merge of #81577 - BoxyUwU:subexpr_const_evaluatable, r=oli-obk
const_evaluatable: consider sub-expressions to be evaluatable

see [zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/const_evaluatable.3A.20subexpressions) for more info

cc `@lcnr`
r? `@oli-obk`
2021-02-02 12:14:59 +01:00
Jonas Schievink
a1887912e8
Rollup merge of #80629 - sexxi-goose:migrations_1, r=nikomatsakis
Add lint for 2229 migrations

Implements the first for RFC 2229 where we make the decision to migrate a root variable based on if the type of the variable needs Drop and if the root variable would be moved into the closure when the feature isn't enabled.

r? `@nikomatsakis`
2021-02-02 12:14:44 +01:00
Hirochika Matsumoto
bad0f288d3 Improve wording of suggestion about accessing field 2021-02-02 15:16:07 +09:00
Aman Arora
84f0a0a1c6 New migration 2021-02-01 22:52:25 -05:00
Aman Arora
8f15cc1d88 PR fixup 2021-02-01 22:13:43 -05:00
Aman Arora
caf06bf5f5 Mark the lint doc as compile_fail 2021-02-01 22:13:42 -05:00
Aman Arora
cc5e6db5f2 Migrations first pass 2021-02-01 18:38:41 -05:00
Aman Arora
d3e85014a7 Process mentioned upvars for analysis first pass after ExprUseVisitor
- This allows us add fake information after handling migrations if
  needed.
- Capture analysis also priortizes what we see earlier, which means
  fake information should go in last.
2021-02-01 18:32:50 -05:00
Mara Bos
ed1de99b4f Fix bug with assert!() calling the wrong edition of panic!().
The span of `panic!` produced by the `assert` macro did not carry the
right edition. This changes `assert` to call the right version.
2021-02-01 23:23:27 +01:00
Felix S. Klock II
a7745d965e placate tidy. 2021-02-01 17:08:38 -05:00
Felix S. Klock II
2307d08d2f Use UFCS instead of method calls in derive(Debug). See issue 81211 for discussion. 2021-02-01 17:08:37 -05:00
Ellen
7f8530f16b more things are const evaluatable *sparkles* 2021-02-01 20:05:50 +00:00
bors
d4e3570db4 Auto merge of #80641 - Danue1:patch-1, r=oli-obk
Add visitors for checking #[inline]

For #80564
2021-02-01 19:31:01 +00:00
Nadrieril
ae6fcab733 Make SubPatSet clearer by flipping its meaning 2021-02-01 19:29:38 +00:00
LingMan
b35d601ab7 Directly use Option<&[T]> instead of converting from Option<&Vec<T>> later on 2021-02-01 19:51:24 +01:00
Jesus Rubio
ee5ea24d36 Add long error explanation for E0521 2021-02-01 18:22:13 +01:00
Jack Huey
4b64bc1fc9 Upgrade Chalk 2021-02-01 10:37:45 -05:00
LingMan
8e34522309 Remove unneeded mut variable
`arg_elide` gets initialized, immediately cloned, and only written to after that.
The last reading access was removed back in
7704762604
2021-02-01 15:37:46 +01:00
Danuel
8bbb2d057d Fixed #[inline] to be warned in fields, arms, macro defs
Add visitors for checking #[inline]

Add visitors for checking #[inline] with struct field

Fix test for #[inline]

Add visitors for checking #[inline] with #[macro_export] macro

Add visitors for checking #[inline] without #[macro_export] macro

Add use alias with Visitor

Fix lint error

Reduce unnecessary variable

Co-authored-by: LingMan <LingMan@users.noreply.github.com>

Change error to warning

Add warning for checking field, arm with #[allow_internal_unstable]

Add name resolver

Formatting

Formatting

Fix error fixture

Add checking field, arm, macro def
2021-02-01 23:36:19 +09:00
Jonas Schievink
b3339ab828
Rollup merge of #81618 - bjorn3:sync_cg_clif-2021-02-01, r=bjorn3
Sync rustc_codegen_cranelift

The highlight of this sync are abi compatibility with cg_llvm allowing mixing of cg_clif and cg_llvm compiled crates and switching to the x64 cranelift backend based on the new backend framework.

r? ``@ghost``

``@rustbot`` label +A-codegen +A-cranelift +T-compiler
2021-02-01 14:29:47 +01:00
Jonas Schievink
82b00ec606
Rollup merge of #81536 - tgnottingham:time-passes-rss, r=oli-obk
Indicate both start and end of pass RSS in time-passes output

Previously, only the end of pass RSS was indicated. This could easily
lead one to believe that the change in RSS from one pass to the next was
attributable to the second pass, when in fact it occurred between the
end of the first pass and the start of the second.

Also, improve alignment of columns.

Sample of output:

```
time:   0.739; rss:   607MB ->   637MB	item_types_checking
time:   8.429; rss:   637MB ->   775MB	item_bodies_checking
time:  11.063; rss:   470MB ->   775MB	type_check_crate
time:   0.232; rss:   775MB ->   777MB	match_checking
time:   0.139; rss:   777MB ->   779MB	liveness_and_intrinsic_checking
time:   0.372; rss:   775MB ->   779MB	misc_checking_2
time:   8.188; rss:   779MB ->  1019MB	MIR_borrow_checking
time:   0.062; rss:  1019MB ->  1021MB	MIR_effect_checking
```
2021-02-01 14:29:40 +01:00
Jonas Schievink
39ea34744b
Rollup merge of #81529 - estebank:case_lints, r=davidtwco
Fix invalid camel case suggestion involving unicode idents

Follow up to #77805.
2021-02-01 14:29:39 +01:00
Jonas Schievink
853cfd462f
Rollup merge of #81504 - matsujika:suggestion-field-access, r=estebank
Suggest accessing field when appropriate

Fix #81222

r? ``@estebank``
2021-02-01 14:29:37 +01:00
Jonas Schievink
9e8753e2bb
Rollup merge of #81463 - matsujika:nll-ensure-c-case, r=varkor
Rename NLL* to Nll* accordingly to C-CASE

Given [C-CASE](https://rust-lang.github.io/api-guidelines/naming.html#casing-conforms-to-rfc-430-c-case), `NLLRegionVariableOrigin` and `NLL` are encouraged to be `NllRegionVariableOrigin` and `Nll` respectively.
2021-02-01 14:29:35 +01:00
Jonas Schievink
ab74346b96
Rollup merge of #81364 - camelid:improve-build-matches-docs, r=varkor
Improve `rustc_mir_build::matches` docs

- Fix typos
- Add more information
- General cleanup
2021-02-01 14:29:31 +01:00
Jonas Schievink
21d0e9b8dc
Rollup merge of #79291 - JulianKnodt:ce_priv, r=petrochenkov
Add error message for private fn

Attempts to add a more detailed error when a `const_evaluatable` fn from another scope is used inside of a scope which cannot access it.

r? ````@lcnr````
2021-02-01 14:29:29 +01:00
bors
e0d9f79399 Auto merge of #80851 - m-ou-se:panic-2021, r=petrochenkov
Implement Rust 2021 panic

This implements the Rust 2021 versions of `panic!()`. See https://github.com/rust-lang/rust/issues/80162 and https://github.com/rust-lang/rfcs/pull/3007.

It does so by replacing `{std, core}::panic!()` by a bulitin macro that expands to either `$crate::panic::panic_2015!(..)` or `$crate::panic::panic_2021!(..)` depending on the edition of the caller.

This does not yet make std's panic an alias for core's panic on Rust 2021 as the RFC proposes. That will be a separate change: c5273bdfb2 That change is blocked on figuring out what to do with https://github.com/rust-lang/rust/issues/80846 first.
2021-02-01 10:25:31 +00:00
bjorn3
27855331e8 Merge commit 'd556c56f792756dd7cfec742b9f2e07612dc10f4' into sync_cg_clif-2021-02-01 2021-02-01 10:11:46 +01:00
Dániel Buga
003fba3fda Assert the size of the refactored enums 2021-02-01 09:23:40 +01:00
Dániel Buga
b87e1ecdf0 Box the biggest ast::ItemKind variants 2021-02-01 09:23:39 +01:00
Aman Arora
bf4bdd95c3 Add lint for 2229 migrations 2021-01-31 23:21:04 -05:00
Camelid
8b52cdc942 Update outdated comment
The highest-priority item is the *first* in the list, not the last.
See [this code][1] for more.

[this code]: 0e63af5da3/compiler/rustc_mir_build/src/build/matches/mod.rs (L1334-L1335)
2021-01-31 15:41:17 -08:00
kadmin
6a03f0350d Add error message for private fn
Bless tests

Update with changes from comments
2021-01-31 20:45:13 +00:00
Julian Wollersberger
988d93c8a0 Indent the code correctly again after removing the query categories. 2021-01-31 21:40:03 +01:00
Julian Wollersberger
7bc09f78af Remove the remains of the query categories. 2021-01-31 21:37:17 +01:00
Aaron Hill
6c14aad58e
Improve handling of spans around macro result parse errors
Fixes #81543

After we expand a macro, we try to parse the resulting tokens as a AST
node. This commit makes several improvements to how we handle spans when
an error occurs:

* Only ovewrite the original `Span` if it's a dummy span. This preserves
  a more-specific span if one is available.
* Use `self.prev_token` instead of `self.token` when emitting an error
  message after encountering EOF, since an EOF token always has a dummy
  span
* Make `SourceMap::next_point` leave dummy spans unused. A dummy span
  does not have a logical 'next point', since it's a zero-length span.
  Re-using the span span preserves its 'dummy-ness' for other checks
2021-01-31 15:24:34 -05:00
Jonas Schievink
9165676d91
Rollup merge of #81590 - KodrAus:stabilize/int_bits_const, r=m-ou-se
Stabilize int_bits_const

Closes #76904

The FCP to stabilize the `int_bits_const` feature completed on the tracking issue.
2021-01-31 16:36:57 +01:00
Jonas Schievink
36af32a740
Rollup merge of #81572 - pierwill:edit-error-codes-1, r=jonas-schievink
Edit multiple error code Markdown files

Makes small edits to several error code files. Fixes some missing punctuation. Changes some wording, grammar, and formatting for clarity and readability.

Adds a link to the rustup book in E0658.
2021-01-31 16:36:54 +01:00
Jonas Schievink
86c01ddc22
Rollup merge of #81571 - schteve:fix_e0759_typo, r=jonas-schievink
Fix typo in E0759

Minor typo in E0759 error message.
2021-01-31 16:36:52 +01:00
Jonas Schievink
024848d013
Rollup merge of #81568 - osa1:remove_old_fixme, r=jonas-schievink
Fix an old FIXME in redundant paren lint

Referenced bug was fixed a while ago
2021-01-31 16:36:51 +01:00
Jonas Schievink
991b31377c
Rollup merge of #81480 - b-naber:nested_fields_suggestion, r=estebank
Add suggestion for nested fields

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

r? ```@estebank```
2021-01-31 16:36:46 +01:00
Jonas Schievink
ed5614599a
Rollup merge of #81255 - sunfishcode:wasi-no-export-dynamic, r=alexcrichton
Don't link with --export-dynamic on wasm32-wasi

Remove --export-dynamic from the link arguments on the wasm32-wasi
target, as it emits spurious exports and increases code size.

Leave it in place for wasm32-unknown-unknown and
wasm32-unknown-emscripten. Even though it isn't a great solution
there, users are likely depending on its behavior there.
2021-01-31 16:36:44 +01:00
Jonas Schievink
99f2f5a830
Rollup merge of #80404 - JulianKnodt:arr_ref, r=oli-obk
Remove const_in_array_repeat

Fixes #80371. Fixes #81315. Fixes #80767. Fixes #75682.

I thought there might be some issue with `Repeats(_, 0)`, but if you increase the items in the array it still ICEs. I'm not sure if this is the best fix but it does fix the given issue.
2021-01-31 16:36:42 +01:00
Jonas Schievink
7e3a8ec688
Rollup merge of #80092 - sexxi-goose:restrict_precision, r=nikomatsakis
2229: Fix issues with move closures and mutability

This PR fixes two issues when feature `capture_disjoint_fields` is used.

1. Can't mutate using a mutable reference
2. Move closures try to move value out through a reference.

To do so, we
1. Compute the mutability of the capture and store it as part of the `CapturedPlace`  that is written in TypeckResults
2. Restrict capture precision. Note this is temporary for now, to allow the feature to be used with move closures and ByValue captures and might change depending on discussions with the lang team.
    - No Derefs are captured for ByValue captures, since that will result in value behind a reference getting moved.
    - No projections are applied to raw pointers since these require unsafe blocks. We capture
    them completely.

r? `````@nikomatsakis`````
2021-01-31 16:36:41 +01:00
Ashley Mannix
8940a2652e stabilize int_bits_const 2021-01-31 21:50:47 +10:00
Hirochika Matsumoto
f45a99361a Rustfmt 2021-01-31 16:52:46 +09:00
Hirochika Matsumoto
a292ac7177 Fix prefix of debug log 2021-01-31 16:49:33 +09:00
bors
9b32429822 Auto merge of #81327 - RalfJung:codegen-no-const-fail, r=oli-obk
codegen: assume constants cannot fail to evaluate

https://github.com/rust-lang/rust/pull/80579 landed, so we can finally remove this old hack from codegen and instead assume that consts never fail to evaluate. :)

r? `@oli-obk`
2021-01-31 07:03:09 +00:00
Esteban Küber
fa9a99fefc review comments 2021-01-30 22:06:10 -08:00
Jonas Schievink
33cd862733
Rollup merge of #81547 - pierwill:edit-typeck-mod-docs, r=davidtwco
Edit rustc_typeck top-level docs

Edit punctuation and wording in note on type variables vs. type parameters.

Also add missing punctuation and two inter-doc links.
2021-01-31 01:47:41 +01:00
Jonas Schievink
3e8ae5dcba
Rollup merge of #81472 - Aaron1011:fix/revert-cursor-clone, r=petrochenkov
Clone entire `TokenCursor` when collecting tokens

Reverts PR #80830
Fixes taiki-e/pin-project#312

We can have an arbitrary number of `None`-delimited group frames pushed
on the stack due to proc-macro invocations, which can legally be exited.
Attempting to account for this would add a lot of complexity for a tiny
performance gain, so let's just use the original strategy.
2021-01-31 01:47:34 +01:00
Jonas Schievink
84b6f46d6e
Rollup merge of #81422 - estebank:dotdot_sugg, r=davidtwco
Account for existing `_` field pattern when suggesting `..`

Follow up to #80017.
2021-01-31 01:47:33 +01:00
Jonas Schievink
1e99f26894
Rollup merge of #80470 - SimonSapin:array-intoiter-type, r=m-ou-se
Stabilize by-value `[T; N]` iterator `core::array::IntoIter`

Tracking issue: https://github.com/rust-lang/rust/issues/65798

This is unblocked now that `min_const_generics` has been stabilized in https://github.com/rust-lang/rust/pull/79135.

This PR does *not* include the corresponding `IntoIterator` impl, which is https://github.com/rust-lang/rust/pull/65819. Instead, an iterator can be constructed through the `new` method.

`new` would become unnecessary when `IntoIterator` is implemented and might be deprecated then, although it will stay stable.
2021-01-31 01:47:25 +01:00
pierwill
fabb332c1a Edit multiple error code Markdown files
Makes small edits to several error code files. Fixes some
missing punctuation. Changes some wording, grammar, and formatting
for clarity and readability.

Adds a link to the rustup book in E0658.
2021-01-30 15:57:46 -08:00
kadmin
6946534d84 Remove const_in_array_rep_expr 2021-01-30 23:20:24 +00:00
b-naber
9946b54823 add suggestion for nested fields 2021-01-30 23:19:41 +01:00
Ömer Sinan Ağacan
8b5187f7ea Fix an old FIXME in redundant paren lint
Referenced bug was fixed a while ago
2021-01-30 22:39:56 +03:00
pierwill
adfb04fc4e Edit rustc_typeck top-level docs
Edit punctuation and wording in note on type variables
vs. type parameters.

Also add missing punctuation and two inter-doc links.
2021-01-30 10:04:19 -08:00
bors
fd20a8be0d Auto merge of #81453 - jumbatm:clashing-extern-decl-perf, r=nagisa
clashing_extern_declarations: Use symbol interning to avoid string alloc.

Use symbol interning as a hack to avoid allocating a string for every symbol name we store in the seen set. This hopefully addresses the minor perf regression described in https://github.com/rust-lang/rust/pull/80009#issuecomment-763526902.

r? `@nagisa`
2021-01-30 16:41:05 +00:00
Steve Heindel
642d27d40a Fix typo in E0759 2021-01-30 09:48:37 -05:00
Ralf Jung
944237f6cd codegen: assume constants cannot fail to evaluate
also don't submit code to LLVM when the session has errors
2021-01-30 12:29:57 +01:00
Hirochika Matsumoto
6bc9634de3 Rename function to suggest_accessing_field_where_appropriate 2021-01-30 14:25:43 +09:00
Hirochika Matsumoto
2ce2d145c2 Account for union 2021-01-30 14:18:50 +09:00
Hirochika Matsumoto
08d31e0f09 Remove logging iterator 2021-01-30 13:50:44 +09:00
Yuki Okushi
5df611c5b1
Rollup merge of #81515 - eltociear:patch-7, r=jonas-schievink
Fix typo in pat.rs

parentesized -> parenthesized
2021-01-30 13:37:01 +09:00
Yuki Okushi
ba40cea487
Rollup merge of #81505 - henryboisdequin:cold_path-not-pub, r=sanxiyn
`fn cold_path` doesn't need to be pub

Fixes #81429

Note: this PR also fixes a small typo that I found
2021-01-30 13:36:58 +09:00
Yuki Okushi
774ba83226
Rollup merge of #81473 - sanxiyn:write-only-field, r=oli-obk
Warn write-only fields

cc `@Boscop's` example in #49256.
2021-01-30 13:36:52 +09:00
Yuki Okushi
fe27dea4b5
Rollup merge of #81468 - est31:cfg_version, r=petrochenkov
cfg(version): treat nightlies as complete

This PR makes cfg(version) treat the nightlies
for version 1.n.0 as 1.n.0, even though that nightly
version might not have all stabilizations and features
of the released 1.n.0. This is done for greater
convenience for people who want to test a newly
stabilized feature on nightly, or in other words,
give newly stabilized features as many eyeballs
as possible.

For users who wish to pin nightlies, this commit adds
a -Z assume-incomplete-release option that they can
enable if they run into any issues due to this change.
Implements the suggestion in https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454
2021-01-30 13:36:50 +09:00
Yuki Okushi
7fa991fb85
Rollup merge of #81291 - sexxi-goose:fix-struct-update-functional-record-update-syntax-error, r=nikomatsakis
Support FRU pattern with `[feature(capture_disjoint_fields)]`

In case of a functional record update syntax for creating a structure, `ExprUseVisitor` to only detect the precise use of some of the field in the `..x` part of the syntax. However, when we start building MIR, we
1. First, build the place for `x`
2. and then, add precise field projections so that only some parts of `x` end up getting read.

When `capture_disjoint_fields` is enabled, and FRU is used within a closure `x` won't be completely captured, and therefore the first step will fail. This PR updates `mir_build` to create a place builder in the first step and then create place from the builder only after applying the field projection.

Closes https://github.com/rust-lang/project-rfc-2229/issues/32
r? ``````@nikomatsakis``````
2021-01-30 13:36:46 +09:00
Yuki Okushi
91ea1cbc17
Rollup merge of #80959 - jhpratt:unsigned_abs-stabilization, r=m-ou-se
Stabilize `unsigned_abs`

Resolves #74913.

This PR stabilizes the `i*::unsigned_abs()` method, which returns the absolute value of an integer _as its unsigned equivalent_. This has the advantage that it does not overflow on `i*::MIN`.

I have gone ahead and used this in a couple locations throughout the repository.
2021-01-30 13:36:44 +09:00
Simonas Kazlauskas
915a04e2a4 Consider Scalar to be a bool only if its unsigned
This seems right, given that conceptually bools are unsigned, but the
implications of this change may have more action at distance that I'm
not sure how to exhaustively consider.

For instance there are a number of cases where code attaches range
metadata if `scalar.is_bool()` holds. Supposedly it would no longer be
attached to the `repr(i8)` enums? Though I'm not sure why booleans are
being special-cased here in the first place...

Fixes #80556
2021-01-30 00:49:10 +02:00
Aman Arora
0f4bab246b Fixme for closure origin when reborrow is implemented 2021-01-29 16:25:01 -05:00
Aman Arora
fadf03ee1b Fix typos 2021-01-29 16:01:27 -05:00
Tyson Nottingham
849dc1a20c Indicate both start and end of pass RSS in time-passes output
Previously, only the end of pass RSS was indicated. This could easily
lead one to believe that the change in RSS from one pass to the next was
attributable to the second pass, when in fact it occurred between the
end of the first pass and the start of the second.

Also, improve alignment of columns.
2021-01-29 12:46:29 -08:00
Aman Arora
ffd53277dc Add fixme for precise path diagnostics 2021-01-29 15:37:44 -05:00
Aman Arora
c748f32ee4 Fix incorrect use mut diagnostics 2021-01-29 15:37:44 -05:00
Aman Arora
604cbdcfdd Fix unused 'mut' warning for capture's root variable 2021-01-29 15:37:42 -05:00
Aman Arora
3488082582 Compute mutability of closure captures
When `capture_disjoint_fields` is not enabled, checking if the root variable
binding is mutable would suffice.

However with the feature enabled, the captured place might be mutable
because it dereferences a mutable reference.

This PR computes the mutability of each capture after capture analysis
in rustc_typeck. We store this in `ty::CapturedPlace` and then use
`ty::CapturedPlace::mutability` in mir_build and borrow_check.
2021-01-29 15:37:40 -05:00
Aman Arora
b421cd56d9 Restrict precision of captures with capture_disjoint_fields set
- No Derefs in move closure, this will result in value behind a reference getting moved.
- No projections are applied to raw pointers, since these require unsafe blocks. We capture
  them completely.

Motivations for these are recorded here: https://hackmd.io/71qq-IOpTNqzMkPpAI1dVg?view
2021-01-29 15:37:05 -05:00
Esteban Küber
d10ee0d07e Fix invalid camel case suggestion involving unicode idents
Follow up to #77805.
2021-01-29 11:07:14 -08:00
Ikko Ashimine
718398ccaf
Fix typo in pat.rs
parentesized -> parenthesized
2021-01-29 23:30:55 +09:00
bors
b122908617 Auto merge of #81470 - tmiasko:remove-allocations, r=matthewjasper
Avoid memory allocation when removing dead blocks

Use `reachable_as_bitset` to reuse a bitset from the traversal rather
than allocating it seprately. Additionally check if there are any
unreachable blocks before proceeding.
2021-01-29 13:10:09 +00:00
Henry Boisdequin
fd5fb86f05 fix typo 2021-01-29 16:08:49 +05:30
bors
c4e33b51c1 Auto merge of #81419 - rylev:canocalize-extern-entries, r=petrochenkov
Pre-canoncalize ExternLocation::ExactPaths

This stores pre-canacolized paths inside `ExternLocation::ExactPaths` so that we don't need to canoncalize them every time we want to compare them to source lib paths.

This is related to #81414.
2021-01-29 10:11:16 +00:00
Ryan Levick
6c7ecd007f Pre-canoncalize ExternLocation::ExactPaths 2021-01-29 11:02:12 +01:00
Henry Boisdequin
c2c2e8dde1 fn cold_path doesn't need to be pub 2021-01-29 14:03:01 +05:30
est31
d8b5745d46 Treat nightlies for a version as complete
This commit makes cfg(version) treat the nightlies
for version 1.n.0 as 1.n.0, even though that nightly
version might not have all stabilizations and features
of the released 1.n.0. This is done for greater
convenience for people who want to test a newly
stabilized feature on nightly.

For users who wish to pin nightlies, this commit adds
a -Z assume-incomplete-release option that they can
enable if there are any issues due to this change.
2021-01-29 07:59:19 +01:00
bors
099f27b6cb Auto merge of #81440 - tmiasko:always-live-locals, r=matthewjasper
Visit only statements in always live locals

No functional changes intended.
2021-01-29 06:56:29 +00:00
Thomas Eizinger
ff00ef4d66
Apply workaround from #72003 for #56935
Related: #72017.
2021-01-29 14:56:37 +11:00
bors
74500b9978 Auto merge of #81493 - JohnTitor:rollup-sa4m4zh, r=JohnTitor
Rollup of 10 pull requests

Successful merges:

 - #79570 (rustc: Stabilize `-Zrun-dsymutil` as `-Csplit-debuginfo`)
 - #79819 (Add `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint)
 - #79991 (rustdoc: Render HRTB correctly for bare functions)
 - #80215 (Use -target when linking binaries for Mac Catalyst)
 - #81158 (Point to span of upvar making closure FnMut)
 - #81176 (Improve safety of `LateContext::qpath_res`)
 - #81287 (Split rustdoc JSON types into separately versioned crate)
 - #81306 (Fuse inner iterator in FlattenCompat and improve related tests)
 - #81333 (clean up some const error reporting around promoteds)
 - #81459 (Fix rustdoc text selection for page titles)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-01-29 00:58:43 +00:00
Yuki Okushi
046a414c19
Rollup merge of #81333 - RalfJung:const-err-simplify, r=oli-obk
clean up some const error reporting around promoteds

These are some error reporting simplifications enabled by https://github.com/rust-lang/rust/pull/80579.

Further simplifications are possible but could be blocked on making `const_err` a hard error.

r? ``````@oli-obk``````
2021-01-29 09:17:38 +09:00
Yuki Okushi
0c5fccea22
Rollup merge of #81176 - camsteffen:qpath-res, r=oli-obk
Improve safety of `LateContext::qpath_res`

This is my first rustc code change, inspired by hacking on clippy!

The first change is to clear cached `TypeckResults` from `LateContext` when visiting a nested item. I took a hint from [here](5e91c4ecc0/compiler/rustc_privacy/src/lib.rs (L1300)).

Clippy has a `qpath_res` util function to avoid a possible ICE in `LateContext::qpath_res`. But the docs of `LateContext::qpath_res` promise no ICE. So this updates the `LateContext` method to keep its promises, and removes the util function.

Related: rust-lang/rust-clippy#4545

CC ````````````@eddyb```````````` since you've done related work
CC ````````````@flip1995```````````` FYI
2021-01-29 09:17:32 +09:00
Yuki Okushi
4283623bc0
Rollup merge of #81158 - 1000teslas:issue-80313-fix, r=Aaron1011
Point to span of upvar making closure FnMut

For #80313.
2021-01-29 09:17:31 +09:00
Yuki Okushi
a3c060c7f5
Rollup merge of #80215 - visigoth:issue-80202-fix, r=estebank
Use -target when linking binaries for Mac Catalyst

When running `rustc` with `-target x86_64-apple-ios-macabi`, the linker
eventually gets run with `-arch x86_64`, because the linker back end splits the
LLVM target triple and uses the first token as the target architecture. However,
this does not work for the Mac Catalyst ABI, which is a separate target from
Darwin.

Specifying the full target triple with `-target` allows Mac Catalyst binaries to
link and run.

closes #80202
2021-01-29 09:17:29 +09:00
Yuki Okushi
4003a73975
Rollup merge of #79819 - Aaron1011:feature/macro-trailing-semicolon, r=petrochenkov
Add `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint

cc #79813

This PR adds an allow-by-default future-compatibility lint
`SEMICOLON_IN_EXPRESSIONS_FROM_MACROS`. It fires when a trailing semicolon in a
macro body is ignored due to the macro being used in expression
position:

```rust
macro_rules! foo {
    () => {
        true; // WARN
    }
}

fn main() {
    let val = match true {
        true => false,
        _ => foo!()
    };
}
```

The lint takes its level from the macro call site, and
can be allowed for a particular macro by adding
`#[allow(macro_trailing_semicolon)]`.

The lint is set to warn for all internal rustc crates (when being built
by a stage1 compiler). After the next beta bump, we can enable
the lint for the bootstrap compiler as well.
2021-01-29 09:17:26 +09:00
Yuki Okushi
d9e56f48c5
Rollup merge of #79570 - alexcrichton:split-debuginfo, r=bjorn3
rustc: Stabilize `-Zrun-dsymutil` as `-Csplit-debuginfo`

This commit adds a new stable codegen option to rustc,
`-Csplit-debuginfo`. The old `-Zrun-dsymutil` flag is deleted and now
subsumed by this stable flag. Additionally `-Zsplit-dwarf` is also
subsumed by this flag but still requires `-Zunstable-options` to
actually activate. The `-Csplit-debuginfo` flag takes one of
three values:

* `off` - This indicates that split-debuginfo from the final artifact is
  not desired. This is not supported on Windows and is the default on
  Unix platforms except macOS. On macOS this means that `dsymutil` is
  not executed.

* `packed` - This means that debuginfo is desired in one location
  separate from the main executable. This is the default on Windows
  (`*.pdb`) and macOS (`*.dSYM`). On other Unix platforms this subsumes
  `-Zsplit-dwarf=single` and produces a `*.dwp` file.

* `unpacked` - This means that debuginfo will be roughly equivalent to
  object files, meaning that it's throughout the build directory
  rather than in one location (often the fastest for local development).
  This is not the default on any platform and is not supported on Windows.

Each target can indicate its own default preference for how debuginfo is
handled. Almost all platforms default to `off` except for Windows and
macOS which default to `packed` for historical reasons.

Some equivalencies for previous unstable flags with the new flags are:

* `-Zrun-dsymutil=yes` -> `-Csplit-debuginfo=packed`
* `-Zrun-dsymutil=no` -> `-Csplit-debuginfo=unpacked`
* `-Zsplit-dwarf=single` -> `-Csplit-debuginfo=packed`
* `-Zsplit-dwarf=split` -> `-Csplit-debuginfo=unpacked`

Note that `-Csplit-debuginfo` still requires `-Zunstable-options` for
non-macOS platforms since split-dwarf support was *just* implemented in
rustc.

There's some more rationale listed on #79361, but the main gist of the
motivation for this commit is that `dsymutil` can take quite a long time
to execute in debug builds and provides little benefit. This means that
incremental compile times appear that much worse on macOS because the
compiler is constantly running `dsymutil` over every single binary it
produces during `cargo build` (even build scripts!). Ideally rustc would
switch to not running `dsymutil` by default, but that's a problem left
to get tackled another day.

Closes #79361
2021-01-29 09:17:20 +09:00
bors
b05fd2a15d Auto merge of #81388 - bjorn3:wasm_bindgen_fix, r=nikomatsakis
Fix abi for wasm-bindgen

Hopefully fixes https://github.com/rust-lang/rust/issues/81386. `@alexcrichton` can you confirm this fixes wasm-bindgen?

r? `@alexcrichton`
2021-01-28 22:01:42 +00:00
Hirochika Matsumoto
9e4ed337c7 Suggest accessing field when code compiles with it 2021-01-29 06:52:49 +09:00
bors
c0b64d97be Auto merge of #81055 - matthewjasper:non-fatal-overflow, r=nikomatsakis
Make hitting the recursion limit in projection non-fatal

This change was originally made in #80246 to avoid future (effectively) infinite loop bugs in projections,
but wundergraph relies on rustc recovering here.

cc #80953

r? `@nikomatsakis`
2021-01-28 18:57:10 +00:00
Alex Crichton
a124043fb0 rustc: Stabilize -Zrun-dsymutil as -Csplit-debuginfo
This commit adds a new stable codegen option to rustc,
`-Csplit-debuginfo`. The old `-Zrun-dsymutil` flag is deleted and now
subsumed by this stable flag. Additionally `-Zsplit-dwarf` is also
subsumed by this flag but still requires `-Zunstable-options` to
actually activate. The `-Csplit-debuginfo` flag takes one of
three values:

* `off` - This indicates that split-debuginfo from the final artifact is
  not desired. This is not supported on Windows and is the default on
  Unix platforms except macOS. On macOS this means that `dsymutil` is
  not executed.

* `packed` - This means that debuginfo is desired in one location
  separate from the main executable. This is the default on Windows
  (`*.pdb`) and macOS (`*.dSYM`). On other Unix platforms this subsumes
  `-Zsplit-dwarf=single` and produces a `*.dwp` file.

* `unpacked` - This means that debuginfo will be roughly equivalent to
  object files, meaning that it's throughout the build directory
  rather than in one location (often the fastest for local development).
  This is not the default on any platform and is not supported on Windows.

Each target can indicate its own default preference for how debuginfo is
handled. Almost all platforms default to `off` except for Windows and
macOS which default to `packed` for historical reasons.

Some equivalencies for previous unstable flags with the new flags are:

* `-Zrun-dsymutil=yes` -> `-Csplit-debuginfo=packed`
* `-Zrun-dsymutil=no` -> `-Csplit-debuginfo=unpacked`
* `-Zsplit-dwarf=single` -> `-Csplit-debuginfo=packed`
* `-Zsplit-dwarf=split` -> `-Csplit-debuginfo=unpacked`

Note that `-Csplit-debuginfo` still requires `-Zunstable-options` for
non-macOS platforms since split-dwarf support was *just* implemented in
rustc.

There's some more rationale listed on #79361, but the main gist of the
motivation for this commit is that `dsymutil` can take quite a long time
to execute in debug builds and provides little benefit. This means that
incremental compile times appear that much worse on macOS because the
compiler is constantly running `dsymutil` over every single binary it
produces during `cargo build` (even build scripts!). Ideally rustc would
switch to not running `dsymutil` by default, but that's a problem left
to get tackled another day.

Closes #79361
2021-01-28 08:51:11 -08:00
Oli Scherer
85ad773049
Add missing brace 2021-01-28 17:49:40 +01:00
Seo Sanghyeon
899aae465e
Simplify base_expr
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2021-01-29 01:44:15 +09:00
bors
bf193d69fe Auto merge of #81441 - tmiasko:ctfe-inline, r=oli-obk
Try inlining trivial functions used by CTFE

r? `@ghost`
2021-01-28 15:19:16 +00:00
Seo Sanghyeon
d3c69a4c0d Warn write-only fields 2021-01-28 23:56:13 +09:00
Aaron Hill
5d739180cd
Clone entire TokenCursor when collecting tokens
Reverts PR #80830
Fixes taiki-e/pin-project#312

We can have an arbitrary number of `None`-delimited group frames pushed
on the stack due to proc-macro invocations, which can legally be exited.
Attempting to account for this would add a lot of complexity for a tiny
performance gain, so let's just use the original strategy.
2021-01-28 09:47:59 -05:00
Aaron Hill
f9025512e7
Add SEMICOLON_IN_EXPRESSIONS_FROM_MACROS lint
cc #79813

This PR adds an allow-by-default future-compatibility lint
`SEMICOLON_IN_EXPRESSIONS_FROM_MACROS`. It fires when a trailing semicolon in a
macro body is ignored due to the macro being used in expression
position:

```rust
macro_rules! foo {
    () => {
        true; // WARN
    }
}

fn main() {
    let val = match true {
        true => false,
        _ => foo!()
    };
}
```

The lint takes its level from the macro call site, and
can be allowed for a particular macro by adding
`#[allow(semicolon_in_expressions_from_macros)]`.

The lint is set to warn for all internal rustc crates (when being built
by a stage1 compiler). After the next beta bump, we can enable
the lint for the bootstrap compiler as well.
2021-01-28 08:51:43 -05:00
bors
643a79af3d Auto merge of #81149 - Aaron1011:feature/better-no-method-found-err, r=estebank
Avoid describing a method as 'not found' when bounds are unsatisfied

Fixes #76267

When there is a single applicable method candidate, but its trait bounds
are not satisfied, we avoid saying that the method is "not found".
Insted, we update the error message to directly mention which bounds are
not satisfied, rather than mentioning them in a note.
2021-01-28 12:09:50 +00:00
Hirochika Matsumoto
f8e0e78d75 Rename NLL* to Nll* accordingly to C-CASE 2021-01-28 16:18:25 +09:00
Yuki Okushi
d98fcbd561
Rollup merge of #81433 - lcnr:stop-looking-into-ty-alias, r=oli-obk
const_evaluatable: stop looking into type aliases

see https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/const_evaluatable.3A.20type.20alias

r? ````@oli-obk````
2021-01-28 15:09:20 +09:00
Yuki Okushi
f183e5f04c
Rollup merge of #81426 - BoxyUwU:boxychangesv2, r=oli-obk
const_evaluatable: expand abstract consts in try_unify

See this [zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/combining.20const.20bounds) for more info

cc ```@lcnr```
r? ```@oli-obk```
2021-01-28 15:09:15 +09:00
Yuki Okushi
b8eac50ff5
Rollup merge of #81416 - estebank:suggestion-span-tweak, r=petrochenkov
Tweak suggestion for missing field in patterns

Account for parser recovered struct and tuple patterns to avoid invalid
suggestion.

Follow up to #81103.
2021-01-28 15:09:13 +09:00
Yuki Okushi
bb6d1d3086
Rollup merge of #81284 - jyn514:impl-times, r=wesleywiser
Make `-Z time-passes` less noisy

- Add the module name to `pre_AST_expansion_passes` and don't make it a
  verbose event (since it normally doesn't take very long, and it's
  emitted many times)
- Don't make the following rustdoc events verbose; they're emitted many times.
  + build_extern_trait_impl
  + build_local_trait_impl
  + build_primitive_trait_impl
  + get_auto_trait_impls
  + get_blanket_trait_impls
- Remove the `get_auto_trait_and_blanket_synthetic_impls` rustdoc event; it's wholly
  covered by get_{auto,blanket}_trait_impls and not very useful.

I found this while working on https://github.com/rust-lang/rust/pull/81275 but it's independent of those changes.
2021-01-28 15:09:10 +09:00
Yuki Okushi
70be5cef69
Rollup merge of #81277 - flip1995:from_diag_items, r=matthewjasper
Make more traits of the From/Into family diagnostic items

Following traits are now diagnostic items:
- `From` (unchanged)
- `Into`
- `TryFrom`
- `TryInto`

This also adds symbols for those items:
- `into_trait`
- `try_from_trait`
- `try_into_trait`

Related: https://github.com/rust-lang/rust-clippy/pull/6620#discussion_r562482587
2021-01-28 15:09:08 +09:00
Yuki Okushi
84ad95be70
Rollup merge of #81062 - sexxi-goose:precise_capture_diagnostics, r=nikomatsakis
Improve diagnostics for Precise Capture

This is just the capture analysis part and borrow checker logging will updated as part of rust-lang/project-rfc-2229#8

Closes rust-lang/project-rfc-2229#22
2021-01-28 15:09:06 +09:00
Yuki Okushi
446edd1e1a
Rollup merge of #79951 - LeSeulArtichaut:ty-ir, r=nikomatsakis
Refractor a few more types to `rustc_type_ir`

In the continuation of #79169, ~~blocked on that PR~~.

This PR:
 - moves `IntVarValue`, `FloatVarValue`, `InferTy` (and friends) and `Variance`
 - creates the `IntTy`, `UintTy` and `FloatTy` enums in `rustc_type_ir`, based on their `ast` and `chalk_ir` equilavents, and uses them for types in the rest of the compiler.

~~I will split up that commit to make this easier to review and to have a better commit history.~~
EDIT: done, I split the PR in commits of 200-ish lines each

r? `````@nikomatsakis````` cc `````@jackh726`````
2021-01-28 15:09:02 +09:00
Ramon de C Valle
3f679fef23 Fix rustc sysroot in systems using CAS
Change filesearch::get_or_default_sysroot() to check if sysroot is found
using env::args().next() if rustc in argv[0] is a symlink; otherwise, or
if it is not found, use env::current_exe() to imply sysroot. This makes
the rustc binary able to locate Rust libraries in systems using
content-addressable storage (CAS).
2021-01-27 19:27:23 -08:00
bors
e32f372c42 Auto merge of #81414 - rylev:fetch-rmeta-crates, r=petrochenkov
Check for rmeta crates when getting existing crates from cache

This change makes sure to check for rmeta files when resolving crates instead of always going to disk in that case.
2021-01-28 01:29:47 +00:00
Tomasz Miąsko
dc6ec3596b Avoid memory allocation when removing dead blocks
Use `reachable_as_bitset` to reuse a bitset from the traversal rather
than allocating it seprately. Additionally check if there are any
unreachable blocks before proceeding.
2021-01-28 00:00:00 +00:00
Amanieu d'Antras
8783d1a47e Add big-endian and ILP32 AArch64 targets 2021-01-27 22:47:57 +00:00
Amanieu d'Antras
d53b0a04a6 Fix ARM and AArch64 calling convention for passing small composite types
On big-endian the values need to be right-aligned within a 64-bit register, as if the value had been read with a 64-bit load instruction.
2021-01-27 22:47:56 +00:00
Amanieu d'Antras
8afe59893a Add big-endian support for AArch64 va_arg 2021-01-27 22:47:56 +00:00
jumbatm
a1a7830465 Use symbol interning to avoid string alloc. 2021-01-28 08:03:36 +10:00
Tomasz Miąsko
20982b386f Inline MemPlace::offset 2021-01-27 16:13:58 +01:00
Tomasz Miąsko
83dc7fe669 Inline trivial implementation of rustc_target::abi::Align 2021-01-27 16:13:18 +01:00
Ellen
f4261772d8 comments 2021-01-27 14:46:43 +00:00
Bastian Kauschke
b519deb224 const_evaluatable: stop looking into type aliases 2021-01-27 13:34:45 +01:00
bors
742c972c4f Auto merge of #79591 - estebank:unexpected-generics, r=oli-obk
Point only at generic arguments when they are unexpected
2021-01-27 07:15:33 +00:00
Aaron Hill
dea8a16af5
Avoid describing a method as 'not found' when bounds are unsatisfied
Fixes #76267

When there is a single applicable method candidate, but its trait bounds
are not satisfied, we avoid saying that the method is "not found".
Insted, we update the error message to directly mention which bounds are
not satisfied, rather than mentioning them in a note.
2021-01-26 23:59:50 -05:00
kadmin
fe39653116 Check that value is explicitly none 2021-01-27 03:56:54 +00:00
Ellen
b0625eb712 boop, ur abstract consts are now expanded 2021-01-27 02:46:19 +00:00
Esteban Küber
a398994cb2 Account for existing _ field pattern when suggesting ..
Follow up to #80017.
2021-01-26 16:53:56 -08:00
bors
78e22069d0 Auto merge of #81393 - pnkfelix:issue-81296-make-weak-item-traversal-deterministic, r=estebank
Make weak item traversal deterministic

Fix #81296.

(No test added. The relevant test *is* ui/panic-handler/weak-lang-item.rs, and this change should make it less flaky.)
2021-01-27 00:19:45 +00:00
Tomasz Miąsko
56865936a7 Visit only statements in always live locals
No functional changes intended.
2021-01-27 00:00:00 +00:00
Esteban Küber
2e846d6f61 Point only at generic arguments when they are unexpected 2021-01-26 15:59:43 -08:00
Yuki Okushi
d68570c78f
Rollup merge of #81407 - osa1:issue81098, r=estebank
Refine "remove semicolon" suggestion in trait selection

Don't suggest it if the last statement doesn't have a semicolon

Fixes #81098

See also #54771 for why this suggestion was added
2021-01-27 04:43:35 +09:00
Yuki Okushi
acbd1010ef
Rollup merge of #81369 - tgnottingham:codegen-to-llvm-ir-wall-time, r=lcnr
rustc_codegen_ssa: use wall time for codegen_to_LLVM_IR time-passes entry

Use elapsed wall time spent on codegen_to_LLVM_IR for all CGUs as a
whole, rather than the sum for each CGU (the distinction matters for
parallel builds, where some CGUs are processed in parallel).
2021-01-27 04:43:28 +09:00
Yuki Okushi
3741844711
Rollup merge of #81353 - jockbert:spelling_in_e0207, r=petrochenkov
Fix spelling in documentation for error E0207

I have trouble parsing the the wording "type parameter parameter".
2021-01-27 04:43:25 +09:00
Yuki Okushi
71f13fb434
Rollup merge of #81325 - osa1:issue81293, r=estebank
typeck: Don't suggest converting LHS exprs

Converting LHS of an assignment does not work, so avoid suggesting that.

Fixes #81293
2021-01-27 04:43:24 +09:00
Yuki Okushi
644df2fd23
Rollup merge of #81195 - estebank:suggest-bound-on-trait-with-params, r=oli-obk
Account for generics when suggesting bound

Fix #81175.
2021-01-27 04:43:20 +09:00
Yuki Okushi
c2c90bf548
Rollup merge of #80900 - camelid:readpointerasbytes-ice, r=oli-obk
Fix ICE with `ReadPointerAsBytes` validation error

Fixes #79690.

r? ``````@oli-obk``````
2021-01-27 04:43:16 +09:00
Esteban Küber
0959f0f912 Tweak suggestion for missing field in patterns
Account for parser recovered struct and tuple patterns to avoid invalid
suggestion.

Follow up to #81103.
2021-01-26 11:27:53 -08:00