Commit graph

10337 commits

Author SHA1 Message Date
Vadim Petrochenkov
4523466770 expand: Import more AST enums 2022-01-07 14:54:16 +08:00
Vadim Petrochenkov
800ba8f8e8 expand: Refactor InvocationCollector visitor for better code reuse 2022-01-07 14:41:22 +08:00
Vadim Petrochenkov
4fd23350cd expand: Remove some unnecessary self mutability 2022-01-07 13:50:03 +08:00
Vadim Petrochenkov
dc7e771155 expand: Rename some AstFragments to match AST structures 2022-01-07 13:50:03 +08:00
Lain Yang
9a337b6fe0 update Cargo.lock and gimli-rs/object for rustc_codegen_ssa 2022-01-07 13:33:20 +08:00
Michael Goulet
d35b23ecd8 Normalize generator-local types with unevaluated constants 2022-01-06 19:08:04 -08:00
Lain Yang
11f180f421 rustc_codegen_ssa: set static lifetime for object::write::Object 2022-01-07 10:47:40 +08:00
Lain Yang
579e8bce7d Make rlib metadata strip works with MIPSr6 architecture
Because MIPSr6 has many differences with previous MIPSr2 arch, the previous rlib metadata stripping code in `rustc_codegen_ssa` is only for MIPSr2/r3/r5 (which share the same elf e_flags).
This commit fixed this problem. It makes `rustc_codegen_ssa` happy when compiling rustc for MIPSr6 target or hosts.
2022-01-07 10:47:27 +08:00
Nicholas Nethercote
facba24926 Unpeel the first iteration of the loop in impl_read_unsigned_leb128. 2022-01-07 13:36:26 +11:00
Nicholas Nethercote
5f549d9b49 Modify the buffer position directly when reading leb128 values.
It's a small but clear performance win.
2022-01-07 10:40:51 +11:00
Matthias Krüger
140b6cb1ba
Rollup merge of #92607 - petrochenkov:doctrscope2, r=cjgillot
rustc_metadata: Some minor cleanups and optimizations

Mostly extracted from https://github.com/rust-lang/rust/pull/88679 (which is otherwise a rustdoc PR).
r? ``@cjgillot``
2022-01-06 23:15:21 +01:00
Matthias Krüger
1591dcb659
Rollup merge of #92559 - durin42:llvm-14-attributemask, r=nikic
RustWrapper: adapt to new AttributeMask API

Upstream LLVM change 9290ccc3c1a1 migrated attribute removal to use
AttributeMask instead of AttrBuilder, so we need to follow suit here.

r? ``@nagisa`` cc ``@nikic``
2022-01-06 23:15:18 +01:00
Matthias Krüger
844a657bb8
Rollup merge of #92504 - dtolnay:wall, r=jackh726
Exit nonzero on rustc -Wall

Previously `rustc -Wall /dev/null` would print a paragraph explaining that `-Wall` is not a thing in Rust, but would then exit 0. I believe exiting 0 is not the right behavior. For something like `rustc --version` or `rustc --help` or `rustc -C help` the user is requesting rustc to print some information; rustc prints that information and exits 0 because what the user requested has been accomplished. In the case of `rustc -Wall path/to/main.rs`, I don't find it correct to conceptualize this as "the user requested rustc to print information about the fact that Wall doesn't exist". The user requested a particular thing, and despite rustc knowing what they probably meant and informing them about that, the thing they requested has *not* been accomplished. Thus a nonzero exit code is needed.
2022-01-06 23:15:17 +01:00
Matthias Krüger
1a8f69826c
Rollup merge of #92417 - dtolnay:printimpl, r=jackh726
Fix spacing and ordering of words in pretty printed Impl

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($item:item) => {
        stringify!($item)
    };
}

fn main() {
    println!("{}", repro!(impl<T> Struct<T> {}));
    println!("{}", repro!(impl<T> const Trait for T {}));
}
```

Before:&ensp;`impl <T> Struct<T> {}`
After:&ensp;`impl<T> Struct<T> {}`

Before:&ensp;`impl const <T> Trait for T {}` 😿
After:&ensp;`impl<T> const Trait for T {}`
2022-01-06 23:15:16 +01:00
Matthias Krüger
0604cf5fd8
Rollup merge of #92207 - tmiasko:delay-drop-elaboration-bug, r=jackh726
Delay remaining `span_bug`s in drop elaboration

This follows changes from #67967 and converts remaining `span_bug`s into
delayed bugs, since for const items drop elaboration might be executed
on a MIR which failed borrowck.

Fixes #81708.
Fixes #91816.
2022-01-06 23:15:14 +01:00
Matthias Krüger
cdc5c1381d
Rollup merge of #91055 - lcnr:type_of-closures, r=nikomatsakis
return the correct type for closures in `type_of`

A bit unhappy about the way `typeck::check_crate` works rn. Would have preferred to not change `CollectItemTypesVisitor` in this way.

r? ``@nikomatsakis``
2022-01-06 23:15:13 +01:00
inquisitivecrystal
f6f8149577 Add #[track_caller] to mirbug 2022-01-06 13:31:28 -08:00
David Tolnay
7174ec22cf
Exit nonzero on rustc -Wall 2022-01-06 13:30:57 -08:00
bors
cfa4ac66c1 Auto merge of #92609 - matthiaskrgr:rollup-ldp47ot, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92058 (Make Run button visible on hover)
 - #92288 (Fix a pair of mistyped test cases in `std::net::ip`)
 - #92349 (Fix rustdoc::private_doc_tests lint for public re-exported items)
 - #92360 (Some cleanups around check_argument_types)
 - #92389 (Regression test for borrowck ICE #92015)
 - #92404 (Fix font size for [src] links in headers)
 - #92443 (Rustdoc: resolve associated traits for non-generic primitive types)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-06 15:30:46 +00:00
Alex Macleod
7ea03db04a Add diagnostic items for macros 2022-01-06 14:59:33 +00:00
Matthias Krüger
fb87e7ceed
Rollup merge of #92360 - jackh726:param-heuristics-1, r=davidtwco
Some cleanups around check_argument_types

Split out in ways from my rebase/continuation of #71827

Commits are mostly self-explanatory and these changes should be fairly straightforward
2022-01-06 12:01:02 +01:00
David Wood
2dc1a8a779 cg: use thorin instead of llvm-dwp
`thorin` is a Rust implementation of a DWARF packaging utility that
supports reading DWARF objects from archive files (i.e. rlibs) and
therefore is better suited for integration into rustc.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-01-06 09:32:42 +00:00
David Wood
08ed338f56 sess/cg: re-introduce split dwarf kind
In #79570, `-Z split-dwarf-kind={none,single,split}` was replaced by `-C
split-debuginfo={off,packed,unpacked}`. `-C split-debuginfo`'s packed
and unpacked aren't exact parallels to single and split, respectively.

On Unix, `-C split-debuginfo=packed` will put debuginfo into object
files and package debuginfo into a DWARF package file (`.dwp`) and
`-C split-debuginfo=unpacked` will put debuginfo into dwarf object files
and won't package it.

In the initial implementation of Split DWARF, split mode wrote sections
which did not require relocation into a DWARF object (`.dwo`) file which
was ignored by the linker and then packaged those DWARF objects into
DWARF packages (`.dwp`). In single mode, sections which did not require
relocation were written into object files but ignored by the linker and
were not packaged. However, both split and single modes could be
packaged or not, the primary difference in behaviour was where the
debuginfo sections that did not require link-time relocation were
written (in a DWARF object or the object file).

This commit re-introduces a `-Z split-dwarf-kind` flag, which can be
used to pick between split and single modes when `-C split-debuginfo` is
used to enable Split DWARF (either packed or unpacked).

Signed-off-by: David Wood <david.wood@huawei.com>
2022-01-06 09:32:42 +00:00
Vadim Petrochenkov
1b88007af0 rustc_metadata: Split fn get_implementations_for_trait into two functions 2022-01-06 15:13:22 +08:00
Vadim Petrochenkov
4e8855bdc9 rustc_metadata: Make opt_item_ident in decoder faster and stricter
By avoiding formatting and allocations in the no-ident case, and by making the span mandatory if the ident exists.

Use the optimized `opt_item_ident` to cleanup `fn each_child_of_item`
2022-01-06 14:57:17 +08:00
Vadim Petrochenkov
4c6120c386 rustc_metadata: Make attribute decoding slightly faster and stricter
Rename `CStore::item_attrs` -> `CStore::item_attrs_untracked` top follow conventions
2022-01-06 12:13:41 +08:00
Vadim Petrochenkov
636fd495c8 rustc_middle: Add a method for getting a SimplifiedType definition/ID
Import `SimplifiedType` more
2022-01-06 12:04:16 +08:00
inquisitivecrystal
486585242e Do not resolve blocks in foreign functions 2022-01-05 15:22:22 -08:00
Augie Fackler
34a6b6c423 RustWrapper: simplify removing attributes
Avoids some extra conversions. Spotted by nikic during review.
2022-01-05 13:51:59 -05:00
Aaron Hill
4ca275add0
Address review comments 2022-01-05 10:30:49 -05:00
bors
f1ce0e6a00 Auto merge of #92587 - matthiaskrgr:rollup-qnwa8qx, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92092 (Drop guards in slice sorting derive src pointers from &mut T, which is invalidated by interior mutation in comparison)
 - #92388 (Fix a minor mistake in `String::try_reserve_exact` examples)
 - #92442 (Add negative `impl` for `Ord`, `PartialOrd` on `LocalDefId`)
 - #92483 (Stabilize `result_cloned` and `result_copied`)
 - #92574 (Add RISC-V detection macro and more architecture instructions)
 - #92575 (ast: Always keep a `NodeId` in `ast::Crate`)
 - #92583 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-05 15:28:36 +00:00
Aaron Hill
560c90f5df
Adjust assert_default_hashing_controls 2022-01-05 10:13:29 -05:00
Aaron Hill
5580e5e1dd
Ensure that Fingerprint caching respects hashing configuration
Fixes #92266

In some `HashStable` impls, we use a cache to avoid re-computing
the same `Fingerprint` from the same structure (e.g. an `AdtDef`).
However, the `StableHashingContext` used can be configured to
perform hashing in different ways (e.g. skipping `Span`s). This
configuration information is not included in the cache key,
which will cause an incorrect `Fingerprint` to be used if
we hash the same structure with different `StableHashingContext`
settings.

To fix this, the configuration settings of `StableHashingContext`
are split out into a separate `HashingControls` struct. This
struct is used as part of the cache key, ensuring that our caches
always produce the correct result for the given settings.

With this in place, we now turn off `Span` hashing during the
entire process of computing the hash included in legacy symbols.
This current has no effect, but will matter when a future PR
starts hashing more `Span`s that we currently skip.
2022-01-05 10:13:28 -05:00
Matthias Krüger
5f03ae3507
Rollup merge of #92575 - petrochenkov:cratenodeid, r=Aaron1011
ast: Always keep a `NodeId` in `ast::Crate`

This makes it more uniform with other expanded nodes.
It makes generic code in https://github.com/rust-lang/rust/pull/92573 simpler in particular.

This is another follow-up to https://github.com/rust-lang/rust/pull/91313.
r? `@Aaron1011`
2022-01-05 15:05:49 +01:00
Matthias Krüger
bf9546c127
Rollup merge of #92442 - pierwill:localdefid-doc-ord, r=Aaron1011
Add negative `impl` for `Ord`, `PartialOrd` on `LocalDefId`

Suggested in https://github.com/rust-lang/rust/pull/92233#discussion_r776123222.

This also fixes some formatting in the doc comment.

r? `@cjgillot`
2022-01-05 15:05:46 +01:00
bors
181e91567c Auto merge of #92580 - matthiaskrgr:rollup-nzyn65y, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92182 (Label more build steps)
 - #92188 (rustdoc: Clean up NestedAttributesExt trait/implementation)
 - #92322 (Add another implementation example to Debug trait)
 - #92448 (Set font size proportional to user's font size)
 - #92517 (Explicitly pass `PATH` to the Windows exe resolver)
 - #92545 (Extract init_env_logger to crate)
 - #92579 (update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-05 12:32:28 +00:00
Andrea Ciliberti
8423ce9f9a Enable default libraries 2022-01-05 11:40:30 +01:00
Matthias Krüger
d83dd85253
Rollup merge of #92545 - dtolnay:rustlog, r=petrochenkov
Extract init_env_logger to crate

I've been doing some work on rustc_ast_pretty using an out-of-tree main.rs and Cargo.toml with the following:

```toml
[dependencies]
rustc_ast = { path = "../rust/compiler/rustc_ast" }
rustc_ast_pretty = { path = "../rust/compiler/rustc_ast_pretty" }
rustc_span = { path = "../rust/compiler/rustc_span" }
```

Rustc_ast_pretty helpfully uses `tracing::debug!` but I found that in order to enable the debug output, my test crate must depend on rustc_driver which is an enormously bigger dependency than what I have been using so far, and slows down iteration time because an enormous dependency tree between rustc_ast and rustc_driver must now be rebuilt after every ast change.

I pulled out the tracing initialization to a new minimal rustc_log crate so that projects depending on the other rustc crates, like rustc_ast_pretty, can access the `debug!` messages in them without building all the rest of rustc.
2022-01-05 11:26:08 +01:00
bors
936ce3dab7 Auto merge of #92103 - Kobzol:stable-hash-skip-zero-bytes, r=the8472
Do not hash leading zero bytes of i64 numbers in Sip128 hasher

I was poking into the stable hasher, trying to improve its performance by compressing the number of hashed bytes. First I was experimenting with LEB128, but it was painful to implement because of the many assumptions that the SipHasher makes, so I tried something simpler - just ignoring leading zero bytes. For example, if an 8-byte integer can fit into a 4-byte integer, I will just hash the four bytes.

I wonder if this could produce any hashing ambiguity. Originally I thought so, but then I struggled to find any counter-example where this could cause different values to have the same hash. I'd be glad for any examples that could be broken by this (there are some ways of mitigating it if that would be the case). It could happen if you had e.g. 2x `u8` vs 1x `u16` hashed after one another in two different runs, but that can also happen now, without this "trick". And with collections, it should be fine, because the length is included in their hash.

I gathered some statistics for common values used in the `clap` benchmark. I observed that especially `i64` often had very low values, so I started with that type, let's see what perf does on CI.

There are some tradeoffs that we can try:
1) What types to use this optimization for? `u64`, `u32`, `u16`? Locally it was a slight loss for `u64`, I noticed that its values are often quite large.
2) What byte sizes to check? E.g. we can only distinguish between `u64`/`u32` or `u64`/`u8` instead of `u64`/`u32`/`u16`/`u8` to reduce branching (with `i64` it seemed to be better to go all the way down to `u8` locally though).

(The macro was introduced because I expect that I will be trying out this "trick" for different types).

Can you please schedule a perf. run? Thanks.

r? `@the8472`
2022-01-05 09:27:18 +00:00
Vadim Petrochenkov
55595c5616 ast: Always keep a NodeId in ast::Crate
This makes it more uniform with other expanded nodes
2022-01-05 17:09:37 +08:00
bors
5883b87563 Auto merge of #92560 - matthiaskrgr:rollup-jeli7ip, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #91587 (core::ops::unsize: improve docs for DispatchFromDyn)
 - #91907 (Allow `_` as the length of array types and repeat expressions)
 - #92515 (RustWrapper: adapt for an LLVM API change)
 - #92516 (Do not use deprecated -Zsymbol-mangling-version in bootstrap)
 - #92530 (Move `contains` method of Option and Result lower in docs)
 - #92546 (Update books)
 - #92551 (rename StackPopClean::None to Root)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-04 23:01:49 +00:00
Matthias Krüger
e525e6a507
Rollup merge of #92551 - RalfJung:stack-pop-cleanup, r=oli-obk
rename StackPopClean::None to Root

With https://github.com/rust-lang/rust/pull/90102, `StackPopClean::None` is now only used for the "root" frame of the stack, so adjust its name accordingly and add an assertion.

r? `@oli-obk`
2022-01-04 21:23:12 +01:00
Matthias Krüger
b9694a132f
Rollup merge of #92515 - krasimirgg:rust-head-llvm-0301, r=nagisa
RustWrapper: adapt for an LLVM API change

No functional changes intended.

The LLVM commit ec501f15a8 removed the signed version of `createExpression`.
This adapts the Rust LLVM wrappers accordingly.
2022-01-04 21:23:08 +01:00
Matthias Krüger
ac7a867715
Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU
Allow `_` as the length of array types and repeat expressions

r? `@BoxyUwU` cc `@varkor`
2022-01-04 21:23:06 +01:00
Augie Fackler
2803fbc447 RustWrapper: adapt to new AttributeMask API
Upstream LLVM change 9290ccc3c1a1 migrated attribute removal to use
AttributeMask instead of AttrBuilder, so we need to follow suit here.
2022-01-04 13:50:02 -05:00
Jakub Beránek
65a3279f4a
Do not hash zero bytes of i64 and u32 in Sip128 hasher 2022-01-04 19:12:10 +01:00
Matthias Krüger
76c02711a5
Rollup merge of #92532 - krasimirgg:gsgdt-down, r=Mark-Simulacrum
revert #92254 "Bump gsgdt to 0.1.3"

This reverts https://github.com/rust-lang/rust/pull/92254 since gsgdt 0.1.3 was yanked: https://github.com/rust-lang/rust/pull/92254#issuecomment-1004269481
2022-01-04 16:34:20 +01:00
Matthias Krüger
25fcc0ef8c
Rollup merge of #92507 - chordtoll:suggest-single-quotes, r=petrochenkov
Suggest single quotes when char expected, str provided

If a type mismatch occurs where a char is expected and a string literal is provided, suggest changing the double quotes to single quotes.

We already provide this suggestion in the other direction ( ' -> " ).

Especially useful for new rust devs used to a language in which single/double quotes are interchangeable.

Fixes #92479.
2022-01-04 16:34:17 +01:00
Matthias Krüger
855f6300fb
Rollup merge of #92107 - nikic:rmeta-lnk-remove, r=nagisa
Actually set IMAGE_SCN_LNK_REMOVE for .rmeta

The code intended to set the IMAGE_SCN_LNK_REMOVE flag for the
.rmeta section, however the value of this flag was set to zero.
Instead use the actual value provided by the object crate.

This dates back to the original introduction of this code in
PR #84449, so we were never setting this flag. As I'm not on
Windows, I'm not sure whether that means we were embedding .rmeta
into executables, or whether the section ended up getting stripped
for some other reason.
2022-01-04 16:34:15 +01:00
Ralf Jung
d60018b44b rename StackPopClean::None to Root 2022-01-04 11:13:08 +01:00
Andre Bogus
7f7b5514a4 Make DefId repr(C), optimize big-endian field order 2022-01-04 08:16:50 +01:00
David Tolnay
ffbeebbf7a
Make rustc_log doc test runnable 2022-01-03 22:31:56 -08:00
chordtoll
3087c4dfb7
Suggest changing quotes when str/char type mismatch 2022-01-03 22:08:08 -08:00
David Tolnay
dd5ee326bc
Justify why rustc_log exists 2022-01-03 20:25:23 -08:00
David Tolnay
6152d15e7c
Extract init_env_logger to crate 2022-01-03 16:45:21 -08:00
bors
2b681ac06b Auto merge of #92259 - Aaron1011:normal-mod-hashing, r=michaelwoerister
Remove special-cased stable hashing for HIR module

All other 'containers' (e.g. `impl` blocks) hashed their contents
in the normal, order-dependent way. However, `Mod` was hashing
its contents in a (sort-of) order-independent way. However, the
exact order is exposed to consumers through `Mod.item_ids`,
and through query results like `hir_module_items`. Therefore,
stable hashing needs to take the order of items into account,
to avoid fingerprint ICEs.

Unforuntately, I was unable to directly build a reproducer
for the ICE, due to the behavior of `Fingerprint::combine_commutative`.
This operation swaps the upper and lower `u64` when constructing the
result, which makes the function non-associative. Since we start
the hashing of module items by combining `Fingerprint::ZERO` with
the first item, it's difficult to actually build an example where
changing the order of module items leaves the final hash unchanged.

However, this appears to have been hit in practice in #92218
While we're not able to reproduce it, the fact that proc-macros
are involved (which can give an entire module the same span, preventing
any span-related invalidations) makes me confident that the root
cause of that issue is our method of hashing module items.

This PR removes all of the special handling for `Mod`, instead deriving
a `HashStable` implementation. This makes `Mod` consistent with other
'contains' like `Impl`, which hash their contents through the typical
derive of `HashStable`.
2022-01-04 00:25:23 +00:00
Aaron Hill
467b72607d
Hash Ident spans in all HIR structures
This PR removes all of the `#[stable_hasher(project(name))]`
attributes used in HIR structs. While these attributes are not known
to be causing any issues in practice, we need to hash these in
order for the incremental system to work correctly -
a query could be otherwise be incorrectly marked green
when a change occures in one of the `Span`s that it uses.
2022-01-03 15:52:38 -05:00
bors
399ba6bb37 Auto merge of #92314 - Kobzol:encoding-u16-leb128, r=michaelwoerister
Do not use LEB128 for encoding u16 and i16

An experiment to try out the suggestion from https://github.com/rust-lang/rust/issues/68779.

Closes: https://github.com/rust-lang/rust/issues/68779
2022-01-03 20:30:23 +00:00
Krasimir Georgiev
a9698e22ec revert #92254 "Bump gsgdt to 0.1.3"
gsgdt 0.1.3 was yanked:
https://github.com/rust-lang/rust/pull/92254#issuecomment-1004269481
2022-01-03 20:25:46 +01:00
bors
ddabe0775c Auto merge of #92518 - matthiaskrgr:rollup-fl8z4e7, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #90102 (Remove `NullOp::Box`)
 - #92011 (Use field span in `rustc_macros` when emitting decode call)
 - #92402 (Suggest while let x = y when encountering while x = y)
 - #92409 (Couple of libtest cleanups)
 - #92418 (Fix spacing in pretty printed PatKind::Struct with no fields)
 - #92444 (Consolidate Result's and Option's methods into fewer impl blocks)

Failed merges:

 - #92483 (Stabilize `result_cloned` and `result_copied`)

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-03 14:30:36 +00:00
Matthias Krüger
df921190f3
Rollup merge of #92418 - dtolnay:emptystructpat, r=michaelwoerister
Fix spacing in pretty printed PatKind::Struct with no fields

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($pat:pat) => {
        stringify!($pat)
    };
}

fn main() {
    println!("{}", repro!(Struct {}));
}
```

Before:&ensp;<code>Struct&nbsp;{&nbsp;&nbsp;}</code>
After:&ensp;<code>Struct&nbsp;{}</code>
2022-01-03 14:44:20 +01:00
Matthias Krüger
0335b7bca9
Rollup merge of #92402 - pr2502:while-let-typo, r=oli-obk
Suggest while let x = y when encountering while x = y

Extends #75931 to also detect where the `let` might be missing from `while let` expressions.
2022-01-03 14:44:18 +01:00
Matthias Krüger
fd09f342f3
Rollup merge of #92011 - Aaron1011:decode-span, r=michaelwoerister
Use field span in `rustc_macros` when emitting decode call

This will cause backtraces to point to the location of
the field in the struct/enum, rather than the derive macro.

This makes it clear which field was being decoded when the
backtrace was captured (which is especially useful if
there are multiple fields with the same type).
2022-01-03 14:44:16 +01:00
Matthias Krüger
57a4f4a634
Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievink
Remove `NullOp::Box`

Follow up of #89030 and MCP rust-lang/compiler-team#460.

~1 month later nothing seems to be broken, apart from a small regression that #89332 (1aac85bb716c09304b313d69d30d74fe7e8e1a8e) shows could be regained by remvoing the diverging path, so it shall be safe to continue and remove `NullOp::Box` completely.

r? `@jonas-schievink`
`@rustbot` label T-compiler
2022-01-03 14:44:15 +01:00
bors
b5efe5727f Auto merge of #92179 - Aaron1011:incr-loaded-from-disk, r=michaelwoerister
Add `#[rustc_clean(loaded_from_disk)]` to assert loading of query result

Currently, you can use `#[rustc_clean]` to assert to that a particular
query (technically, a `DepNode`) is green or red. However, a green
`DepNode` does not mean that the query result was actually deserialized
from disk - we might have never re-run a query that needed the result.

Some incremental tests are written as regression tests for ICEs that
occured during query result decoding. Using
`#[rustc_clean(loaded_from_disk="typeck")]`, you can now assert
that the result of a particular query (e.g. `typeck`) was actually
loaded from disk, in addition to being green.
2022-01-03 11:20:08 +00:00
lcnr
a02bf76c96 review 2022-01-03 11:59:01 +01:00
Krasimir Georgiev
4ce56b414d RustWrapper: adapt for an LLVM API change
No functional changes intended.

The LLVM commit
ec501f15a8
removed the signed version of `createExpression`. This adapts the Rust
LLVM wrappers accordingly.
2022-01-03 11:25:33 +01:00
bors
d367c349ef Auto merge of #92080 - Aaron1011:pattern-ice, r=cjgillot
Move `PatKind::Lit` checking from ast_validation to ast lowering

Fixes #92074

This allows us to insert an `ExprKind::Err` when an invalid expression
is used in a literal pattern, preventing later stages of compilation
from seeing an unexpected literal pattern.
2022-01-03 06:59:52 +00:00
bors
b5da80871d Auto merge of #92395 - Kobzol:rustdoc-bindings-thin-vec, r=camelid
Rustdoc: use ThinVec for GenericArgs bindings

The bindings are almost always empty. This reduces the size of `PathSegment` and `GenericArgs` by about one fourth.
2022-01-03 03:49:01 +00:00
bors
8f3238f898 Auto merge of #90128 - joshtriplett:stabilize-symbol-mangling-version, r=wesleywiser
Stabilize -Z symbol-mangling-version=v0 as -C symbol-mangling-version=v0

This allows selecting `v0` symbol-mangling without an unstable option. Selecting `legacy` still requires -Z unstable-options.

This does not change the default symbol-mangling-version. See https://github.com/rust-lang/rust/pull/89917 for a pull request changing the default. Rationale, from #89917:

Rust's current mangling scheme depends on compiler internals; loses information about generic parameters (and other things) which makes for a worse experience when using external tools that need to interact with Rust symbol names; is inconsistent; and can contain . characters which aren't universally supported. Therefore, Rust has defined its own symbol mangling scheme which is defined in terms of the Rust language, not the compiler implementation; encodes information about generic parameters in a reversible way; has a consistent definition; and generates symbols that only use the characters A-Z, a-z, 0-9, and _.

Support for the new Rust symbol mangling scheme has been added to upstream tools that will need to interact with Rust symbols (e.g. debuggers).

This pull request allows enabling the new v0 symbol-mangling-version.

See #89917 for references to the implementation of v0, and for references to the tool changes to decode Rust symbols.
2022-01-02 15:49:23 +00:00
bors
03360be6b7 Auto merge of #92066 - Smittyvb:concat_bytes-repeat, r=nagisa
Support [x; n] expressions in concat_bytes!

Currently trying to use `concat_bytes!` with a repeating array value like `[42; 5]` results in an error:
```
error: expected a byte literal
 --> src/main.rs:3:27
  |
3 |     let x = concat_bytes!([3; 4]);
  |                           ^^^^^^
  |
  = note: only byte literals (like `b"foo"`, `b's'`, and `[3, 4, 5]`) can be passed to `concat_bytes!()`
```

This makes it so repeating array syntax can be used the same way normal arrays can be. The RFC doesn't explicitly mention repeat expressions, but it seems reasonable to allow them as well, since normal arrays are allowed.

It is possible to make the compiler get stuck compiling forever with `concat_bytes!([3; 999999999])`, but I don't think that's much of an issue since you can do that already with `const X: [u8; 999999999] = [3; 999999999];`.

Contributes to #87555.
2022-01-02 12:38:41 +00:00
bors
f7934f693b Auto merge of #92034 - petrochenkov:nolinknores, r=joshtriplett
Remove effect of `#[no_link]` attribute on name resolution

Previously it hid all non-macro names from other crates.
This has no relation to linking and can change name resolution behavior in some cases (e.g. glob conflicts), in addition to just producing the "unresolved name" errors.

I can kind of understand the possible reasoning behind the current behavior - if you can use names from a `no_link` crates then you can use, for example, functions too, but whether it will actually work or produce link-time errors will depend on random factors like inliner behavior.
(^^^ This is not the actual reason why the current behavior exist, I've looked through git history and it's mostly accidental.)

I think this risk is ok for such an obscure attribute, and we don't need to specifically prevent use of non-macro items from such crates.
(I'm not actually sure why would anyone use `#[no_link]` on a crate, even if it's macro only, if you aware of any use cases, please share. IIRC, at some point it was used for crates implementing custom derives - the now removed legacy ones, not the current proc macros.)

Extracted from https://github.com/rust-lang/rust/pull/91795.
2022-01-02 06:28:34 +00:00
David Tolnay
a18f43f25d
Fix unclosed boxes in pretty printing of TraitAlias 2022-01-01 18:02:00 -08:00
Josh Triplett
ff94b3b12b Update references to -Z symbol-mangling-version to use -C
Replace `-Z symbol-mangling-version=v0` with `-C symbol-mangling-version=v0`.

Replace `-Z symbol-mangling-version=legacy` with
`-Z unstable-options -C symbol-mangling-version=legacy`.
2022-01-01 15:53:11 -08:00
Josh Triplett
bbf4b6699e Stabilize -Z symbol-mangling-version as -C symbol-mangling-version
This allows selecting `v0` symbol-mangling without an unstable option.
Selecting `legacy` still requires -Z unstable-options.

Continue supporting -Z symbol-mangling-version for compatibility for
now, but show a deprecation warning for it.
2022-01-01 15:51:02 -08:00
Matthias Krüger
2004a51fa4
Rollup merge of #92468 - NieDzejkob:silent-cfg, r=petrochenkov
Emit an error for `--cfg=)`

Fixes #73026

See also: #64467, #89468

The issue stems from a `FatalError` being silently raised in
`panictry_buffer`. Normally this is not a problem, because
`panictry_buffer` emits the causes of the error, but they are not
themselves fatal, so they get filtered out by the silent emitter.

To fix this, we use a parser entrypoint which doesn't use
`panictry_buffer`, and we handle the error ourselves.
2022-01-01 22:49:53 +01:00
Aaron Hill
137c374c41
Move PatKind::Lit checking from ast_validation to ast lowering
Fixes #92074

This allows us to insert an `ExprKind::Err` when an invalid expression
is used in a literal pattern, preventing later stages of compilation
from seeing an unexpected literal pattern.
2022-01-01 15:10:43 -05:00
bors
c145692254 Auto merge of #92455 - petrochenkov:alltraits2, r=cjgillot
rustc_metadata: Use a query for collecting all traits in encoder

Implement refactoring suggested in https://github.com/rust-lang/rust/pull/92244#discussion_r775976336
r? `@cjgillot`
2022-01-01 17:34:12 +00:00
bors
4f49627c6f Auto merge of #92419 - erikdesjardins:coldland, r=nagisa
Mark drop calls in landing pads `cold` instead of `noinline`

Now that deferred inlining has been disabled in LLVM (#92110), this shouldn't cause catastrophic size blowup.

I confirmed that the test cases from https://github.com/rust-lang/rust/issues/41696#issuecomment-298696944 still compile quickly (<1s) after this change. ~Although note that I wasn't able to reproduce the original issue using a recent rustc/llvm with deferred inlining enabled, so those tests may no longer be representative. I was also unable to create a modified test case that reproduced the original issue.~ (edit: I reproduced it on CI by accident--the first commit timed out on the LLVM 12 builder, because I forgot to make it conditional on LLVM version)

r? `@nagisa`
cc `@arielb1` (this effectively reverts #42771 "mark calls in the unwind path as !noinline")
cc `@RalfJung` (fixes #46515)

edit: also fixes #87055
2022-01-01 13:28:13 +00:00
Jakub Beránek
3d8d3f1435
Rustdoc: use ThinVec for GenericArgs bindings 2022-01-01 11:29:14 +01:00
Matthias Krüger
913bc8644a
Rollup merge of #92460 - dwrensha:fix-92267, r=petrochenkov
[rustc_builtin_macros] add indices to format_foreign::printf::Substitution::Escape

Fixes #92267.

The problem was that the escape string "%%" does not need to appear at the very beginning of the format string, but
the iterator implementation assumed that it did.

The solution follows the pattern used by `format_foregin:🐚:Subtitution::Escape`: 8ed935e92d/compiler/rustc_builtin_macros/src/format_foreign.rs (L629)
2022-01-01 10:48:57 +01:00
Matthias Krüger
a76128b365
Rollup merge of #92457 - bjorn3:sync_cg_gcc-2021-12-31, r=antoyo
Sync rustc_codegen_gcc

r? `@ghost`

cc `@antoyo`

`@rustbot` label +A-codegen +A-gcc +T-compiler
2022-01-01 10:48:57 +01:00
Matthias Krüger
efe415878b
Rollup merge of #92420 - dtolnay:patrange, r=Mark-Simulacrum
Fix whitespace in pretty printed PatKind::Range

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($pat:pat) => {
        stringify!($pat)
    };
}

fn main() {
    println!("{}", repro!(0..=1));
}
```

Before:&ensp;`0 ..=1`
After:&ensp;`0..=1`

The canonical spacing applied by rustfmt has no space after the lower expr. Rustc's parser diagnostics also do not put a space there:

df96fb166f/compiler/rustc_parse/src/parser/pat.rs (L754)
2022-01-01 10:48:56 +01:00
Matthias Krüger
682b4cbc4e
Rollup merge of #92412 - dtolnay:tryspace, r=Mark-Simulacrum
Fix double space in pretty printed TryBlock

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($expr:expr) => {
        stringify!($expr)
    };
}

fn main() {
    println!("{}", repro!(try {}));
}
```

Before:&ensp;<code>try&nbsp;&nbsp;{}</code>
After:&ensp;<code>try&nbsp;{}</code>

The `head` helper already appends a space:

2b67c30bfe/compiler/rustc_ast_pretty/src/pprust/state.rs (L654-L664)

so doing `head` followed by `space` resulted in a double space:

2b67c30bfe/compiler/rustc_ast_pretty/src/pprust/state.rs (L2241-L2242)
2022-01-01 10:48:55 +01:00
Vadim Petrochenkov
2dd50d5eb2 rustc_metadata: Use a query for collecting all traits in encoder 2022-01-01 13:06:50 +08:00
Jakub Kądziołka
193342eb8d
Emit an error for --cfg=)
Fixes #73026

See also: #64467, #89468

The issue stems from a `FatalError` being silently raised in
`panictry_buffer`. Normally this is not a problem, because
`panictry_buffer` emits the causes of the error, but they are not
themselves fatal, so they get filtered out by the silent emitter.

To fix this, we use a parser entrypoint which doesn't use
`panictry_buffer`, and we handle the error ourselves.
2022-01-01 05:21:36 +01:00
bors
c9cf9c6507 Auto merge of #92294 - Kobzol:rustdoc-meta-kind, r=GuillaumeGomez
Add Attribute::meta_kind

The `AttrItem::meta` function is being called on a lot of places, however almost always the caller is only interested in the `kind` of the result `MetaItem`. Before, the `path`  had to be cloned in order to get the kind, now it does not have to be.

There is a larger related "problem". In a lot of places, something wants to know contents of attributes. This is accessed through `Attribute::meta_item_list`, which calls `AttrItem::meta` (now `AttrItem::meta_kind`), among other methods. When this function is called, the meta item list has to be recreated from scratch. Everytime something asks a simple question (like is this item/list of attributes `#[doc(hidden)]`?), the tokens of the attribute(s) are cloned, parsed and the results are allocated on the heap. That seems really unnecessary. What would be the best way to cache this? Turn `meta_item_list` into a query perhaps? Related PR: https://github.com/rust-lang/rust/pull/92227

r? rust-lang/rustdoc
2022-01-01 02:03:23 +00:00
bors
4d2e0fd96c Auto merge of #92465 - matthiaskrgr:rollup-yuary84, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #90383 (Extend check for UnsafeCell in consts to cover unions)
 - #91375 (config.rs: Add support for a per-target default_linker option.)
 - #91480 (rustdoc: use smaller number of colors to distinguish items)
 - #92338 (Add try_reserve and  try_reserve_exact for OsString)
 - #92405 (Add a couple needs-asm-support headers to tests)
 - #92435 (Sync rustc_codegen_cranelift)
 - #92440 (Fix mobile toggles position)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-31 22:57:51 +00:00
Matthias Krüger
4e4d2585e5
Rollup merge of #92435 - bjorn3:sync_cg_clif-2021-12-30, r=bjorn3
Sync rustc_codegen_cranelift

The main highlight this sync is enforcing rustfmt and lack of warnings on cg_clif's CI. I will open a separate PR to remove the cg_clif exceptions for them from this repo.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2021-12-31 23:14:48 +01:00
Matthias Krüger
ac1060e188
Rollup merge of #90383 - tmiasko:union-validity, r=RalfJung
Extend check for UnsafeCell in consts to cover unions

A validity companion to changes from #90373.

`@rust-lang/wg-const-eval`
2021-12-31 23:14:44 +01:00
bors
cfa3fe5af3 Auto merge of #90637 - Mark-Simulacrum:liveness-btree, r=lqd
Store liveness in interval sets for region inference

On the 100,000 line test case from https://github.com/rust-lang/rust/issues/90445, this reduces memory usage from 35 GB to 444 MB at peak (based on DHAT results, though with regular malloc), and yields a 9.4x speedup, with wall time going from 14.5 seconds to 1.5s. Performance results show that for the majority of real-world code this has little to no impact, but it's expected to generally scale better for auto-generated functions and other cases which stress this area of the compiler, as results on #90445 illustrate.

There may also be further room for improvement in future PRs making use of this data structures benefits over raw bitsets (which, at some level, are a less perfect fit for representing liveness, which is almost always composed of contiguous ranges, not point locations).

Fixes #90445.
2021-12-31 19:54:10 +00:00
David Renshaw
4a7f276cb6 update tests 2021-12-31 12:51:27 -05:00
David Renshaw
a661671ae3 [rustc_builtin_macros] add indices to format_foreign::printf::Substitution::Escape 2021-12-31 12:42:15 -05:00
bors
984a6bf9c1 Auto merge of #92175 - Aaron1011:fix-missing-source-file, r=cjgillot
Import `SourceFile`s from crate before decoding foreign `Span`

Fixes #92163
Fixes #92014

When writing to the incremental cache, we encode all `Span`s
we encounter, regardless of whether or not their `SourceFile`
comes from the local crate, or from a foreign crate.

When we decode a `Span`, we use the `StableSourceFileId` we encoded
to locate the matching `SourceFile` in the current session. If this
id corresponds to a `SourceFile` from another crate, then we need to
have already imported that `SourceFile` into our current session.

This usually happens automatically during resolution / macro expansion,
when we try to resolve definitions from other crates. In certain cases,
however, we may try to load a `Span` from a transitive dependency
without having ever imported the `SourceFile`s from that crate, leading
to an ICE.

This PR fixes the issue by enconding the `SourceFile`'s `CrateNum`
when we encode a `Span`. During decoding, we call `imported_source_files()`
when we encounter a foreign `CrateNum`, which ensure that all
`SourceFile`s from that crate are imported into the current session.
2021-12-31 16:38:23 +00:00
bjorn3
e7357e3340 Remove unused extern crate rustc_symbol_mangling 2021-12-31 16:57:33 +01:00
bjorn3
b799d6e0a5 Merge commit '1411a98352ba6bee8ba3b0131c9243e5db1e6a2e' into sync_cg_clif-2021-12-31 2021-12-31 16:26:32 +01:00
Tomasz Miąsko
2eb637a9f2 Extend check for UnsafeCell in consts to cover unions
A validity companion to changes from #90373.
2021-12-31 08:53:12 +01:00
bors
e670844012 Auto merge of #91929 - anuvratsingh:remove_in_band_lifetimes_compiler_rustc_traits, r=jackh726
Removed `in_band_lifetimes` from `rustc_traits`

Issue: [#91867](https://github.com/rust-lang/rust/issues/91867)
2021-12-31 05:08:24 +00:00
Mark Rousskov
4abb3283f3 Use SparseIntervalMatrix instead of SparseBitMatrix
Region inference contains several bitsets which are filled with large intervals
representing liveness. These can cause excessive memory usage, and are
relatively slow when growing to large sizes compared to the IntervalSet.
2021-12-30 22:33:52 -05:00
Mark Rousskov
00c55a1bb8 Introduce IntervalSet
This is a compact, fast storage for variable-sized sets, typically consisting of
larger ranges. It is less efficient than a bitset if ranges are both small and
the domain size is small, but will still perform acceptably. With enormous
domain sizes and large ranges, the interval set performs much better, as it can
be much more densely packed in memory than the uncompressed bit set alternative.
2021-12-30 22:33:44 -05:00
Anuvrat
58a888fcc1
Removed in_band_lifetimes from rustc_traits 2021-12-30 13:59:19 -05:00
pierwill
0bac713569 Add negative impl for Ord, PartialOrd on LocalDefId
Add comment about why `LocalDefId` should not be `Ord`

Also fix some formatting in the doc comment.
2021-12-30 11:45:20 -06:00
bors
b60e32c828 Auto merge of #92434 - matthiaskrgr:rollup-m8wuq0v, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #91519 (ast: Avoid aborts on fatal errors thrown from mutable AST visitor)
 - #92414 (Fix spacing of pretty printed const item without body)
 - #92423 (Add UI test for #92292)
 - #92427 (Use `UnsafeCell::get_mut()` in `core::lazy::OnceCell::get_mut()`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-30 14:52:50 +00:00
bjorn3
a8e6d5b04d Merge commit '40b00f4200fbdeefd11815398cb46394b8cb0a5e' into sync_cg_clif-2021-12-30 2021-12-30 14:53:41 +01:00
Deadbeef
7fd6ddfba2
Error when selected impl is not const in constck 2021-12-30 20:13:55 +08:00
Matthias Krüger
e810487b4d
Rollup merge of #92414 - dtolnay:constnoexpr, r=oli-obk
Fix spacing of pretty printed const item without body

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($item:item) => {
        stringify!($item)
    };
}

fn main() {
    println!("{}", repro!(extern "C" { static S: i32; }));
}
```

Before:&ensp;`extern "C" { static S: i32 ; }`
After:&ensp;`extern "C" { static S: i32; }`
2021-12-30 13:12:34 +01:00
Matthias Krüger
b9f7197ab3
Rollup merge of #91519 - petrochenkov:cratexp2, r=Aaron1011
ast: Avoid aborts on fatal errors thrown from mutable AST visitor

Set the node to some dummy value and rethrow the error instead.

When using the old aborting `visit_clobber` in `InvocationCollector::visit_crate` the next tests abort due to fatal errors:
```
ui\modules\path-invalid-form.rs
ui\modules\path-macro.rs
ui\modules\path-no-file-name.rs
ui\parser\issues\issue-5806.rs
ui\parser\mod_file_with_path_attr.rs
```

Follow up to https://github.com/rust-lang/rust/pull/91313.
2021-12-30 13:12:33 +01:00
bors
f8d4ee7c7a Auto merge of #89336 - Aaron1011:variance-struct-diag, r=cjgillot
Refactor variance diagnostics to work with more types

Instead of special-casing mutable pointers/references, we
now support general generic types (currently, we handle
`ty::Ref`, `ty::RawPtr`, and `ty::Adt`)

When a `ty::Adt` is involved, we show an additional note
explaining which of the type's generic parameters is
invariant (e.g. the `T` in `Cell<T>`). Currently, we don't
explain *why* a particular generic parameter ends up becoming
invariant. In the general case, this could require printing
a long 'backtrace' of types, so doing this would be
more suitable for a follow-up PR.

We still only handle the case where our variance switches
to `ty::Invariant`.
2021-12-30 11:34:24 +00:00
Erik Desjardins
e4463b2453 keep noinline for system llvm < 14 2021-12-30 00:15:51 -05:00
bors
1b3a5f29dd Auto merge of #91125 - eskarn:llvm-passes-plugin-support, r=nagisa
Allow loading LLVM plugins with both legacy and new pass manager

Opening a draft PR to get feedback and start discussion on this feature. There is already a codegen option `passes` which allow giving a list of LLVM pass names, however we currently can't use a LLVM pass plugin (as described here : https://llvm.org/docs/WritingAnLLVMPass.html), the only available passes are the LLVM built-in ones.

The proposed modification would be to add another codegen option `pass-plugins`, which can be set with a list of paths to shared library files. These libraries are loaded using the LLVM function `PassPlugin::Load`, which calls the expected symbol `lvmGetPassPluginInfo`, and register the pipeline parsing and optimization callbacks.

An example usage with a single plugin and 3 passes would look like this in the `.cargo/config`:

```toml
rustflags = [
    "-C", "pass-plugins=/tmp/libLLVMPassPlugin",
    "-C", "passes=pass1 pass2 pass3",
]
```
This would give the same functionality as the opt LLVM tool directly integrated in rust build system.

Additionally, we can also not specify the `passes` option, and use a plugin which inserts passes in the optimization pipeline, as one could do using clang.
2021-12-30 02:53:09 +00:00
Aaron Hill
b15cb29a4a
Refactor variance diagnostics to work with more types
Instead of special-casing mutable pointers/references, we
now support general generic types (currently, we handle
`ty::Ref`, `ty::RawPtr`, and `ty::Adt`)

When a `ty::Adt` is involved, we show an additional note
explaining which of the type's generic parameters is
invariant (e.g. the `T` in `Cell<T>`). Currently, we don't
explain *why* a particular generic parameter ends up becoming
invariant. In the general case, this could require printing
a long 'backtrace' of types, so doing this would be
more suitable for a follow-up PR.

We still only handle the case where our variance switches
to `ty::Invariant`.
2021-12-29 18:53:40 -05:00
bors
d331cb710f Auto merge of #88354 - Jmc18134:hint-space-pauth-opt, r=nagisa
Add codegen option for branch protection and pointer authentication on AArch64

The branch-protection codegen option enables the use of hint-space pointer
authentication code for AArch64 targets.
2021-12-29 22:35:11 +00:00
David Tolnay
bc1a1ff3c8
Fix whitespace in pretty printed PatKind::Range 2021-12-29 13:02:14 -08:00
Erik Desjardins
2b662217e7 Mark drop calls in landing pads cold instead of noinline
Now that deferred inlining has been disabled in LLVM,
this shouldn't cause catastrophic size blowup.
2021-12-29 15:47:49 -05:00
David Tolnay
8d7cf1a4ca
Fix spacing in pretty printed PatKind::Struct with no fields 2021-12-29 12:45:23 -08:00
David Tolnay
b62163515a
Move equal sign back into head ibox 2021-12-29 12:26:50 -08:00
David Tolnay
b7df49895c
Fix spacing of pretty printed const item without body 2021-12-29 12:26:50 -08:00
David Tolnay
a24e238bdf
Fix spacing and ordering of words in pretty printed Impl 2021-12-29 12:10:24 -08:00
bors
78fd0f633f Auto merge of #92244 - petrochenkov:alltraits, r=cjgillot
rustc_metadata: Encode list of all crate's traits into metadata

While working on https://github.com/rust-lang/rust/pull/88679 I noticed that rustdoc is casually doing something quite expensive, something that is used only for error reporting in rustc - collecting all traits from all crates in the dependency tree.

This PR trades some minor extra time spent by metadata encoder in rustc for major gains for rustdoc (and for rustc runs with errors, which execute the `all_traits` query for better diagnostics).
2021-12-29 19:22:33 +00:00
David Tolnay
2f25a4ab30
Fix double space in pretty printed TryBlock 2021-12-29 11:13:33 -08:00
ametisf
874cd08e23 Suggest while let x = y when encountering while x = y
Extends #75931 to also detect where the `let` might be missing from `while let` expressions.
2021-12-29 13:23:19 +01:00
bors
2b67c30bfe Auto merge of #92397 - matthiaskrgr:rollup-xnfou17, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92075 (rustdoc: Only special case struct fields for intra-doc links, not enum variants)
 - #92118 (Parse and suggest moving where clauses after equals for type aliases)
 - #92237 (Visit expressions in-order when resolving pattern bindings)
 - #92340 (rustdoc: Start cleaning up search index generation)
 - #92351 (Add long error explanation for E0227)
 - #92371 (Remove pretty printer space inside block with only outer attrs)
 - #92372 (Print space after formal generic params in fn type)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-29 12:07:33 +00:00
Matthias Krüger
949769cf3b
Rollup merge of #92372 - dtolnay:fntype, r=jackh726
Print space after formal generic params in fn type

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($ty:ty) => {
        stringify!($ty)
    };
}

fn main() {
    println!("{}", repro!(for<'a> fn(&'a u8)));
}
```

Before:&ensp;`for<'a>fn(&'a u8)`
After:&ensp;`for<'a> fn(&'a u8)`

The pretty printer's `print_formal_generic_params` already prints formal generic params correctly with a space, we just need to call it when printing BareFn types instead of reimplementing the printing incorrectly without a space.

83b15bfe1c/compiler/rustc_ast_pretty/src/pprust/state.rs (L1394-L1400)
2021-12-29 10:17:13 +01:00
Matthias Krüger
5583010347
Rollup merge of #92371 - dtolnay:attrblock, r=oli-obk
Remove pretty printer space inside block with only outer attrs

Follow-up to #92238 fixing one of the FIXMEs.

```rust
macro_rules! repro {
    ($expr:expr) => {
        stringify!($expr)
    };
}

fn main() {
    println!("{}", repro!(#[attr] {}));
}
```

Before:&ensp;`#[attr] { }`
After:&ensp;`#[attr] {}`
2021-12-29 10:17:12 +01:00
Matthias Krüger
c82b2bc590
Rollup merge of #92351 - TmLev:master, r=GuillaumeGomez
Add long error explanation for E0227

Part of the #61137.
2021-12-29 10:17:11 +01:00
Matthias Krüger
f044c6c86c
Rollup merge of #92237 - compiler-errors:issue-92100, r=cjgillot
Visit expressions in-order when resolving pattern bindings

[edited:] Visit the pattern's sub-expressions before defining any bindings.

Otherwise, we might get into a case where a Lit/Range expression in a pattern has a qpath pointing to a Ident pattern that is defined after it, causing an ICE when lowering to HIR. I have a more detailed explanation in the issue linked.

Fixes #92100
2021-12-29 10:17:10 +01:00
Matthias Krüger
bee14712ab
Rollup merge of #92118 - jackh726:type-alias-position-error, r=petrochenkov
Parse and suggest moving where clauses after equals for type aliases

~Mostly the same as #90076, but doesn't make any syntax changes.~ Whether or not we want to land the syntax changes, we should  parse the invalid where clause position and suggest moving.

r? `@nikomatsakis`
cc `@petrochenkov` you might have thoughts on implementation
2021-12-29 10:17:08 +01:00
bors
6211dd7250 Auto merge of #92254 - krasimirgg:gsgdt-up, r=Mark-Simulacrum
Bump `gsgdt` to 0.1.3

No functional changes intended.

The 0.1.2 -> 0.1.3 commit 3e1dcec539 renames `Node::new` to `Node::from_list`.
2021-12-29 09:00:27 +00:00
ThePuzzlemaker
eddf80698f
Suggest returning tail expressions in async fn's 2021-12-28 19:43:30 -06:00
David Tolnay
ad29c177f4
Print space after formal generic params in fn type 2021-12-28 12:56:55 -08:00
David Tolnay
cbccc4a597
Remove pretty printer space inside block with only outer attrs 2021-12-28 12:42:50 -08:00
Jack Huey
4391a11537 Parse and suggest moving where clauses after equals for type aliases 2021-12-28 14:20:15 -05:00
Jack Huey
bbb8bde989 Slight cleanup 2021-12-28 12:58:31 -05:00
Jack Huey
555119fa14 Introduce demand_compatible 2021-12-28 12:58:31 -05:00
Jack Huey
45341a6cbf Rename a couple variables 2021-12-28 12:58:29 -05:00
bors
83b15bfe1c Auto merge of #92352 - matthiaskrgr:rollup-19fbq7u, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92076 (Ignore other `PredicateKind`s in rustdoc auto trait finder)
 - #92219 (Remove VCVARS_BAT)
 - #92238 (Add a test suite for stringify macro)
 - #92330 (Add myself to .mailmap)
 - #92333 (Tighten span when suggesting lifetime on path)
 - #92335 (Document units for `std::column`)
 - #92344 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-28 16:59:56 +00:00
Guillaume Gomez
ee97600a6f Fix invalid removal of backlines from doc comments 2021-12-28 17:09:22 +01:00
bors
442248d6bc Auto merge of #92153 - petrochenkov:foreignchild, r=cjgillot
rustc_metadata: Merge items from `extern` blocks into their parent modules during metadata encoding rather than during metadata decoding
2021-12-28 13:47:22 +00:00
Matthias Krüger
98c61b673e
Rollup merge of #92333 - compiler-errors:elided-lifetime-spans, r=cjgillot
Tighten span when suggesting lifetime on path

This is kind of a hack.

Really the issue here is that we want to suggest the segment's span if the path resolves to something defined outside of the macro, and the macro's span if it resolves to something defined within.. I'll look into seeing if we can do something like that.

Fixes #92324

r? `@cjgillot`
2021-12-28 13:59:25 +01:00
Matthias Krüger
bec499e08d
Rollup merge of #92076 - Aaron1011:rustdoc-auto-trait-ignore, r=cjgillot
Ignore other `PredicateKind`s in rustdoc auto trait finder

Fixes #92073

There's not really anything we can do with them, and they're
causing ICEs. I'm not using a wildcard match, as we should check
that any new `PredicateKind`s are handled properly by rustdoc.
2021-12-28 13:59:22 +01:00
TmLev
406d6d4028 docs(error-codes): Add long error explanation for E0227 2021-12-28 15:46:20 +03:00
Vadim Petrochenkov
90e371027e rustc_metadata: Encode list of all crate's traits into metadata 2021-12-28 19:31:51 +08:00
Jakub Beránek
6c9ffe4aec
Do not use LEB128 for encoding u16 and i16 2021-12-28 09:29:08 +01:00
Michael Goulet
e37d012a06 Tighten span when suggesting lifetime on path 2021-12-27 23:34:52 -08:00
bors
e91ad5fc62 Auto merge of #92159 - petrochenkov:decoditer, r=cjgillot
rustc_metadata: Switch crate data iteration from a callback to iterator

The iteration looks more conventional this way, and some allocations are avoided.
2021-12-28 07:32:43 +00:00
Vadim Petrochenkov
a5efceacd1 rustc_metadata: Merge items from extern blocks into their parent modules
during metadata encoding rather than during metadata decoding
2021-12-28 14:25:41 +08:00
bors
41ce641a40 Auto merge of #92130 - Kobzol:stable-hash-str, r=cjgillot
Use hash_stable for hashing str

This seemed like an oversight. With this change the hash can go through the `HashStable` machinery directly.
2021-12-28 01:04:33 +00:00
David Tolnay
e9fbe79292
Remove &self from PrintState::to_string 2021-12-27 16:20:50 -08:00
Matthias Krüger
a11414d62e
Rollup merge of #92161 - petrochenkov:misclean, r=cjgillot
resolve: Minor miscellaneous cleanups from #89059

`@bors` rollup=always
2021-12-27 21:42:27 +01:00
Matthias Krüger
a7c79c08d6
Rollup merge of #92147 - calebcartwright:publicize-builtin_macro-asm, r=cjgillot
rustc_builtin_macros: make asm mod public for rustfmt

Follow up to #92016, as I'd completely missed that the mod we needed was internal
2021-12-27 21:42:26 +01:00
Matthias Krüger
bd77fbfef1
Rollup merge of #92112 - SparrowLii:issue92010, r=cjgillot
Fix the error of checking `base_expr` twice in type_changing_struct_update

Fixes #92010
2021-12-27 21:42:25 +01:00
Matthias Krüger
b57a6b38c5
Rollup merge of #90586 - jswrenn:relax-privacy-lints, r=petrochenkov
Relax priv-in-pub lint on generic bounds and where clauses of trait impls.

The priv-in-pub lint is a legacy mechanism of the compiler, supplanted by a reachability-based [type privacy](https://github.com/rust-lang/rfcs/blob/master/text/2145-type-privacy.md) analysis. This PR does **not** relax type privacy; it only relaxes the lint (as proposed by the type privacy RFC) in the case of trait impls.

## Current Behavior
On public trait impls, it's currently an **error** to have a `where` bound constraining a private type with a trait:
```rust
pub trait Trait {}
pub struct Type {}

struct Priv {}
impl Trait for Priv {}

impl Trait for Type
where
    Priv: Trait // ERROR
{}
```

...and it's a **warning** to have have a public type constrained by a private trait:
```rust
pub trait Trait {}
pub struct Type {}

pub struct Pub {}
trait Priv {}
impl Priv for Pub {}

impl Trait for Type
where
    Pub: Priv // WARNING
{}
```

This lint applies to `where` clauses in other contexts, too; e.g. on free functions:
```rust
struct Priv<T>(T);
pub trait Pub {}
impl<T: Pub> Pub for Priv<T> {}

pub fn function<T>()
where
    Priv<T>: Pub // WARNING
{}
```

**These constraints could be relaxed without issue.**

## New Behavior
This lint is relaxed for `where` clauses on trait impls, such that it's okay to have a `where` bound constraining a private type with a trait:
```rust
pub trait Trait {}
pub struct Type {}

struct Priv {}
impl Trait for Priv {}

impl Trait for Type
where
    Priv: Trait // OK
{}
```

...and it's okay to have a public type constrained by a private trait:
```rust
pub trait Trait {}
pub struct Type {}

pub struct Pub {}
trait Priv {}
impl Priv for Pub {}

impl Trait for Type
where
    Pub: Priv // OK
{}
```

## Rationale
While the priv-in-pub lint is not essential for soundness, it *can* help programmers avoid pitfalls that would make their libraries difficult to use by others. For instance, such a lint *is* useful for free functions; e.g. if a downstream crate tries to call the `function` in the previous snippet in a generic context:
```rust
fn callsite<T>()
where
    Priv<T>: Pub // ERROR: omitting this bound is a compile error, but including it is too
{
    function::<T>()
}
```
...it cannot do so without repeating `function`'s `where` bound, which we cannot do because `Priv` is out-of-scope. A lint for this case is arguably helpful.

However, this same reasoning **doesn't** hold for trait impls. To call an unconstrained method on a public trait impl with private bounds, you don't need to forward those private bounds, you can forward the public trait:
```rust
mod upstream {
    pub trait Trait {
        fn method(&self) {}
    }
    pub struct Type<T>(T);

    pub struct Pub<T>(T);
    trait Priv {}
    impl<T: Priv> Priv for Pub<T> {}

    impl<T> Trait for Type<T>
    where
        Pub<T>: Priv // WARNING
    {}
}

mod downstream {
    use super::upstream::*;

    fn function<T>(value: Type<T>)
    where
        Type<T>: Trait // <- no private deets!
    {
        value.method();
    }
}
```

**This PR only eliminates the lint on trait impls.** It leaves it intact for all other contexts, including trait definitions, inherent impls, and function definitions. It doesn't need to exist in those cases either, but I figured I'd first target a case where it's mostly pointless.

## Other Notes
- See discussion [on zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/relax.20priv-in-pub.20lint.20for.20trait.20impl.20.60where.60.20bounds/near/222458397).
- This PR effectively reverts #79291.
2021-12-27 21:42:25 +01:00
Michael Goulet
b1529a680a Visit patterns' literal expressions before binding new idents 2021-12-27 12:20:13 -08:00
Wesley Wiser
ebc0d0d2a8 Address review comments 2021-12-27 14:07:05 -05:00
Smitty
9702348957 Clarify that repeat count must be positive 2021-12-27 12:31:40 -05:00
Jack Wrenn
ebef8a8cee relax priv-in-pub lint on generic bounds and where clauses in trait impls 2021-12-27 00:22:09 +00:00
Jakub Beránek
047275a682
Add Attribute::meta_kind 2021-12-26 16:56:34 +01:00
bors
f8abed9ed4 Auto merge of #92257 - fee1-dead:fix_env_further_bounds, r=oli-obk
normalize env constness for nested obligations

Closes #92230.
2021-12-26 08:52:31 +00:00
Jack Huey
9a38ed12ca Rename args to check_argument_types and add some comments for what they are 2021-12-24 14:35:36 -05:00
Aaron Hill
da3f196a4e
Remove special-cased stable hashing for HIR module
All other 'containers' (e.g. `impl` blocks) hashed their contents
in the normal, order-dependent way. However, `Mod` was hashing
its contents in a (sort-of) order-independent way. However, the
exact order is exposed to consumers through `Mod.item_ids`,
and through query results like `hir_module_items`. Therefore,
stable hashing needs to take the order of items into account,
to avoid fingerprint ICEs.

Unforuntately, I was unable to directly build a reproducer
for the ICE, due to the behavior of `Fingerprint::combine_commutative`.
This operation swaps the upper and lower `u64` when constructing the
result, which makes the function non-associative. Since we start
the hashing of module items by combining `Fingerprint::ZERO` with
the first item, it's difficult to actually build an example where
changing the order of module items leaves the final hash unchanged.

However, this appears to have been hit in practice in #92218
While we're not able to reproduce it, the fact that proc-macros
are involved (which can give an entire module the same span, preventing
any span-related invalidations) makes me confident that the root
cause of that issue is our method of hashing module items.

This PR removes all of the special handling for `Mod`, instead deriving
a `HashStable` implementation. This makes `Mod` consistent with other
'contains' like `Impl`, which hash their contents through the typical
derive of `HashStable`.
2021-12-24 12:38:29 -05:00
bors
aad4f1039f Auto merge of #92156 - petrochenkov:ctorkind, r=davidtwco
rustc_metadata: Merge `get_ctor_def_id` and `get_ctor_kind`

Also avoid decoding the whole `ty::AssocItem` to get a `has_self` flag.

A small optimization and cleanup extracted from https://github.com/rust-lang/rust/pull/89059.
2021-12-24 17:09:21 +00:00
Deadbeef
77297e5f1c
normalize env constness for nested obligations 2021-12-25 00:33:23 +08:00
Krasimir Georgiev
9127f497be Bump gsgdt to 0.1.3
No functional changes intended.

The 0.1.2 -> 0.1.3 commit 3e1dcec539
renames `Node::new` to `Node::from_list`.
2021-12-24 13:46:37 +01:00
Michael Goulet
5a1c460898 Normalize struct tail type when checking Pointee trait 2021-12-24 01:41:18 -08:00
bors
59337cddd4 Auto merge of #91342 - RalfJung:fn-abi, r=eddyb,oli-obk
CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibility

This makes use of the `FnAbi` type in CTFE/Miri, which `@eddyb` has been saying for years is what we should do.^^ `FnAbi` is used to
- determine which arguments to skip (rather than the previous heuristic of skipping ZST arguments with the Rust ABI)
- impose further restrictions on whether caller and callee are consistent in how a given argument is passed

I was hoping it would also simplify the code, but that is not the case -- the previous type compatibility checks are still required (AFAIK), only the ZST skipping is gone and that took barely any code. We also need some hacks because `FnAbi` assumes a certain way of implementing `caller_location` (by passing extra arguments), but Miri can just read the caller location from the call stack so it doesn't need those arguments. (The fact that every backend has to separately implement support for these arguments seems suboptimal -- looks like this might have been better implemented on the MIR level.) To avoid having to implement those unnecessary arguments in Miri, we just compute *whether* the argument is present on the caller/callee side, but don't actually pass that argument around.

I have no idea if this looks the way `@eddyb` thinks it should look... but it makes Miri's test suite pass. ;)
One of rustc's tests fails unfortunately (`ui/const-generics/issues/issue-67739.rs`), some const generic code that is evaluated too early -- I think that should raise `TooGeneric` but instead it ICEs. My assumption is this is some FnAbi code that has not been properly tested on polymorphic code, but it might also be me calling that FnAbi code the wrong way.

r? `@oli-obk` `@eddyb`
Fixes https://github.com/rust-lang/rust/issues/56166
Miri PR at https://github.com/rust-lang/miri/pull/1928
2021-12-24 04:59:05 +00:00
bors
d6d12b6a5d Auto merge of #92222 - nnethercote:rm-global_allocator-rustc-rustdoc, r=alexcrichton
Remove useless `#[global_allocator]` from rustc and rustdoc.

This was added in #83152, which has several errors in its comments.

This commit also fix up the comments, which are quite wrong and
misleading.

r? `@alexcrichton`
2021-12-23 22:34:13 +00:00
Aaron Hill
27ed52c0a2
Adjust wording of comment 2021-12-23 13:44:04 -05:00
Aaron Hill
28f19f62c7
Address review comments 2021-12-23 13:38:54 -05:00
Aaron Hill
ab168e69ac
Some cleanup 2021-12-23 13:38:53 -05:00
Aaron Hill
49560e9c49
Ban deps only during query loading from disk 2021-12-23 13:38:53 -05:00
Aaron Hill
75181dc22f
Error if we try to read dep during deserialization 2021-12-23 13:38:53 -05:00
Aaron Hill
d9220924dc
Import SourceFiles from crate before decoding foreign Span
Fixes #92163
Fixes #92014

When writing to the incremental cache, we encode all `Span`s
we encounter, regardless of whether or not their `SourceFile`
comes from the local crate, or from a foreign crate.

When we decode a `Span`, we use the `StableSourceFileId` we encoded
to locate the matching `SourceFile` in the current session. If this
id corresponds to a `SourceFile` from another crate, then we need to
have already imported that `SourceFile` into our current session.

This usually happens automatically during resolution / macro expansion,
when we try to resolve definitions from other crates. In certain cases,
however, we may try to load a `Span` from a transitive dependency
without having ever imported the `SourceFile`s from that crate, leading
to an ICE.

This PR fixes the issue by calling `imported_source_files()`
when we encounter a `SourceFile` with a foreign `CrateNum`.
This ensures that all `SourceFile`s from that crate are imported
into the current session.
2021-12-23 12:56:12 -05:00
Matthias Krüger
8a61ae0479
Rollup merge of #92203 - Aaron1011:mir-adt-def, r=oli-obk
Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt`

The `AggregateKind` enum ends up in the final mir `Body`. Currently,
any changes to `AdtDef` (regardless of how significant they are)
will legitimately cause the overall result of `optimized_mir` to change,
invalidating any codegen re-use involving that mir.

This will get worse once we start hashing the `Span` inside `FieldDef`
(which is itself contained in `AdtDef`).

To try to reduce these kinds of invalidations, this commit changes
`AggregateKind::Adt` to store just the `DefId`, instead of the full
`AdtDef`. This allows the result of `optimized_mir` to be unchanged
if the `AdtDef` changes in a way that doesn't actually affect any
of the MIR we build.
2021-12-23 17:48:31 +01:00
lcnr
e3f5cc6c38 implement generic_arg_infer for array lengths 2021-12-23 10:09:35 +01:00
bors
c1d301bb29 Auto merge of #92167 - pierwill:chalk-update, r=jackh726
Update chalk to 0.75.0

- Compute flags in `intern_ty`
- Remove `tracing-serde` from `PERMITTED_DEPENDENCIES`
- Bump `tracing-tree` to 0.2.0
- Bump `tracing-subscriber` to 0.3.3
2021-12-23 08:59:55 +00:00
Nicholas Nethercote
bb23bfc2cd Remove useless #[global_allocator] from rustc and rustdoc.
This was added in #83152, which has several errors in its comments.

This commit also fix up the comments, which are quite wrong and
misleading.
2021-12-23 17:23:21 +11:00
bors
5aa0239b16 Auto merge of #92216 - matthiaskrgr:rollup-luplvuc, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #88858 (Allow reverse iteration of lowercase'd/uppercase'd chars)
 - #91544 (Fix duplicate derive clone suggestion)
 - #92026 (Add some JSDoc comments to rustdoc JS)
 - #92117 (kmc-solid: Add `std::sys::solid::fs::File::read_buf`)
 - #92139 (Change Backtrace::enabled atomic from SeqCst to Relaxed)
 - #92146 (Don't emit shared files when scraping examples from dependencies in Rustdoc)
 - #92208 (Quote bat script command line)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-23 01:47:08 +00:00
Matthias Krüger
d8bf974df5
Rollup merge of #91544 - rukai:91492, r=wesleywiser
Fix duplicate derive clone suggestion

closes https://github.com/rust-lang/rust/issues/91492

The addition of:
```rust
derives.sort();
derives.dedup();
```
is what actually solves the problem.
The rest is just cleanup.

I want to improve the diagnostic message to provide the suggestion as a proper diff but ran into some problems, so I'll attempt that again in a follow up PR.
2021-12-23 00:28:51 +01:00
Tomasz Miąsko
0db192a48c Delay remaining span_bugs in drop elaboration
This follows changes from #67967 and converts remaining `span_bug`s into
delayed bugs, since for const items drop elaboration might be executed
on a MIR which failed borrowck.
2021-12-22 21:32:06 +01:00
Aaron Hill
cac431ba75
Store a DefId instead of an AdtDef in AggregateKind::Adt
The `AggregateKind` enum ends up in the final mir `Body`. Currently,
any changes to `AdtDef` (regardless of how significant they are)
will legitimately cause the overall result of `optimized_mir` to change,
invalidating any codegen re-use involving that mir.

This will get worse once we start hashing the `Span` inside `FieldDef`
(which is itself contained in `AdtDef`).

To try to reduce these kinds of invalidations, this commit changes
`AggregateKind::Adt` to store just the `DefId`, instead of the full
`AdtDef`. This allows the result of `optimized_mir` to be unchanged
if the `AdtDef` changes in a way that doesn't actually affect any
of the MIR we build.
2021-12-22 14:36:34 -05:00
pierwill
e6ff0bac1e rustc VecGraph: require the index type to implement Ord 2021-12-22 10:50:57 -06:00
pierwill
a4a8c241c7 Require Ord for rustc_index::SparseBitSet::last_set_in 2021-12-22 10:50:57 -06:00
pierwill
8df9248591 Remove PartialOrd and Ord from LocalDefId
Implement `Ord`, `PartialOrd` for SpanData
2021-12-22 10:50:57 -06:00
pierwill
155a4a87af Upgrade tracing-subscriber 2021-12-22 10:47:36 -06:00
pierwill
ea25b779eb Update chalk to 0.75.0
- Compute flags in `intern_ty`
- Remove tracing-serde from PERMITTED_DEPENDENCIES
- Disable `tracing-full` feature in `chalk-solve`
- Bump tracing-tree to 0.2.0
2021-12-22 10:07:44 -06:00
Jack Huey
d3aecc1001 When obligation is a sized predicate, prefer projection or object candidates instead of param_env candidates 2021-12-22 04:14:20 -05:00
Vadim Petrochenkov
337ced2ef0 rustc_metadata: Merge get_ctor_def_id and get_ctor_kind
Also avoid decoding the whole `ty::AssocItem` to get a `has_self` flag
2021-12-22 11:05:54 +08:00
Aaron Hill
f1d682334d
Add #[rustc_clean(loaded_from_disk)] to assert loading of query result
Currently, you can use `#[rustc_clean]` to assert to that a particular
query (technically, a `DepNode`) is green or red. However, a green
`DepNode` does not mean that the query result was actually deserialized
from disk - we might have never re-run a query that needed the result.

Some incremental tests are written as regression tests for ICEs that
occured during query result decoding. Using
`#[rustc_clean(loaded_from_disk="typeck")]`, you can now assert
that the result of a particular query (e.g. `typeck`) was actually
loaded from disk, in addition to being green.
2021-12-21 16:34:12 -05:00
Alik Aslanyan
852dea89b2
Remove ArenaCacheSelector for visible_parent_map query.
Optimize visible_parent_map to use LRC to prevent unnecessary cloning
2021-12-21 22:40:21 +04:00
Caleb Cartwright
63c2edefda rustc_builtin_macros: make asm mod public for rustfmt 2021-12-21 11:52:40 -06:00
bors
8ad3c1dd1d Auto merge of #92149 - fee1-dead:cache-fix, r=oli-obk
Fix bad caching of `~const Drop` bounds

Fixes #92111.
2021-12-21 12:49:10 +00:00
Vadim Petrochenkov
1324100800 resolve: Minor miscellaneous cleanups from #89059 2021-12-21 20:26:41 +08:00
Vadim Petrochenkov
046a682899 rustc_metadata: Switch crate data iteration from a callback to iterator
The iteration looks more conventional this way, and some allocations are avoided.
2021-12-21 19:46:19 +08:00
bors
3d57c61a9e Auto merge of #92152 - matthiaskrgr:rollup-nmskpw6, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #90345 (Stabilise entry_insert)
 - #91412 (Improve suggestions for importing out-of-scope traits reexported as `_`)
 - #91770 (Suggest adding a `#[cfg(test)]` to to a test module)
 - #91823 (Make `PTR::as_ref` and similar methods `const`.)
 - #92127 (Move duplicates removal when generating results instead of when displaying them)
 - #92129 (JoinHandle docs: add missing 'the')
 - #92131 (Sync rustc_codegen_cranelift)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-21 09:01:25 +00:00
Matthias Krüger
ee45a532f3
Rollup merge of #92131 - bjorn3:sync_cg_clif-2021-12-20, r=bjorn3
Sync rustc_codegen_cranelift

The main highlight this sync is improved support for inline assembly. Thanks `@nbdd0121!` Inline assembly is still disabled by default for builds in the main rust repo though. Cranelift will now also be built from the crates.io releases rather than the git repo. Git repos are incompatible with vendoring.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
2021-12-21 08:33:43 +01:00
Matthias Krüger
790950a530
Rollup merge of #91770 - TaKO8Ki:suggest-adding-cfg-test, r=joshtriplett
Suggest adding a `#[cfg(test)]` to to a test module

closes #88138
2021-12-21 08:33:39 +01:00
bors
87e8639d8d Auto merge of #91903 - tmiasko:bit-set-hash, r=jackh726
Implement StableHash for BitSet and BitMatrix via Hash

This fixes an issue where bit sets / bit matrices the same word
content but a different domain size would receive the same hash.
2021-12-21 05:42:10 +00:00
Deadbeef
aaaad5b46b
Fix bad caching of ~const Drop bounds 2021-12-21 13:25:43 +08:00
Michael Goulet
f83508592b Suggest glob-import if we need to import a trait, but it has no visible name 2021-12-20 19:50:15 -08:00
Michael Goulet
c327627a68 Bail if printing item named _ in try_print_visible_def_path 2021-12-20 19:50:15 -08:00