]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoRollup merge of #94863 - pierwill:bootstrap-slicing, r=Mark-Simulacrum
Matthias Krüger [Sat, 12 Mar 2022 08:35:47 +0000 (09:35 +0100)]
Rollup merge of #94863 - pierwill:bootstrap-slicing, r=Mark-Simulacrum

Remove redundant slicing of whole ranges in `bootstrap`

Found with `clippy::redundant_slicing`.

2 years agoRollup merge of #94833 - c410-f3r:meta-take-2, r=petrochenkov
Matthias Krüger [Sat, 12 Mar 2022 08:35:45 +0000 (09:35 +0100)]
Rollup merge of #94833 - c410-f3r:meta-take-2, r=petrochenkov

[2/2] Implement macro meta-variable expression

Final part of https://github.com/rust-lang/rust/pull/93545#issuecomment-1050963295

r? `@petrochenkov`

2 years agoRollup merge of #94150 - Enselic:synthetic-generic-parameters-in-json, r=CraftSpider
Matthias Krüger [Sat, 12 Mar 2022 08:35:44 +0000 (09:35 +0100)]
Rollup merge of #94150 - Enselic:synthetic-generic-parameters-in-json, r=CraftSpider

rustdoc-json: Include GenericParamDefKind::Type::synthetic in JSON

The rustdoc JSON for

```
pub fn f(_: impl Clone) {}
```

will effectively be

```
pub fn f<impl Clone: Clone>(_: impl Clone) {}
```

where a synthetic generic parameter called `impl Clone` with generic trait bound
`Clone` is added to the function declaration.

The generated HTML filters out these generic parameters by doing
`self.params.iter().filter(|p| !p.is_synthetic_type_param())`, because the
synthetic generic paramter is not of interest to regular users.

For the same reason, we should expose whether or not a generic parameter is
synthetic or not also in the rustdoc JSON, so that rustdoc JSON clients can also
have the option to hide syntehtic generic parameters.

`@rustbot` modify labels: +A-rustdoc-json

2 years agoAuto merge of #94733 - nnethercote:fix-AdtDef-interning, r=fee1-dead
bors [Sat, 12 Mar 2022 07:02:05 +0000 (07:02 +0000)]
Auto merge of #94733 - nnethercote:fix-AdtDef-interning, r=fee1-dead

Improve `AdtDef` interning.

This commit makes `AdtDef` use `Interned`. Much of the commit is tedious
changes to introduce getter functions. The interesting changes are in
`compiler/rustc_middle/src/ty/adt.rs`.

r? `@fee1-dead`

2 years agorust-lang/portable-simd#259: remove Miri from CI
Ralf Jung [Sat, 12 Mar 2022 02:14:52 +0000 (21:14 -0500)]
rust-lang/portable-simd#259: remove Miri from CI

2 years agofix another assumption about box
DrMeepster [Sat, 12 Mar 2022 01:00:56 +0000 (17:00 -0800)]
fix another assumption about box

2 years agoChange beginner's guide to explain Reducing rather than Horizontal.
Jacob Lifshay [Fri, 11 Mar 2022 22:54:36 +0000 (14:54 -0800)]
Change beginner's guide to explain Reducing rather than Horizontal.

2 years agodiagnostics: do not spurriously claim something is "not an iterator"
Michael Howell [Fri, 11 Mar 2022 23:58:14 +0000 (16:58 -0700)]
diagnostics: do not spurriously claim something is "not an iterator"

Fixes a minor regression caused by #94746, where iter::Filter is
spurriously declared "not an iterator."

2 years agoAdd regression test for `<i32 as Iterator>::count`
Michael Howell [Fri, 11 Mar 2022 23:21:31 +0000 (16:21 -0700)]
Add regression test for `<i32 as Iterator>::count`

Fixes #84495

2 years agoreplace horizontal_* with reduce_*
Jacob Lifshay [Fri, 11 Mar 2022 22:49:06 +0000 (14:49 -0800)]
replace horizontal_* with reduce_*

2 years agodiagnostics: single colon within `<>` probably, not type ascription
Michael Howell [Fri, 11 Mar 2022 22:26:19 +0000 (15:26 -0700)]
diagnostics: single colon within `<>` probably, not type ascription

Fixes #94812

2 years agorun rust-fix in amputate-span.rs. (Thanks to ekuber for pushing me to do this.)
Felix S. Klock II [Fri, 11 Mar 2022 21:57:34 +0000 (16:57 -0500)]
run rust-fix in amputate-span.rs. (Thanks to ekuber for pushing me to do this.)

2 years agoAuto merge of #94860 - Dylan-DPC:rollup-n06j8h6, r=Dylan-DPC
bors [Fri, 11 Mar 2022 21:44:06 +0000 (21:44 +0000)]
Auto merge of #94860 - Dylan-DPC:rollup-n06j8h6, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #87618 (Add missing documentation for std::char types)
 - #94769 (Collapse blanket and auto-trait impls by default)
 - #94798 (`parse_tt` refactorings)
 - #94818 (Rename `IntoFuture::Future` to `IntoFuture::IntoFuture`)
 - #94827 (CTFE/Miri: detect out-of-bounds pointers in offset_from)
 - #94838 (Make float parsing docs more comprehensive)
 - #94839 (Suggest using double colon when a struct field type include single colon)

Failed merges:

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

2 years agoImplement macro meta-variable expression
Caio [Fri, 11 Mar 2022 20:48:51 +0000 (17:48 -0300)]
Implement macro meta-variable expression

2 years agoRemove redundant slicing of whole ranges in `bootstrap`
pierwill [Fri, 11 Mar 2022 19:51:48 +0000 (13:51 -0600)]
Remove redundant slicing of whole ranges in `bootstrap`

2 years agoRemove unneeded conversions in bootstrapping code
pierwill [Fri, 11 Mar 2022 19:38:31 +0000 (13:38 -0600)]
Remove unneeded conversions in bootstrapping code

Fixes warnings from `clippy::useless_conversion` in `src/bootstrap`.

2 years agoRollup merge of #94839 - TaKO8Ki:suggest-using-double-colon-for-struct-field-type...
Dylan DPC [Fri, 11 Mar 2022 19:29:47 +0000 (20:29 +0100)]
Rollup merge of #94839 - TaKO8Ki:suggest-using-double-colon-for-struct-field-type, r=cjgillot

Suggest using double colon when a struct field type include single colon

#92685

2 years agoRollup merge of #94838 - antonok-edm:float-parse-docs, r=Dylan-DPC
Dylan DPC [Fri, 11 Mar 2022 19:29:46 +0000 (20:29 +0100)]
Rollup merge of #94838 - antonok-edm:float-parse-docs, r=Dylan-DPC

Make float parsing docs more comprehensive

I was working on some code with some specialized restrictions on float parsing. I noticed the doc comments for `f32::from_str` and `f64::from_str` were missing several cases of valid inputs that are otherwise difficult to discover without looking at source code.

I'm not sure if the doc comments were initially intended to contain a comprehensive description of valid inputs, but I figured it's useful to include these extra cases for reference.

2 years agoRollup merge of #94827 - RalfJung:offset-from-ub, r=oli-obk
Dylan DPC [Fri, 11 Mar 2022 19:29:45 +0000 (20:29 +0100)]
Rollup merge of #94827 - RalfJung:offset-from-ub, r=oli-obk

CTFE/Miri: detect out-of-bounds pointers in offset_from

Also I became uneasy with aggressively doing `try_to_int` here -- this will always succeed on Miri, leading to the wrong codepath being taken. We should rather try to convert them both to pointers, and use the integer path as a fallback, so that's what I implemented now.

Hiding whitespaces helps with the diff.

Fixes https://github.com/rust-lang/miri/issues/1950

r? ``@oli-obk``

2 years agoRollup merge of #94818 - yoshuawuyts:into-future-associated-type, r=joshtriplett
Dylan DPC [Fri, 11 Mar 2022 19:29:45 +0000 (20:29 +0100)]
Rollup merge of #94818 - yoshuawuyts:into-future-associated-type, r=joshtriplett

Rename `IntoFuture::Future` to `IntoFuture::IntoFuture`

Ref: https://github.com/rust-lang/rust/issues/67644#issuecomment-1051401459

This renames `IntoFuture::Future` to `IntoFuture::IntoFuture`. This adds the `Into*` prefix to the associated type, similar to the [`IntoIterator::IntoIter`](https://doc.rust-lang.org/std/iter/trait.IntoIterator.html#associatedtype.IntoIter) associated type. It's my mistake we didn't do so in the first place. This fixes that and brings the two closer together. Thanks!

### References
__`IntoIterator` trait def__
```rust
pub trait IntoIterator {
    type Item;
    type IntoIter: Iterator<Item = Self::Item>;
    fn into_iter(self) -> Self::IntoIter;
}
```
__`IntoFuture` trait def__
```rust
pub trait IntoFuture {
    type Output;
    type IntoFuture: Future<Output = Self::Output>; // Prior to this PR: `type Future:`
    fn into_future(self) -> Self::IntoFuture;
}
```

cc/ `@eholk` `@rust-lang/wg-async`

2 years agoRollup merge of #94798 - nnethercote:parse_tt-refactor, r=petrochenkov
Dylan DPC [Fri, 11 Mar 2022 19:29:44 +0000 (20:29 +0100)]
Rollup merge of #94798 - nnethercote:parse_tt-refactor, r=petrochenkov

`parse_tt` refactorings

Some readability improvements.

r? ``@petrochenkov``

2 years agoRollup merge of #94769 - GuillaumeGomez:collapsed-by-default, r=notriddle
Dylan DPC [Fri, 11 Mar 2022 19:29:43 +0000 (20:29 +0100)]
Rollup merge of #94769 - GuillaumeGomez:collapsed-by-default, r=notriddle

Collapse blanket and auto-trait impls by default

Blocked on #94740 (the two first commits come from it).

This behaviour was changed in https://github.com/rust-lang/rust/pull/88490 and apparently wasn't caught since then.

You can test it [here](https://rustdoc.crud.net/imperio/collapsed-by-default/test_docs/struct.Foo.html#blanket-implementations).

r? ``@notriddle``

2 years agoRollup merge of #87618 - GuillaumeGomez:std-char-types-doc, r=jyn514,camelid
Dylan DPC [Fri, 11 Mar 2022 19:29:42 +0000 (20:29 +0100)]
Rollup merge of #87618 - GuillaumeGomez:std-char-types-doc, r=jyn514,camelid

Add missing documentation for std::char types

2 years agoAuto merge of #94472 - JmPotato:use_maybeuninit_for_vecdeque, r=m-ou-se
bors [Fri, 11 Mar 2022 19:23:55 +0000 (19:23 +0000)]
Auto merge of #94472 - JmPotato:use_maybeuninit_for_vecdeque, r=m-ou-se

Use MaybeUninit in VecDeque to remove the undefined behavior of slice

Signed-off-by: JmPotato <ghzpotato@gmail.com>
Ref https://github.com/rust-lang/rust/issues/74189. Adjust the code to follow the [doc.rust-lang.org/reference/behavior-considered-undefined.html](https://doc.rust-lang.org/reference/behavior-considered-undefined.html).

* Change the return type of `buffer_as_slice` from `&[T]` to `&[MaybeUninit<T>]`.
* Add some corresponding safety comments.

Benchmark results:

master 8d6f527530f4ba974d922269267fe89050188789

```rust
test collections::vec_deque::tests::bench_pop_back_100       ... bench:          47 ns/iter (+/- 1)
test collections::vec_deque::tests::bench_pop_front_100      ... bench:          50 ns/iter (+/- 4)
test collections::vec_deque::tests::bench_push_back_100      ... bench:          69 ns/iter (+/- 10)
test collections::vec_deque::tests::bench_push_front_100     ... bench:          72 ns/iter (+/- 6)
test collections::vec_deque::tests::bench_retain_half_10000  ... bench:     145,891 ns/iter (+/- 7,975)
test collections::vec_deque::tests::bench_retain_odd_10000   ... bench:     141,647 ns/iter (+/- 3,711)
test collections::vec_deque::tests::bench_retain_whole_10000 ... bench:     120,132 ns/iter (+/- 4,078)
```

This PR

```rust
test collections::vec_deque::tests::bench_pop_back_100       ... bench:          48 ns/iter (+/- 2)
test collections::vec_deque::tests::bench_pop_front_100      ... bench:          51 ns/iter (+/- 3)
test collections::vec_deque::tests::bench_push_back_100      ... bench:          73 ns/iter (+/- 2)
test collections::vec_deque::tests::bench_push_front_100     ... bench:          73 ns/iter (+/- 2)
test collections::vec_deque::tests::bench_retain_half_10000  ... bench:     131,796 ns/iter (+/- 5,440)
test collections::vec_deque::tests::bench_retain_odd_10000   ... bench:     137,563 ns/iter (+/- 3,349)
test collections::vec_deque::tests::bench_retain_whole_10000 ... bench:     128,815 ns/iter (+/- 3,289)
```

2 years agoAuto merge of #90253 - Kobzol:hash-stable-sort-index-map, r=cjgillot
bors [Fri, 11 Mar 2022 16:37:55 +0000 (16:37 +0000)]
Auto merge of #90253 - Kobzol:hash-stable-sort-index-map, r=cjgillot

Change several HashMaps to IndexMap to improve incremental hashing performance

Stable hashing hash maps in incremental mode takes a lot of time, especially for some benchmarks like `clap`. As noted by `@Mark-Simulacrum` [here](https://github.com/rust-lang/rust/pull/89404#issuecomment-950043892), this cost could be reduced by replacing some hash maps by indexmaps.

I gathered some statistics and found several hash maps that took a lot of time to hash and replaced them by indexmaps. However, in order for this to work, we need to make sure that these indexmaps have deterministic insertion order. These three are used only in visitors as far as I can see, which seems deterministic. Can we enforce this somehow? Or should some explaining comment be included for these maps?

2 years agoAuto merge of #94845 - Dylan-DPC:rollup-3phylaq, r=Dylan-DPC
bors [Fri, 11 Mar 2022 13:56:33 +0000 (13:56 +0000)]
Auto merge of #94845 - Dylan-DPC:rollup-3phylaq, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #93283 (Fix for localized windows editions in testcase fn read_link() Issue#93211)
 - #94592 (Fallback to top-level config.toml if not present in current directory, and remove fallback for env vars and CLI flags)
 - #94776 (Optimize ascii::escape_default)
 - #94840 (update `replace_bound_vars_with_placeholders` doc comment)
 - #94842 (Remove unnecessary try_opt for operations that cannot fail)

Failed merges:

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

2 years agoUpdate GUI test
Guillaume Gomez [Tue, 8 Mar 2022 16:52:31 +0000 (17:52 +0100)]
Update GUI test

2 years agoCollapse Blanket Implementations and Auto-trait implementations by default
Guillaume Gomez [Tue, 8 Mar 2022 16:51:16 +0000 (17:51 +0100)]
Collapse Blanket Implementations and Auto-trait implementations by default

2 years agoRollup merge of #94842 - tspiteri:there-is-no-try, r=Dylan-DPC
Dylan DPC [Fri, 11 Mar 2022 12:38:39 +0000 (13:38 +0100)]
Rollup merge of #94842 - tspiteri:there-is-no-try, r=Dylan-DPC

Remove unnecessary try_opt for operations that cannot fail

As indicated in the added comments, some operation cannot overflow, so using `try_opt!` for them is unnecessary.

2 years agoRollup merge of #94840 - lcnr:update-comment, r=Dylan-DPC
Dylan DPC [Fri, 11 Mar 2022 12:38:38 +0000 (13:38 +0100)]
Rollup merge of #94840 - lcnr:update-comment, r=Dylan-DPC

update `replace_bound_vars_with_placeholders` doc comment

2 years agoRollup merge of #94776 - martingms:optimize-escape-default, r=nnethercote
Dylan DPC [Fri, 11 Mar 2022 12:38:37 +0000 (13:38 +0100)]
Rollup merge of #94776 - martingms:optimize-escape-default, r=nnethercote

Optimize ascii::escape_default

`ascii::escape_default` showed up as a hot function when compiling `deunicode-1.3.1` in `@nnethercote's` [analysis](https://hackmd.io/mxdn4U58Su-UQXwzOHpHag) of `@lqd's` [rustc-benchmarking-data](https://github.com/lqd/rustc-benchmarking-data).
After taking a look at the generated assembly it looked like a LUT-based approach could be faster for `hexify()`-ing ascii characters, so that's what this PR implements

The patch looks like it provides about a 1-2% improvement in instructions for that particular crate. This should definitely be verified with a perf run as I'm still getting used to the `rustc-perf` tooling and might easily have made an error!

2 years agoRollup merge of #94592 - jyn514:consistent-config-loading, r=Mark-Simulacrum
Dylan DPC [Fri, 11 Mar 2022 12:38:36 +0000 (13:38 +0100)]
Rollup merge of #94592 - jyn514:consistent-config-loading, r=Mark-Simulacrum

Fallback to top-level config.toml if not present in current directory, and remove fallback for env vars and CLI flags

This preserves the behavior where x.py will only give a hard error on a missing config file if it was configured through `--config` or RUST_BOOTSTRAP_CONFIG. It also removes the top-level fallback for everything except the default path; presumably if you're passing the path explicitly, you expect it to be exactly there and don't want to look in the root directory.

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

2 years agoRollup merge of #93283 - m1guelperez:master, r=Mark-Simulacrum
Dylan DPC [Fri, 11 Mar 2022 12:38:36 +0000 (13:38 +0100)]
Rollup merge of #93283 - m1guelperez:master, r=Mark-Simulacrum

Fix for localized windows editions in testcase fn read_link() Issue#93211

This PR aims to fix the issue with localized windows versions that do not necessarily have the folder "Documents and settings" in English.

The idea was provided by `@the8472.` We check if the "CI" environment variable is set, then we always check for the "Documents and Settings"-folder, otherwise we check if the folder exists on the local machine, and if not we skip this assert.

Resoles #93211.

2 years agofix a suggestion message
Takayuki Maeda [Fri, 11 Mar 2022 12:26:06 +0000 (21:26 +0900)]
fix a suggestion message

2 years agoremove unnecessary try_opt for operations that cannot fail
Trevor Spiteri [Fri, 11 Mar 2022 10:07:45 +0000 (11:07 +0100)]
remove unnecessary try_opt for operations that cannot fail

2 years agoupdate comment
lcnr [Fri, 11 Mar 2022 08:51:42 +0000 (09:51 +0100)]
update comment

2 years agosuggest using double colon when using single colon in struct field type path
Takayuki Maeda [Fri, 11 Mar 2022 07:15:57 +0000 (16:15 +0900)]
suggest using double colon when using single colon in struct field type path

2 years agoAuto merge of #94304 - notriddle:notriddle/buffer-args, r=CraftSpider
bors [Fri, 11 Mar 2022 06:47:49 +0000 (06:47 +0000)]
Auto merge of #94304 - notriddle:notriddle/buffer-args, r=CraftSpider

rustdoc: write directly to buffer in `inner_full_print`

This change avoids several temporary allocations for every argument.

2 years agomake float parsing docs more comprehensive
Anton Lazarev [Fri, 11 Mar 2022 06:20:46 +0000 (22:20 -0800)]
make float parsing docs more comprehensive

2 years agoAuto merge of #94834 - Dylan-DPC:rollup-sza4qc2, r=Dylan-DPC
bors [Fri, 11 Mar 2022 04:32:33 +0000 (04:32 +0000)]
Auto merge of #94834 - Dylan-DPC:rollup-sza4qc2, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #93293 (Implement `MIN`/`MAX` constants for non-zero integers)
 - #94356 (Rename unix::net::SocketAddr::from_path to from_pathname and stabilize it)
 - #94765 (Rename is_{some,ok,err}_with to is_{some,ok,err}_and.)
 - #94819 (configure: don't serialize empty array elements)
 - #94826 (Improve doc wording for retain on some collections)

Failed merges:

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

2 years agoMove a `parse_tt` error case into a separate function.
Nicholas Nethercote [Wed, 9 Mar 2022 03:51:31 +0000 (14:51 +1100)]
Move a `parse_tt` error case into a separate function.

2 years agoMake next_items a `SmallVec`.
Nicholas Nethercote [Wed, 9 Mar 2022 03:37:45 +0000 (14:37 +1100)]
Make next_items a `SmallVec`.

For consistency, and to make the code slightly nicer.

2 years agoMove `eof_items` handling entirely within `inner_parse_loop`.
Nicholas Nethercote [Wed, 9 Mar 2022 03:34:24 +0000 (14:34 +1100)]
Move `eof_items` handling entirely within `inner_parse_loop`.

Also rename `inner_parse_loop` as `parse_tt_inner`, because it's no
longer just a loop.

2 years agoAdd a useful assertion.
Nicholas Nethercote [Wed, 9 Mar 2022 23:06:57 +0000 (10:06 +1100)]
Add a useful assertion.

2 years agoDisallow `TokenTree::{MetaVar,MetaVarExpr}` in matchers.
Nicholas Nethercote [Wed, 9 Mar 2022 05:58:13 +0000 (16:58 +1100)]
Disallow `TokenTree::{MetaVar,MetaVarExpr}` in matchers.

They should only appear in transcribers.

2 years agoRefactor the second half of `parse_tt`.
Nicholas Nethercote [Wed, 9 Mar 2022 03:18:32 +0000 (14:18 +1100)]
Refactor the second half of `parse_tt`.

The current structure makes it hard to tell that there are just four
distinct code paths, depending on how many items there are in `bb_items`
and `next_items`. This commit introduces a `match` that clarifies
things.

2 years agoRollup merge of #94826 - allgoewer:fix-retain-documentation, r=yaahc
Dylan DPC [Fri, 11 Mar 2022 02:32:06 +0000 (03:32 +0100)]
Rollup merge of #94826 - allgoewer:fix-retain-documentation, r=yaahc

Improve doc wording for retain on some collections

I found the documentation wording on the various retain methods on many collections to be unusual.
I tried to invert the relation by switching `such that` with `for which` .

2 years agoRollup merge of #94819 - jonhoo:configure-empty-list, r=Mark-Simulacrum
Dylan DPC [Fri, 11 Mar 2022 02:32:05 +0000 (03:32 +0100)]
Rollup merge of #94819 - jonhoo:configure-empty-list, r=Mark-Simulacrum

configure: don't serialize empty array elements

Before this change:

    $ ./configure --codegen-backends=
    [..]
    $ grep -P '^codegen-backends' config.toml
    codegen-backends = ['']

After this change:

    $ ./configure --codegen-backends=
    [..]
    $ grep -P '^codegen-backends' config.toml
    codegen-backends = []

2 years agoRollup merge of #94765 - m-ou-se:is-some-and, r=Dylan-DPC
Dylan DPC [Fri, 11 Mar 2022 02:32:04 +0000 (03:32 +0100)]
Rollup merge of #94765 - m-ou-se:is-some-and, r=Dylan-DPC

Rename is_{some,ok,err}_with to is_{some,ok,err}_and.

This renames `is_{some,ok,err}_with` to `is_{some,ok,err}_and`. This was discussed on the [tracking issue](https://github.com/rust-lang/rust/issues/93050).

2 years agoRollup merge of #94356 - Thomasdezeeuw:stabilize_unix_socket_creation, r=dtolnay
Dylan DPC [Fri, 11 Mar 2022 02:32:03 +0000 (03:32 +0100)]
Rollup merge of #94356 - Thomasdezeeuw:stabilize_unix_socket_creation, r=dtolnay

Rename unix::net::SocketAddr::from_path to from_pathname and stabilize it

Stabilizes `unix_socket_creation`.

Closes https://github.com/rust-lang/rust/issues/93423
r? `@m-ou-se`

2 years agoRollup merge of #93293 - nvzqz:nonzero-min-max, r=joshtriplett
Dylan DPC [Fri, 11 Mar 2022 02:32:02 +0000 (03:32 +0100)]
Rollup merge of #93293 - nvzqz:nonzero-min-max, r=joshtriplett

Implement `MIN`/`MAX` constants for non-zero integers

This adds the associated [`MIN`](https://doc.rust-lang.org/stable/std/primitive.usize.html#associatedconstant.MIN)/[`MAX`](https://doc.rust-lang.org/stable/std/primitive.usize.html#associatedconstant.MAX) constants to `NonZero{U,I}{8,16,32,64,128,size}`, requested in #89065.

This reimplements #89077 due that PR being stagnant for 4 months. I am fine with closing this in favor of that one if the author revisits it. If so, I'd like to see that PR have the docs link to the `$Int`'s constants.

2 years agoImprove `AdtDef` interning.
Nicholas Nethercote [Fri, 4 Mar 2022 20:28:41 +0000 (07:28 +1100)]
Improve `AdtDef` interning.

This commit makes `AdtDef` use `Interned`. Much the commit is tedious
changes to introduce getter functions. The interesting changes are in
`compiler/rustc_middle/src/ty/adt.rs`.

2 years agoImprove `AdtDef` interning.
Nicholas Nethercote [Fri, 4 Mar 2022 20:28:41 +0000 (07:28 +1100)]
Improve `AdtDef` interning.

This commit makes `AdtDef` use `Interned`. Much the commit is tedious
changes to introduce getter functions. The interesting changes are in
`compiler/rustc_middle/src/ty/adt.rs`.

2 years agobootstrap: untangle static-libstdcpp & llvm-tools
Jon Gjengset [Wed, 9 Mar 2022 20:06:12 +0000 (12:06 -0800)]
bootstrap: untangle static-libstdcpp & llvm-tools

Previously, the static-libstdcpp setting was tied to llvm-tools such
that enabling the latter always enabled the latter. This seems
unfortunate, since it is entirely reasonable for someone to want to
_not_ statically link stdc++, but _also_ want to build the llvm-tools.
This patch therefore separates the two settings such that neither
implies the other.

On its own, that would change the default behavior in a way that's
likely to surprise users. Specifically, users who build llvm-tools
_likely_ want those tools to be statically compiled against libstdc++,
since otherwise users with older GLIBCXX will be unable to run the
vended tools. So, we also flip the default for the `static-libstdcpp`
setting such that builds always link statically against libstdc++ by
default, but it's _possible_ to opt out.

See also #94719.

2 years agoAuto merge of #94276 - scottmcm:primitive-clone, r=oli-obk
bors [Fri, 11 Mar 2022 01:51:49 +0000 (01:51 +0000)]
Auto merge of #94276 - scottmcm:primitive-clone, r=oli-obk

mir-opt: Replace clone on primitives with copy

We can't do it for everything, but it would be nice to at least stop making calls to clone methods in debug from things like derived-clones.

r? `@ghost`

2 years agoadjust offset_from logic: check that both pointers are in-bounds
Ralf Jung [Thu, 10 Mar 2022 23:30:32 +0000 (18:30 -0500)]
adjust offset_from logic: check that both pointers are in-bounds

2 years agoImprove doc wording for retain on some collections
Maik Allgöwer [Thu, 10 Mar 2022 23:16:45 +0000 (00:16 +0100)]
Improve doc wording for retain on some collections

2 years agorust-lang/portable-simd#260: Add `.min` and `.max` for integers
Jorge Leitao [Thu, 10 Mar 2022 23:12:40 +0000 (00:12 +0100)]
rust-lang/portable-simd#260: Add `.min` and `.max` for integers

2 years agoAuto merge of #94824 - Dylan-DPC:rollup-iamc09j, r=Dylan-DPC
bors [Thu, 10 Mar 2022 23:10:59 +0000 (23:10 +0000)]
Auto merge of #94824 - Dylan-DPC:rollup-iamc09j, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #93950 (Use modern formatting for format! macros)
 - #94274 (Treat unstable lints as unknown)
 - #94368 ([1/2] Implement macro meta-variable expressions)
 - #94719 (Statically compile libstdc++ everywhere if asked)
 - #94728 (Only emit pointer-like metadata for `Box<T, A>` when `A` is ZST)
 - #94790 (enable portable-simd doctests in Miri)
 - #94811 (Update browser-ui-test version)

Failed merges:

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

2 years agoMove note about 0 gap to signed integers
Nikolai Vazquez [Thu, 10 Mar 2022 22:52:48 +0000 (17:52 -0500)]
Move note about 0 gap to signed integers

Was accidentally placed on unsigned integers, where it is not relevant.

2 years agoRollup merge of #94811 - GuillaumeGomez:update-browser-ui-test, r=notriddle
Dylan DPC [Thu, 10 Mar 2022 22:13:02 +0000 (23:13 +0100)]
Rollup merge of #94811 - GuillaumeGomez:update-browser-ui-test, r=notriddle

Update browser-ui-test version

It should help with #93784 (the important PR helping in this regard is https://github.com/GuillaumeGomez/browser-UI-test/pull/273).

r? `@notriddle`

2 years agoRollup merge of #94790 - RalfJung:portable-simd-miri, r=Dylan-DPC
Dylan DPC [Thu, 10 Mar 2022 22:13:01 +0000 (23:13 +0100)]
Rollup merge of #94790 - RalfJung:portable-simd-miri, r=Dylan-DPC

enable portable-simd doctests in Miri

With https://github.com/rust-lang/miri/pull/2013 we shouldn't need to disable these tests any more. :)

2 years agoRollup merge of #94728 - compiler-errors:box-allocator-zst-meta, r=michaelwoerister
Dylan DPC [Thu, 10 Mar 2022 22:13:00 +0000 (23:13 +0100)]
Rollup merge of #94728 - compiler-errors:box-allocator-zst-meta, r=michaelwoerister

Only emit pointer-like metadata for `Box<T, A>` when `A` is ZST

Basically copy the change in #94043, but for debuginfo.

r? ``@michaelwoerister``

Fixes #94725

2 years agoRollup merge of #94719 - jonhoo:enable-static-lld, r=Mark-Simulacrum
Dylan DPC [Thu, 10 Mar 2022 22:12:59 +0000 (23:12 +0100)]
Rollup merge of #94719 - jonhoo:enable-static-lld, r=Mark-Simulacrum

Statically compile libstdc++ everywhere if asked

PR #93918 made it so that `-static-libstdc++` was only set in one place,
and was only set during linking, but accidentally also made it so that
it is no longer passed when building LLD, only when building LLVM
itself. This moves the logic for setting `-static-libstdc++` in the
linker flags to `configure_cmake` so that it takes effect for all CMake
invocations in `native.rs`.

As a side-effect, this also causes libstdc++ to be statically compiled
into sanitizers, whereas previously the `llvm-static-stdcpp` flag had no
effect on sanitizers. It also makes it so that LLD will be compiled
statically if `llvm-tools-enabled` is set, even though previously it was
only linked statically if `llvm-static-stdcpp` was set explicitly. Both
of these seem like they match expected behavior than what was there
prior to #93918.

2 years agoRollup merge of #94368 - c410-f3r:metaaaaaaaaaaaaaaaaaaaaaaaaaaa, r=petrochenkov
Dylan DPC [Thu, 10 Mar 2022 22:12:58 +0000 (23:12 +0100)]
Rollup merge of #94368 - c410-f3r:metaaaaaaaaaaaaaaaaaaaaaaaaaaa, r=petrochenkov

[1/2] Implement macro meta-variable expressions

See https://github.com/rust-lang/rust/pull/93545#issuecomment-1050963295

The logic behind `length`, `index` and `count` was removed but the parsing code is still present, i.e., everything is simply ignored like `ignored`.

r? ``@petrochenkov``

2 years agoRollup merge of #94274 - djkoloski:unknown_unstable_lints, r=tmandry
Dylan DPC [Thu, 10 Mar 2022 22:12:57 +0000 (23:12 +0100)]
Rollup merge of #94274 - djkoloski:unknown_unstable_lints, r=tmandry

Treat unstable lints as unknown

This change causes unstable lints to be ignored if the `unknown_lints`
lint is allowed. To achieve this, it also changes lints to apply as soon
as they are processed. Previously, lints in the same set were processed
as a batch and then all simultaneously applied.

Implementation of https://github.com/rust-lang/compiler-team/issues/469

2 years agoRollup merge of #93950 - T-O-R-U-S:use-modern-formatting-for-format!-macros, r=Mark...
Dylan DPC [Thu, 10 Mar 2022 22:12:57 +0000 (23:12 +0100)]
Rollup merge of #93950 - T-O-R-U-S:use-modern-formatting-for-format!-macros, r=Mark-Simulacrum

Use modern formatting for format! macros

This updates the standard library's documentation to use the new format_args syntax.
The documentation is worthwhile to update as it should be more idiomatic
(particularly for features like this, which are nice for users to get acquainted
with). The general codebase is likely more hassle than benefit to update: it'll
hurt git blame, and generally updates can be done by folks updating the code if
(and when) that makes things more readable with the new format.

A few places in the compiler and library code are updated (mostly just due to
already having been done when this commit was first authored).

`eprintln!("{}", e)` becomes `eprintln!("{e}")`, but `eprintln!("{}", e.kind())` remains untouched.

2 years agoconfigure: don't serialize empty array elements
Jon Gjengset [Thu, 10 Mar 2022 20:39:29 +0000 (12:39 -0800)]
configure: don't serialize empty array elements

Before this change:

    $ ./configure --codegen-backends=
    [..]
    $ grep -P '^codegen-backends' config.toml
    codegen-backends = ['']

After this change:

    $ ./configure --codegen-backends=
    [..]
    $ grep -P '^codegen-backends' config.toml
    codegen-backends = []

2 years agoAdd `Atomic*::get_mut_slice`
Maybe Waffle [Thu, 10 Mar 2022 18:57:02 +0000 (22:57 +0400)]
Add `Atomic*::get_mut_slice`

Just as `get_mut` is the inverse of `from_mut`, `get_mut_slice` is the
inverse of `from_mut_slice`.

2 years agoRename `IntoFuture::Future` to `IntoFuture::IntoFuture`
Yoshua Wuyts [Thu, 10 Mar 2022 19:29:35 +0000 (20:29 +0100)]
Rename `IntoFuture::Future` to `IntoFuture::IntoFuture`

2 years agoAuto merge of #94814 - matthiaskrgr:rollup-a5sk366, r=matthiaskrgr
bors [Thu, 10 Mar 2022 18:28:45 +0000 (18:28 +0000)]
Auto merge of #94814 - matthiaskrgr:rollup-a5sk366, r=matthiaskrgr

Rollup of 8 pull requests

Successful merges:

 - #94440 (Better error for normalization errors from parent crates that use `#![feature(generic_const_exprs)]`)
 - #94587 (Document new recommended use of `FromIterator::from_iter`)
 - #94644 (Fix soundness issue in scoped threads.)
 - #94740 (Unify impl blocks by wrapping them into a div)
 - #94753 (Improve rustdoc book)
 - #94796 (Allow `cargo run` instead of `cargo run -p bootstrap`)
 - #94805 (Revert accidental stabilization)
 - #94809 (RustWrapper: add missing include)

Failed merges:

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

2 years agoRollup merge of #94809 - durin42:llvm-15-modulepass, r=nikic
Matthias Krüger [Thu, 10 Mar 2022 18:00:12 +0000 (19:00 +0100)]
Rollup merge of #94809 - durin42:llvm-15-modulepass, r=nikic

RustWrapper: add missing include

This is required after LLVM change 3c4410dfcaaf (aka
https://reviews.llvm.org/D121168) did some includes cleanup.

r? nikic

2 years agoRollup merge of #94805 - oli-obk:drop_box, r=pnkfelix
Matthias Krüger [Thu, 10 Mar 2022 18:00:11 +0000 (19:00 +0100)]
Rollup merge of #94805 - oli-obk:drop_box, r=pnkfelix

Revert accidental stabilization

fixes #94804

2 years agoRollup merge of #94796 - jyn514:cargo-run-bootstrap, r=Mark-Simulacrum
Matthias Krüger [Thu, 10 Mar 2022 18:00:10 +0000 (19:00 +0100)]
Rollup merge of #94796 - jyn514:cargo-run-bootstrap, r=Mark-Simulacrum

Allow `cargo run` instead of `cargo run -p bootstrap`

This was part of `@Mark-Simulacrum` 's original PR in https://github.com/rust-lang/rust/commit/ecb424f12992a4aebace8a153d5efea040327a01,
but I missed it when writing #92260.

This also has the side effect of allowing `cargo build --bins` instead of `cargo build -p bootstrap --bins`. I'm not sure when you would want to run cargo build/check/test without going through bootstrap, but this still allows you to do so as long as you pass `-p` for all the crates you want to build.

2 years agoRollup merge of #94753 - Urgau:rustdoc-book-improvements, r=GuillaumeGomez
Matthias Krüger [Thu, 10 Mar 2022 18:00:09 +0000 (19:00 +0100)]
Rollup merge of #94753 - Urgau:rustdoc-book-improvements, r=GuillaumeGomez

Improve rustdoc book

This pull-request improves the `rustdoc` book by doing some (light) cleanup, by merging some stuff, by adding some missing stuff (like tracking issues links, for those who had one) and also by moving some chapter's into sub-chapter's to improve the flow of the book.

~~Note that I locally tested with `mdbook-lintcheck` that no links became accidentally broken.~~ (Not enough, ;-))

r? `````@GuillaumeGomez`````

2 years agoRollup merge of #94740 - GuillaumeGomez:unify-impl-blocks, r=notriddle
Matthias Krüger [Thu, 10 Mar 2022 18:00:08 +0000 (19:00 +0100)]
Rollup merge of #94740 - GuillaumeGomez:unify-impl-blocks, r=notriddle

Unify impl blocks by wrapping them into a div

The blanket and "auto traits" sections are wrapped into a `div` with an ID. This PR fixes this incoherence by wrapping each impl section (the "deref impl" and the "inherent impl" sections were missing it). It'll also make some tests simpler to write.

r? `````@notriddle`````

2 years agoRollup merge of #94644 - m-ou-se:scoped-threads-drop-soundness, r=joshtriplett
Matthias Krüger [Thu, 10 Mar 2022 18:00:07 +0000 (19:00 +0100)]
Rollup merge of #94644 - m-ou-se:scoped-threads-drop-soundness, r=joshtriplett

Fix soundness issue in scoped threads.

This was discovered in https://github.com/rust-lang/rust/pull/94559#discussion_r820116323

The `scope()` function returns when all threads are finished, but I accidentally considered a thread 'finished' before dropping their panic payload or ignored return value.

So if a thread returned (or panics with) something that in its `Drop` implementation still uses borrowed stuff, it goes wrong.

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=2a1f19ac4676cdabe43e24e536ff9358

2 years agoRollup merge of #94587 - JKAnderson409:issue-90107-fix, r=scottmcm
Matthias Krüger [Thu, 10 Mar 2022 18:00:06 +0000 (19:00 +0100)]
Rollup merge of #94587 - JKAnderson409:issue-90107-fix, r=scottmcm

Document new recommended use of `FromIterator::from_iter`

#90107
Most of the added prose was paraphrased from the links provided in the issue. The suggested `VecDeque` example seemed to make the point well enough so I just used that.

2 years agoRollup merge of #94440 - compiler-errors:issue-94282, r=lcnr
Matthias Krüger [Thu, 10 Mar 2022 18:00:05 +0000 (19:00 +0100)]
Rollup merge of #94440 - compiler-errors:issue-94282, r=lcnr

Better error for normalization errors from parent crates that use `#![feature(generic_const_exprs)]`

This PR implements a somewhat rudimentary heuristic to suggest using `#![feature(generic_const_exprs)]` in a child crate when a function from a foreign crate (that may have used `#![feature(generic_const_exprs)]`) fails to normalize during codegen.

cc: #79018
cc: #94287

2 years agoUpdate browser-ui-test version
Guillaume Gomez [Thu, 10 Mar 2022 16:49:50 +0000 (17:49 +0100)]
Update browser-ui-test version

2 years agoRustWrapper: add missing include
Augie Fackler [Thu, 10 Mar 2022 16:16:33 +0000 (11:16 -0500)]
RustWrapper: add missing include

This is required after LLVM change 3c4410dfcaaf (aka
https://reviews.llvm.org/D121168) did some includes cleanup.

2 years agodebuginfo: Fix bug in type name generation for dyn types with associated types but...
Michael Woerister [Thu, 10 Mar 2022 15:19:33 +0000 (16:19 +0100)]
debuginfo: Fix bug in type name generation for dyn types with associated types but no other generic arguments.

2 years agoUse implicit capture syntax in format_args
T-O-R-U-S [Sat, 12 Feb 2022 19:16:17 +0000 (23:16 +0400)]
Use implicit capture syntax in format_args

This updates the standard library's documentation to use the new syntax. The
documentation is worthwhile to update as it should be more idiomatic
(particularly for features like this, which are nice for users to get acquainted
with). The general codebase is likely more hassle than benefit to update: it'll
hurt git blame, and generally updates can be done by folks updating the code if
(and when) that makes things more readable with the new format.

A few places in the compiler and library code are updated (mostly just due to
already having been done when this commit was first authored).

2 years agoRevert accidental stabilization
Oli Scherer [Thu, 10 Mar 2022 14:28:28 +0000 (14:28 +0000)]
Revert accidental stabilization

2 years agoInline <EscapeDefault as Iterator>::next
Martin Gammelsæter [Thu, 10 Mar 2022 14:35:22 +0000 (15:35 +0100)]
Inline <EscapeDefault as Iterator>::next

2 years agoAuto merge of #94802 - matthiaskrgr:rollup-4plu0fi, r=matthiaskrgr
bors [Thu, 10 Mar 2022 12:32:01 +0000 (12:32 +0000)]
Auto merge of #94802 - matthiaskrgr:rollup-4plu0fi, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #92150 (Improve suggestion when casting usize to (possibly) wide pointer)
 - #94635 (Merge `#[deprecated]` and `#[rustc_deprecated]`)
 - #94657 (Constify `Index{,Mut}` for `[T]`, `str`, and `[T; N]`)
 - #94746 (diagnostics: use rustc_on_unimplemented to recommend `[].iter()`)
 - #94788 (Account for suggestions for complete removal of lines)

Failed merges:

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

2 years agoRollup merge of #94788 - estebank:removal-suggestion, r=petrochenkov
Matthias Krüger [Thu, 10 Mar 2022 11:20:54 +0000 (12:20 +0100)]
Rollup merge of #94788 - estebank:removal-suggestion, r=petrochenkov

Account for suggestions for complete removal of lines

Fix  #94192.

2 years agoRollup merge of #94746 - notriddle:notriddle/method-rustc-on-unimplemented, r=davidtwco
Matthias Krüger [Thu, 10 Mar 2022 11:20:53 +0000 (12:20 +0100)]
Rollup merge of #94746 - notriddle:notriddle/method-rustc-on-unimplemented, r=davidtwco

diagnostics: use rustc_on_unimplemented to recommend `[].iter()`

To make this work, the `#[rustc_on_unimplemented]` data needs to be used to
report method resolution errors, which is most of what this commit does.

Fixes #94581

2 years agoRollup merge of #94657 - fee1-dead:const_slice_index, r=oli-obk
Matthias Krüger [Thu, 10 Mar 2022 11:20:52 +0000 (12:20 +0100)]
Rollup merge of #94657 - fee1-dead:const_slice_index, r=oli-obk

Constify `Index{,Mut}` for `[T]`, `str`, and `[T; N]`

Several panic functions were rewired (via `const_eval_select`) to simpler implementations that do not require formatting for compile-time usage.

r? ```@oli-obk```

2 years agoRollup merge of #94635 - jhpratt:merge-deprecated-attrs, r=davidtwco
Matthias Krüger [Thu, 10 Mar 2022 11:20:51 +0000 (12:20 +0100)]
Rollup merge of #94635 - jhpratt:merge-deprecated-attrs, r=davidtwco

Merge `#[deprecated]` and `#[rustc_deprecated]`

The first commit makes "reason" an alias for "note" in `#[rustc_deprecated]`, while still prohibiting it in `#[deprecated]`.

The second commit changes "suggestion" to not just be a feature of `#[rustc_deprecated]`. This is placed behind the new `deprecated_suggestion` feature. This needs a tracking issue; let me know if this PR will be approved and I can create one.

The third commit is what permits `#[deprecated]` to be used when `#![feature(staged_api)]` is enabled. This isn't yet used in stdlib (only tests), as it would require duplicating all deprecation attributes until a bootstrap occurs. I intend to submit a follow-up PR that replaces all uses and removes the remaining `#[rustc_deprecated]` code after the next bootstrap.

`@rustbot` label +T-libs-api +C-feature-request +A-attributes +S-waiting-on-review

2 years agoRollup merge of #92150 - compiler-errors:better_usize_to_wide_ptr_cast, r=petrochenkov
Matthias Krüger [Thu, 10 Mar 2022 11:20:50 +0000 (12:20 +0100)]
Rollup merge of #92150 - compiler-errors:better_usize_to_wide_ptr_cast, r=petrochenkov

Improve suggestion when casting usize to (possibly) wide pointer

I thought #92125 was a wonderful idea, so I went ahead and took a stab at it. Not sure if my approach is the best going forward, but I'm happy with the improvement in the error message.

Iwill definitely address any changes if people are more opinionated with the wordings or want more features.

Also, do I need to add a new error code?

(Fixes #92125)

2 years agoThe `Clone::clone` call is now a `ConstantKind::Val`, not a `ConstantKind::Ty`
Scott McMurray [Thu, 10 Mar 2022 09:50:47 +0000 (01:50 -0800)]
The `Clone::clone` call is now a `ConstantKind::Val`, not a `ConstantKind::Ty`

2 years agoDisable the test on wasm32
Scott McMurray [Wed, 9 Mar 2022 23:50:14 +0000 (15:50 -0800)]
Disable the test on wasm32

Since the expected output has unwind targets

2 years agoshort-circuit the easy cases in `is_copy_modulo_regions`
Scott McMurray [Sun, 6 Mar 2022 07:51:10 +0000 (23:51 -0800)]
short-circuit the easy cases in `is_copy_modulo_regions`

This change is somewhat extensive, since it affects MIR -- since this is called to determine Copy vs Move -- so any test that's `no_core` needs to actually have the normal `impl`s it uses.

2 years agoMove `is_trivially_pure_clone_copy` onto `Ty` instead
Scott McMurray [Sat, 5 Mar 2022 23:19:57 +0000 (15:19 -0800)]
Move `is_trivially_pure_clone_copy` onto `Ty` instead

2 years agomir-opt: Replace clone on primitives with copy
Scott McMurray [Wed, 23 Feb 2022 07:19:57 +0000 (23:19 -0800)]
mir-opt: Replace clone on primitives with copy

We can't do it for everything, but it would be nice to at least stop making calls to clone methods in debug from things like derived-clones.

2 years agoAuto merge of #94764 - nikic:update-llvm-3, r=nagisa
bors [Thu, 10 Mar 2022 08:56:02 +0000 (08:56 +0000)]
Auto merge of #94764 - nikic:update-llvm-3, r=nagisa

Update LLVM submodule

This merges upstream changes from the 14.x release branch.

Fixes #89609.
Fixes #93923.
Fixes #94032.

2 years agoremove parameters that are only used in recursion
Jaeyong Sung [Thu, 10 Mar 2022 07:06:35 +0000 (16:06 +0900)]
remove parameters that are only used in recursion

2 years agofix build error
Jaeyong Sung [Thu, 10 Mar 2022 06:53:53 +0000 (15:53 +0900)]
fix build error

2 years agoadd checking for `x -> x` and `ref x -> x` and related test cases.
J-ZhengLi [Thu, 10 Mar 2022 06:46:58 +0000 (14:46 +0800)]
add checking for `x -> x` and `ref x -> x` and related test cases.