Yuki Okushi [Tue, 12 Jan 2021 07:13:15 +0000 (16:13 +0900)]
Rollup merge of #79757 - jryans:long-line-tab-handling-early-expand, r=estebank
Replace tabs earlier in diagnostics
This replaces tabs earlier in the diagnostics emitting process, which allows various margin calculations to ignore the existence of tabs. It does add a string copy for the source lines that are emitted.
bors [Tue, 12 Jan 2021 02:56:51 +0000 (02:56 +0000)]
Auto merge of #76580 - rokob:iss76011, r=estebank
Suggest async {} for async || {}
Fixes #76011
This adds support for adding help diagnostics to the feature gating checks and
then uses it for the async_closure gate to add the extra bit of help
information as described in the issue.
bors [Tue, 12 Jan 2021 00:14:46 +0000 (00:14 +0000)]
Auto merge of #80928 - JohnTitor:rollup-sgerm3j, r=JohnTitor
Rollup of 9 pull requests
Successful merges:
- #79997 (Emit a reactor for cdylib target on wasi)
- #79998 (Use correct ABI for wasm32 by default)
- #80042 (Split a func into cold/hot parts, reducing binary size)
- #80324 (Explain method-call move errors in loops)
- #80864 (std/core docs: fix wrong link in PartialEq)
- #80870 (resolve: Simplify built-in macro table)
- #80885 (rustdoc: Resolve `&str` as `str`)
- #80904 (Fix small typo)
- #80923 (Merge different function exits)
Yuki Okushi [Mon, 11 Jan 2021 22:59:13 +0000 (07:59 +0900)]
Rollup merge of #80870 - petrochenkov:bmactable, r=oli-obk
resolve: Simplify built-in macro table
We don't use full `SyntaxExtension`s from the table, only `SyntaxExtensionKind`s, and `Ident` in `register_builtin_macro` always had dummy span. This PR removes unnecessary data from the table and related function signatures.
Yuki Okushi [Mon, 11 Jan 2021 22:59:11 +0000 (07:59 +0900)]
Rollup merge of #80864 - ericseppanen:master, r=jyn514
std/core docs: fix wrong link in PartialEq
PartialEq doc was attempting to link to ``[`Eq`]`` but instead we got a link to `` `eq` ``. Disambiguate with `trait@Eq`.
You can see the bad link [here](https://doc.rust-lang.org/std/cmp/trait.PartialEq.html) (Second sentence, "floating point types implement PartialEq but not Eq").
Yuki Okushi [Mon, 11 Jan 2021 22:59:10 +0000 (07:59 +0900)]
Rollup merge of #80324 - Aaron1011:loop-move-fn-self, r=oli-obk
Explain method-call move errors in loops
PR #73708 added a more detailed explanation of move errors that occur
due to a call to a method that takes `self`. This PR extends that logic
to work when a move error occurs due to a method call in the previous
iteration of a loop.
Yuki Okushi [Mon, 11 Jan 2021 22:59:08 +0000 (07:59 +0900)]
Rollup merge of #80042 - sivadeilra:cold_bits, r=oli-obk
Split a func into cold/hot parts, reducing binary size
I noticed that the Size::bits function is called in many places,
and is inlined into them. On x86_64-pc-windows-msvc, this function
is inlined 527 times, and compiled separately (non-inlined) 3 times.
Each of those inlined calls contains code that panics. This commit
moves the `panic!` call into a separate function and marks that
function with `#[cold]`.
This reduces binary size by 24 KB. Not much, but it's something.
Changes like this often reduce pressure on instruction-caches,
since it reduces the amount of code that is inlined into hot code
paths. Or more precisely, it removes cold code from hot cache lines.
Yuki Okushi [Mon, 11 Jan 2021 22:58:59 +0000 (07:58 +0900)]
Rollup merge of #79997 - coolreader18:wasm-reactor, r=alexcrichton
Emit a reactor for cdylib target on wasi
Fixes #79199, and relevant to #73432
Implements wasi reactors, as described in WebAssembly/WASI#13 and [`design/application-abi.md`](https://github.com/WebAssembly/WASI/blob/master/design/application-abi.md)
I went with repurposing cdylib because I figured that it doesn't make much sense to have a wasi shared library that can't be initialized, and even if someone was using it adding an `_initialize` export is a very small change.
bors [Mon, 11 Jan 2021 18:50:53 +0000 (18:50 +0000)]
Auto merge of #75490 - LukasKalbertodt:add-basic-array-methods, r=dtolnay
Add `[T; N]::each_ref` and `[T; N]::each_mut`
This PR adds the methods `each_ref` and `each_mut` to `[T; N]`. The ability to add methods to arrays was added in #75212. These two methods are particularly useful with `map` which was also added in that PR. Tracking issue: #76118
Lukas Kalbertodt [Wed, 12 Aug 2020 22:19:53 +0000 (00:19 +0200)]
Add `[T; N]::each_ref` and `[T; N]::each_mut`
These methods work very similarly to `Option`'s methods `as_ref` and
`as_mut`. They are useful in several situation, particularly when
calling other array methods (like `map`) on the result. Unfortunately,
we can't easily call them `as_ref` and `as_mut` as that would shadow
those methods on slices, thus being a breaking change (that is likely
to affect a lot of code).
bors [Mon, 11 Jan 2021 06:09:50 +0000 (06:09 +0000)]
Auto merge of #80905 - JohnTitor:rollup-tmmwmnb, r=JohnTitor
Rollup of 6 pull requests
Successful merges:
- #80809 (Use standard formatting for "rust-call" ABI message)
- #80872 (Fix typo in source-based-code-coverage.md)
- #80878 (Add ABI argument to `find_mir_or_eval_fn`)
- #80881 ( Fix intra-doc links to `Self` and `crate` )
- #80887 (log-color: Detect TTY based on stderr, not stdout)
- #80892 (rustdoc: Remove `*` intra-doc alias for `pointer`)
Yuki Okushi [Mon, 11 Jan 2021 05:34:54 +0000 (14:34 +0900)]
Rollup merge of #80892 - camelid:intra-doc-remove-star, r=jyn514
rustdoc: Remove `*` intra-doc alias for `pointer`
It's not valid Rust code and it can easily be confused with a wildcard
glob pattern or something else. People can always use `pointer` instead,
so it's just removing an alias.
It hasn't hit stable yet (I think it's still on nightly), so it's okay
to remove it. (We can always add it back later if we change our mind
too.)
r? `@jyn514`
cc https://github.com/rust-lang/rust/pull/80885#discussion_r554622737
Camelid [Sun, 10 Jan 2021 23:40:20 +0000 (15:40 -0800)]
rustdoc: Remove `*` intra-doc alias for `pointer`
It's not valid Rust code and it can easily be confused with a wildcard
glob pattern or something else. People can always use `pointer` instead,
so it's just removing an alias.
It hasn't hit stable yet (I think it's still on nightly), so it's okay
to remove it. (We can always add it back later if we change our mind
too.)
bors [Sun, 10 Jan 2021 23:36:33 +0000 (23:36 +0000)]
Auto merge of #80782 - petrochenkov:viscopes, r=matthewjasper
resolve: Scope visiting doesn't need an `Ident`
Resolution scope visitor (`fn visit_scopes`) currently takes an `Ident` parameter, but it doesn't need a full identifier, or even its span, it only needs the `SyntaxContext` part.
The `SyntaxContext` part is necessary because scope visitor has to jump to macro definition sites, so it has to be directed by macro expansion information somehow.
I think it's clearer to pass only the necessary part.
Yes, usually visiting happens as a part of an identifier resolution, but in cases like collecting traits in scope (#80765) or collecting typo suggestions that's not the case.
bors [Sun, 10 Jan 2021 10:48:55 +0000 (10:48 +0000)]
Auto merge of #80391 - ssomers:btree_cleanup_slices_3, r=Mark-Simulacrum
BTreeMap: tougher checking on most uses of copy_nonoverlapping
Miri checks pointer provenance and destination, but we can check it in debug builds already.
Also, we can let Miri confirm we don't mistake imprints of moved keys and values as genuine.
r? `@Mark-Simulacrum`
Yuki Okushi [Sun, 10 Jan 2021 07:56:05 +0000 (16:56 +0900)]
Rollup merge of #80850 - m-ou-se:rustc-builtin-macro-name, r=petrochenkov
Allow #[rustc_builtin_macro = "name"]
This adds the option of specifying the name of a builtin macro in the `#[rustc_builtin_macro]` attribute: `#[rustc_builtin_macro = "name"]`.
This makes it possible to have both `std::panic!` and `core::panic!` as a builtin macro, by using different builtin macro names for each. This is needed to implement the edition-specific behaviour of the panic macros of RFC 3007.
Also removes `SyntaxExtension::is_derive_copy`, as the macro name (e.g. `sym::Copy`) is now tracked and provides that information directly.
Yuki Okushi [Sun, 10 Jan 2021 07:56:03 +0000 (16:56 +0900)]
Rollup merge of #80825 - GuillaumeGomez:rustdoc-cleanup-bis-repetita, r=jyn514
Remove under-used ImplPolarity enum
It doesn't make much sense to have an enum with only two possible values and to store it inside an `Option` in my opinion when you can do all the same with a simple boolean. I don't expect any chances, performance or RSS usage wise.
Yuki Okushi [Sun, 10 Jan 2021 07:55:57 +0000 (16:55 +0900)]
Rollup merge of #80774 - LingMan:patch-1, r=nagisa
Fix safety comment
The size assertion in the comment was inverted compared to the code. After fixing that the implication that `(new_size >= old_size) => new_size != 0` still doesn't hold so explain why `old_size != 0` at this point.
Yuki Okushi [Sun, 10 Jan 2021 07:55:53 +0000 (16:55 +0900)]
Rollup merge of #79502 - Julian-Wollersberger:from_char_for_u64, r=withoutboats
Implement From<char> for u64 and u128.
With this PR you can write
```
let u = u64::from('👤');
let u = u128::from('👤');
```
Previously, you could already write `as` conversions ([Playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=cee18febe28e69024357d099f07ca081)):
```
// Lossless conversions
dbg!('👤' as u32); // Prints 128100
dbg!('👤' as u64); // Prints 128100
dbg!('👤' as u128); // Prints 128100
// truncates, thus no `From` impls.
dbg!('👤' as u8); // Prints 100
dbg!('👤' as u16); // Prints 62564
// These `From` impls already exist.
dbg!(u32::from('👤')); // Prints 128100
dbg!(u64::from(u32::from('👤'))); // Prints 128100
```
The idea is from ``@gendx`` who opened [this Internals thread](https://internals.rust-lang.org/t/implement-from-char-for-u64/13454), and ``@withoutboats`` responded that someone should open a PR for it.
Some people mentioned `From<char>` impls for `f32` and `f64`, but that doesn't seem correct to me, so I didn't include them here.
I don't know what the feature should be named. Must it be registered somewhere, like unstable features?
bors [Sun, 10 Jan 2021 05:15:01 +0000 (05:15 +0000)]
Auto merge of #77862 - danielhenrymantilla:rustdoc/fix-macros_2_0-paths, r=jyn514,petrochenkov
Rustdoc: Fix macros 2.0 and built-in derives being shown at the wrong path
Fixes #74355
- ~~waiting on author + draft PR since my code ought to be cleaned up _w.r.t._ the way I avoid the `.unwrap()`s:~~
- ~~dummy items may avoid the first `?`,~~
- ~~but within the module traversal some tests did fail (hence the second `?`), meaning the crate did not possess the exact path of the containing module (`extern` / `impl` blocks maybe? I'll look into that).~~
bors [Sun, 10 Jan 2021 01:08:41 +0000 (01:08 +0000)]
Auto merge of #80831 - jyn514:no-inline, r=Mark-Simulacrum
Don't mark `force_query_with_job` as `inline(always)`
It's rather large, and using `inline(always)` forces it to be recompiled
in each calling crate. Hopefully this change will help with #65031. I intentionally only removed inline from `force_query_with_job` because the other functions are tiny and I wanted to measure this change on its own.
This may conflict with https://github.com/rust-lang/rust/issues/78780. I am not sure if it will hurt or help.
bors [Sat, 9 Jan 2021 19:33:23 +0000 (19:33 +0000)]
Auto merge of #80830 - Aaron1011:capture-token-empty-stack, r=petrochenkov
Use an empty `TokenCursorFrame` stack when capturing tokens
We will never need to pop past our starting frame during token
capturing. Using an empty stack allows us to avoid pointless heap
allocations/deallocations.
bors [Sat, 9 Jan 2021 16:46:54 +0000 (16:46 +0000)]
Auto merge of #80563 - petrochenkov:expattronmac, r=Aaron1011
resolve/expand: Improve attribute expansion on macro definitions and calls
- Do not forget to visit attributes on macro definitions and calls in couple of places.
- Remove some weird special treatment of macro definition items, which is probably left from old times when macro definitions were treated more like macro calls.
bors [Sat, 9 Jan 2021 11:06:46 +0000 (11:06 +0000)]
Auto merge of #80797 - pietroalbini:fix-relative-install, r=Mark-Simulacrum
Fix x.py install not working with relative prefix
The code powering `./x.py install` did not handle relative paths well: the installation script is executed inside a temporary directory, so all the relative paths specified in `config.toml` and in the `DESTDIR` environment variable were relative to that temporary directory. The original code fixed the problem for `config.toml` paths by canonicalizing the prefix, but breaking `DESTDIR`. https://github.com/rust-lang/rust/pull/80240 fixed the `DESTDIR` problem, but also regressed `config.toml` paths (#80683).
This PR refactors the installation code to generate paths that *in my understanding* are correct, adding comments in the meantime to explain what each step does. There was no documentation on why choices were made before, so my understanding could actually be wrong.
Regardless, executed `./x.py install` with various combinations of `config.toml` and `DESTDIR` paths, and everything seems to work according to my understanding. Still, I'd love if `@vext01` and `@yshui` could test these changes.
bors [Sat, 9 Jan 2021 07:48:53 +0000 (07:48 +0000)]
Auto merge of #80755 - sunfishcode:path-cleanup/copy, r=nagisa
Optimize away some path lookups in the generic `fs::copy` implementation
This also eliminates a use of a `Path` convenience function, in support
of #80741, refactoring `std::path` to focus on pure data structures and
algorithms.
bors [Sat, 9 Jan 2021 04:36:24 +0000 (04:36 +0000)]
Auto merge of #80749 - as-com:target-cpu-actually-native, r=nagisa
Make target-cpu=native detect individual features
This PR makes target-cpu=native check for and enable/disable individual features instead of detecting and targeting a CPU by name. This brings the flag's behavior more in line with clang and gcc and ensures that the host actually supports each feature that we are compiling for.
This should resolve issues with miscompilations on e.g. "Haswell" Pentiums and Celerons that lack support for AVX, and also enable support for `aes` on Broadwell processors that support it. It should also resolve issues with failing to detect feature support in newer CPUs that aren't yet known by LLVM (see: #80633).
Aaron Hill [Fri, 8 Jan 2021 23:16:20 +0000 (18:16 -0500)]
Use an empty `TokenCursorFrame` stack when capturing tokens
We will never need to pop past our starting frame during token
capturing. Using an empty stack allows us to avoid pointless heap
allocations/deallocations.
Aaron Hill [Wed, 23 Dec 2020 03:15:40 +0000 (22:15 -0500)]
Explain method-call move errors in loops
PR #73708 added a more detailed explanation of move errors that occur
due to a call to a method that takes `self`. This PR extends that logic
to work when a move error occurs due to a method call in the previous
iteration of a loop.
bors [Fri, 8 Jan 2021 18:16:00 +0000 (18:16 +0000)]
Auto merge of #78452 - cjgillot:ddk-struct, r=Mark-Simulacrum
Access query (DepKind) metadata through fields
This refactors the access to query definition metadata (attributes such as eval always, anon, has_params) and loading/forcing functions to generate a number of structs, instead of matching on the DepKind enum. This makes access to the fields cheaper to compile. Using a struct means that finding the metadata for a given query is just an offset away; previously the match may have been compiled to a jump table but likely not completely inlined as we expect here.
A previous attempt explored a similar strategy, but using trait objects in #78314 that proved less effective, likely due to higher overheads due to forcing dynamic calls and poorer cache utilization (all metadata is fairly densely packed with this PR).
bors [Fri, 8 Jan 2021 12:34:20 +0000 (12:34 +0000)]
Auto merge of #80653 - jryans:doc-deref-recursive, r=jyn514,GuillaumeGomez
Recursively document methods via `Deref` traits
This changes `rustdoc` to recursively follow `Deref` targets so that methods from all levels are added to the rendered output. This implementation displays the methods from all levels in the expanded state with separate sections for each level.
This adjusts the `rustdoc` trait impl collection path to preserve `Deref` impls
from other crates. This adds a first pass to map all of the `Deref` type to
target edges and then recursively preserves all targets.