Commit Graph

164373 Commits

Author SHA1 Message Date
Matthias Krüger
6cfb44486c
Rollup merge of #94867 - notriddle:notriddle/i32-count-regression-test, r=Dylan-DPC
Add regression test for `<i32 as Iterator>::count`

Closes #84495
2022-03-12 22:56:01 +01:00
bors
f103b2969b Auto merge of #94865 - notriddle:notriddle/single-colon-path-not-const-generics, r=cjgillot
diagnostics: single colon within `<>` probably, not type ascription

Fixes #94812
2022-03-12 19:10:33 +00:00
bors
22a20e3f0f Auto merge of #94711 - ouz-a:master3, r=oli-obk
Return early to fix ICE

This fixes #94627, ICE happens because compiler tries to suggest constraining type parameter but the only constraint is implicit `std::Sized` one, so it gets removed and there is nothing to suggest resulting in ICE.
2022-03-12 16:37:07 +00:00
ouz-a
1853ffccbc don't call multipart_suggestion 2022-03-12 18:51:28 +03:00
Michael Howell
26e299a4a7 Use consistent prose for ::
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2022-03-12 08:20:36 -07:00
bors
ed2a69c4a9 Auto merge of #94873 - DrMeepster:box_alloc_ice3, r=oli-obk
Fix ICE when using Box<T, A>, again

Sequel to #94043, fixes #94835.
2022-03-12 14:18:34 +00:00
bors
258256697b Auto merge of #94870 - notriddle:notriddle/filter-regression, r=oli-obk
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."
2022-03-12 11:58:07 +00:00
bors
f8a29bd95e Auto merge of #94875 - matthiaskrgr:rollup-tq1li2d, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #94150 (rustdoc-json: Include GenericParamDefKind::Type::synthetic in JSON)
 - #94833 ([2/2] Implement macro meta-variable expression)
 - #94863 (Remove redundant slicing of whole ranges in `bootstrap`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-03-12 09:30:06 +00:00
Matthias Krüger
49e0137a15
Rollup merge of #94863 - pierwill:bootstrap-slicing, r=Mark-Simulacrum
Remove redundant slicing of whole ranges in `bootstrap`

Found with `clippy::redundant_slicing`.
2022-03-12 09:35:47 +01:00
Matthias Krüger
8c87132103
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`
2022-03-12 09:35:45 +01:00
Matthias Krüger
27e674d9e9
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
2022-03-12 09:35:44 +01:00
bors
012720ffb0 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`
2022-03-12 07:02:05 +00:00
DrMeepster
9d72dd54d0 fix another assumption about box 2022-03-11 17:00:56 -08:00
Michael Howell
317f684160 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."
2022-03-11 16:59:32 -07:00
Michael Howell
ce6f987bdb Add regression test for <i32 as Iterator>::count
Fixes #84495
2022-03-11 16:21:31 -07:00
Michael Howell
7e323370b3 diagnostics: single colon within <> probably, not type ascription
Fixes #94812
2022-03-11 15:35:18 -07:00
bors
2c6a29af35 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
2022-03-11 21:44:06 +00:00
Caio
d0eca08bc4 Implement macro meta-variable expression 2022-03-11 17:48:51 -03:00
pierwill
df9797b791 Remove redundant slicing of whole ranges in bootstrap 2022-03-11 13:52:14 -06:00
Dylan DPC
298c9a0e14
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
2022-03-11 20:29:47 +01:00
Dylan DPC
ad513548ce
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.
2022-03-11 20:29:46 +01:00
Dylan DPC
9e70b1a033
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``
2022-03-11 20:29:45 +01:00
Dylan DPC
fedf70acb1
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`
2022-03-11 20:29:45 +01:00
Dylan DPC
86376e3aea
Rollup merge of #94798 - nnethercote:parse_tt-refactor, r=petrochenkov
`parse_tt` refactorings

Some readability improvements.

r? ``@petrochenkov``
2022-03-11 20:29:44 +01:00
Dylan DPC
0e3ae8d2bf
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``
2022-03-11 20:29:43 +01:00
Dylan DPC
85056107fa
Rollup merge of #87618 - GuillaumeGomez:std-char-types-doc, r=jyn514,camelid
Add missing documentation for std::char types
2022-03-11 20:29:42 +01:00
bors
335ffbfa54 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 8d6f527530

```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)
```
2022-03-11 19:23:55 +00:00
bors
c9b45e6010 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?
2022-03-11 16:37:55 +00:00
bors
af8604fadd 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
2022-03-11 13:56:33 +00:00
Guillaume Gomez
aad4227607 Update GUI test 2022-03-11 14:48:53 +01:00
Guillaume Gomez
87fba23d52 Collapse Blanket Implementations and Auto-trait implementations by default 2022-03-11 14:48:53 +01:00
Dylan DPC
fb3d126458
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.
2022-03-11 13:38:39 +01:00
Dylan DPC
4ec98d8415
Rollup merge of #94840 - lcnr:update-comment, r=Dylan-DPC
update `replace_bound_vars_with_placeholders` doc comment
2022-03-11 13:38:38 +01:00
Dylan DPC
cdd6d39ecc
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!
2022-03-11 13:38:37 +01:00
Dylan DPC
b711d17c37
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.
2022-03-11 13:38:36 +01:00
Dylan DPC
7189fceab7
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.
2022-03-11 13:38:36 +01:00
Takayuki Maeda
813f00dd4f fix a suggestion message 2022-03-11 21:26:06 +09:00
Trevor Spiteri
ed10356d52 remove unnecessary try_opt for operations that cannot fail 2022-03-11 11:07:45 +01:00
lcnr
c833a9b4b4 update comment 2022-03-11 09:51:42 +01:00
Takayuki Maeda
bdc3177868 suggest using double colon when using single colon in struct field type path 2022-03-11 16:15:57 +09:00
bors
f58d51b3c0 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.
2022-03-11 06:47:49 +00:00
Anton Lazarev
4c17217f99
make float parsing docs more comprehensive 2022-03-10 22:26:30 -08:00
bors
8756ed20b2 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
2022-03-11 04:32:33 +00:00
Nicholas Nethercote
95d13fa37d Move a parse_tt error case into a separate function. 2022-03-11 14:10:21 +11:00
Nicholas Nethercote
235a87fbd3 Make next_items a SmallVec.
For consistency, and to make the code slightly nicer.
2022-03-11 14:10:21 +11:00
Nicholas Nethercote
c13ca42d67 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.
2022-03-11 14:10:21 +11:00
Nicholas Nethercote
9f0798b2eb Add a useful assertion. 2022-03-11 14:10:21 +11:00
Nicholas Nethercote
4d4baf7c9a Disallow TokenTree::{MetaVar,MetaVarExpr} in matchers.
They should only appear in transcribers.
2022-03-11 14:10:19 +11:00
Nicholas Nethercote
09c3e82050 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.
2022-03-11 13:56:54 +11:00
Dylan DPC
f97a1c6909
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` .
2022-03-11 03:32:06 +01:00