Commit Graph

160620 Commits

Author SHA1 Message Date
Josh Triplett
0d55bd1100 Make tidy check for magic numbers that spell things
Remove existing problematic cases.
2021-12-31 21:13:07 -08: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
Ben Kimock
777c853b4a Clarify safety comment 2021-12-31 18:03:07 -05: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
2da54c729e
Rollup merge of #92440 - GuillaumeGomez:fix-mobile-toggles, r=jsha
Fix mobile toggles position

Before:

![Screenshot from 2021-12-29 18-53-33](https://user-images.githubusercontent.com/3050060/147764842-082f6fa2-b631-4c47-ba34-ced76fe8494f.png)

After:

![Screenshot from 2021-12-29 18-52-48](https://user-images.githubusercontent.com/3050060/147764853-13046330-2442-4fad-b26a-84c167711b54.png)

r? `@jsha`
2021-12-31 23:14:49 +01: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
81f5dbdbd1
Rollup merge of #92405 - bjorn3:more_needs_inline_asm, r=lqd
Add a couple needs-asm-support headers to tests

This will allow them to be ignored by codegen backends that don't support inline asm.
2021-12-31 23:14:47 +01:00
Matthias Krüger
8322603970
Rollup merge of #92338 - Xuanwo:try_reserve, r=dtolnay
Add try_reserve and  try_reserve_exact for OsString

Add `try_reserve` and `try_reserve_exact` for OsString.

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

I will squash the commits after PR is ready to merge.

Signed-off-by: Xuanwo <github@xuanwo.io>
2021-12-31 23:14:46 +01:00
Matthias Krüger
72e36d47e8
Rollup merge of #91480 - jsha:fewer-colors, r=GuillaumeGomez
rustdoc: use smaller number of colors to distinguish items

This reduces visual distractions when reading method signatures.

As discussed in https://github.com/rust-lang/rust/issues/59845#issuecomment-974757191, this categorizes items into one of six colors (down from thirteen):

 - method, function (ochre `#AD7C37`)
 - trait, trait alias (dark slate blue `#6E4FC9`)
 - enum, struct, type alias, union, primitive (maroon `#AD378A`)
 - static, module, keyword, associated type, foreign type (steel blue `#3873AD`)
 - macro (green `#068000`)
 - generic params, self, Self (unmarked black `#000000`)

I slightly tweaked the actual color values so they'd have the same lightness (previously the trait color stood out much more than the others). And I made the color for links in general consistently use steel blue (previously there was a slightly different color for "search-failed").

The ayu and dark themes have been updated according to the same logic. I haven't changed any of the color values in those themes, just their assignment to types.

Demo:

https://rustdoc.crud.net/jsha/fewer-colors/std/string/struct.String.html
https://rustdoc.crud.net/jsha/fewer-colors/std/vec/struct.Vec.html
https://rustdoc.crud.net/jsha/fewer-colors/std/io/trait.Read.html
https://rustdoc.crud.net/jsha/fewer-colors/std/iter/trait.Iterator.html
2021-12-31 23:14:45 +01:00
Matthias Krüger
198fca8601
Rollup merge of #91375 - Apteryks:per-target-default-linker, r=Mark-Simulacrum
config.rs: Add support for a per-target default_linker option.

* src/bootstrap/config.rs (Target) <default_linker>: New field.
(TomlTarget): Likewise.
* src/bootstrap/compile.rs (rustc_cargo_env): Prefer a
target-specified default_linker over a global one if available.
* config.toml.example: Adjust doc.
2021-12-31 23:14:44 +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
Thom Chiovoloni
51a1681b69 Remove pronunciation guide from Vec<T> 2021-12-31 16:04:13 -05: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
Maxim Cournoyer
b1fbafddbb rustbuild: Add support for a per-target default-linker option. 2021-12-31 13:13:24 -05: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
worldeva
1326bd6484 Lock x.py build state
Prevent spurious build failures and other bugs caused by parallel runs of
x.py. We back the lock with sqlite, so that we have a cross-platform locking
strategy, and which can be done nearly first in the build process (from Python),
which helps move the lock as early as possible.
2021-12-31 10:31:13 -05:00
bjorn3
b799d6e0a5 Merge commit '1411a98352ba6bee8ba3b0131c9243e5db1e6a2e' into sync_cg_clif-2021-12-31 2021-12-31 16:26:32 +01:00
bors
8ed935e92d Auto merge of #92252 - GuillaumeGomez:update-pulldown, r=camelid,xFrednet
Update pulldown-cmark version to 0.9

Fixes https://github.com/rust-lang/rust/issues/92206.

r? `@camelid`
2021-12-31 12:46:38 +00: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
bors
8baeddfe8f Auto merge of #92437 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2021-12-31 00:07:29 +00:00
bors
a09f775e5a Auto merge of #92426 - calebcartwright:sync-rustfmt-subtree, r=calebcartwright
Sync rustfmt subtree

r? `@ghost`

Mostly refactoring and a few minor lint fixes, along with a couple small bug fixes
2021-12-30 20:53:39 +00:00
David Tolnay
d29941e724
Remove needless allocation from example code of OsString 2021-12-30 12:45:02 -08:00
David Tolnay
1f62c24d5a
Fix some copy/paste hysteresis in OsString try_reserve docs
It appears `find_max_slow` comes from the BinaryHeap docs, where the
try_reserve example is a slow implementation of find_max. It has no
relevance to this code in OsString though.
2021-12-30 12:41:26 -08:00
David Tolnay
5960f7a617
UI test updates for Result and Option method moves 2021-12-30 11:15:50 -08:00
Anuvrat
58a888fcc1
Removed in_band_lifetimes from rustc_traits 2021-12-30 13:59:19 -05:00
bjorn3
1411a98352 Remove unnecessary report_symbol_names call (#113)
rustc_interface already calls it for you
2021-12-30 13:55:42 -05:00
David Tolnay
dc3291614a
Consolidate impl Option<&mut T> 2021-12-30 10:37:53 -08:00
David Tolnay
538fe4b28d
Consolidate impl Option<&T> 2021-12-30 10:37:27 -08:00
David Tolnay
9d65bc51c1
Move Option::as_deref_mut 2021-12-30 10:36:55 -08:00
David Tolnay
48a91a08d1
Move Option::as_deref 2021-12-30 10:36:37 -08:00
David Tolnay
bbcf09f2fb
Move Option::unwrap_or_default 2021-12-30 10:34:35 -08:00
David Tolnay
b7a0ab18f6
Consolidate impl Result<&mut T, E> 2021-12-30 10:31:26 -08:00
David Tolnay
e63e2680da
Consolidate impl Result<&T, E> 2021-12-30 10:30:28 -08:00
David Tolnay
b2df61fa9f
Move Result::into_err 2021-12-30 10:28:54 -08:00
David Tolnay
778ca204a6
Move Result::into_ok 2021-12-30 10:28:23 -08:00
David Tolnay
06ea5ebe4e
Move Result::expect_err and Result::unwrap_err 2021-12-30 10:27:43 -08:00
David Tolnay
aa2aca2c8c
Move Result::unwrap_or_default 2021-12-30 10:26:36 -08:00
David Tolnay
15f57a6c59
Move Result::expect and Result::unwrap 2021-12-30 10:25:42 -08:00
David Tolnay
5aa8f91ff0
Move Result::as_deref_mut 2021-12-30 10:24:23 -08:00
David Tolnay
eda61d8d8a
Move Result::as_deref 2021-12-30 10:23:46 -08:00
bjorn3
92fbc8f591 Ignore new failing test_is_sorted test 2021-12-30 18:16:04 +01:00
bjorn3
0afd012837 Disable long running libcore tests
These only finish in reasonable time with optimizations enabled.

This patch file is copied from cg_clif.
2021-12-30 17:50:54 +01:00