Commit graph

3520 commits

Author SHA1 Message Date
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
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
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
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
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
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
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