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 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.
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.
bors [Fri, 8 Jan 2021 07:01:30 +0000 (07:01 +0000)]
Auto merge of #80756 - sunfishcode:path-cleanup/rustc-incremental, r=nagisa
Optimize away some `fs::metadata` calls.
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 [Fri, 8 Jan 2021 03:09:03 +0000 (03:09 +0000)]
Auto merge of #80806 - JohnTitor:rollup-y64z7ph, r=JohnTitor
Rollup of 7 pull requests
Successful merges:
- #79675 (Make sure rust-call errors occur correctly for traits)
- #80372 (Don't panic when an external crate can't be resolved)
- #80761 (handle generic trait methods in coverage-report tests)
- #80785 (rustc_ast_pretty: Remove `PrintState::insert_extra_parens`)
- #80791 (Fix type name in doc example for Iter and IterMut)
- #80794 (Use Option::map_or instead of `.map(..).unwrap_or(..)`)
- #80799 (Get rid of custom pretty-printing in rustdoc)
Yuki Okushi [Fri, 8 Jan 2021 02:11:34 +0000 (11:11 +0900)]
Rollup merge of #79675 - CraftSpider:79669, r=estebank
Make sure rust-call errors occur correctly for traits
Fixes #79669
Adds trait method resolution to the error, and adds UI tests to ensure it doesn't happen again. Opening as draft because I'm getting weird link errors from unrelated code on my machine, and want to see what CI thinks.
bors [Fri, 8 Jan 2021 00:20:06 +0000 (00:20 +0000)]
Auto merge of #80746 - ehuss:update-cargo, r=ehuss
Update cargo
12 commits in 75d5d8cffe3464631f82dcd3c470b78dc1dda8bb..329895f5b52a358e5d9ecb26215708b5cb31d906
2020-12-22 18:10:56 +0000 to 2021-01-06 00:01:52 +0000
- metadata: Supply local path for path dependencies (rust-lang/cargo#8994)
- Add support for Rust edition 2021. (rust-lang/cargo#8922)
- Stabilize -Zfeatures and -Zpackage-features. (rust-lang/cargo#8997)
- Small refactor, adding a list of all kinds to BuildContext (rust-lang/cargo#9046)
- Fix git http.proxy config setting. (rust-lang/cargo#8986)
- Clarify the help text of `--aggressive` and `--precise` of `update` (rust-lang/cargo#9031)
- Assert that tests are run in the crate directory (rust-lang/cargo#9037)
- Update mdbook (rust-lang/cargo#9044)
- Bump to 0.52.0, update changelog (rust-lang/cargo#9042)
- Fix redundant semicolon. (rust-lang/cargo#9033)
- Clarify fingerprint log messages (rust-lang/cargo#9026)
- Update credential docs for gnome-secret. (rust-lang/cargo#9013)
Yuki Okushi [Thu, 7 Jan 2021 17:06:20 +0000 (02:06 +0900)]
Rollup merge of #80784 - petrochenkov:nontspan, r=Aaron1011
rustc_parse: Better spans for synthesized token streams
I think using the nonterminal span for synthesizing its tokens is a better approximation than using `DUMMY_SP` or the attribute span like #79472 did in `expand.rs`.
Yuki Okushi [Thu, 7 Jan 2021 17:06:16 +0000 (02:06 +0900)]
Rollup merge of #80769 - ejez:patch-1, r=jonas-schievink
Improve wording of parse doc
Change:
```
`parse` can parse any type that...
```
to:
```
`parse` can parse into any type that...
```
Word `into` added to be more precise and in coherence with other parts of the doc.
Yuki Okushi [Thu, 7 Jan 2021 17:06:11 +0000 (02:06 +0900)]
Rollup merge of #80738 - arusahni:master, r=GuillaumeGomez
Remove bottom margin from crate version when the docs sidebar is collapsed
This fixes a mobile UI bug where a vertical scrollbar would always be
rendered on the sidebar nav when the menu was closed. When opened, the overflow would be handled by the opened sidebar, causing the scrollbar to disappear, and the contents to shift to the right.
bors [Thu, 7 Jan 2021 15:21:30 +0000 (15:21 +0000)]
Auto merge of #77853 - ijackson:slice-strip-stab, r=Amanieu
Stabilize slice::strip_prefix and slice::strip_suffix
These two methods are useful. The corresponding methods on `str` are already stable.
I believe that stablising these now would not get in the way of, in the future, extending these to take a richer pattern API a la `str`'s patterns.
Tracking PR: #73413. I also have an outstanding PR to improve the docs for these two functions and the corresponding ones on `str`: #75078
I have tried to follow the [instructions in the dev guide](https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr). The part to do with `compiler/rustc_feature` did not seem applicable. I assume that's because these are just library features, so there is no corresponding machinery in rustc.
bors [Thu, 7 Jan 2021 11:22:42 +0000 (11:22 +0000)]
Auto merge of #79863 - JohnTitor:compiler-builtins, r=bjorn3
Update `compiler_builtins` to 0.1.39
This version contains the fixes of https://github.com/rust-lang/compiler-builtins/issues/390 and https://github.com/rust-lang/compiler-builtins/issues/391.
Also, rename features following https://github.com/rust-lang/compiler-builtins/pull/386.
LingMan [Thu, 7 Jan 2021 08:13:21 +0000 (09:13 +0100)]
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.
Ejez [Thu, 7 Jan 2021 04:47:03 +0000 (07:47 +0300)]
Improve wording of parse doc
Change:
```
`parse` can parse any type that...
```
to:
```
`parse` can parse into any type that...
```
Word `into` added to be more precise and in coherence with other parts of the doc.
bors [Wed, 6 Jan 2021 21:48:06 +0000 (21:48 +0000)]
Auto merge of #80754 - sunfishcode:path-cleanup/rustc-fs-util, r=davidtwco
Optimize away a `fs::metadata` call.
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.
Camelid [Mon, 28 Dec 2020 00:54:47 +0000 (16:54 -0800)]
Rename to `nearest_parent_mod`
* Rename `ModuleData.normal_ancestor_id` to `nearest_parent_mod`
`normal_ancestor_id` is a very confusing name if you don't already
understand what it means. Adding docs helps, but using a clearer and
more obvious name is also important.
* Rename `Resolver::nearest_mod_parent` to `nearest_parent_mod`
Dan Gohman [Wed, 6 Jan 2021 02:00:38 +0000 (18:00 -0800)]
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.
Dan Gohman [Wed, 6 Jan 2021 16:20:58 +0000 (08:20 -0800)]
Optimize away a `fs::metadata` call.
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.
Dan Gohman [Wed, 6 Jan 2021 16:31:25 +0000 (08:31 -0800)]
Optimize away some `fs::metadata` calls.
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.