Commit graph

160563 commits

Author SHA1 Message Date
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
bors 7b13c628a2 Auto merge of #92482 - matthiaskrgr:rollup-uso1zi0, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #84083 (Clarify the guarantees that ThreadId does and doesn't make.)
 - #91593 (Remove unnecessary bounds for some Hash{Map,Set} methods)
 - #92297 (Reduce compile time of rustbuild)
 - #92332 (Add test for where clause order)
 - #92438 (Enforce formatting for rustc_codegen_cranelift)
 - #92463 (Remove pronunciation guide from Vec<T>)
 - #92468 (Emit an error for `--cfg=)`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-02 00:20:04 +00: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
Matthias Krüger aa31c9726d
Rollup merge of #92463 - thomcc:thats-not-how-its-pronounced, r=joshtriplett
Remove pronunciation guide from Vec<T>

I performed an extremely scientific poll on twitter, and determined this is not how it's pronounced: https://twitter.com/at_tcsc/status/1476643344285581315
2022-01-01 22:49:52 +01:00
Matthias Krüger f6ce1e8627
Rollup merge of #92438 - bjorn3:less_cg_clif_exceptions, r=Mark-Simulacrum
Enforce formatting for rustc_codegen_cranelift
2022-01-01 22:49:51 +01:00
Matthias Krüger a015c86a1d
Rollup merge of #92332 - GuillaumeGomez:where-clause-order, r=jsha
Add test for where clause order

I didn't use ``@snapshot`` because of the `&nbsp;` characters, it's much simpler doing it through rustdoc-gui testsuite.

r? `@camelid`
2022-01-01 22:49:50 +01:00
Matthias Krüger ab7a356b5d
Rollup merge of #92297 - bjorn3:smaller_bootstrap, r=Mark-Simulacrum
Reduce compile time of rustbuild

Best reviewed commit by commit. The `ignore` crate and it's dependencies are probably responsible for the majority of the compile time after this PR.

cc `@jyn514` as you got a couple of open rustbuild PR.
2022-01-01 22:49:49 +01:00
Matthias Krüger 5137f7c9db
Rollup merge of #91593 - upsuper-forks:hashmap-set-methods-bound, r=dtolnay
Remove unnecessary bounds for some Hash{Map,Set} methods

This PR moves `HashMap::{into_keys,into_values,retain}` and `HashSet::retain` from `impl` blocks with `K: Eq + Hash, S: BuildHasher` into the blocks without them. It doesn't seem to me there is any reason these methods need to be bounded by that. This change brings `HashMap::{into_keys,into_values}` on par with `HashMap::{keys,values,values_mut}` which are not bounded either.
2022-01-01 22:49:48 +01:00
Matthias Krüger 30ec1f0384
Rollup merge of #84083 - ltratt:threadid_doc_tweak, r=dtolnay
Clarify the guarantees that ThreadId does and doesn't make.

The existing documentation does not spell out whether `ThreadId`s are unique during the lifetime of a thread or of a process. I had to examine the source code to realise (pleasingly!) that they're unique for the lifetime of a process. That seems worth documenting clearly, as it's a strong guarantee.

Examining the way `ThreadId`s are created also made me realise that the `as_u64` method on `ThreadId` could be a trap for the unwary on those platforms where the platform's notion of a thread identifier is also a 64 bit integer (particularly if they happen to use a similar identifier scheme to `ThreadId`). I therefore think it's worth being even clearer that there's no relationship between the two.
2022-01-01 22:49:47 +01:00
bors dd3ac41495 Auto merge of #92396 - xfix:remove-commandenv-apply, r=Mark-Simulacrum
Remove CommandEnv::apply

It's not being used and uses unsound set_var and remove_var functions. This is an internal function that isn't exported (even with `process_internals` feature), so this shouldn't break anything.

Also see #92365. Note that this isn't the only use of those methods in standard library, so that particular pull request will need more changes than just this to work (in particular, `test_capture_env_at_spawn` is using `set_var` and `remove_var`).
2022-01-01 20:45:37 +00:00
bjorn3 7ea6e713c2 Remove some dead code 2022-01-01 18:50:56 +01: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
bjorn3 ad6f98cd28 Remove the merge dependency 2022-01-01 17:03:24 +01:00
bjorn3 947e9483e9 Make the rustc and rustdoc wrapper not depend on libbootstrap
This slightly improves compilation time by reducing linking time
(saving about a 1/10 of the the total compilation time after
changing rustbuild) and slightly reduces disk usage (from 16MB for
the rustc wrapper to 4MB).
2022-01-01 16:56:05 +01:00
bjorn3 043745cb96 Avoid the merge derive macro in rustbuild
The task of the macro is simple enough that a decl macro is almost ten
times shorter than the original proc macro. The proc macro is 159 lines
while the decl macro is just 18 lines.

This reduces the amount of dependencies of rustbuild from 45 to 37. It
also slight reduces compilation time from 47s to 44s for debug builds.
2022-01-01 16:56:03 +01:00
bjorn3 2fe2728fa9 Remove the lazy_static dependency from rustbuild
Rustbuild already depends on once_cell which in the future can be
replaced with std::lazy::Lazy.
2022-01-01 16:53:47 +01:00
bjorn3 bffe880cfd Enforce formatting for rustc_codegen_cranelift 2022-01-01 16:52:30 +01: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
bors 028c6f1454 Auto merge of #92471 - matthiaskrgr:rollup-lmduxwh, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #88310 (Lock bootstrap (x.py) build directory)
 - #92097 (Implement split_at_spare_mut without Deref to a slice so that the spare slice is valid)
 - #92412 (Fix double space in pretty printed TryBlock)
 - #92420 (Fix whitespace in pretty printed PatKind::Range)
 - #92457 (Sync rustc_codegen_gcc)
 - #92460 ([rustc_builtin_macros] add indices to format_foreign::printf::Substitution::Escape)
 - #92469 (Make tidy check for magic numbers that spell things)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-01 09:57:35 +00:00
Guillaume Gomez ec0c83821e Add test for where clause order 2022-01-01 10:50:55 +01:00
Matthias Krüger 4bd4e271e4
Rollup merge of #92469 - joshtriplett:test-number-fix, r=Mark-Simulacrum
Make tidy check for magic numbers that spell things

Remove existing problematic cases.

r? `@Mark-Simulacrum`
2022-01-01 10:48:58 +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
Matthias Krüger a6e4d684aa
Rollup merge of #92097 - saethlin:split-without-deref, r=the8472
Implement split_at_spare_mut without Deref to a slice so that the spare slice is valid

~I'm not sure I understand what's going on here correctly. And I'm pretty sure this safety comment needs to be changed. I'm just referring to the same thing that `as_mut_ptr_range` does.~ (Thanks `@RalfJung` for the guidance and clearing things up)

I tried to run https://github.com/rust-lang/miri-test-libstd on alloc with -Zmiri-track-raw-pointers, and got a failure on the test `vec::test_extend_from_within`.

I minimized the test failure into this program:
```rust
#![feature(vec_split_at_spare)]
fn main() {
    Vec::<i32>::with_capacity(1).split_at_spare_mut();
}
```

The problem is that the existing implementation is actually getting a pointer range where both pointers are derived from the initialized region of the Vec's allocation, but we need the second one to be valid for the region between len and capacity. (thanks Ralf for clearing this up)
2022-01-01 10:48:54 +01:00
Matthias Krüger 5a5c9282e0
Rollup merge of #88310 - worldeva:bootstrap-locking, r=Mark-Simulacrum
Lock bootstrap (x.py) build directory

Closes #76661,  closes #80849,
`x.py` creates a lock file at `project_root/lock.db`

r? `@jyn514` , because he was one that told me about this~
2022-01-01 10:48:53 +01:00
bors ad0d4190fa Auto merge of #92374 - ehuss:update-libssh2-sys, r=Mark-Simulacrum
Update libssh2-sys

Updates libssh2-sys from 0.2.19 to 0.2.23.  This brings in libssh2 1.10 ([RELEASE-NOTES](https://github.com/libssh2/libssh2/blob/libssh2-1.10.0/RELEASE-NOTES)).  One of the major changes is to add support for OpenSSH agent on Windows.

Closes https://github.com/rust-lang/cargo/issues/10237
2022-01-01 05:21:22 +00:00
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