Commit graph

158911 commits

Author SHA1 Message Date
luojia65
0ccf58b928 Update stdarch dependency 2021-12-09 22:33:25 +08:00
luojia65
70855b24b8 Add spin_loop hint for RISC-V architecture
This commit also updates `stdarch` git submodule.
2021-12-05 16:39:21 +08:00
bors
bdaa901049 Auto merge of #91475 - ecstatic-morse:mir-pass-manager3, r=oli-obk
Add a MIR pass manager (Taylor's Version)

The final draft of #91386 and #77665.

While the compile-time constraints in #91386 are cool, I decided on a more minimal approach for now. I want to explore phase constraints and maybe relative-ordering constraints in the future, though. This should preserve existing behavior **exactly** (please let me know if it doesn't) while making the following changes to the way we organize things today:

- Each `MirPhase` now corresponds to a single MIR pass. `run_passes` is not responsible for listing the correct MIR phase.
- `run_passes` no longer silently skips passes if the declared MIR phase is greater than or equal to the body's. This has bitten me multiple times. If you want this behavior, you can always branch on `body.phase` yourself.
- If your pass is solely to emit errors, you can use the `MirLint` interface instead, which gets a shared reference to `Body` instead of a mutable one. By differentiating the two, I hope to make it clearer in the short term where lints belong in the pipeline. In the long term perhaps we could enforce this at compile-time?
- MIR is no longer dumped for passes that aren't enabled, or for lints.

I tried to check that `-Zvalidate` still works correctly, since the MIR phase is now updated as soon as the associated pass is done, instead of at the end of all the passes in `run_passes`. However, it looks like `-Zvalidate` is broken with current nightlies anyways 😢 (it spits out a bunch of errors).

cc `@oli-obk` `@wesleywiser`

r? rust-lang/wg-mir-opt
2021-12-05 03:41:18 +00:00
bors
5e93f6e318 Auto merge of #91539 - matthiaskrgr:rollup-rnl10yb, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #89642 (environ on macos uses directly libc which has the correct signature.)
 - #90022 (Explain why `Self` is invalid in generic parameters)
 - #90023 (Postpone the evaluation of constant expressions that depend on inference variables)
 - #91215 (Implement VecDeque::retain_mut)
 - #91355 (std: Stabilize the `thread_local_const_init` feature)
 - #91528 (LLVM support .insn directive)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-05 00:38:01 +00:00
Matthias Krüger
2ba5917cbc
Rollup merge of #91528 - piegamesde:master, r=cuviper
LLVM support .insn directive

Closes #90558. See also https://github.com/rust-lang/llvm-project/pull/121.
2021-12-05 00:38:01 +01:00
Matthias Krüger
23012b5200
Rollup merge of #91355 - alexcrichton:stabilize-thread-local-const, r=m-ou-se
std: Stabilize the `thread_local_const_init` feature

This commit is intended to follow the stabilization disposition of the
FCP that has now finished in #84223. This stabilizes the ability to flag
thread local initializers as `const` expressions which enables the macro
to generate more efficient code for accessing it, notably removing
runtime checks for initialization.

More information can also be found in #84223 as well as the tests where
the feature usage was removed in this PR.

Closes #84223
2021-12-05 00:38:00 +01:00
Matthias Krüger
4af985ac00
Rollup merge of #91215 - GuillaumeGomez:vec-deque-retain-mut, r=m-ou-se
Implement VecDeque::retain_mut

Part of https://github.com/rust-lang/rust/issues/90829.

In https://github.com/rust-lang/rust/pull/90772, someone suggested that `retain_mut` should also be implemented on `VecDeque`. I think that it follows the same logic (coherency). So first: is it ok? Second: should I create a new feature for it or can we put it into the same one?

r? `@joshtriplett`
2021-12-05 00:37:59 +01:00
Matthias Krüger
1f2a26e999
Rollup merge of #90023 - b-naber:postpone_const_eval_infer_vars, r=nikomatsakis
Postpone the evaluation of constant expressions that depend on inference variables

Previously `delay_span_bug` calls were triggered once an inference variable was included in the substs of a constant that was to be evaluated. Some of these would merely have resulted in trait candidates being rejected, hence no real error was ever encountered, but the triggering of the `delay_span_bug` then caused an ICE in later stages of the compiler due to no error ever occurring.
We now postpone the evaluation of these constants, so any trait obligation fulfillment will simply stall on this constant and the existing type inference machinery of the compiler handles any type errors if present.

Fixes https://github.com/rust-lang/rust/issues/89320
Fixes https://github.com/rust-lang/rust/issues/89146
Fixes https://github.com/rust-lang/rust/issues/87964
Fixes https://github.com/rust-lang/rust/issues/87470
Fixes https://github.com/rust-lang/rust/issues/83288
Fixes https://github.com/rust-lang/rust/issues/83249
Fixes https://github.com/rust-lang/rust/issues/90654

I want to thank `@BoxyUwU` for cooperating on this and for providing some help.

r? `@lcnr` maybe?
2021-12-05 00:37:58 +01:00
Matthias Krüger
29fe57def2
Rollup merge of #90022 - hkmatsumoto:self-upper-as-generic-parameter, r=jackh726
Explain why `Self` is invalid in generic parameters

Close #89985.

r? `@estebank`
2021-12-05 00:37:56 +01:00
Matthias Krüger
b97f375ea2
Rollup merge of #89642 - devnexen:macos_getenv_chng, r=m-ou-se
environ on macos uses directly libc which has the correct signature.
2021-12-05 00:37:55 +01:00
piegames
ced2676488 LLVM support .insn directive 2021-12-04 16:56:21 +01:00
bors
efec545293 Auto merge of #91517 - matthiaskrgr:rollup-3fmp4go, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #87054 (Add a `try_reduce` method to the Iterator trait)
 - #89701 (Updated error message for accidental uses of derive attribute as a crate attribute)
 - #90519 (Keep spans for generics in `#[derive(_)]` desugaring)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-04 13:23:50 +00:00
Matthias Krüger
0311cfa88c
Rollup merge of #90519 - estebank:issue-84003, r=petrochenkov
Keep spans for generics in `#[derive(_)]` desugaring

Keep the spans for generics coming from a `derive`d Item, so that errors
and suggestions have better detail.

Fix #84003.
2021-12-04 10:42:20 +01:00
Matthias Krüger
9f8e822364
Rollup merge of #89701 - tom7980:issue-89566-fix, r=petrochenkov
Updated error message for accidental uses of derive attribute as a crate attribute

This partially fixes the original issue #89566 by adding derive to the list of invalid crate attributes and then providing an updated error message however I'm not sure how to prevent the resolution error message from emitting without causing the compiler to just abort when it finds an invalid crate attribute (which I'd prefer not to do so we can find and emit other errors).

`@petrochenkov` I have been told you may have some insight on why it's emitting the resolution error though honestly I'm not sure if we need to worry about fixing it as long as we can provide the invalid crate attribute error also (which happens first anyway)
2021-12-04 10:42:19 +01:00
Matthias Krüger
c223a1c109
Rollup merge of #87054 - kit-981:master, r=scottmcm
Add a `try_reduce` method to the Iterator trait

Tracking issue: #87053
2021-12-04 10:42:19 +01:00
bors
887999d163 Auto merge of #88439 - cynecx:unwind_asm, r=Amanieu
Unwinding support for inline assembly

r? `@Amanieu`
2021-12-04 05:59:16 +00:00
kit
aef59e4fb8 Add a try_reduce method to the Iterator trait 2021-12-04 15:17:14 +11:00
bors
f581572778 Auto merge of #91505 - matthiaskrgr:rollup-orxgsxo, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #90538 (Document how recursion is handled for `ty::Ty`)
 - #90851 (Add unchecked downcast methods)
 - #91209 (Implement ``@snapshot`` check for htmldocck)
 - #91385 (Suggest the `pat_param` specifier before `|` on 2021 edition )
 - #91478 (Remove incorrect newline from float cast suggestion)
 - #91481 (Use let_else in some more places in rustc_lint)
 - #91488 (Fix ICE when `yield`ing in function returning `impl Trait`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-04 02:53:54 +00:00
Matthias Krüger
df51bffe6b
Rollup merge of #91488 - compiler-errors:issue-91477, r=estebank
Fix ICE when `yield`ing in function returning `impl Trait`

Change an assert to a `delay_span_bug` and remove an unwrap, that should fix it.

Fixes #91477
2021-12-04 02:26:26 +01:00
Matthias Krüger
af546dba31
Rollup merge of #91481 - est31:let_else, r=jackh726
Use let_else in some more places in rustc_lint

Follow-up of #91018 and #89933 . Also cc #90985 which added the first let_else uses to rustc_lint.
2021-12-04 02:26:25 +01:00
Matthias Krüger
f9587b60b6
Rollup merge of #91478 - estebank:fix-newline-in-cast-suggestion, r=camelid
Remove incorrect newline from float cast suggestion
2021-12-04 02:26:24 +01:00
Matthias Krüger
2b64476b9c
Rollup merge of #91385 - ecstatic-morse:pat-param-spec-suggest, r=estebank
Suggest the `pat_param` specifier before `|` on 2021 edition

Ran into this today after writing some Rust for the first time in a while.

r? `@estebank`
2021-12-04 02:26:23 +01:00
Matthias Krüger
420ddd0b7e
Rollup merge of #91209 - camelid:snapshot, r=jyn514
Implement `@snapshot` check for htmldocck

This form of check allows performing snapshot tests (à la `src/test/ui`)
on rustdoc HTML output, making it easier to create and update tests.

See [this Zulip thread][1] for more information about the motivation for
this change.

[1]: https://zulip-archive.rust-lang.org/stream/266220-rustdoc/topic/HTML.20snapshot.20tests.html#262651142

r? `@GuillaumeGomez`
2021-12-04 02:26:22 +01:00
Matthias Krüger
0bd4ee79e0
Rollup merge of #90851 - ibraheemdev:downcast-unchecked, r=scottmcm
Add unchecked downcast methods

```rust
impl dyn Any (+ Send + Sync) {
    pub unsafe fn downcast_ref_unchecked<T: Any>(&self) -> &T;
    pub unsafe fn downcast_mut_unchecked<T: Any>(&mut self) -> &mut T;
}

impl<A: Allocator> Box<dyn Any (+ Send + Sync), A> {
    pub unsafe fn downcast_unchecked<T: Any>(&self) -> Box<T, A>;
}
```
2021-12-04 02:26:21 +01:00
Matthias Krüger
f99cd4022a
Rollup merge of #90538 - camelid:doc-recur-ty, r=estebank
Document how recursion is handled for `ty::Ty`

Based on this forum discussion:
https://internals.rust-lang.org/t/recursive-type-representation-in-rustc/15235/4

cc `@estebank`
2021-12-04 02:26:20 +01:00
bors
14c1e71d09 Auto merge of #91501 - camelid:rm-tuple-impls-2, r=GuillaumeGomez
rustdoc: Remove Clean impls for tuples

This PR removes all nine Clean impls on tuples, converting them to
functions instead.

The fact that these are impls causes several problems:

  1. They are nameless, so it's unclear what they do.

  2. It's hard to find where they're used apart from removing them and
     seeing what errors occur (this applies to all Clean impls, not just
     the tuple ones).

  3. Rustc doesn't currently warn when impls are unused, so dead code
     can accumulate easily (all Clean impls).

  4. Their bodies often use tuple field indexing syntax (e.g., `self.1`)
     to refer to their "arguments", which makes reading the code more
     difficult.

As I noted, some of these problems apply to all Clean impls, but even
those problems are exacerbated by the tuple impls since they make
general understanding of the code harder.

Converting the impls to functions solves all four of these problems.

r? `@GuillaumeGomez`
2021-12-03 23:46:53 +00:00
cynecx
3dbb621c72 limit may_unwind codegen test to x86_64 2021-12-03 23:53:31 +01:00
cynecx
afdafcbcf8 fix feature-gate test for may_unwind 2021-12-03 23:51:49 +01:00
cynecx
233dede5b6 fix inline asm test by not hardcoding symbol names 2021-12-03 23:51:49 +01:00
cynecx
7f870be4b5 fix inline asm test because of missing attribute 2021-12-03 23:51:49 +01:00
cynecx
021a8d80eb rustc_codegen_gcc: proper check for may_unwind 2021-12-03 23:51:49 +01:00
cynecx
fb35cee709 add clobber_abi("C") to may_unwind inline-asm tests 2021-12-03 23:51:49 +01:00
cynecx
8e9ccdf28f add tests for asm's options(may_unwind) 2021-12-03 23:51:49 +01:00
cynecx
686ace3b41 add unwind_asm feature gate for may_unwind option 2021-12-03 23:51:49 +01:00
cynecx
059d3b3f34 rustc_codegen_gcc: error on unwinding inline asm 2021-12-03 23:51:49 +01:00
cynecx
e33a3f9c27 Update unstable-book with recent asm changes (may_unwind) 2021-12-03 23:51:49 +01:00
cynecx
6cbf44f1d4 cg_cranelift: check may_unwind flag instead of cleanup 2021-12-03 23:51:49 +01:00
cynecx
91021de1f6 LLVM codgen support for unwinding inline assembly 2021-12-03 23:51:49 +01:00
cynecx
491dd1f387 Adjust llvm wrapper for unwinding support for inlineasm 2021-12-03 23:51:49 +01:00
Amanieu d'Antras
940b2eabad Add initial AST and MIR support for unwinding from inline assembly 2021-12-03 23:51:46 +01:00
Noah Lev
e36561dbdd Remove a Clean impl for a tuple (9)
This was the last one!
2021-12-03 14:05:42 -08:00
Noah Lev
de5ea80437 Remove a Clean impl for a tuple (8) 2021-12-03 14:05:42 -08:00
Noah Lev
38c6b13c3a Remove a Clean impl for a tuple (7) 2021-12-03 14:05:42 -08:00
Noah Lev
4ede1f8a75 Remove a Clean impl for a tuple (6) 2021-12-03 14:05:42 -08:00
Noah Lev
c39ef72d74 Remove a Clean impl for a tuple (5) 2021-12-03 14:05:42 -08:00
Noah Lev
9b51072309 Remove a Clean impl for a tuple (4) 2021-12-03 14:05:42 -08:00
Noah Lev
f9ed012000 Clean up definition of clean_ty_generics a bit 2021-12-03 14:05:41 -08:00
Noah Lev
927a5e393c Remove a Clean impl for a tuple (3) 2021-12-03 14:05:41 -08:00
Noah Lev
63d434a363 Remove a Clean impl for a tuple (2) 2021-12-03 14:05:41 -08:00
Noah Lev
2fbdc79ae6 Remove a Clean impl for a tuple (1)
This commit removes the first of nine Clean impls on tuples, converting
it to a function instead.

The fact that these are impls causes several problems:

  1. They are nameless, so it's unclear what they do.

  2. It's hard to find where they're used apart from removing them and
     seeing what errors occur (this applies to all Clean impls, not just
     the tuple ones).

  3. Rustc doesn't currently warn when impls are unused, so dead code
     can accumulate easily (all Clean impls).

  4. Their bodies often use tuple field indexing syntax (e.g., `self.1`)
     to refer to their "arguments", which makes reading the code more
     difficult.

As I noted, some of these problems apply to all Clean impls, but even
those problems are exacerbated by the tuple impls since they make
general understanding of the code harder.

Converting the impls to functions solves all four of these problems.
2021-12-03 13:58:45 -08:00