Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustup #8788

Merged
merged 42 commits into from
May 5, 2022
Merged

Rustup #8788

merged 42 commits into from
May 5, 2022

Conversation

flip1995
Copy link
Member

@flip1995 flip1995 commented May 5, 2022

r? @ghost

changelog: move trait_duplication_in_bounds and type_repetition_in_bounds to nursery temporarily. This could already be reverted before the release. Check the Clippy in the Rust repo beta branch when writing this changelog.

b-naber and others added 30 commits April 2, 2022 12:21
- Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems
- use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId
- add par_items(impl Fn(hir::ItemId)) to traverse all items in parallel

Signed-off-by: Miguel Guarniz <[email protected]>
…cote

Cached stable hash cleanups

r? `@nnethercote`

Add a sanity assertion in debug mode to check that the cached hashes are actually the ones we get if we compute the hash each time.

Add a new data structure that bundles all the hash-caching work to make it easier to re-use it for different interned data structures
Loading the fallback bundle in compilation sessions that won't go on to
emit any errors unnecessarily degrades compile time performance, so
lazily create the Fluent bundle when it is first required.

Signed-off-by: David Wood <[email protected]>
Use mir constant in thir instead of ty::Const

This is blocked on rust-lang/rust#94059 (does include its changes, the first two commits in this PR correspond to those changes) and rust-lang/rust#93800 being reinstated (which had to be reverted). Mainly opening since `@lcnr` offered to give some feedback and maybe also for a perf-run (if necessary).

This currently contains a lot of duplication since some of the logic of `ty::Const` had to be copied to `mir::ConstantKind`, but with the introduction of valtrees a lot of that functionality will disappear from `ty::Const`.

Only the last commit contains changes that need to be reviewed here. Did leave some `FIXME` comments regarding future implementation decisions and some things that might be incorrectly implemented.

r? `@oli-obk`
errors: lazily load fallback fluent bundle

Addresses (hopefully) rust-lang/rust#95667 (comment).

Loading the fallback bundle in compilation sessions that won't go on to emit any errors unnecessarily degrades compile time performance, so lazily create the Fluent bundle when it is first required.

r? `@ghost` (just for perf initially)
Check var scope if it exist

Fixes #92893.

Added helper function to check the scope of a variable, if it doesn't have a scope call delay_span_bug, which avoids us trying to get a block/scope that doesn't exist.

Had to increase `ROOT_ENTRY_LIMIT` was getting tidy error
Implement sym operands for global_asm!

Tracking issue: #93333

This PR is pretty much a complete rewrite of `sym` operand support for inline assembly so that the same implementation can be shared by `asm!` and `global_asm!`. The main changes are:
- At the AST level, `sym` is represented as a special `InlineAsmSym` AST node containing a path instead of an `Expr`.
- At the HIR level, `sym` is split into `SymStatic` and `SymFn` depending on whether the path resolves to a static during AST lowering (defaults to `SynFn` if `get_early_res` fails).
  - `SymFn` is just an `AnonConst`. It runs through typeck and we just collect the resulting type at the end. An error is emitted if the type is not a `FnDef`.
  - `SymStatic` directly holds a path and the `DefId` of the `static` that it is pointing to.
- The representation at the MIR level is mostly unchanged. There is a minor change to THIR where `SymFn` is a constant instead of an expression.
- At the codegen level we need to apply the target's symbol mangling to the result of `tcx.symbol_name()` depending on the target. This is done by calling the LLVM name mangler, which handles all of the details.
  - On Mach-O, all symbols have a leading underscore.
  - On x86 Windows, different mangling is used for cdecl, stdcall, fastcall and vectorcall.
  - No mangling is needed on other platforms.

r? `@nagisa`
cc `@eddyb`
Refactor HIR item-like traversal (part 1)

Issue  #95004

- Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems
- use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId
- use tcx.hir_crate_items to introduce a tcx.hir().par_items(impl Fn(hir::ItemId)) to traverse all items in parallel;

Signed-off-by: Miguel Guarniz <[email protected]>

cc `@cjgillot`
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
Report undeclared lifetimes during late resolution.

First step in rust-lang/rust#91557

We reuse the rib design of the current resolution framework. Specific `LifetimeRib` and `LifetimeRibKind` types are introduced. The most important variant is `LifetimeRibKind::Generics`, which happens each time we encounter something which may introduce generic lifetime parameters. It can be an item or a `for<...>` binder. The `LifetimeBinderKind` specifies how this rib behaves with respect to in-band lifetimes.

r? `@petrochenkov`
Stop using CRATE_DEF_INDEX outside of metadata encoding.

`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.  We should not manipulate raw `DefIndex` outside of metadata encoding.
Change `span_suggestion` (and variants) to take `impl ToString` rather
than `String` for the suggested code, as this simplifies the
requirements on the diagnostic derive.

Signed-off-by: David Wood <[email protected]>
bjorn3 and others added 7 commits May 3, 2022 11:26
This allows it to be used by lightweight formatting systems and may
allow it to be used by rust-analyzer.
Make rustc_parse_format compile on stable

This allows it to be used by lightweight formatting systems and may allow it to be used by rust-analyzer.
The value in `MacArgs::Eq` is currently represented as a `Token`.
Because of `TokenKind::Interpolated`, `Token` can be either a token or
an arbitrary AST fragment. In practice, a `MacArgs::Eq` starts out as a
literal or macro call AST fragment, and then is later lowered to a
literal token. But this is very non-obvious. `Token` is a much more
general type than what is needed.

This commit restricts things, by introducing a new type `MacArgsEqKind`
that is either an AST expression (pre-lowering) or an AST literal
(post-lowering). The downside is that the code is a bit more verbose in
a few places. The benefit is that makes it much clearer what the
possibilities are (though also shorter in some other places). Also, it
removes one use of `TokenKind::Interpolated`, taking us a step closer to
removing that variant, which will let us make `Token` impl `Copy` and
remove many "handle Interpolated" code paths in the parser.

Things to note:
- Error messages have improved. Messages like this:
  ```
  unexpected token: `"bug" + "found"`
  ```
  now say "unexpected expression", which makes more sense. Although
  arbitrary expressions can exist within tokens thanks to
  `TokenKind::Interpolated`, that's not obvious to anyone who doesn't
  know compiler internals.
- In `parse_mac_args_common`, we no longer need to collect tokens for
  the value expression.
Overhaul `MacArgs`

Motivation:
- Clarify some code that I found hard to understand.
- Eliminate one use of three places where `TokenKind::Interpolated` values are created.

r? `@petrochenkov`
Those lints are trait_duplication_in_bounds and
type_repetition_in_bounds. I don't think those can be fixed on the
Clippy side alone, but need changes in the compiler. So let's move them
to nursery to get the sync through and then fix them on the rustc side.

Also adds a regression test that has to be fixed before they can be
moved back to pedantic.
@flip1995
Copy link
Member Author

flip1995 commented May 5, 2022

@bors r+

@bors
Copy link
Contributor

bors commented May 5, 2022

📌 Commit bb01aca has been approved by flip1995

bors added a commit that referenced this pull request May 5, 2022
Rustup

r? `@ghost`

changelog: move trait_duplication_in_bounds and type_repetition_in_bounds to nursery temporarily. This could already be reverted before the release. Check the Clippy in the Rust repo beta branch when writing this changelog.
@bors
Copy link
Contributor

bors commented May 5, 2022

⌛ Testing commit bb01aca with merge 2c974dd...

@bors
Copy link
Contributor

bors commented May 5, 2022

💔 Test failed - checks-action_test

@flip1995
Copy link
Member Author

flip1995 commented May 5, 2022

@bors try

bors added a commit that referenced this pull request May 5, 2022
Rustup

r? `@ghost`

changelog: move trait_duplication_in_bounds and type_repetition_in_bounds to nursery temporarily. This could already be reverted before the release. Check the Clippy in the Rust repo beta branch when writing this changelog.
@bors
Copy link
Contributor

bors commented May 5, 2022

⌛ Trying commit e209ae2 with merge dc80619...

@bors
Copy link
Contributor

bors commented May 5, 2022

💔 Test failed - checks-action_dev_test

@xFrednet
Copy link
Member

xFrednet commented May 5, 2022

The last too commits LGTM, it looks like fmt failed

@flip1995
Copy link
Member Author

flip1995 commented May 5, 2022

@bors r=xFrednet,flip1995

@bors
Copy link
Contributor

bors commented May 5, 2022

📌 Commit 0062829 has been approved by xFrednet,flip1995

@bors
Copy link
Contributor

bors commented May 5, 2022

⌛ Testing commit 0062829 with merge 7c21f91...

@bors
Copy link
Contributor

bors commented May 5, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet,flip1995
Pushing 7c21f91 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.