Commit graph

8803 commits

Author SHA1 Message Date
Yuki Okushi
371fd4f1c0
Rollup merge of #90074 - klensy:upvar-all, r=wesleywiser
2229 migrations small cleanup

This removes needless `format!`'ing of empty string and replaces `vec!` with const strings with const array.
2021-10-21 14:11:09 +09:00
Yuki Okushi
afdd0c3ade
Rollup merge of #90071 - cjgillot:no-blocks, r=oli-obk
Remove hir::map::blocks and use FnKind instead

The principal tool is `FnLikeNode`, which is not often used and can be easily implemented using `rustc_hir::intravisit::FnKind`.
2021-10-21 14:11:08 +09:00
Yuki Okushi
6f0acbcbd0
Rollup merge of #88644 - eopb:abstractconst_leaf_subst, r=lcnr
`AbstractConst` private fields

Calls `subst` in `AbstractConst::root` when `Node` is `Leaf`.

r? ``@lcnr``
2021-10-21 14:11:03 +09:00
bors
efd0483949 Auto merge of #89978 - cjgillot:qarray, r=Mark-Simulacrum
Merge the two depkind vtables

Knowledge of `DepKind`s is managed using two arrays containing flags (is_anon, eval_always, fingerprint_style), and function pointers (forcing and loading code).

This PR aims at merging the two arrays so as to reduce unneeded indirect calls and (hopefully) increase code locality.
r? `@ghost`
2021-10-20 17:57:35 +00:00
Camille GILLOT
b11ec29e28 Address review. 2021-10-20 18:51:15 +02:00
Camille GILLOT
8785b70774 Inline DepNodeParams methods. 2021-10-20 18:46:25 +02:00
Camille GILLOT
df71d0874a Compute query vtable manually. 2021-10-20 18:41:28 +02:00
Camille GILLOT
69a3594635 Store node_intern_event_id in CurrentDepGraph. 2021-10-20 18:37:11 +02:00
Camille GILLOT
bd5c107672 Build jump table at runtime. 2021-10-20 18:32:29 +02:00
Camille GILLOT
602d3cbce3 Invoke callbacks from rustc_middle. 2021-10-20 18:29:33 +02:00
Camille GILLOT
b09de95fab Merge two query callbacks arrays. 2021-10-20 18:29:27 +02:00
Camille GILLOT
dc7143367c Drop has_params. 2021-10-20 18:29:22 +02:00
Camille GILLOT
aa404c24dd Make hash_result an Option. 2021-10-20 18:29:18 +02:00
Camille GILLOT
e53404cca6 Move def_path_hash_to_def_id to rustc_middle. 2021-10-20 18:28:54 +02:00
Camille GILLOT
88c6d3de95 Avoid trivial lambdas. 2021-10-20 18:24:16 +02:00
bors
3d71e749a2 Auto merge of #90050 - michaelwoerister:fix-vtable-debug-name-crash-90019, r=wesleywiser
Erase late-bound regions before computing vtable debuginfo name.

Fixes #90019.

The `msvc_enum_fallback()` for computing enum type names needs to access the memory layout of niche enums in order to determine the type name. `compute_debuginfo_vtable_name()` did not properly erase regions before computing type names which made memory layout computation ICE when encountering un-erased regions.

r? `@wesleywiser`
2021-10-20 14:37:48 +00:00
Ethan Brierley
be30e60296 remove duplicate subst 2021-10-20 10:21:06 +01:00
bors
6162529a01 Auto merge of #89100 - petrochenkov:localbind, r=cjgillot
resolve: Use `NameBinding` for local variables and generic parameters

`NameBinding` is a structure used for representing any name introduction (an item, or import, or even a built-in).
Except that local variables and generic parameters weren't represented as `NameBinding`s, for this reason they requires separate paths in name resolution code in several places.

This PR introduces `NameBinding`s for local variables as well and simplifies all the code working with them leaving only the `NameBinding` paths.
2021-10-20 07:21:01 +00:00
klensy
f3fb821f3b use array explicitly instead of vec for const content (even if optimizer smart enought to remove allocation) 2021-10-20 03:24:07 +03:00
klensy
aad48f71b3 replace format!("") with String::new()
use array explicitly instead of vec for const content (even if optimizer smart enought to remove allocation)
2021-10-20 03:23:24 +03:00
Camille GILLOT
6e98688e68 Replace FnLikeNode by FnKind. 2021-10-19 23:31:51 +02:00
Ethan Brierley
99b8c016ce Address lcnr review 2021-10-19 22:18:13 +01:00
Camille GILLOT
05eb6f36f1 Cleanup dead code in hir::map::blocks. 2021-10-19 23:10:09 +02:00
Yuki Okushi
d8b3764bd2
Rollup merge of #90025 - JohnTitor:revert-86011, r=estebank
Revert #86011 to fix an incorrect bound check

This reverts commit 36a1076d24, reversing
changes made to e1e9319d93.

Fixes #89935
r? ``@estebank``
2021-10-20 04:35:17 +09:00
Yuki Okushi
f7024998c7
Rollup merge of #88860 - nbdd0121:panic, r=m-ou-se
Deduplicate panic_fmt

std's begin_panic_fmt and core's panic_fmt are duplicates. Merge them to declutter code and remove a lang item.
2021-10-20 04:35:14 +09:00
Yuki Okushi
3d95330230
Rollup merge of #87404 - rylev:artifact-size-profiling, r=wesleywiser
Add support for artifact size profiling

This adds support for profiling artifact file sizes (incremental compilation artifacts and query cache to begin with).

Eventually we want to track this in perf.rlo so we can ensure that file sizes do not change dramatically on each pull request.

This relies on support in measureme: https://github.com/rust-lang/measureme/pull/169. Once that lands we can update this PR to not point to a git dependency.

This was worked on together with `@michaelwoerister.`

r? `@wesleywiser`
2021-10-20 04:35:11 +09:00
bors
1af55d19c7 Auto merge of #89933 - est31:let_else, r=michaelwoerister
Adopt let_else across the compiler

This performs a substitution of code following the pattern:

```
let <id> = if let <pat> = ... { identity } else { ... : ! };
```

To simplify it to:

```
let <pat> = ... { identity } else { ... : ! };
```

By adopting the `let_else` feature (cc #87335).

The PR also updates the syn crate because the currently used version of the crate doesn't support `let_else` syntax yet.

Note: Generally I'm the person who *removes* usages of unstable features from the compiler, not adds more usages of them, but in this instance I think it hopefully helps the feature get stabilized sooner and in a better state. I have written a [comment](https://github.com/rust-lang/rust/issues/87335#issuecomment-944846205) on the tracking issue about my experience and what I feel could be improved before stabilization of `let_else`.
2021-10-19 14:41:39 +00:00
Gary Guo
9370156957 Deduplicate panic_fmt
std's begin_panic_fmt and core's panic_fmt are duplicates.
Merge them to declutter code and remove a lang item.
2021-10-19 15:02:21 +01:00
Michael Woerister
bf39d86e0f Erase late-bound regions before computing vtable debuginfo name. 2021-10-19 13:57:35 +02:00
bors
d45ed7502a Auto merge of #90040 - nbdd0121:issue-90038, r=oli-obk
Fix wrong niche calculation when 2+ niches are placed at the start

When the niche is at the start, existing code incorrectly uses 1 instead of count for subtraction.

Fix #90038

`@rustbot` label: T-compiler
2021-10-19 08:13:35 +00:00
Gary Guo
7dbd5bb0bd Fix issue 90038 2021-10-19 06:43:33 +01:00
bors
2f22e63cc4 Auto merge of #90037 - matthiaskrgr:rollup-cdfhxtn, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #89766 (RustWrapper: adapt for an LLVM API change)
 - #89867 (Fix macro_rules! duplication when reexported in the same module)
 - #89941 (removing TLS support in x86_64-unknown-none-hermitkernel)
 - #89956 (Suggest a case insensitive match name regardless of levenshtein distance)
 - #89988 (Do not promote values with const drop that need to be dropped)
 - #89997 (Add test for issue #84957 - `str.as_bytes()` in a `const` expression)
 - #90002 (⬆️ rust-analyzer)
 - #90034 (Tiny tweak to Iterator::unzip() doc comment example.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-10-19 05:04:38 +00:00
Matthias Krüger
a0724d72b0
Rollup merge of #89988 - tmiasko:unpromote-const-drop, r=oli-obk
Do not promote values with const drop that need to be dropped

Changes from #88558 allowed using `~const Drop` in constants by
introducing a new `NeedsNonConstDrop` qualif.

The new qualif was also used for promotion purposes, and allowed
promotion to happen for values that needs to be dropped but which
do have a const drop impl.

Since for promoted the drop implementation is never executed,
this lead to observable change in behaviour. For example:

```rust

struct Panic();

impl const Drop for Panic {
    fn drop(&mut self) {
        panic!();
    }
}

fn main() {
    let _ = &Panic();
}
```

Restore the use of `NeedsDrop` qualif during promotion to avoid the issue.
2021-10-19 05:40:54 +02:00
Matthias Krüger
8c8835d277
Rollup merge of #89956 - JohnTitor:suggest-case-insensitive-match-names, r=estebank
Suggest a case insensitive match name regardless of levenshtein distance

Fixes #86170

Currently, `find_best_match_for_name` only returns a case insensitive match name depending on a Levenshtein distance. It's a bit unfortunate that that hides some suggestions for typos like `Bar` -> `BAR`. That idea is from https://github.com/rust-lang/rust/pull/46347#discussion_r153701834, but I think it still makes some sense to show a candidate when we find a case insensitive match name as it's more like a typo.
Skipped the `candidate != lookup` check because the current (i.e, `levenshtein_match`) returns the exact same `Symbol` anyway but it doesn't seem to confuse anything on UI tests.

r? ``@estebank``
2021-10-19 05:40:53 +02:00
Matthias Krüger
9dccb7bd89
Rollup merge of #89941 - hermitcore:kernel, r=joshtriplett
removing TLS support in x86_64-unknown-none-hermitkernel

HermitCore's kernel itself doesn't support TLS. Consequently, the entries in x86_64-unknown-none-hermitkernel should be removed. This commit should help to finalize #89062.
2021-10-19 05:40:52 +02:00
Matthias Krüger
54aa5477ac
Rollup merge of #89766 - krasimirgg:llvm-14-targetregistrty, r=nagisa
RustWrapper: adapt for an LLVM API change

No functional changes intended.

The LLVM commit
89b57061f7
moved TargetRegistry.(h|cpp) from Support to MC.
This adapts RustWrapper accordingly.
2021-10-19 05:40:50 +02:00
bors
cd8b56f528 Auto merge of #89905 - matthiaskrgr:rev_89709_entirely, r=michaelwoerister
Revert "Auto merge of #89709 - clemenswasser:apply_clippy_suggestions…

…_2, r=petrochenkov"

The PR had some unforseen perf regressions that are not as easy to find.
Revert the PR for now.

This reverts commit 6ae8912a3e, reversing
changes made to 86d6d2b738.
2021-10-19 02:03:21 +00:00
bors
ec724ac075 Auto merge of #89229 - oli-obk:i_love_inferctxt, r=jackh726
Remove redundant member-constraint check

impl trait will, for each lifetime in the hidden type, register a "member constraint" that says the lifetime must be equal or outlive one of the lifetimes of the impl trait. These member constraints will be solved by borrowck

But, as you can see in the big red block of removed code, there was an ad-hoc check for member constraints happening at the site where they get registered. This check had some minor effects on diagnostics, but will fall down on its feet with my big type alias impl trait refactor. So we removed it and I pulled the removal out into a (hopefully) reviewable PR that works on master directly.
2021-10-18 23:02:53 +00:00
Tomasz Miąsko
915a581bcb Do not promote values with const drop that need to be dropped
Changes from #88558 allowed using `~const Drop` in constants by
introducing a new `NeedsNonConstDrop` qualif.

The new qualif was also used for promotion purposes, and allowed
promotion to happen for values that needs to be dropped but which
do have a const drop impl.

Since for promoted the drop implementation is never executed,
this lead to observable change in behaviour. For example:

```rust

struct Panic();

impl const Drop for Panic {
    fn drop(&mut self) {
        panic!();
    }
}

fn main() {
    let _ = &Panic();
}
```

Restore the use of `NeedsDrop` qualif during promotion to avoid the issue.
2021-10-18 21:56:57 +02:00
bors
bd41e09da3 Auto merge of #89124 - cjgillot:owner-info, r=michaelwoerister
Index and hash HIR as part of lowering

Part of https://github.com/rust-lang/rust/pull/88186
~Based on https://github.com/rust-lang/rust/pull/88880 (see merge commit).~

Once HIR is lowered, it is later indexed by the `index_hir` query and hashed for `crate_hash`. This PR moves those post-processing steps to lowering itself. As a side objective, the HIR crate data structure is refactored as an `IndexVec<LocalDefId, Option<OwnerInfo<'hir>>>` where `OwnerInfo` stores all the relevant information for an HIR owner.

r? `@michaelwoerister`
cc `@petrochenkov`
2021-10-18 19:53:05 +00:00
Tomasz Miąsko
171cbc01ef Rename needs_drop to needs_non_const_drop 2021-10-18 20:51:22 +02:00
Yuki Okushi
e2453dc2ff
Revert "Rollup merge of #86011 - tlyu:correct-sized-bound-spans, r=estebank"
This reverts commit 36a1076d24, reversing
changes made to e1e9319d93.
2021-10-19 02:33:38 +09:00
Oli Scherer
4413f8c709 Member constraints already covered all of E0482 already, so that error never occurred anymore 2021-10-18 15:50:56 +00:00
Oli Scherer
2220fafa8c Guarding a loop with a check that it never runs is useless 2021-10-18 15:50:56 +00:00
Oli Scherer
2431540b62 Remove unused enum variant 2021-10-18 15:50:56 +00:00
Oli Scherer
b02f2982e7 Remove regionck member constraint handling and leave it to mir borrowck 2021-10-18 15:50:56 +00:00
Krasimir Georgiev
e3c3f4a09c RustWrapper: adapt for an LLVM API change
No functional changes intended.

The LLVM commit
89b57061f7
moved TargetRegistry.(h|cpp) from Support to MC.
This adapts RustWrapper accordingly.
2021-10-18 09:48:47 +02:00
Vadim Petrochenkov
c1e8fc8c97 resolve: Use NameBinding for local variables and generic parameters 2021-10-18 10:42:39 +03:00
Matthias Krüger
2fd765c1d9
Rollup merge of #89990 - petrochenkov:idempty, r=wesleywiser
rustc_span: `Ident::invalid` -> `Ident::empty`

The equivalent for `Symbol`s was renamed some time ago (`kw::Invalid` -> `kw::Empty`), and it makes sense to do the same thing for `Ident`s as well.
2021-10-18 08:13:30 +02:00
Matthias Krüger
cd72393566
Rollup merge of #89987 - pierwill:fix-85526-docs-hidden-assoc, r=GuillaumeGomez
Check implementing type for `#[doc(hidden)]`

Closes #85526.
2021-10-18 08:13:28 +02:00