]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoMove directly when Rc/Arc::make_mut splits from Weak
Josh Stone [Tue, 12 Jan 2021 01:32:21 +0000 (17:32 -0800)]
Move directly when Rc/Arc::make_mut splits from Weak

When only other `Weak` references remain, we can directly move the data
into the new unique allocation as a plain memory copy.

3 years agoSpecialize Rc/Arc::make_mut clones to try to avoid locals
Josh Stone [Fri, 8 Jan 2021 21:02:27 +0000 (13:02 -0800)]
Specialize Rc/Arc::make_mut clones to try to avoid locals

As we did with `Box`, we can allocate an uninitialized `Rc` or `Arc`
beforehand, giving the optimizer a chance to skip the local value for
regular clones, or avoid any local altogether for `T: Copy`.

3 years agoSpecialize Box clones to try to avoid locals
Josh Stone [Fri, 8 Jan 2021 21:02:23 +0000 (13:02 -0800)]
Specialize Box clones to try to avoid locals

For generic `T: Clone`, we can allocate an uninitialized box beforehand,
which gives the optimizer a chance to create the clone directly in the
heap. For `T: Copy`, we can go further and do a simple memory copy,
regardless of optimization level.

3 years agoAuto merge of #79012 - tgnottingham:span_data_to_lines_and_cols, r=estebank
bors [Mon, 11 Jan 2021 21:32:50 +0000 (21:32 +0000)]
Auto merge of #79012 - tgnottingham:span_data_to_lines_and_cols, r=estebank

rustc_span: add span_data_to_lines_and_cols to caching source map view

3 years agoAuto merge of #75490 - LukasKalbertodt:add-basic-array-methods, r=dtolnay
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

```rust
impl<T, const N: usize> [T; N] {
    pub fn each_ref(&self) -> [&T; N];
    pub fn each_mut(&mut self) -> [&mut T; N];
}
```

3 years agoAuto merge of #80889 - cjgillot:asa, r=oli-obk
bors [Mon, 11 Jan 2021 14:54:52 +0000 (14:54 +0000)]
Auto merge of #80889 - cjgillot:asa, r=oli-obk

Do not query the HIR directly in `opt_associated_item`.

Papercut found by `@Aaron1011.`

3 years agoAdd `[T; N]::each_ref` and `[T; N]::each_mut`
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).

3 years agoAuto merge of #80905 - JohnTitor:rollup-tmmwmnb, r=JohnTitor
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`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #80892 - camelid:intra-doc-remove-star, r=jyn514
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

3 years agoRollup merge of #80887 - camelid:fix-log-color-auto, r=RalfJung
Yuki Okushi [Mon, 11 Jan 2021 05:34:52 +0000 (14:34 +0900)]
Rollup merge of #80887 - camelid:fix-log-color-auto, r=RalfJung

log-color: Detect TTY based on stderr, not stdout

Fixes #78435 (again).

Logging goes to stderr, not stdout, so we should base our automated
detection on stderr instead of stdout.

Thanks to Ralf Jung for noticing and reporting the bug!

r? `@oli-obk`
cc `@RalfJung`

3 years agoRollup merge of #80881 - jyn514:intra-doc-self, r=GuillaumeGomez
Yuki Okushi [Mon, 11 Jan 2021 05:34:51 +0000 (14:34 +0900)]
Rollup merge of #80881 - jyn514:intra-doc-self, r=GuillaumeGomez

 Fix intra-doc links to `Self` and `crate`

Closes https://github.com/rust-lang/rust/issues/77732.

3 years agoRollup merge of #80878 - unseddd:abi, r=RalfJung
Yuki Okushi [Mon, 11 Jan 2021 05:34:49 +0000 (14:34 +0900)]
Rollup merge of #80878 - unseddd:abi, r=RalfJung

Add ABI argument to `find_mir_or_eval_fn`

Add ABI argument for called function in `find_mir_or_eval_fn` and
`call_extra_fn`. Useful for comparing with expected ABI in interpreters.

Related to [miri/1631](https://github.com/rust-lang/miri/issues/1631)

r? `@RalfJung`

3 years agoRollup merge of #80872 - eltociear:patch-4, r=jonas-schievink
Yuki Okushi [Mon, 11 Jan 2021 05:34:47 +0000 (14:34 +0900)]
Rollup merge of #80872 - eltociear:patch-4, r=jonas-schievink

Fix typo in source-based-code-coverage.md

preceeding -> preceding

3 years agoRollup merge of #80809 - camelid:rust-call-abi-msg, r=lcnr
Yuki Okushi [Mon, 11 Jan 2021 05:34:40 +0000 (14:34 +0900)]
Rollup merge of #80809 - camelid:rust-call-abi-msg, r=lcnr

Use standard formatting for "rust-call" ABI message

Nearly all error messages start with a lowercase letter and don't use
articles - instead they refer to the plural case.

3 years agoAuto merge of #80818 - 12101111:system-libunwind, r=Mark-Simulacrum
bors [Mon, 11 Jan 2021 03:24:14 +0000 (03:24 +0000)]
Auto merge of #80818 - 12101111:system-libunwind, r=Mark-Simulacrum

Don't build in-tree llvm-libunwind if system-llvm-libunwind is enable

When "system-llvm-libunwind" is enabled, some target eg. musl still build in-tree llvm-libunwind which is useless.

3 years agorustdoc: Remove `*` intra-doc alias for `pointer`
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.)

3 years agoAuto merge of #80782 - petrochenkov:viscopes, r=matthewjasper
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.

r? `@matthewjasper`

3 years agoDo not query the HIR in `opt_associated_item`.
Camille GILLOT [Sun, 10 Jan 2021 21:41:50 +0000 (22:41 +0100)]
Do not query the HIR in `opt_associated_item`.

3 years agolog-color: Detect TTY based on stderr, not stdout
Camelid [Sun, 10 Jan 2021 21:16:06 +0000 (13:16 -0800)]
log-color: Detect TTY based on stderr, not stdout

Logging goes to stderr, not stdout, so we should base our automated
detection on stderr instead of stdout.

Thanks to Ralf Jung for noticing and reporting the bug!

3 years agoAuto merge of #79414 - sasurau4:feature/add-suggestion-for-pattern-in-fns-without...
bors [Sun, 10 Jan 2021 20:48:27 +0000 (20:48 +0000)]
Auto merge of #79414 - sasurau4:feature/add-suggestion-for-pattern-in-fns-without-body, r=matthewjasper

Add suggestion for PATTERNS_IN_FNS_WITHOUT_BODY

## Overview

Fix #78927

3 years agoUse standard formatting for "rust-call" ABI message
Camelid [Fri, 8 Jan 2021 05:21:21 +0000 (21:21 -0800)]
Use standard formatting for "rust-call" ABI message

Nearly all error messages start with a lowercase letter and don't use
articles - instead they refer to the plural case.

3 years agoAuto merge of #80789 - Aaron1011:fix/stmt-empty, r=petrochenkov
bors [Sun, 10 Jan 2021 17:58:38 +0000 (17:58 +0000)]
Auto merge of #80789 - Aaron1011:fix/stmt-empty, r=petrochenkov

Synthesize a `TokenStream` for `StmtKind::Empty`

Fixes #80760

3 years agoAdd ABI argument to `find_mir_or_eval_fn`
Nym Seddon [Sun, 10 Jan 2021 14:31:02 +0000 (14:31 +0000)]
Add ABI argument to `find_mir_or_eval_fn`

Add ABI argument for called function in `find_mir_or_eval_fn` and
`call_extra_fn`. Useful for comparing with expected ABI in interpreters.

Related to [miri/1631](https://github.com/rust-lang/miri/issues/1631)

3 years agoSmall cleanups
Joshua Nelson [Sun, 10 Jan 2021 15:00:41 +0000 (10:00 -0500)]
Small cleanups

3 years agoFix intra-doc links to `Self` and `crate`
Joshua Nelson [Sun, 10 Jan 2021 15:00:17 +0000 (10:00 -0500)]
Fix intra-doc links to `Self` and `crate`

3 years agoFix typo in source-based-code-coverage.md
Ikko Ashimine [Sun, 10 Jan 2021 13:17:51 +0000 (22:17 +0900)]
Fix typo in source-based-code-coverage.md

preceeding -> preceding

3 years agoAuto merge of #80391 - ssomers:btree_cleanup_slices_3, r=Mark-Simulacrum
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`

3 years agoAuto merge of #80867 - JohnTitor:rollup-tvqw555, r=JohnTitor
bors [Sun, 10 Jan 2021 08:01:12 +0000 (08:01 +0000)]
Auto merge of #80867 - JohnTitor:rollup-tvqw555, r=JohnTitor

Rollup of 9 pull requests

Successful merges:

 - #79502 (Implement From<char> for u64 and u128.)
 - #79968 (Improve core::ptr::drop_in_place debuginfo)
 - #80774 (Fix safety comment)
 - #80801 (Use correct span for structured suggestion)
 - #80803 (Remove useless `fill_in` function)
 - #80820 (Support `download-ci-llvm` on NixOS)
 - #80825 (Remove under-used ImplPolarity enum)
 - #80850 (Allow #[rustc_builtin_macro = "name"])
 - #80857 (Add comment to `Vec::truncate` explaining `>` vs `>=`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoRollup merge of #80857 - camelid:vec-truncate-comment, r=scottmcm
Yuki Okushi [Sun, 10 Jan 2021 07:56:07 +0000 (16:56 +0900)]
Rollup merge of #80857 - camelid:vec-truncate-comment, r=scottmcm

Add comment to `Vec::truncate` explaining `>` vs `>=`

Hopefully this will prevent people from continuing to ask about this
over and over again :)

See [this Zulip discussion][1] for more.

[1]: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Vec.3A.3Atruncate.20implementation

r? ``@scottmcm``

3 years agoRollup merge of #80850 - m-ou-se:rustc-builtin-macro-name, r=petrochenkov
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.

r? ``@petrochenkov``

3 years agoRollup merge of #80825 - GuillaumeGomez:rustdoc-cleanup-bis-repetita, r=jyn514
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.

r? ``@jyn514``

3 years agoRollup merge of #80820 - nagisa:nagisa/dcl-nixos, r=Mark-Simulacrum
Yuki Okushi [Sun, 10 Jan 2021 07:56:02 +0000 (16:56 +0900)]
Rollup merge of #80820 - nagisa:nagisa/dcl-nixos, r=Mark-Simulacrum

Support `download-ci-llvm` on NixOS

In particular, the CI built `libLLVM-*.so` needs to have `libz.so`
RPATHed so that binaries like `llvm-config` work at all.

3 years agoRollup merge of #80803 - jyn514:cleanup-fill-in, r=GuillaumeGomez
Yuki Okushi [Sun, 10 Jan 2021 07:56:00 +0000 (16:56 +0900)]
Rollup merge of #80803 - jyn514:cleanup-fill-in, r=GuillaumeGomez

Remove useless `fill_in` function

It was only used once, in a function that was otherwise trivial.

3 years agoRollup merge of #80801 - estebank:correct-binding-sugg-span, r=petrochenkov
Yuki Okushi [Sun, 10 Jan 2021 07:55:59 +0000 (16:55 +0900)]
Rollup merge of #80801 - estebank:correct-binding-sugg-span, r=petrochenkov

Use correct span for structured suggestion

On structured suggestion for `let` -> `const`  and `const` -> `let`, use
a proper `Span` and update tests to check the correct application.

Follow up to #80012.

3 years agoRollup merge of #80774 - LingMan:patch-1, r=nagisa
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.

3 years agoRollup merge of #79968 - bjorn3:better_drop_glue_debuginfo, r=matthewjasper
Yuki Okushi [Sun, 10 Jan 2021 07:55:55 +0000 (16:55 +0900)]
Rollup merge of #79968 - bjorn3:better_drop_glue_debuginfo, r=matthewjasper

Improve core::ptr::drop_in_place debuginfo

* Use span of the dropped type as function span when possible.
* Rename symbol from `core::ptr::drop_in_place::$hash` to `{{drop}}::<$TYPE>::$hash`.

Fixes #77465

(I haven't yet updated the tests)

3 years agoRollup merge of #79502 - Julian-Wollersberger:from_char_for_u64, r=withoutboats
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?

r? ``@withoutboats``

3 years agoAuto merge of #77862 - danielhenrymantilla:rustdoc/fix-macros_2_0-paths, r=jyn514...
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).~~

r? `@jyn514`

3 years agoAuto merge of #80831 - jyn514:no-inline, r=Mark-Simulacrum
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.

cc `@cjgillot`

3 years agoAuto merge of #80441 - petrochenkov:kwtok, r=Aaron1011
bors [Sat, 9 Jan 2021 22:19:46 +0000 (22:19 +0000)]
Auto merge of #80441 - petrochenkov:kwtok, r=Aaron1011

ast: Remove some indirection layers from values in key-value attributes

Trying to address some perf regressions from https://github.com/rust-lang/rust/pull/78837#issuecomment-745380762.

3 years agoAdd comment to `Vec::truncate` explaining `>` vs `>=`
Camelid [Sat, 9 Jan 2021 20:35:47 +0000 (12:35 -0800)]
Add comment to `Vec::truncate` explaining `>` vs `>=`

Hopefully this will prevent people from continuing to ask about this
over and over again :)

See [this Zulip discussion][1] for more.

[1]: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Vec.3A.3Atruncate.20implementation

3 years agoSynthesize a `TokenStream` for `StmtKind::Empty`
Aaron Hill [Thu, 7 Jan 2021 16:43:21 +0000 (11:43 -0500)]
Synthesize a `TokenStream` for `StmtKind::Empty`

Fixes #80760

3 years agoAuto merge of #80830 - Aaron1011:capture-token-empty-stack, r=petrochenkov
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.

3 years agoDon't set builtin_name for builtin macro implementations.
Mara Bos [Sat, 9 Jan 2021 19:24:23 +0000 (19:24 +0000)]
Don't set builtin_name for builtin macro implementations.

This used to be necessary for `is_builtin` in the past, but is no longer required.

Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
3 years agoast: Remove some indirection layers from values in key-value attributes
Vadim Petrochenkov [Sat, 19 Dec 2020 20:38:22 +0000 (23:38 +0300)]
ast: Remove some indirection layers from values in key-value attributes

3 years agoFormatting.
Mara Bos [Sat, 9 Jan 2021 15:54:12 +0000 (16:54 +0100)]
Formatting.

3 years agoAllow #[rustc_builtin_macro = "name"].
Mara Bos [Sat, 9 Jan 2021 15:48:58 +0000 (16:48 +0100)]
Allow #[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.

Also removes SyntaxExtension::is_derive_copy, as the macro name (e.g.
sym::Copy) is now tracked and provides that information directly.

3 years agoAuto merge of #80563 - petrochenkov:expattronmac, r=Aaron1011
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.

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

3 years agoSupport `download-ci-llvm` on NixOS
Simonas Kazlauskas [Fri, 8 Jan 2021 19:21:30 +0000 (21:21 +0200)]
Support `download-ci-llvm` on NixOS

In particular, the CI built `libLLVM-*.so` needs to have `libz.so`
RPATHed so that binaries like `llvm-config` work at all.

3 years agoresolve/expand: Improve attribute expansion on macro definitions and calls
Vadim Petrochenkov [Thu, 31 Dec 2020 14:59:09 +0000 (17:59 +0300)]
resolve/expand: Improve attribute expansion on macro definitions and calls

3 years agoReplace under-used ImplPolarity enum with a boolean
Guillaume Gomez [Fri, 8 Jan 2021 21:54:35 +0000 (22:54 +0100)]
Replace under-used ImplPolarity enum with a boolean

3 years agoAuto merge of #80808 - CAD97:patch-3, r=nagisa
bors [Sat, 9 Jan 2021 13:56:15 +0000 (13:56 +0000)]
Auto merge of #80808 - CAD97:patch-3, r=nagisa

Fix typo in Step trait

... I don't know how this major typo happened, whoops ðŸ™ƒ

`@bors` rollup=always
(comment only change)

3 years agoUpdate the stabilisation version.
Julian Wollersberger [Sat, 9 Jan 2021 11:31:30 +0000 (12:31 +0100)]
Update the stabilisation version.

3 years agoAuto merge of #80797 - pietroalbini:fix-relative-install, r=Mark-Simulacrum
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.

r? `@Mark-Simulacrum`
`@rustbot` modify labels: beta-nominated T-infra

3 years agoAuto merge of #80755 - sunfishcode:path-cleanup/copy, r=nagisa
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.

3 years agoDon't build in-tree llvm-libunwind if system-llvm-libunwind is enable
12101111 [Fri, 8 Jan 2021 18:23:02 +0000 (02:23 +0800)]
Don't build in-tree llvm-libunwind if system-llvm-libunwind is enable

3 years agoAuto merge of #80749 - as-com:target-cpu-actually-native, r=nagisa
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).

Fixes #54688
Fixes #48464
Fixes #38218

3 years agoDon't mark `force_query_with_job` as `inline(always)`
Joshua Nelson [Fri, 8 Jan 2021 23:38:33 +0000 (18:38 -0500)]
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.

3 years agoUse an empty `TokenCursorFrame` stack when capturing tokens
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.

3 years agoAdd doc comment explaining what the second Array's field is about
Guillaume Gomez [Fri, 8 Jan 2021 21:43:53 +0000 (22:43 +0100)]
Add doc comment explaining what the second Array's field is about

3 years agoBTreeMap: tougher checks on most uses of copy_nonoverlapping
Stein Somers [Mon, 23 Nov 2020 13:41:53 +0000 (14:41 +0100)]
BTreeMap: tougher checks on most uses of copy_nonoverlapping

3 years agoAuto merge of #78452 - cjgillot:ddk-struct, r=Mark-Simulacrum
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).

3 years agoCheck is_anon outside of can_reconstruct_query_key.
Camille GILLOT [Wed, 6 Jan 2021 17:54:27 +0000 (18:54 +0100)]
Check is_anon outside of can_reconstruct_query_key.

3 years agoMake DepConstructor a module.
Camille GILLOT [Fri, 25 Dec 2020 18:07:28 +0000 (19:07 +0100)]
Make DepConstructor a module.

3 years agoMake force_from_dep_node a function pointer.
Camille GILLOT [Tue, 27 Oct 2020 18:33:03 +0000 (19:33 +0100)]
Make force_from_dep_node a function pointer.

3 years agoMake try_load_from_on_disk_cache a function pointer.
Camille GILLOT [Tue, 27 Oct 2020 18:22:58 +0000 (19:22 +0100)]
Make try_load_from_on_disk_cache a function pointer.

3 years agoMake can_reconstruct_query_key a function pointer.
Camille GILLOT [Tue, 27 Oct 2020 18:49:10 +0000 (19:49 +0100)]
Make can_reconstruct_query_key a function pointer.

3 years agoUse a field for has_params.
Camille GILLOT [Tue, 27 Oct 2020 17:46:43 +0000 (18:46 +0100)]
Use a field for has_params.

3 years agoUse a field for is_eval_always.
Camille GILLOT [Tue, 27 Oct 2020 17:43:49 +0000 (18:43 +0100)]
Use a field for is_eval_always.

3 years agoUse a field for is_anon.
Camille GILLOT [Fri, 20 Nov 2020 18:35:17 +0000 (19:35 +0100)]
Use a field for is_anon.

3 years agoCheck if the pointer is null/string is not utf8
Andrew Sun [Fri, 8 Jan 2021 16:50:21 +0000 (11:50 -0500)]
Check if the pointer is null/string is not utf8

3 years agoUse a side-table of consts instead of matching on the DepKind enum.
Camille GILLOT [Tue, 27 Oct 2020 17:36:11 +0000 (18:36 +0100)]
Use a side-table of consts instead of matching on the DepKind enum.

3 years agoSimplify DepNodeParams.
Camille GILLOT [Tue, 27 Oct 2020 18:54:28 +0000 (19:54 +0100)]
Simplify DepNodeParams.

3 years agoMove DepNodeExt outside of the macro.
Camille GILLOT [Sat, 24 Oct 2020 15:37:26 +0000 (17:37 +0200)]
Move DepNodeExt outside of the macro.

3 years agoAuto merge of #76896 - spastorino:codegen-inline-fns2, r=davidtwco,wesleywiser
bors [Fri, 8 Jan 2021 15:21:45 +0000 (15:21 +0000)]
Auto merge of #76896 - spastorino:codegen-inline-fns2, r=davidtwco,wesleywiser

Do not make local copies of inline fns in debug mode

r? `@wesleywiser`

cc `@rust-lang/wg-incr-comp`

If this is correct it supersedes https://github.com/rust-lang/rust/pull/76889

Related to #54089

3 years agoAuto merge of #80653 - jryans:doc-deref-recursive, r=jyn514,GuillaumeGomez
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.

![image](https://user-images.githubusercontent.com/279572/103482863-46723b00-4ddb-11eb-972b-c463351a425c.png)

Fixes https://github.com/rust-lang/rust/issues/26207
Fixes https://github.com/rust-lang/rust/issues/53038
Fixes https://github.com/rust-lang/rust/issues/71640

r? `@jyn514`

3 years agoAuto merge of #80535 - JohnTitor:improve-use-diag, r=estebank
bors [Fri, 8 Jan 2021 09:51:26 +0000 (09:51 +0000)]
Auto merge of #80535 - JohnTitor:improve-use-diag, r=estebank

Add a note for `*` and `{}` usage on `use`

Closes #80333

3 years agoAdd a note for `*` and `{}` usage on `use`
Yuki Okushi [Wed, 30 Dec 2020 22:40:54 +0000 (07:40 +0900)]
Add a note for `*` and `{}` usage on `use`

3 years agoCombine several `push_str` calls
J. Ryan Stinnett [Sun, 3 Jan 2021 17:32:48 +0000 (17:32 +0000)]
Combine several `push_str` calls

3 years agoPreserve non-local recursive `Deref` impls
J. Ryan Stinnett [Sun, 3 Jan 2021 13:13:30 +0000 (13:13 +0000)]
Preserve non-local recursive `Deref` impls

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.

3 years agoUse target in `Deref` method section IDs
J. Ryan Stinnett [Thu, 31 Dec 2020 02:45:15 +0000 (02:45 +0000)]
Use target in `Deref` method section IDs

There can now be multiple `Deref` method sections, so this adds the target type
to the section ID to ensure they are unique.

3 years agoRecursively document methods via `Deref` traits
J. Ryan Stinnett [Thu, 31 Dec 2020 02:23:19 +0000 (02:23 +0000)]
Recursively document methods via `Deref` traits

3 years agoAuto merge of #80756 - sunfishcode:path-cleanup/rustc-incremental, r=nagisa
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.

3 years agoUse LLVMGetHostCPUFeatures instead of stdsimd
Andrew Sun [Fri, 8 Jan 2021 04:25:19 +0000 (23:25 -0500)]
Use LLVMGetHostCPUFeatures instead of stdsimd

3 years agoAuto merge of #80806 - JohnTitor:rollup-y64z7ph, r=JohnTitor
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)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup

3 years agoFix typo in Step trait
Christopher Durham [Fri, 8 Jan 2021 02:29:17 +0000 (21:29 -0500)]
Fix typo in Step trait

3 years agoRollup merge of #80799 - jyn514:pretty-print, r=CraftSpider
Yuki Okushi [Fri, 8 Jan 2021 02:11:50 +0000 (11:11 +0900)]
Rollup merge of #80799 - jyn514:pretty-print, r=CraftSpider

Get rid of custom pretty-printing in rustdoc

and use rustc_hir_pretty directly instead.

Closes https://github.com/rust-lang/rust/issues/79497.

r? `@CraftSpider`

3 years agoRollup merge of #80794 - LingMan:map_or, r=jyn514
Yuki Okushi [Fri, 8 Jan 2021 02:11:48 +0000 (11:11 +0900)]
Rollup merge of #80794 - LingMan:map_or, r=jyn514

Use Option::map_or instead of `.map(..).unwrap_or(..)`

r? `@jyn514`
`@rustbot` modify labels +C-cleanup +T-rustdoc

3 years agoRollup merge of #80791 - mrcz:master, r=jyn514
Yuki Okushi [Fri, 8 Jan 2021 02:11:47 +0000 (11:11 +0900)]
Rollup merge of #80791 - mrcz:master, r=jyn514

Fix type name in doc example for Iter and IterMut

3 years agoRollup merge of #80785 - petrochenkov:prettyparen, r=Aaron1011
Yuki Okushi [Fri, 8 Jan 2021 02:11:45 +0000 (11:11 +0900)]
Rollup merge of #80785 - petrochenkov:prettyparen, r=Aaron1011

rustc_ast_pretty: Remove `PrintState::insert_extra_parens`

It's no longer necessary after #79472.

r? `@Aaron1011`

3 years agoRollup merge of #80761 - andjo403:generic_coverage, r=spastorino
Yuki Okushi [Fri, 8 Jan 2021 02:11:43 +0000 (11:11 +0900)]
Rollup merge of #80761 - andjo403:generic_coverage, r=spastorino

handle generic trait methods in coverage-report tests

also make the generic function pattern more specific and remove the extra $ that fails the matching.

r? `@wesleywiser`
as this was failing the test of #76896

3 years agoRollup merge of #80372 - jyn514:fix-panics, r=Manishearth
Yuki Okushi [Fri, 8 Jan 2021 02:11:41 +0000 (11:11 +0900)]
Rollup merge of #80372 - jyn514:fix-panics, r=Manishearth

Don't panic when an external crate can't be resolved

This isn't actually a bug, it can occur when rustdoc tries to resolve a
crate that isn't used in the main code.

Fixes #72381.

r? `@kinnison` if you have time, otherwise `@Manishearth`

3 years agoRollup merge of #79675 - CraftSpider:79669, r=estebank
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.

3 years agoRemove useless `fill_in` function
Joshua Nelson [Fri, 8 Jan 2021 01:41:34 +0000 (20:41 -0500)]
Remove useless `fill_in` function

It was only used once, in a function that was otherwise trivial.

3 years agoUse correct span for structured suggestion
Esteban Küber [Fri, 8 Jan 2021 00:44:08 +0000 (16:44 -0800)]
Use correct span for structured suggestion

On structured suggestion for `let` -> `const`  and `const` -> `let`, use
a proper `Span` and update tests to check the correct application.

Follow up to #80012.

3 years agoAuto merge of #80746 - ehuss:update-cargo, r=ehuss
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)

3 years agoGet rid of custom pretty-printing in rustdoc
Joshua Nelson [Thu, 7 Jan 2021 22:40:07 +0000 (17:40 -0500)]
Get rid of custom pretty-printing in rustdoc

and use rustc_hir_pretty directly instead

3 years agorustc_ast_pretty: Remove `PrintState::insert_extra_parens`
Vadim Petrochenkov [Thu, 7 Jan 2021 14:58:05 +0000 (17:58 +0300)]
rustc_ast_pretty: Remove `PrintState::insert_extra_parens`

It's no longer necessary after #79472

3 years agoAuto merge of #80709 - lzutao:target-enumerate, r=petrochenkov
bors [Thu, 7 Jan 2021 21:33:57 +0000 (21:33 +0000)]
Auto merge of #80709 - lzutao:target-enumerate, r=petrochenkov

Limit target endian to an enum instead of free string

This is #77604 revived.

3 years agobootstrap: fix x.py install not working with relative prefix
Pietro Albini [Thu, 7 Jan 2021 18:59:24 +0000 (19:59 +0100)]
bootstrap: fix x.py install not working with relative prefix