]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoAuto merge of #97442 - hafeoz:master, r=GuillaumeGomez
bors [Fri, 27 May 2022 08:50:51 +0000 (08:50 +0000)]
Auto merge of #97442 - hafeoz:master, r=GuillaumeGomez

Fix multiline attributes processing in doctest

Fixes #97440.

It seems like the call to `check_if_attr_is_complete` is not provided with the correct argument: the pending attribute should be passed, while the current line is actually being passed. This causes any attribute with more than 2 lines to fail and produces ICE when running through doctest.

2 years agoAuto merge of #97004 - nnethercote:proc-macro-tweaks, r=eddyb
bors [Fri, 27 May 2022 06:09:45 +0000 (06:09 +0000)]
Auto merge of #97004 - nnethercote:proc-macro-tweaks, r=eddyb

Proc macro tweaks

Various improvements I spotted while looking through the proc macro code.

r? `@eddyb`

2 years agoCut down `associated_item`.
Nicholas Nethercote [Mon, 16 May 2022 21:42:57 +0000 (07:42 +1000)]
Cut down `associated_item`.

The part of it dealing with types obfuscates and makes the code less
concise. This commit removes that part.

2 years agoRemove unnecessary blank line.
Nicholas Nethercote [Mon, 16 May 2022 22:39:57 +0000 (08:39 +1000)]
Remove unnecessary blank line.

2 years agoRename `b` as `buf` in several places.
Nicholas Nethercote [Wed, 18 May 2022 23:03:26 +0000 (09:03 +1000)]
Rename `b` as `buf` in several places.

Because it's easy to confuse with `bridge`.

2 years agoAdd some comments about `_marker` fields.
Nicholas Nethercote [Sun, 15 May 2022 23:36:52 +0000 (09:36 +1000)]
Add some comments about `_marker` fields.

There is some non-obvious information required to understand them.

2 years agoClarify a comment.
Nicholas Nethercote [Fri, 13 May 2022 05:57:55 +0000 (15:57 +1000)]
Clarify a comment.

`reverse_encode` isn't necessary to please the borrow checker, it's to
match the ordering done by `reverse_decode`.

2 years agoRename `ProcMacroDerive` as `DeriveProcMacro`.
Nicholas Nethercote [Mon, 16 May 2022 01:56:36 +0000 (11:56 +1000)]
Rename `ProcMacroDerive` as `DeriveProcMacro`.

So it matches the existing `AttrProcMacro` and `BangProcMacro` types.

2 years agoRename `ProcMacro` trait as `BangProcMacro`.
Nicholas Nethercote [Fri, 13 May 2022 04:07:56 +0000 (14:07 +1000)]
Rename `ProcMacro` trait as `BangProcMacro`.

Similar to the existing `AttrProcMacro` trait.

2 years agoSimplify types in `proc_macro_harness.rs`.
Nicholas Nethercote [Fri, 13 May 2022 01:45:51 +0000 (11:45 +1000)]
Simplify types in `proc_macro_harness.rs`.

This gives the more obvious derive/attr/bang distinction, and reduces
code size slightly.

2 years agoMake `Buffer<T>` non-generic.
Nicholas Nethercote [Thu, 12 May 2022 23:38:02 +0000 (09:38 +1000)]
Make `Buffer<T>` non-generic.

`u8` is the only type that makes sense for `T`, as demonstrated by the
fact that several impls and functions are hardwired to `Buffer<u8>`.

2 years agoImprove formatting in `associated_item!` definition.
Nicholas Nethercote [Fri, 13 May 2022 00:21:38 +0000 (10:21 +1000)]
Improve formatting in `associated_item!` definition.

2 years agoAdd some comments.
Nicholas Nethercote [Fri, 13 May 2022 00:07:45 +0000 (10:07 +1000)]
Add some comments.

2 years agoFix a typo in a comment.
Nicholas Nethercote [Thu, 12 May 2022 23:44:17 +0000 (09:44 +1000)]
Fix a typo in a comment.

2 years agoAuto merge of #97444 - compiler-errors:rollup-2gvdav6, r=compiler-errors
bors [Fri, 27 May 2022 03:27:04 +0000 (03:27 +0000)]
Auto merge of #97444 - compiler-errors:rollup-2gvdav6, r=compiler-errors

Rollup of 3 pull requests

Successful merges:

 - #96051 (Use rounding in float to Duration conversion methods)
 - #97066 (rustdoc: Remove `ItemFragment(Kind)`)
 - #97436 (Update `triagebot.toml` for macos ping group)

Failed merges:

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

2 years agoRollup merge of #97436 - compiler-errors:macos-ping-2, r=Mark-Simulacrum
Michael Goulet [Fri, 27 May 2022 03:15:09 +0000 (20:15 -0700)]
Rollup merge of #97436 - compiler-errors:macos-ping-2, r=Mark-Simulacrum

Update `triagebot.toml` for macos ping group

idk what i'm doing but i saw https://github.com/rust-lang/rust/pull/96392#issuecomment-1138893845

cc: `@thomcc`

2 years agoRollup merge of #97066 - petrochenkov:nofragkind, r=camelid
Michael Goulet [Fri, 27 May 2022 03:15:08 +0000 (20:15 -0700)]
Rollup merge of #97066 - petrochenkov:nofragkind, r=camelid

rustdoc: Remove `ItemFragment(Kind)`

And stop using `write!` when rendering URL fragments to avoid impossible errors.

2 years agoRollup merge of #96051 - newpavlov:duration_rounding, r=nagisa,joshtriplett
Michael Goulet [Fri, 27 May 2022 03:15:07 +0000 (20:15 -0700)]
Rollup merge of #96051 - newpavlov:duration_rounding, r=nagisa,joshtriplett

Use rounding in float to Duration conversion methods

Closes #96045

2 years agofmt
Артём Павлов [Artyom Pavlov] [Fri, 27 May 2022 02:15:22 +0000 (05:15 +0300)]
fmt

2 years agofix nanos overflow for f64
Артём Павлов [Artyom Pavlov] [Fri, 27 May 2022 01:59:01 +0000 (04:59 +0300)]
fix nanos overflow for f64

2 years agoAuto merge of #96298 - petrochenkov:fromgen, r=estebank
bors [Fri, 27 May 2022 01:01:15 +0000 (01:01 +0000)]
Auto merge of #96298 - petrochenkov:fromgen, r=estebank

libcore: Add `iter::from_generator` which is like `iter::from_fn`, but for coroutines instead of functions

An equally useful little helper.

I didn't follow any of the async-wg work, so I don't know why something like this wasn't added before.

2 years agoadd debug asserts
Artyom Pavlov [Fri, 27 May 2022 00:22:56 +0000 (00:22 +0000)]
add debug asserts

2 years agolibcore: Add `iter::from_generator` which is like `iter::from_fn`, but for coroutines...
Vadim Petrochenkov [Thu, 21 Apr 2022 20:47:39 +0000 (23:47 +0300)]
libcore: Add `iter::from_generator` which is like `iter::from_fn`, but for coroutines instead of functions

2 years agoFormatting
hafeoz [Thu, 26 May 2022 22:27:41 +0000 (23:27 +0100)]
Formatting

2 years agoRemove few characters for tidy check to pass
hafeoz [Thu, 26 May 2022 22:13:37 +0000 (23:13 +0100)]
Remove few characters for tidy check to pass

2 years agoAuto merge of #97386 - nnethercote:optimize-pos-adjustments, r=bjorn3
bors [Thu, 26 May 2022 22:01:19 +0000 (22:01 +0000)]
Auto merge of #97386 - nnethercote:optimize-pos-adjustments, r=bjorn3

Optimize position adjustments

A small improvement.

r? `@bjorn3`

2 years agoAdd tests
hafeoz [Thu, 26 May 2022 21:55:29 +0000 (22:55 +0100)]
Add tests

2 years agoUse correct var for attribute completeness fn
hafeoz [Thu, 26 May 2022 21:54:31 +0000 (22:54 +0100)]
Use correct var for attribute completeness fn

2 years agoUpdate `triagebot.toml` for macos ping group
Michael Goulet [Thu, 26 May 2022 19:42:14 +0000 (12:42 -0700)]
Update `triagebot.toml` for macos ping group

2 years agoAuto merge of #97434 - matthiaskrgr:rollup-7j3y16l, r=matthiaskrgr
bors [Thu, 26 May 2022 19:33:22 +0000 (19:33 +0000)]
Auto merge of #97434 - matthiaskrgr:rollup-7j3y16l, r=matthiaskrgr

Rollup of 3 pull requests

Successful merges:

 - #96033 (Add section on common message styles for Result::expect)
 - #97354 (Updates to browser-ui-test)
 - #97424 (clippy::complexity fixes)

Failed merges:

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

2 years agoRollup merge of #97424 - matthiaskrgr:clippy_complexity_may26, r=oli-obk
Matthias Krüger [Thu, 26 May 2022 18:59:43 +0000 (20:59 +0200)]
Rollup merge of #97424 - matthiaskrgr:clippy_complexity_may26, r=oli-obk

clippy::complexity fixes

clone_on_copy
useless_format
bind_instead_of_map
filter_map_identity
useless_conversion
map_flatten
unnecessary_unwrap

2 years agoRollup merge of #97354 - GuillaumeGomez:browser-ui-test-update, r=notriddle
Matthias Krüger [Thu, 26 May 2022 18:59:42 +0000 (20:59 +0200)]
Rollup merge of #97354 - GuillaumeGomez:browser-ui-test-update, r=notriddle

Updates to browser-ui-test

I took the commits from #97317. Since the ubuntu 22.04 version, you either need to use `--no-sandbox` or use another binary to run the GUI tests. I couldn't find out why the chromium used by `browser-ui-test` isn't working anymore on this ubuntu version.

r? `@notriddle`

2 years agoRollup merge of #96033 - yaahc:expect-elaboration, r=scottmcm
Matthias Krüger [Thu, 26 May 2022 18:59:40 +0000 (20:59 +0200)]
Rollup merge of #96033 - yaahc:expect-elaboration, r=scottmcm

Add section on common message styles for Result::expect

Based on a question from https://github.com/rust-lang/project-error-handling/issues/50#issuecomment-1092339937

~~One thing I haven't decided on yet, should I duplicate this section on `Option::expect`, link to this section, or move it somewhere else and link to that location from both docs?~~: I ended up moving the section to `std::error` and referencing it from both `Result::expect` and `Option::expect`'s docs.

I think this section, when combined with the similar update I made on [`std::panic!`](https://doc.rust-lang.org/nightly/std/macro.panic.html#when-to-use-panic-vs-result) implies that we should possibly more aggressively encourage and support the "expect as precondition" style described in this section. The consensus among the libs team seems to be that panic should be used for bugs, not expected potential failure modes. The "expect as error message" style seems to align better with the panic for unrecoverable errors style where they're seen as normal errors where the only difference is a desire to kill the current execution unit (aka erlang style error handling). I'm wondering if we should be providing a panic hook similar to `human-panic` or more strongly recommending the "expect as precondition" style of expect message.

2 years agoAuto merge of #97046 - conradludgate:faster-ascii-case-conv-path, r=thomcc
bors [Thu, 26 May 2022 15:29:01 +0000 (15:29 +0000)]
Auto merge of #97046 - conradludgate:faster-ascii-case-conv-path, r=thomcc

improve case conversion happy path

Someone shared the source code for [Go's string case conversion](https://github.com/golang/go/blob/19156a54741d4f353c9e8e0860197ca95a6ee6ca/src/strings/strings.go#L558-L616).

It features a hot path for ascii-only strings (although I assume for reasons specific to go, they've opted for a read safe hot loop).

I've borrowed these ideas and also kept our existing code to provide a fast path + seamless utf-8 correct path fallback.

(Naive) Benchmarks can be found here https://github.com/conradludgate/case-conv

For the cases where non-ascii is found near the start, the performance of this algorithm does fall back to original speeds and has not had any measurable speed loss

2 years agoimprove case conversion happy path
Conrad Ludgate [Sat, 14 May 2022 17:44:31 +0000 (18:44 +0100)]
improve case conversion happy path

2 years agoAuto merge of #97168 - SparrowLii:accesses, r=cjgillot
bors [Thu, 26 May 2022 11:15:15 +0000 (11:15 +0000)]
Auto merge of #97168 - SparrowLii:accesses, r=cjgillot

omit `record_accesses` function when collecting `MonoItem`s

This PR fixes the FIXME in the impl of `record_accesses` function.
[Edit] We can call `instantiation_mode` when push the `MonoItem` into `neighbors`. This avoids extra local variables `accesses: SmallVec<[_; 128]>`

2 years agoclippy::complexity fixes
Matthias Krüger [Thu, 26 May 2022 11:14:24 +0000 (13:14 +0200)]
clippy::complexity fixes

clone_on_copy
useless_format
bind_instead_of_map
filter_map_identity
useless_conversion
map_flatten
unnecessary_unwrap

2 years agoAuto merge of #96742 - m-ou-se:bsd-no-ancillary, r=joshtriplett
bors [Thu, 26 May 2022 08:50:33 +0000 (08:50 +0000)]
Auto merge of #96742 - m-ou-se:bsd-no-ancillary, r=joshtriplett

Disable unix::net::ancillary on BSD.

See https://github.com/rust-lang/rust/issues/76915#issuecomment-1118954474

2 years agoAuto merge of #97410 - jyn514:tool-std-features, r=Mark-Simulacrum
bors [Thu, 26 May 2022 05:45:54 +0000 (05:45 +0000)]
Auto merge of #97410 - jyn514:tool-std-features, r=Mark-Simulacrum

Only allow `compiletest` to use `feature(test)`, not any other feature

Using language features occasionally causes issues when using nightly to bootstrap, rather than beta.
See #59264 for additional context.

2 years agoDisable unix::net::ancillary on BSD.
Mara Bos [Thu, 5 May 2022 19:01:07 +0000 (21:01 +0200)]
Disable unix::net::ancillary on BSD.

2 years agoAuto merge of #97369 - tmiasko:codgen-ssa-atomic-ordering, r=michaelwoerister
bors [Thu, 26 May 2022 02:00:17 +0000 (02:00 +0000)]
Auto merge of #97369 - tmiasko:codgen-ssa-atomic-ordering, r=michaelwoerister

rustc_codegen_ssa: cleanup `AtomicOrdering`

* Remove unused `NotAtomic` ordering.
* Rename `Monotonic` to `Relaxed` - a Rust specific name.
* Derive copy and clone.

2 years agocall `instantiation_mode` when pushing a new mono_item
SparrowLii [Thu, 26 May 2022 01:36:54 +0000 (09:36 +0800)]
call `instantiation_mode` when pushing a new mono_item

2 years agoOnly allow `compiletest` to use `feature(test)`, not any other feature
Joshua Nelson [Wed, 25 May 2022 23:43:09 +0000 (18:43 -0500)]
Only allow `compiletest` to use `feature(test)`, not any other feature

Using language features occasionally causes issues when using nightly to bootstrap, rather than beta.
See #59264 for additional context.

2 years agoAuto merge of #97409 - GuillaumeGomez:rollup-808v9ge, r=GuillaumeGomez
bors [Wed, 25 May 2022 23:02:37 +0000 (23:02 +0000)]
Auto merge of #97409 - GuillaumeGomez:rollup-808v9ge, r=GuillaumeGomez

Rollup of 4 pull requests

Successful merges:

 - #97317 (Allow to click on setting text)
 - #97375 (Simplify implementation of `-Z gcc-ld`)
 - #97394 (Add more eslint rules)
 - #97407 (Update books)

Failed merges:

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

2 years agoAvoid adjusting file positions twice.
Nicholas Nethercote [Wed, 25 May 2022 04:01:18 +0000 (14:01 +1000)]
Avoid adjusting file positions twice.

`imported_source_files` adjusts lots of file positions, and then calls
`new_imported_source_file`, which then adjust them all again. This
commit combines the two adjustments into one, for a small perf win.

2 years agoAugment a comment.
Nicholas Nethercote [Wed, 25 May 2022 04:47:28 +0000 (14:47 +1000)]
Augment a comment.

2 years agoRollup merge of #97407 - ehuss:update-books, r=ehuss
Guillaume Gomez [Wed, 25 May 2022 22:32:12 +0000 (00:32 +0200)]
Rollup merge of #97407 - ehuss:update-books, r=ehuss

Update books

## reference

6 commits in 8e36971959ff238b5aa2575fbc7a2e09e1313e82..b74825d8f88b685e239ade00f00de68ba4cd63d4
2022-05-09 17:20:59 -0700 to 2022-05-20 14:30:30 -0700
- Inline assembly: Clarify references to quoted regs (rust-lang/reference#1191)
- Add tile registers to inline-assembly documentation (rust-lang/reference#1220)
- Upper bound on hashes in raw string literals (rust-lang/reference#1180)
- Remove footnote on warning about lifetime shadowing labels.
- Makes explanation for Spans in "Procedural Macros" clearer (rust-lang/reference#1219)
- Update "Match Expressions" to remove 'cold' (rust-lang/reference#1216)

## book

18 commits in d9415b7cbfcb4b24062683f429bd0ff535396362..b4dd5f00b87190ad5ef42cbc2a88a783c6ae57ef
2022-05-09 09:10:44 -0400 to 2022-05-24 21:37:06 -0400
- Snapshot of appendices for nostarch
- Update rust-analyzer URLs and make links less repetitive
- Correct byte string literal type. Fixes rust-lang/book#2631.
- Fix verb agreement. Fixes rust-lang/book#3176
- Propagate ch19 edits to src
- Edits to chapter 19 from nostarch
- Propagate ch18 edits to src
- Edits to ch18 from nostarch
- Propagate tech review edits to src ch5
- Responses to chapter 5 tech review
- Ch5 after tech review
- Merge branch 'ch7-edits'
- fix: mdBook authors
- Propagating ch17 edits to src
- Edits from nostarch for ch17
- Fix rust-lang/book#3152 - Wrong character used
- & is not valid inside image alt text
- Merge branch 'ch20'

## rust-by-example

2 commits in e9f93cfcf410bc092c9107b8a41a82f144c761f2..2ed26865e8c29ef939dc913a97bd321cadd72a9a
2022-05-08 18:24:06 -0300 to 2022-05-18 17:23:47 -0300
- Rework cpuid asm example. (rust-lang/rust-by-example#1542)
- chore: better description for eprint macro (rust-lang/rust-by-example#1541)

## rustc-dev-guide

11 commits in 0c02acdb6f48f03907a02ea8e537c3272b4fde9f..554c00e4805df7f7bffac7db408437d62d6dfb9a
2022-05-10 09:45:31 -0300 to 2022-05-24 17:15:35 -0700
- Cleanup rustdoc-internals
- Fix some wording on the "Incremental Compilation In Detail" page
- Exclude `tomlee.co` from link-checking (rust-lang/rustc-dev-guide#1356)
- Add note about patching dependencies and warnings. (rust-lang/rustc-dev-guide#1354)
- make sentence more simple (rust-lang/rustc-dev-guide#1353)
- Update some links and docs (rust-lang/rustc-dev-guide#1340)
- Replace a broken YouTube link (rust-lang/rustc-dev-guide#1295)
- Edit the "Compiler Source Code" chapter (rust-lang/rustc-dev-guide#1307)
- Add docs for logging of queries. (rust-lang/rustc-dev-guide#1350)
- Fix configuration names for vscode/r-a (rust-lang/rustc-dev-guide#1352)
- Update docs for deprecated attribute (rust-lang/rustc-dev-guide#1338)

2 years agoRollup merge of #97394 - GuillaumeGomez:more-eslint-rules, r=notriddle
Guillaume Gomez [Wed, 25 May 2022 22:32:11 +0000 (00:32 +0200)]
Rollup merge of #97394 - GuillaumeGomez:more-eslint-rules, r=notriddle

Add more eslint rules

This PR adds more eslint rules. Here are the explanations for each of them:

 * [space-infix-ops](https://eslint.org/docs/rules/space-infix-ops)
 * [space-before-function-paren](https://eslint.org/docs/rules/space-before-function-paren)
 * [space-before-blocks](https://eslint.org/docs/rules/space-before-blocks)
 * [comma-dangle](https://eslint.org/docs/rules/comma-dangle)
 * [comma-style](https://eslint.org/docs/rules/comma-style)
 * [max-len](https://eslint.org/docs/rules/max-len)
 * [eol-last](https://eslint.org/docs/rules/eol-last)

r? `@notriddle`

2 years agoRollup merge of #97375 - petrochenkov:zgccld, r=bjorn3
Guillaume Gomez [Wed, 25 May 2022 22:32:10 +0000 (00:32 +0200)]
Rollup merge of #97375 - petrochenkov:zgccld, r=bjorn3

Simplify implementation of `-Z gcc-ld`

- The logic is now unified for all targets (wasm targets should also be supported now)
- Additional "symlink" files like `ld64` are eliminated
- lld-wrapper is used for propagating the correct lld flavor
- Cleanup "unwrap or exit" logic in lld-wrapper

cc https://github.com/rust-lang/rust/issues/97352
r? `@bjorn3`

2 years agoRollup merge of #97317 - GuillaumeGomez:gui-settings-text-click, r=jsha
Guillaume Gomez [Wed, 25 May 2022 22:32:09 +0000 (00:32 +0200)]
Rollup merge of #97317 - GuillaumeGomez:gui-settings-text-click, r=jsha

Allow to click on setting text

You can test it [here](https://rustdoc.crud.net/imperio/gui-settings-text-click/doc/foo/index.html).

This PR allows to click on the text alongside the toggle to change it.

r? `@jsha`

2 years agoSimplify implementation of `-Z gcc-ld`
Vadim Petrochenkov [Tue, 24 May 2022 20:29:15 +0000 (23:29 +0300)]
Simplify implementation of `-Z gcc-ld`

- The logic is now unified for all targets (wasm targets should also be supported now)
- Additional "symlink" files like `ld64` are eliminated
- lld-wrapper is used for propagating the correct lld flavor
- Cleanup "unwrap or exit" logic in lld-wrapper

2 years agoAuto merge of #97403 - arlosi:update-cargo, r=ehuss
bors [Wed, 25 May 2022 20:35:49 +0000 (20:35 +0000)]
Auto merge of #97403 - arlosi:update-cargo, r=ehuss

Update cargo

10 commits in a4c1cd0eb6b18082a7e693f5a665548fe1534be4..39ad1039d9e3e1746177bf5d134af4c164f95528
2022-05-20 00:55:25 +0000 to 2022-05-25 00:50:02 +0000

* doc: discuss build script instruction order (rust-lang/cargo#10600)
* Require http-registry URLs to end with a '/' (rust-lang/cargo#10698)
* No printing executable names when running tests and benchmarks with json message format (rust-lang/cargo#10691)
* Restore proper error for crate not in local reg (rust-lang/cargo#10683)
* Update libcurl (rust-lang/cargo#10696)
* Fixed small typos (rust-lang/cargo#10693)
* fix bugs with `workspace` key and `update_toml` (rust-lang/cargo#10685)
* Bump to 0.64.0, update changelog (rust-lang/cargo#10687)
* List C compiler as a build dependency in README (rust-lang/cargo#10678)
* Add unstable `rustc-check-cfg` build script output (rust-lang/cargo#10539)

r? `@ehuss`

2 years agoUpdate books
Eric Huss [Wed, 25 May 2022 19:45:28 +0000 (12:45 -0700)]
Update books

2 years agofix broken doctest
Jane Lusby [Wed, 25 May 2022 19:20:48 +0000 (12:20 -0700)]
fix broken doctest

2 years agoupdate option and result references to expect message docs
Jane Lusby [Wed, 25 May 2022 18:37:39 +0000 (11:37 -0700)]
update option and result references to expect message docs

2 years agofix links
Jane Lusby [Wed, 25 May 2022 17:46:56 +0000 (10:46 -0700)]
fix links

2 years agoUpdate cargo
Arlo Siemsen [Wed, 25 May 2022 17:31:30 +0000 (10:31 -0700)]
Update cargo

2 years agoAuto merge of #97401 - Dylan-DPC:rollup-fh9e61o, r=Dylan-DPC
bors [Wed, 25 May 2022 16:39:37 +0000 (16:39 +0000)]
Auto merge of #97401 - Dylan-DPC:rollup-fh9e61o, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #97302 (Do writeback of Closure params before visiting the parent expression)
 - #97328 (rustc: Fix ICE in native library error reporting)
 - #97351 (Output correct type responsible for structural match violation)
 - #97398 (Add regression test for #82830)
 - #97400 (Fix a typo on Struct `Substructure`)

Failed merges:

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

2 years agoRollup merge of #97400 - JohnTitor:typo-fix-substructure, r=cjgillot
Dylan DPC [Wed, 25 May 2022 15:37:23 +0000 (17:37 +0200)]
Rollup merge of #97400 - JohnTitor:typo-fix-substructure, r=cjgillot

Fix a typo on Struct `Substructure`

2 years agoRollup merge of #97398 - JohnTitor:issue-82830, r=compiler-errors
Dylan DPC [Wed, 25 May 2022 15:37:22 +0000 (17:37 +0200)]
Rollup merge of #97398 - JohnTitor:issue-82830, r=compiler-errors

Add regression test for #82830

Closes #82830
r? `@compiler-errors`

2 years agoRollup merge of #97351 - b-naber:adt-const-params-structural-match-violation, r=micha...
Dylan DPC [Wed, 25 May 2022 15:37:21 +0000 (17:37 +0200)]
Rollup merge of #97351 - b-naber:adt-const-params-structural-match-violation, r=michaelwoerister

Output correct type responsible for structural match violation

Previously we included the outermost type that caused a structural match violation in the error message and stated that that type must be annotated with `#[derive(Eq, PartialEq)]` even if it already had that annotation. This PR outputs the correct type in the error message.

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

2 years agoRollup merge of #97328 - petrochenkov:nativice, r=michaelwoerister
Dylan DPC [Wed, 25 May 2022 15:37:20 +0000 (17:37 +0200)]
Rollup merge of #97328 - petrochenkov:nativice, r=michaelwoerister

rustc: Fix ICE in native library error reporting

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

2 years agoRollup merge of #97302 - compiler-errors:writeback-ascending, r=cjgillot
Dylan DPC [Wed, 25 May 2022 15:37:18 +0000 (17:37 +0200)]
Rollup merge of #97302 - compiler-errors:writeback-ascending, r=cjgillot

Do writeback of Closure params before visiting the parent expression

This means that given the expression:

```
let x = |a: Vec<_>| {};
```

We will visit the HIR node for `a` before `x`, and report the ambiguity on the former instead of the latter. This also moves writeback for struct field ids and const blocks before, but the ordering of this and walking the expr doesn't seem to matter.

2 years agoAuto merge of #94954 - SimonSapin:null-thin3, r=yaahc
bors [Wed, 25 May 2022 13:58:51 +0000 (13:58 +0000)]
Auto merge of #94954 - SimonSapin:null-thin3, r=yaahc

Extend ptr::null and null_mut to all thin (including extern) types

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

This change was accepted in https://rust-lang.github.io/rfcs/2580-ptr-meta.html

Note that this changes the signature of **stable** functions. The change should be backward-compatible, but it is **insta-stable** since it cannot (easily, at all?) be made available only through a `#![feature(…)]` opt-in.

The RFC also proposed the same change for `NonNull::dangling`, which makes sense it terms of its signature but not in terms of its implementation. `dangling` uses `align_of()` as an address. But what `align_of()` should be for extern types or whether it should be allowed at all remains an open question.

This commit depends on https://github.com/rust-lang/rust/pull/93977, which is not yet part of the bootstrap compiler. So `#[cfg]` is used to only apply the change in stage 1+. As far a I know bounds cannot be made conditional with `#[cfg]`, so the entire functions are duplicated. This is unfortunate but temporary.

Since this duplication makes it less obvious in the diff, the new definitions differ in:

* More permissive bounds (`Thin` instead of implied `Sized`)
* Different implementation
* Having `rustc_allow_const_fn_unstable(const_fn_trait_bound)`
* Having `rustc_allow_const_fn_unstable(ptr_metadata)`

2 years agoFix a typo on Struct `Substructure`
Yuki Okushi [Wed, 25 May 2022 13:25:37 +0000 (22:25 +0900)]
Fix a typo on Struct `Substructure`

2 years agoAdd regression test for #82830
Yuki Okushi [Wed, 25 May 2022 13:14:20 +0000 (22:14 +0900)]
Add regression test for #82830

2 years agoAdd new eslint rule "eol-last"
Guillaume Gomez [Wed, 25 May 2022 11:58:42 +0000 (13:58 +0200)]
Add new eslint rule "eol-last"

2 years agoAdd new eslint rule "max-len"
Guillaume Gomez [Wed, 25 May 2022 11:58:14 +0000 (13:58 +0200)]
Add new eslint rule "max-len"

2 years agoAdd new eslint rule "comma-style"
Guillaume Gomez [Wed, 25 May 2022 11:57:08 +0000 (13:57 +0200)]
Add new eslint rule "comma-style"

2 years agoAdd new eslint rule "comma-dangle"
Guillaume Gomez [Wed, 25 May 2022 11:56:27 +0000 (13:56 +0200)]
Add new eslint rule "comma-dangle"

2 years agoAdd new eslint rule "space-before-blocks"
Guillaume Gomez [Wed, 25 May 2022 11:55:54 +0000 (13:55 +0200)]
Add new eslint rule "space-before-blocks"

2 years agoAdd new eslint rule "space-before-function-paren"
Guillaume Gomez [Wed, 25 May 2022 11:55:09 +0000 (13:55 +0200)]
Add new eslint rule "space-before-function-paren"

2 years agoAdd eslint rule "space-infix-ops"
Guillaume Gomez [Wed, 25 May 2022 11:53:19 +0000 (13:53 +0200)]
Add eslint rule "space-infix-ops"

2 years agoAuto merge of #97388 - Dylan-DPC:rollup-tfuc4tf, r=Dylan-DPC
bors [Wed, 25 May 2022 11:17:34 +0000 (11:17 +0000)]
Auto merge of #97388 - Dylan-DPC:rollup-tfuc4tf, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #95953 (Modify MIR building to drop repeat expressions with length zero)
 - #96913 (RFC3239: Implement `cfg(target)` - Part 2)
 - #97233 ([RFC 2011] Library code)
 - #97370 (Minor improvement on else-no-if diagnostic)
 - #97384 (Fix metadata stats.)

Failed merges:

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

2 years agoRollup merge of #97384 - nnethercote:fix-metadata-stats, r=bjorn3
Dylan DPC [Wed, 25 May 2022 08:48:31 +0000 (10:48 +0200)]
Rollup merge of #97384 - nnethercote:fix-metadata-stats, r=bjorn3

Fix metadata stats.

This commit:
- Counts some things that weren't being counted previously, and adds
  an assertion that ensure everything is counted.
- Reorders things so the `eprintln`s order matches the code order.
- Adds percentages, and makes clear that the zero bytes count is orthogonal to
  the other measurements.

Example of the new output:
```
55463779 metadata bytes, of which 18054531 bytes (32.6%) are zero
             preamble:       30 bytes ( 0.0%)
                  dep:        0 bytes ( 0.0%)
          lib feature:    17458 bytes ( 0.0%)
            lang item:      337 bytes ( 0.0%)
      diagnostic item:     1788 bytes ( 0.0%)
           native lib:        0 bytes ( 0.0%)
      foreign modules:     5113 bytes ( 0.0%)
       def-path table:   720180 bytes ( 1.3%)
               traits:      359 bytes ( 0.0%)
                impls:    64624 bytes ( 0.1%)
     incoherent_impls:      130 bytes ( 0.0%)
                  mir: 16137354 bytes (29.1%)
                 item: 23773099 bytes (42.9%)
interpret_alloc_index:      599 bytes ( 0.0%)
      proc-macro-data:        0 bytes ( 0.0%)
               tables: 10081135 bytes (18.2%)
 debugger visualizers:        0 bytes ( 0.0%)
     exported symbols:     5666 bytes ( 0.0%)
              hygiene:  1539390 bytes ( 2.8%)
      def-path hashes:  2752564 bytes ( 5.0%)
           source_map:   363540 bytes ( 0.7%)
                final:      413 bytes ( 0.0%)
```
r? `@bjorn3`

2 years agoRollup merge of #97370 - compiler-errors:else-no-if-2, r=Dylan-DPC
Dylan DPC [Wed, 25 May 2022 08:48:30 +0000 (10:48 +0200)]
Rollup merge of #97370 - compiler-errors:else-no-if-2, r=Dylan-DPC

Minor improvement on else-no-if diagnostic

Don't suggest wrapping in block since it's highly likely to be a missing `if` after `else`. Also rework message a bit (open to further suggestions).

cc: https://github.com/rust-lang/rust/pull/97298#discussion_r880933431

r? `@estebank`

2 years agoRollup merge of #97233 - c410-f3r:assert-lib, r=scottmcm
Dylan DPC [Wed, 25 May 2022 08:48:29 +0000 (10:48 +0200)]
Rollup merge of #97233 - c410-f3r:assert-lib, r=scottmcm

[RFC 2011] Library code

CC https://github.com/rust-lang/rust/pull/96496

Based on https://github.com/dtolnay/case-studies/tree/master/autoref-specialization.

Basically creates two traits with the same method name. One trait is generic over any `T` and the other is specialized to any `T: Printable`.

The compiler will then call the corresponding trait method through auto reference.

```rust
fn main() {
    let mut a = Capture::new();
    let mut b = Capture::new();

    (&Wrapper(&1i32)).try_capture(&mut a); // `try_capture` from `TryCapturePrintable`
    (&Wrapper(&vec![1i32])).try_capture(&mut b); // `try_capture` from `TryCaptureGeneric`

    assert_eq!(format!("{:?}", a), "1");
    assert_eq!(format!("{:?}", b), "N/A");
}
```

r? `@scottmcm`

2 years agoRollup merge of #96913 - Urgau:rfc3239-part2, r=petrochenkov
Dylan DPC [Wed, 25 May 2022 08:48:28 +0000 (10:48 +0200)]
Rollup merge of #96913 - Urgau:rfc3239-part2, r=petrochenkov

RFC3239: Implement `cfg(target)` - Part 2

This pull-request implements the compact `cfg(target(..))` part of [RFC 3239](https://github.com/rust-lang/rust/issues/96901).

I recommend reviewing this PR on a per commit basics, because of some moving parts.

cc `@GuillaumeGomez`
r? `@petrochenkov`

2 years agoRollup merge of #95953 - JakobDegen:repeat-leak, r=oli-obk
Dylan DPC [Wed, 25 May 2022 08:48:27 +0000 (10:48 +0200)]
Rollup merge of #95953 - JakobDegen:repeat-leak, r=oli-obk

Modify MIR building to drop repeat expressions with length zero

Closes #74836 .

Previously, when a user wrote `[foo; 0]` we used to simply leak `foo`. The goal is to fix that. This PR changes MIR building to make `[foo; 0]` equivalent to `{ drop(foo); [] }` in all cases. Of course, this is a breaking change (see below). A crater run did not indicate any regressions though, and given that the previous behavior was almost definitely not what any user wanted, it seems unlikely that anyone was relying on this.

Note that const generics are in general unaffected by this. Inserting the extra `drop` is only meaningful/necessary when `foo` is of a non-`Copy` type, and array repeat expressions with const generic repetition count must always be `Copy`.

Besides the obvious change to behavior associated with the additional drop, there are three categories of examples where this also changes observable behavior. In all of these cases, the new behavior is consistent with what you would get by replacing `[foo; 0]` with `{ drop(foo); [] }`. As such, none of these give the user new powers to express more things.

**No longer allowed in const (breaking)**:

```rust
const _: [String; 0] = [String::new(); 0];
```

This compiles on stable today. Because we now introduce the drop of `String`, this no longer compiles as `String` may not be dropped in a const context.

**Reduced dataflow (non-breaking)**:

```rust
let mut x: i32 = 0;
let r = &x;
let a = [r; 0];
x = 5;
let _b = a;
```

Borrowck rejects this code on stable because it believes there is dataflow between `a` and `r`, and so the lifetime of `r` has to extend to the last statement. This change removes the dataflow and the above code is allowed to compile.

**More const promotion (non-breaking)**:

```rust
let _v: &'static [String; 0] = &[String::new(); 0];
```

This does not compile today because `String` having drop glue keeps it from being const promoted (despite that drop glue never being executed). After this change, this is allowed to compile.

### Alternatives

A previous attempt at this tried to reduce breakage by various tricks. This is still a possibility, but given that crater showed no regressions it seems unclear why we would want to introduce this complexity.

Disallowing `[foo; 0]` completely is also an option, but obviously this is more of a breaking change. I do not know how often this is actually used though.

r? `@oli-obk`

2 years agoAuto merge of #97345 - lcnr:fast_reject, r=nnethercote
bors [Wed, 25 May 2022 08:36:46 +0000 (08:36 +0000)]
Auto merge of #97345 - lcnr:fast_reject, r=nnethercote

add a deep fast_reject routine

continues the work on #97136.

r? `@nnethercote`

Actually agree with you on the match structure :laughing: let's see how that impacted perf :sweat_smile:

2 years agorustc_codegen_ssa: derive copy and clone for various enums
Tomasz Miąsko [Tue, 24 May 2022 00:00:00 +0000 (00:00 +0000)]
rustc_codegen_ssa: derive copy and clone for various enums

2 years agorustc_codegen_ssa: cleanup `AtomicOrdering`
Tomasz Miąsko [Tue, 24 May 2022 00:00:00 +0000 (00:00 +0000)]
rustc_codegen_ssa: cleanup `AtomicOrdering`

* Remove unused `NotAtomic` ordering.
* Rename `Monotonic` to `Relaxed` - a Rust specific name.

2 years agoFix metadata stats.
Nicholas Nethercote [Wed, 25 May 2022 06:24:07 +0000 (16:24 +1000)]
Fix metadata stats.

This commit:
- Counts some things that weren't being counted previously, and adds
  an assertion that ensure everything is counted.
- Reorders things so the `eprintln`s order matches the code order.
- Adds percentages, and makes clear that the zero bytes count is orthogonal to
  the other measurements.

Example of the new output:
```
55463779 metadata bytes, of which 18054531 bytes (32.6%) are zero
             preamble:       30 bytes ( 0.0%)
                  dep:        0 bytes ( 0.0%)
          lib feature:    17458 bytes ( 0.0%)
            lang item:      337 bytes ( 0.0%)
      diagnostic item:     1788 bytes ( 0.0%)
           native lib:        0 bytes ( 0.0%)
      foreign modules:     5113 bytes ( 0.0%)
       def-path table:   720180 bytes ( 1.3%)
               traits:      359 bytes ( 0.0%)
                impls:    64624 bytes ( 0.1%)
     incoherent_impls:      130 bytes ( 0.0%)
                  mir: 16137354 bytes (29.1%)
                 item: 23773099 bytes (42.9%)
interpret_alloc_index:      599 bytes ( 0.0%)
      proc-macro-data:        0 bytes ( 0.0%)
               tables: 10081135 bytes (18.2%)
 debugger visualizers:        0 bytes ( 0.0%)
     exported symbols:     5666 bytes ( 0.0%)
              hygiene:  1539390 bytes ( 2.8%)
      def-path hashes:  2752564 bytes ( 5.0%)
           source_map:   363540 bytes ( 0.7%)
                final:      413 bytes ( 0.0%)
```

2 years agoAuto merge of #97382 - Dylan-DPC:rollup-2t4ov4z, r=Dylan-DPC
bors [Wed, 25 May 2022 06:14:15 +0000 (06:14 +0000)]
Auto merge of #97382 - Dylan-DPC:rollup-2t4ov4z, r=Dylan-DPC

Rollup of 5 pull requests

Successful merges:

 - #93604 (Make llvm-libunwind a per-target option)
 - #97026 (Change orderings of `Debug` for the Atomic types to `Relaxed`.)
 - #97105 (Add tests for lint on type dependent on consts)
 - #97323 (Introduce stricter checks for might_permit_raw_init under a debug flag )
 - #97379 (Add aliases for `current_dir`)

Failed merges:

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

2 years agomove fast reject test out of `SelectionContext::match_impl`.
lcnr [Tue, 24 May 2022 07:22:24 +0000 (09:22 +0200)]
move fast reject test out of `SelectionContext::match_impl`.

`match_impl` has two call sites. For one of them (within `rematch_impl`)
the fast reject test isn't necessary, because any rejection would
represent a compiler bug.

This commit moves the fast reject test to the other `match_impl` call
site, in `assemble_candidates_from_impls`. This lets us move the fast
reject test outside the `probe` call in that function. This avoids the
taking of useless snapshots when the fast reject test succeeds, which
gives a performance win when compiling the `bitmaps` and `nalgebra`
crates.

Co-authored-by: name <n.nethercote@gmail.com>
2 years agoadd a deep fast_reject routine
lcnr [Tue, 24 May 2022 07:15:19 +0000 (09:15 +0200)]
add a deep fast_reject routine

2 years agoRollup merge of #97379 - ear7h:master, r=thomcc
Dylan DPC [Wed, 25 May 2022 05:31:45 +0000 (07:31 +0200)]
Rollup merge of #97379 - ear7h:master, r=thomcc

Add aliases for `current_dir`

Aliases were added for the equivalent C/C++ APIs for POSIX and Windows. Also, I added one for `pwd` which users may be more familiar with, from the command line.

2 years agoRollup merge of #97323 - 5225225:strict_init_checks, r=oli-obk
Dylan DPC [Wed, 25 May 2022 05:31:44 +0000 (07:31 +0200)]
Rollup merge of #97323 - 5225225:strict_init_checks, r=oli-obk

Introduce stricter checks for might_permit_raw_init under a debug flag

This is intended to be a version of the strict checks tried out in #79296, but also checking number validity (under the assumption that `let _ = std::mem::uninitialized::<u32>()` is UB, which seems to be what https://github.com/rust-lang/unsafe-code-guidelines/issues/71 is leaning towards.)

2 years agoRollup merge of #97105 - JulianKnodt:const_dep_gen_const_expr, r=lcnr
Dylan DPC [Wed, 25 May 2022 05:31:43 +0000 (07:31 +0200)]
Rollup merge of #97105 - JulianKnodt:const_dep_gen_const_expr, r=lcnr

Add tests for lint on type dependent on consts

r? `@lcnr`

2 years agoRollup merge of #97026 - Nilstrieb:make-atomic-debug-relaxed, r=scottmcm
Dylan DPC [Wed, 25 May 2022 05:31:42 +0000 (07:31 +0200)]
Rollup merge of #97026 - Nilstrieb:make-atomic-debug-relaxed, r=scottmcm

Change orderings of `Debug` for the Atomic types to `Relaxed`.

This reduces synchronization between threads when debugging the atomic types.  Reducing the synchronization means that executions with and without the debug calls will be more consistent, making it easier to debug.

We discussed this on the Rust Community Discord with `@ibraheemdev` before.

2 years agoRollup merge of #93604 - tmandry:libunwind-fuchsia-default, r=Mark-Simulacrum
Dylan DPC [Wed, 25 May 2022 05:31:41 +0000 (07:31 +0200)]
Rollup merge of #93604 - tmandry:libunwind-fuchsia-default, r=Mark-Simulacrum

Make llvm-libunwind a per-target option

Fuchsia doesn't ship libunwind in its SDK, so we must provide it statically.

2 years agoAuto merge of #97376 - compiler-errors:lazy-polymorphic, r=jackh726
bors [Wed, 25 May 2022 03:53:39 +0000 (03:53 +0000)]
Auto merge of #97376 - compiler-errors:lazy-polymorphic, r=jackh726

Make `Lazy*<T>` types in `rustc_metadata` not care about lifetimes until decode

This allows us to remove the `'tcx` lifetime from `CrateRoot`. This is necessary because of #97287, which makes the `'tcx` lifetime on `Ty` invariant instead of covariant, so [this hack](https://github.com/rust-lang/rust/blob/0a437b2ca081bc12425a3318cb66aade9824cbae/compiler/rustc_metadata/src/rmeta/decoder.rs#L89-92) no longer holds under that PR.

Introduces a trait called `ParameterizedOverTcx` which has a generic associated type that allows a type to be parameterized over that lifetime. This means we can decode, for example, `Lazy<Ty<'static>>` into any `Ty<'tcx>` depending on the `TyCtxt<'tcx>` we pass into the decode function.

2 years agoadd aliases for current_dir
julio [Wed, 25 May 2022 02:41:40 +0000 (19:41 -0700)]
add aliases for current_dir

2 years agotweak doctests
Артём Павлов [Artyom Pavlov] [Wed, 25 May 2022 02:14:30 +0000 (05:14 +0300)]
tweak doctests

2 years agoimplement tie to even
Артём Павлов [Artyom Pavlov] [Wed, 25 May 2022 02:01:11 +0000 (05:01 +0300)]
implement tie to even

2 years agoAuto merge of #97365 - klensy:rustdoc-vs-clippy, r=notriddle
bors [Wed, 25 May 2022 01:12:54 +0000 (01:12 +0000)]
Auto merge of #97365 - klensy:rustdoc-vs-clippy, r=notriddle

rustdoc: fix few clippy lints

Fix few clippy lints: second commit - perf ones, first - other ones.

2 years agoMake llvm-libunwind a per-target option
Tyler Mandry [Wed, 2 Feb 2022 22:48:09 +0000 (22:48 +0000)]
Make llvm-libunwind a per-target option

2 years agoMake Lazy not care about lifetimes until decode
Michael Goulet [Sun, 22 May 2022 19:34:34 +0000 (12:34 -0700)]
Make Lazy not care about lifetimes until decode

2 years agoexplained unwrap vs expect
Jane Losare-Lusby [Tue, 24 May 2022 22:51:54 +0000 (22:51 +0000)]
explained unwrap vs expect

2 years agoAuto merge of #97372 - JohnTitor:rollup-6owv1v0, r=JohnTitor
bors [Tue, 24 May 2022 22:32:57 +0000 (22:32 +0000)]
Auto merge of #97372 - JohnTitor:rollup-6owv1v0, r=JohnTitor

Rollup of 6 pull requests

Successful merges:

 - #93966 (document expectations for Waker::wake)
 - #97266 (Make weird name lints trigger behind cfg_attr)
 - #97355 (Remove unused brush image)
 - #97358 (Update minifier-rs version to 0.1.0)
 - #97363 (Fix a small mistake in `SliceIndex`'s documentation)
 - #97364 (Fix weird indentation in continue_keyword docs)

Failed merges:

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