]> git.lizzy.rs Git - rust.git/log
rust.git
21 months agoAuto merge of #102484 - beetrees:duration-debug-bug-fix, r=scottmcm
bors [Fri, 30 Sep 2022 14:16:57 +0000 (14:16 +0000)]
Auto merge of #102484 - beetrees:duration-debug-bug-fix, r=scottmcm

Fix integer overflow in `format!("{:.0?}", Duration::MAX)`

Currently `format!("{:.0?}", Duration::MAX)` causes an integer overflow in the `Duration` `Debug` impl ([playground link](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=67675c6895bdb2e37ee727f0ed7622b2)). This is because the carry from the rounding of the fractional_part into the integer_part will cause the integer_part to overflow as it is already `u64::MAX`. This PR uses a larger integer type to avoid that issue, and adds a test for the correct behaviour.

21 months agoAuto merge of #102509 - matthiaskrgr:rollup-gtenet8, r=matthiaskrgr
bors [Fri, 30 Sep 2022 10:39:09 +0000 (10:39 +0000)]
Auto merge of #102509 - matthiaskrgr:rollup-gtenet8, r=matthiaskrgr

Rollup of 5 pull requests

Successful merges:

 - #101075 (Migrate rustc_codegen_gcc to SessionDiagnostics )
 - #102350 (Improve errors for incomplete functions in struct definitions)
 - #102481 (rustdoc: remove unneeded CSS `.rust-example-rendered { position }`)
 - #102491 (rustdoc: remove no-op source sidebar `opacity`)
 - #102499 (Adjust the s390x data layout for LLVM 16)

Failed merges:

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

21 months agoRollup merge of #102499 - cuviper:llvm-16-s390x, r=nikic
Matthias Krüger [Fri, 30 Sep 2022 08:22:39 +0000 (10:22 +0200)]
Rollup merge of #102499 - cuviper:llvm-16-s390x, r=nikic

Adjust the s390x data layout for LLVM 16

LLVM [D131158] changed the SystemZ data layout to always set 64-bit
vector alignment, which used to be conditional on the "vector" feature.

[D131158]: https://reviews.llvm.org/D131158

r? `@nikic`

21 months agoRollup merge of #102491 - notriddle:notriddle/sidebar-opacity, r=GuillaumeGomez
Matthias Krüger [Fri, 30 Sep 2022 08:22:38 +0000 (10:22 +0200)]
Rollup merge of #102491 - notriddle:notriddle/sidebar-opacity, r=GuillaumeGomez

rustdoc: remove no-op source sidebar `opacity`

These rules were added in dc2c9723343c985740be09919236a6e96c4e4433 to work with CSS transitions. They're otherwise redundant, since the `visibility` property already hides everything.

https://github.com/rust-lang/rust/blob/dc2c9723343c985740be09919236a6e96c4e4433/src/librustdoc/html/static/css/rustdoc.css#L350-L354

The transition was remove with 237d62588ddb4b7a93f3f5c61ea9253eba30ed5d, but the now-redundant `opacity` property was not.

21 months agoRollup merge of #102481 - notriddle:notriddle/rust-example-rendered, r=GuillaumeGomez
Matthias Krüger [Fri, 30 Sep 2022 08:22:38 +0000 (10:22 +0200)]
Rollup merge of #102481 - notriddle:notriddle/rust-example-rendered, r=GuillaumeGomez

rustdoc: remove unneeded CSS `.rust-example-rendered { position }`

The Run button isn't inside the `<pre>` any more. It's instead nested below the example wrapper.

The class name can't be removed from the DOM, because `main.js` uses it.

21 months agoRollup merge of #102350 - TaKO8Ki:incomplete-fn-in-struct-definition, r=fee1-dead
Matthias Krüger [Fri, 30 Sep 2022 08:22:37 +0000 (10:22 +0200)]
Rollup merge of #102350 - TaKO8Ki:incomplete-fn-in-struct-definition, r=fee1-dead

Improve errors for incomplete functions in struct definitions

Given the following code:

```rust
fn main() {}

struct Foo {
    fn
}
```

[playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=29139f870511f6918324be5ddc26c345)

The current output is:

```
   Compiling playground v0.0.1 (/playground)
error: functions are not allowed in struct definitions
 --> src/main.rs:4:5
  |
4 |     fn
  |     ^^
  |
  = help: unlike in C++, Java, and C#, functions are declared in `impl` blocks
  = help: see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information

error: could not compile `playground` due to previous error
```

In this case, rustc should suggest escaping `fn` to use it as an identifier.

21 months agoRollup merge of #101075 - ellishg:rustc_codegen_gcc_diagnostics, r=davidtwco
Matthias Krüger [Fri, 30 Sep 2022 08:22:36 +0000 (10:22 +0200)]
Rollup merge of #101075 - ellishg:rustc_codegen_gcc_diagnostics, r=davidtwco

Migrate rustc_codegen_gcc to SessionDiagnostics

As part of #100717 this pr migrates diagnostics to `SessionDiagnostics` for the `rustc_codegen_gcc` crate.

``@rustbot`` label +A-translation

21 months agoAuto merge of #102387 - nnethercote:inline-Token-PartialEq, r=lqd
bors [Fri, 30 Sep 2022 07:57:12 +0000 (07:57 +0000)]
Auto merge of #102387 - nnethercote:inline-Token-PartialEq, r=lqd

Inline a few functions.

r? `@ghost`

21 months agoAuto merge of #102164 - compiler-errors:rpitit-foreign, r=TaKO8Ki
bors [Fri, 30 Sep 2022 04:24:14 +0000 (04:24 +0000)]
Auto merge of #102164 - compiler-errors:rpitit-foreign, r=TaKO8Ki

Serialize return-position `impl Trait` in trait hidden values in foreign libraries

Fixes #101630

21 months agoAuto merge of #102304 - lcnr:coherence-cleanup, r=compiler-errors
bors [Fri, 30 Sep 2022 01:32:15 +0000 (01:32 +0000)]
Auto merge of #102304 - lcnr:coherence-cleanup, r=compiler-errors

remove outdated coherence hack

we have a more precise detection for downstream conflicts in candidate assembly: the `is_knowable` check in `candidate_from_obligation_no_cache`.

r? types cc `@nikomatsakis`

21 months agoAdjust the s390x data layout for LLVM 16
Josh Stone [Fri, 30 Sep 2022 01:18:26 +0000 (18:18 -0700)]
Adjust the s390x data layout for LLVM 16

LLVM [D131158] changed the SystemZ data layout to always set 64-bit
vector alignment, which used to be conditional on the "vector" feature.

[D131158]: https://reviews.llvm.org/D131158

21 months agoAuto merge of #101887 - nnethercote:shrink-Res, r=spastorino
bors [Thu, 29 Sep 2022 22:45:24 +0000 (22:45 +0000)]
Auto merge of #101887 - nnethercote:shrink-Res, r=spastorino

Shrink `hir::def::Res`

r? `@spastorino`

21 months agorustdoc: update test case now that the UI animation is removed
Michael Howell [Thu, 29 Sep 2022 22:40:24 +0000 (15:40 -0700)]
rustdoc: update test case now that the UI animation is removed

21 months agorustdoc: remove no-op source sidebar `opacity`
Michael Howell [Thu, 29 Sep 2022 22:33:02 +0000 (15:33 -0700)]
rustdoc: remove no-op source sidebar `opacity`

These rules were added in dc2c9723343c985740be09919236a6e96c4e4433 to work
with CSS transitions. They're otherwise redundant, since the `visibility`
property already hides everything.

https://github.com/rust-lang/rust/blob/dc2c9723343c985740be09919236a6e96c4e4433/src/librustdoc/html/static/css/rustdoc.css#L350-L354

The transition was remove with 237d62588ddb4b7a93f3f5c61ea9253eba30ed5d, but
the now-redundant `opacity` property was not.

21 months agoFix integer overflow in `format!("{:.0?}", Duration::MAX)`
beetrees [Thu, 29 Sep 2022 17:50:10 +0000 (18:50 +0100)]
Fix integer overflow in `format!("{:.0?}", Duration::MAX)`

21 months agoAuto merge of #102482 - notriddle:rollup-fjm618g, r=notriddle
bors [Thu, 29 Sep 2022 19:52:48 +0000 (19:52 +0000)]
Auto merge of #102482 - notriddle:rollup-fjm618g, r=notriddle

Rollup of 7 pull requests

Successful merges:

 - #102214 (Fix span of byte-escaped left format args brace)
 - #102426 (Don't export `__wasm_init_memory` on WebAssembly.)
 - #102437 (rustdoc: cut margin-top from first header in docblock)
 - #102442 (rustdoc: remove bad CSS font-weight on `.impl`, `.method`, etc)
 - #102447 (rustdoc: add method spacing to trait methods)
 - #102468 (tidy: make rustc dependency error less confusing)
 - #102476 (Split out the error reporting logic into a separate function)

Failed merges:

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

21 months agoRollup merge of #102476 - oli-obk:split_error_path, r=cjgillot
Michael Howell [Thu, 29 Sep 2022 17:15:20 +0000 (10:15 -0700)]
Rollup merge of #102476 - oli-obk:split_error_path, r=cjgillot

Split out the error reporting logic into a separate function

I was trying to read the function and got distracted by the huge block of code in the middle of it. Turns out it only reports diagnostics and all paths within it end in an error. The main function is now more readable imo.

21 months agoRollup merge of #102468 - RalfJung:tidy, r=jyn514
Michael Howell [Thu, 29 Sep 2022 17:15:20 +0000 (10:15 -0700)]
Rollup merge of #102468 - RalfJung:tidy, r=jyn514

tidy: make rustc dependency error less confusing

The current wording leads to very confusing messages:
```
tidy error: Dependencies for main workspace not explicitly permitted:
* unicode-ident 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)
```
Miri is part of that workspace, and there never was a problem adding Miri dependencies. The actual error is that due to a crate bump this now showed up as a rustc dependency, and *those* are restricted.

21 months agoRollup merge of #102447 - notriddle:notriddle/method-toggle, r=jsha
Michael Howell [Thu, 29 Sep 2022 17:15:19 +0000 (10:15 -0700)]
Rollup merge of #102447 - notriddle:notriddle/method-toggle, r=jsha

rustdoc: add method spacing to trait methods

More cleanup for 8846c0853d8687fda0e5f23f6687b03b243980ee, this time in trait layouts when things are collapsed.

This PR makes two changes to the appearance of trait pages:

* It adds the `method-toggle` class to method toggles on traits, making the DOM more consistent with type pages (which already have this class).

  ## Before

  ![image](https://user-images.githubusercontent.com/1593513/192914353-ed17e1eb-df1d-480b-9998-3b5e8283b0ee.png)

  ## After

  ![image](https://user-images.githubusercontent.com/1593513/192914570-bdd0f2e1-5254-4e2e-9576-a797b82b3b3b.png)

* It adds a bottom margin to docblocks nested directly in the implementors list, giving it a similar appearance to if it was nested within a toggle.

  ## Before

  ![image](https://user-images.githubusercontent.com/1593513/192914503-1c3f39d5-690f-44ec-8f11-385302477d04.png)

  ## After

  ![image](https://user-images.githubusercontent.com/1593513/192914702-cbce4b3b-5cc6-49dc-b7f8-73be9e76791c.png)

21 months agoRollup merge of #102442 - notriddle:notriddle/header-weight, r=GuillaumeGomez
Michael Howell [Thu, 29 Sep 2022 17:15:19 +0000 (10:15 -0700)]
Rollup merge of #102442 - notriddle:notriddle/header-weight, r=GuillaumeGomez

rustdoc: remove bad CSS font-weight on `.impl`, `.method`, etc

This line was added in c494a06064017f307a8d9dc4797e614d2ed99143, because at the time, the headers had these classes on them. Now, the headers are children of the `<section>` with the class on it.

This commit also adds a test case, to make sure the srclink font weight does not regress again.

21 months agoRollup merge of #102437 - notriddle:notriddle/margin-top-h2, r=jsha
Michael Howell [Thu, 29 Sep 2022 17:15:18 +0000 (10:15 -0700)]
Rollup merge of #102437 - notriddle:notriddle/margin-top-h2, r=jsha

rustdoc: cut margin-top from first header in docblock

Fixes a regression caused by 8846c0853d8687fda0e5f23f6687b03b243980ee, where a header's top margin used to be collapsed, but isn't any more.

## Before

![image](https://user-images.githubusercontent.com/1593513/192893092-8e158bf7-ae18-41ef-8f11-6f34c724d345.png)

## After

![image](https://user-images.githubusercontent.com/1593513/192893139-d6ee06bf-9c0b-4194-bd5d-636312c89367.png)

21 months agoRollup merge of #102426 - sunfishcode:sunfishcode/no-wasm-init-memory, r=nagisa
Michael Howell [Thu, 29 Sep 2022 17:15:18 +0000 (10:15 -0700)]
Rollup merge of #102426 - sunfishcode:sunfishcode/no-wasm-init-memory, r=nagisa

Don't export `__wasm_init_memory` on WebAssembly.

Since #72889, the Rust wasm target doesn't use --passive-segments, so remove the `--export=__wasm_init_memory`.

As documented in the [tool-conventions Linking convention], `__wasm_init_memory` is not intended to be exported.

[tool-conventions Linking convention]: https://github.com/WebAssembly/tool-conventions/blob/7c064f304858f67ebf22964a84b7e9658e29557a/Linking.md#shared-memory-and-passive-segments

21 months agoRollup merge of #102214 - cassaundra:fix-format-args-span, r=cjgillot
Michael Howell [Thu, 29 Sep 2022 17:15:17 +0000 (10:15 -0700)]
Rollup merge of #102214 - cassaundra:fix-format-args-span, r=cjgillot

Fix span of byte-escaped left format args brace

Fix #102057 (see issue for example).

Previously, the use of escaped left braces (`\x7B`) in format args resulted in an incorrectly offset span. This patch fixes that by considering any escaped characters within the string instead of using a constant offset.

21 months agorustdoc: remove unneeded CSS `.rust-example-rendered { position }`
Michael Howell [Thu, 29 Sep 2022 17:08:12 +0000 (10:08 -0700)]
rustdoc: remove unneeded CSS `.rust-example-rendered { position }`

The Run button isn't inside the `<pre>` any more. It's instead nested below
the example wrapper.

The class name can't be removed from the DOM, because `main.js` uses it.

21 months agoAuto merge of #101893 - oli-obk:lift_derive, r=lcnr
bors [Thu, 29 Sep 2022 17:05:00 +0000 (17:05 +0000)]
Auto merge of #101893 - oli-obk:lift_derive, r=lcnr

Fix perf regression from TypeVisitor changes

Regression occurred in https://github.com/rust-lang/rust/pull/101858#issuecomment-1248732579

Instead of just reverting, we only fixed part of the regression. The main regression was due to actually correctly visiting a type that contains types and consts and should therefor be visited. This is not actually observable (yet?), but we should still do it correctly instead of risking major bugs in the future.

21 months agoSplit out the error reporting logic into a separate function
Oli Scherer [Thu, 29 Sep 2022 14:29:36 +0000 (14:29 +0000)]
Split out the error reporting logic into a separate function

21 months agomore clear function and variable names
Ralf Jung [Thu, 29 Sep 2022 14:09:14 +0000 (16:09 +0200)]
more clear function and variable names

21 months agoAuto merge of #102471 - Dylan-DPC:rollup-ij3okjt, r=Dylan-DPC
bors [Thu, 29 Sep 2022 13:27:28 +0000 (13:27 +0000)]
Auto merge of #102471 - Dylan-DPC:rollup-ij3okjt, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #102336 (Fix associated type bindings with anon const in GAT position)
 - #102342 (Add negation methods for signed non-zero integers.)
 - #102385 (Don't export `__heap_base` and `__data_end` on wasm32-wasi.)
 - #102435 (Improve example of Iterator::reduce)
 - #102436 (rustdoc: clean up "normalize.css 8" input override CSS)
 - #102452 (fix minor ungrammatical sentence)
 - #102455 (Use let-chaining in `WhileTrue::check_expr`.)

Failed merges:

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

21 months agoRollup merge of #102455 - nnethercote:WhileTrue-check_expr, r=lqd
Dylan DPC [Thu, 29 Sep 2022 12:43:22 +0000 (18:13 +0530)]
Rollup merge of #102455 - nnethercote:WhileTrue-check_expr, r=lqd

Use let-chaining in `WhileTrue::check_expr`.

This has been bugging me for a while.

r? `@lqd`

21 months agoRollup merge of #102452 - granolocks:grammar-tweak, r=thomcc
Dylan DPC [Thu, 29 Sep 2022 12:43:21 +0000 (18:13 +0530)]
Rollup merge of #102452 - granolocks:grammar-tweak, r=thomcc

fix minor ungrammatical sentence

This fixes an innocuous ungrammatical sentence in example code in the  `TryFrom` documentation.

21 months agoRollup merge of #102436 - notriddle:notriddle/normalize-form, r=GuillaumeGomez
Dylan DPC [Thu, 29 Sep 2022 12:43:21 +0000 (18:13 +0530)]
Rollup merge of #102436 - notriddle:notriddle/normalize-form, r=GuillaumeGomez

rustdoc: clean up "normalize.css 8" input override CSS

These rules were copied from normalize.css 3, and are mostly redundant.

* `optgroup` isn't used in rustdoc at all
* `textarea` is only used for the "copy" button, so it's not visible
* The remaining buttons and inputs mostly have styles set anyway.
* We should never be setting `color` without also setting the background to something. Otherwise, you get white-on-gray text. That seems to be [the reason] why `normalize.css` changed this.

[the reason]: https://github.com/necolas/normalize.css/pull/502

21 months agoRollup merge of #102435 - GuillaumeGomez:improve-iterator-reduce-example, r=thomcc...
Dylan DPC [Thu, 29 Sep 2022 12:43:20 +0000 (18:13 +0530)]
Rollup merge of #102435 - GuillaumeGomez:improve-iterator-reduce-example, r=thomcc,vacuus

Improve example of Iterator::reduce

Fixes #81819.

I took your example `@bstrie` from https://github.com/rust-lang/rust/issues/81819 and applied it here.

r? `@thomcc`

21 months agoRollup merge of #102385 - sunfishcode:sunfishcode/wasm-no-export-heap-base, r=davidtwco
Dylan DPC [Thu, 29 Sep 2022 12:43:20 +0000 (18:13 +0530)]
Rollup merge of #102385 - sunfishcode:sunfishcode/wasm-no-export-heap-base, r=davidtwco

Don't export `__heap_base` and `__data_end` on wasm32-wasi.

`__heap_base` and `__data_end` are exported for use by wasm-bindgen, which uses the wasm32-unknown-unknown target. On wasm32-wasi, as a step toward implementing the Canonical ABI, and as an aid to building speicalized WASI API polyfill wrappers, don't export `__heap_base` and `__data_end` on wasm32-wasi.

21 months agoRollup merge of #102342 - jmillikin:nonzero-negation, r=scottmcm
Dylan DPC [Thu, 29 Sep 2022 12:43:19 +0000 (18:13 +0530)]
Rollup merge of #102342 - jmillikin:nonzero-negation, r=scottmcm

Add negation methods for signed non-zero integers.

Performing negation with defined wrapping semantics (such as `wrapping_neg()`) on a non-zero integer currently requires unpacking to a primitive and re-wrapping. Since negation of non-zero signed integers always produces a non-zero result, it is safe to implement the various `*_neg()` methods for `NonZeroI{N}`.

I'm not sure what to do about the `#[unstable(..., issue = "none")]` here -- should I file a tracking issue, or is that handled by the Rust dev team?

ACP: https://github.com/rust-lang/libs-team/issues/105

21 months agoRollup merge of #102336 - compiler-errors:issue-102333, r=jackh726
Dylan DPC [Thu, 29 Sep 2022 12:43:19 +0000 (18:13 +0530)]
Rollup merge of #102336 - compiler-errors:issue-102333, r=jackh726

Fix associated type bindings with anon const in GAT position

The first commit formats `type_of.rs`, which is really hard to maintain since it uses a bunch of features like `let`-chains and `if let` match arm bindings. Best if you just review the second two diffs.

Fixes #102333

21 months agomake tidy dependency error less confusing
Ralf Jung [Thu, 29 Sep 2022 11:42:57 +0000 (13:42 +0200)]
make tidy dependency error less confusing

21 months agoAuto merge of #102461 - oli-obk:split_collect_rs, r=lcnr
bors [Thu, 29 Sep 2022 10:44:29 +0000 (10:44 +0000)]
Auto merge of #102461 - oli-obk:split_collect_rs, r=lcnr

Split collect.rs

This file was way too big (adding a few lines of code caused tidy to trigger)

21 months agoSome path updates
Oli Scherer [Thu, 29 Sep 2022 09:33:30 +0000 (09:33 +0000)]
Some path updates

21 months agoSplit collect.rs
Oli Scherer [Thu, 29 Sep 2022 09:31:46 +0000 (09:31 +0000)]
Split collect.rs

21 months agoAuto merge of #102328 - cuviper:ibm-stack-probes, r=nagisa
bors [Thu, 29 Sep 2022 08:00:54 +0000 (08:00 +0000)]
Auto merge of #102328 - cuviper:ibm-stack-probes, r=nagisa

Enable inline stack probes on PowerPC and SystemZ

The LLVM PowerPC and SystemZ targets have both supported `"probe-stack"="inline-asm"` for longer than our current minimum LLVM 13 requirement, so we can turn this on for all `powerpc`, `powerpc64`, `powerpc64le`, and `s390x` targets in Rust. These are all tier-2 or lower, so CI does not run their tests, but I have confirmed that their `linux-gnu` variants do pass on RHEL.

cc #43241

21 months agoAuto merge of #102450 - JohnTitor:rollup-ahleg93, r=JohnTitor
bors [Thu, 29 Sep 2022 05:12:30 +0000 (05:12 +0000)]
Auto merge of #102450 - JohnTitor:rollup-ahleg93, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #98368 (Make `std::os::fd` public.)
 - #102085 (Code refactoring smart_resolve_report_errors)
 - #102351 (Improve E0585 help)
 - #102368 (Add a niche to `Duration`, unix `SystemTime`, and non-apple `Instant`)
 - #102393 (Add regression test for issue 94923)
 - #102399 (Account for use of index-based lifetime names in print of binder)
 - #102416 (remove FIXME, improve documentation)
 - #102433 (env::temp_dir: fix a typo)

Failed merges:

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

21 months agofix minor ungrammatical sentence
Gabe Koss [Thu, 29 Sep 2022 04:20:05 +0000 (00:20 -0400)]
fix minor ungrammatical sentence

21 months agorustdoc: add method spacing to trait methods
Michael Howell [Thu, 29 Sep 2022 00:38:25 +0000 (17:38 -0700)]
rustdoc: add method spacing to trait methods

More cleanup for 8846c0853d8687fda0e5f23f6687b03b243980ee, this time in trait
layouts when things are collapsed.

21 months agoRollup merge of #102433 - RalfJung:temp-dir-typo, r=thomcc
Yuki Okushi [Thu, 29 Sep 2022 02:42:06 +0000 (11:42 +0900)]
Rollup merge of #102433 - RalfJung:temp-dir-typo, r=thomcc

env::temp_dir: fix a typo

21 months agoRollup merge of #102416 - lcnr:specialization-fixme, r=compiler-errors
Yuki Okushi [Thu, 29 Sep 2022 02:42:06 +0000 (11:42 +0900)]
Rollup merge of #102416 - lcnr:specialization-fixme, r=compiler-errors

remove FIXME, improve documentation

r? types

21 months agoRollup merge of #102399 - b-naber:binder-print-ice, r=lcnr
Yuki Okushi [Thu, 29 Sep 2022 02:42:06 +0000 (11:42 +0900)]
Rollup merge of #102399 - b-naber:binder-print-ice, r=lcnr

Account for use of index-based lifetime names in print of binder

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

r? ```@lcnr```

cc ```@steffahn```

21 months agoRollup merge of #102393 - Rageking8:add-regression-test-for-issue-94923, r=JohnTitor
Yuki Okushi [Thu, 29 Sep 2022 02:42:05 +0000 (11:42 +0900)]
Rollup merge of #102393 - Rageking8:add-regression-test-for-issue-94923, r=JohnTitor

Add regression test for issue 94923

Fixes #94923

21 months agoRollup merge of #102368 - beetrees:nano-niche, r=joshtriplett
Yuki Okushi [Thu, 29 Sep 2022 02:42:05 +0000 (11:42 +0900)]
Rollup merge of #102368 - beetrees:nano-niche, r=joshtriplett

Add a niche to `Duration`, unix `SystemTime`, and non-apple `Instant`

As the nanoseconds fields is always between `0` and `(NANOS_PER_SEC - 1)` inclusive, use the `rustc_layout_scalar_valid_range` attributes to create a niche in the nanosecond field of `Duration` and `Timespec` (which is used to implement unix `SystemTime` and non-apple unix `Instant`; windows `Instant` is implemented with `Duration` and therefore will also benefit). This change has the benefit of making `Option<T>` the same size as `T` for the previously mentioned types. Also shrinks the nanoseconds field of `Timespec` to a `u32` as nanoseconds do not need the extra range of an `i64`, shrinking `Timespec` by 4 bytes on 32-bit platforms.

r? ```@joshtriplett```

21 months agoRollup merge of #102351 - Rageking8:improve-E0585, r=wesleywiser
Yuki Okushi [Thu, 29 Sep 2022 02:42:04 +0000 (11:42 +0900)]
Rollup merge of #102351 - Rageking8:improve-E0585, r=wesleywiser

Improve E0585 help

21 months agoRollup merge of #102085 - chenyukang:code-refactor, r=cjgillot
Yuki Okushi [Thu, 29 Sep 2022 02:42:03 +0000 (11:42 +0900)]
Rollup merge of #102085 - chenyukang:code-refactor, r=cjgillot

Code refactoring smart_resolve_report_errors

`smart_resolve_report_errors` https://github.com/rust-lang/rust/blob/4ecfdfac51b159f68fce608792affb34a70e6f73/compiler/rustc_resolve/src/late/diagnostics.rs#L143
is almost 600 lines of code, we should do some code refactoring.

21 months agoRollup merge of #98368 - sunfishcode:sunfishcode/std-os-fd, r=joshtriplett
Yuki Okushi [Thu, 29 Sep 2022 02:42:03 +0000 (11:42 +0900)]
Rollup merge of #98368 - sunfishcode:sunfishcode/std-os-fd, r=joshtriplett

Make `std::os::fd` public.

`std::os::fd` defines types like `OwnedFd` and `RawFd` and is common
between Unix and non-Unix platforms that share a basic file-descriptor
concept. Rust currently uses this internally to simplify its own code,
but it would be useful for external users in the same way, so make it
public.

This means that `OwnedFd` etc. will all appear in three places, for
example on unix platforms:
 - `std::os::fd::OwnedFd`
 - `std::os::unix::io::OwnedFd`
 - `std::os::unix::prelude::OwnedFd`

r? `````@joshtriplett`````

21 months agoAuto merge of #101833 - jyn514:cross-compile-compiler-builtins, r=Mark-Simulacrum
bors [Thu, 29 Sep 2022 02:28:50 +0000 (02:28 +0000)]
Auto merge of #101833 - jyn514:cross-compile-compiler-builtins, r=Mark-Simulacrum

Make the `c` feature for `compiler-builtins` an explicit opt-in

Its build script doesn't support cross-compilation. I tried fixing it, but the cc crate itself doesn't appear to support cross-compiling to windows either unless you use the -gnu toolchain:
```
  error occurred: Failed to find tool. Is `lib.exe` installed?
```

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

21 months agoprint <signal> when ranlib failed without an exit code
Ellis Hoag [Thu, 29 Sep 2022 02:02:38 +0000 (19:02 -0700)]
print <signal> when ranlib failed without an exit code

21 months agorustdoc: remove bad CSS font-weight on `.impl`, `.method`, etc
Michael Howell [Wed, 28 Sep 2022 21:47:56 +0000 (14:47 -0700)]
rustdoc: remove bad CSS font-weight on `.impl`, `.method`, etc

This line was added in c494a06064017f307a8d9dc4797e614d2ed99143, because at
the time, the headers had these classes on them. Now, the headers are
children of the `<section>` with the class on it.

This commit also adds a test case, to make sure the srclink font weight does
not regress again.

21 months agoUse let-chaining in `WhileTrue::check_expr`.
Nicholas Nethercote [Wed, 28 Sep 2022 23:10:57 +0000 (09:10 +1000)]
Use let-chaining in `WhileTrue::check_expr`.

This has been bugging me for a while.

21 months agoImprove example of Iterator::reduce
Guillaume Gomez [Wed, 28 Sep 2022 21:01:10 +0000 (23:01 +0200)]
Improve example of Iterator::reduce

21 months agoShrink `hir::def::Res`.
Nicholas Nethercote [Fri, 16 Sep 2022 01:45:33 +0000 (11:45 +1000)]
Shrink `hir::def::Res`.

`Res::SelfTy` currently has two `Option`s. When the second one is `Some`
the first one is never consulted. So we can split it into two variants,
`Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res`
from 24 bytes to 12. This then shrinks `hir::Path` and
`hir::PathSegment`, which are the HIR types that take up the most space.

21 months agorustdoc: clean up "normalize.css 8" input override CSS
Michael Howell [Wed, 28 Sep 2022 20:52:13 +0000 (13:52 -0700)]
rustdoc: clean up "normalize.css 8" input override CSS

These rules were copied from normalize.css 3, and are mostly redundant.

* `optgroup` isn't used in rustdoc at all
* `textarea` is only used for the "copy" button, so it's not visible
* The remaining buttons and inputs mostly have styles set anyway.
* We should never be setting `color` without also setting the
  background to something. Otherwise, you get white-on-gray
  text. That seems to be [the reason] why `normalize.css` changed this.

[the reason]: https://github.com/necolas/normalize.css/pull/502

21 months agononzero_negation_ops: `inline(always)` -> `inline`.
John Millikin [Wed, 28 Sep 2022 22:33:05 +0000 (07:33 +0900)]
nonzero_negation_ops: `inline(always)` -> `inline`.

21 months agononzero_negation_ops: Set `issue = "102443"`.
John Millikin [Wed, 28 Sep 2022 22:32:15 +0000 (07:32 +0900)]
nonzero_negation_ops: Set `issue = "102443"`.

21 months agoAuto merge of #102384 - camelid:extrainfo, r=GuillaumeGomez
bors [Wed, 28 Sep 2022 22:15:28 +0000 (22:15 +0000)]
Auto merge of #102384 - camelid:extrainfo, r=GuillaumeGomez

rustdoc: Remove `clean::TraitWithExtraInfo` and queryify `is_notable_trait`

cc `@notriddle` `@GuillaumeGomez`

21 months agorustdoc: cut margin-top from first header in docblock
Michael Howell [Wed, 28 Sep 2022 21:33:56 +0000 (14:33 -0700)]
rustdoc: cut margin-top from first header in docblock

Fixes a regression caused by 8846c0853d8687fda0e5f23f6687b03b243980ee, where
a header's top margin used to be collapsed, but isn't any more.

21 months agoInline two `Ident` methods.
Nicholas Nethercote [Wed, 28 Sep 2022 04:45:31 +0000 (14:45 +1000)]
Inline two `Ident` methods.

21 months agoInline `<Token as PartialEq<TokenKind>>::eq`.
Nicholas Nethercote [Wed, 28 Sep 2022 03:55:00 +0000 (13:55 +1000)]
Inline `<Token as PartialEq<TokenKind>>::eq`.

21 months agoChange the "dummy self type".
Nicholas Nethercote [Wed, 14 Sep 2022 07:14:30 +0000 (17:14 +1000)]
Change the "dummy self type".

Because this is the only occurrence of a `Res::SelfTy` with `None` and
`None` fields, and the next commit will rely on those not being present.

21 months agoFix span of byte-escaped left format args brace
Cassaundra Smith [Fri, 23 Sep 2022 23:26:17 +0000 (16:26 -0700)]
Fix span of byte-escaped left format args brace

Fix #102057.

21 months agoenv::temp_dir: fix a typo
Ralf Jung [Wed, 28 Sep 2022 19:51:09 +0000 (21:51 +0200)]
env::temp_dir: fix a typo

21 months agoAuto merge of #100719 - CohenArthur:rust-safe-intrinsic-attribute, r=wesleywiser
bors [Wed, 28 Sep 2022 19:07:50 +0000 (19:07 +0000)]
Auto merge of #100719 - CohenArthur:rust-safe-intrinsic-attribute, r=wesleywiser

Add `#[rustc_safe_intrinsic]`

This PR adds the `#[rustc_safe_intrinsic]` attribute as mentionned on Zulip. The goal of this attribute is to avoid keeping a list of symbols as the source for stable intrinsics, and instead rely on an attribute. This is similar to `#[rustc_const_stable]` and `#[rustc_const_unstable]`, which among other things, are used to mark the constness of intrinsic functions.

21 months agoDon't export `__wasm_init_memory` on WebAssembly.
Dan Gohman [Wed, 28 Sep 2022 18:13:51 +0000 (11:13 -0700)]
Don't export `__wasm_init_memory` on WebAssembly.

Since #72889, the Rust wasm target doesn't use --passive-segments, so
remove the `--export=__wasm_init_memory`.

As documented in the [tool-conventions Linking convention],
`__wasm_init_memory` is not intended to be exported.

[tool-conventions Linking convention]: https://github.com/WebAssembly/tool-conventions/blob/7c064f304858f67ebf22964a84b7e9658e29557a/Linking.md#shared-memory-and-passive-segments

21 months agoAdd a niche to `Duration`, unix `SystemTime`, and non-apple `Instant`
beetrees [Wed, 14 Sep 2022 10:43:02 +0000 (11:43 +0100)]
Add a niche to `Duration`, unix `SystemTime`, and non-apple `Instant`

21 months agoimprove E0585 help
Rageking8 [Tue, 27 Sep 2022 08:08:04 +0000 (16:08 +0800)]
improve E0585 help

21 months agoupdate fixme
lcnr [Wed, 28 Sep 2022 15:04:29 +0000 (17:04 +0200)]
update fixme

21 months agoAuto merge of #101454 - cjgillot:concat-binders, r=estebank
bors [Wed, 28 Sep 2022 14:42:55 +0000 (14:42 +0000)]
Auto merge of #101454 - cjgillot:concat-binders, r=estebank

Do not overwrite lifetime binders for another HirId.

This PR makes higher-ranked bounds in where clauses a bit more principled.
We used to conflate `for<'a> T: Trait` with `(for<'a> T): Trait`.
This PR separates both binders.

This caused issued with fn types, which have their own binder, causing us to overwrite the predicates's binders with `fn`'s binders, ICEing.

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

21 months agoAuto merge of #101619 - Xiretza:rustc_parse-session-diagnostics, r=davidtwco
bors [Wed, 28 Sep 2022 11:11:42 +0000 (11:11 +0000)]
Auto merge of #101619 - Xiretza:rustc_parse-session-diagnostics, r=davidtwco

Migrate more of rustc_parse to SessionDiagnostic

Still far from complete, but I thought I'd add a checkpoint here because rebasing was starting to get annoying.

21 months agoadd test
b-naber [Wed, 28 Sep 2022 10:31:19 +0000 (12:31 +0200)]
add test

21 months agoaccount for use of index-based lifetime names in print of binder
b-naber [Wed, 28 Sep 2022 10:31:08 +0000 (12:31 +0200)]
account for use of index-based lifetime names in print of binder

21 months agoadd regression test
Rageking8 [Wed, 28 Sep 2022 08:30:06 +0000 (16:30 +0800)]
add regression test

21 months agoMake the `c` feature for `compiler-builtins` opt-in instead of inferred
Joshua Nelson [Thu, 15 Sep 2022 00:33:00 +0000 (19:33 -0500)]
Make the `c` feature for `compiler-builtins` opt-in instead of inferred

The build script for `compiler_builtins` doesn't support cross-compilation. I tried fixing it, but the cc crate itself
doesn't appear to support cross-compiling to windows either unless you use the -gnu toolchain:
```
  error occurred: Failed to find tool. Is `lib.exe` installed?
```

Rather than trying to fix it or special-case the platforms without bugs,
make it opt-in instead of automatic.

21 months agoAuto merge of #102302 - nnethercote:more-lexer-improvements, r=matklad
bors [Wed, 28 Sep 2022 08:14:04 +0000 (08:14 +0000)]
Auto merge of #102302 - nnethercote:more-lexer-improvements, r=matklad

More lexer improvements

A follow-up to #99884.

r? `@matklad`

21 months agorustc_safe_intrinsic: Add UI test
Arthur Cohen [Tue, 27 Sep 2022 05:22:07 +0000 (07:22 +0200)]
rustc_safe_intrinsic: Add UI test

21 months agorustc_safe_intrinsic: Keep list of safe intrinsics within the compiler
Arthur Cohen [Fri, 9 Sep 2022 14:38:33 +0000 (16:38 +0200)]
rustc_safe_intrinsic: Keep list of safe intrinsics within the compiler

21 months agoAuto merge of #102388 - JohnTitor:rollup-mbyw6fl, r=JohnTitor
bors [Wed, 28 Sep 2022 04:18:19 +0000 (04:18 +0000)]
Auto merge of #102388 - JohnTitor:rollup-mbyw6fl, r=JohnTitor

Rollup of 8 pull requests

Successful merges:

 - #100747 (Add long description and test for E0311)
 - #102232 (Stabilize bench_black_box)
 - #102288 (Suggest unwrapping `???<T>` if a method cannot be found on it but is present on `T`.)
 - #102338 (Deny associated type bindings within associated type bindings)
 - #102347 (Unescaping cleanups)
 - #102348 (Tweak `FulfillProcessor`.)
 - #102378 (Use already resolved `self_ty` in `confirm_fn_pointer_candidate`)
 - #102380 (rustdoc: remove redundant mobile `.source > .sidebar` CSS)

Failed merges:

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

21 months agoRollup merge of #102380 - notriddle:notriddle/rustdoc-source-sidebar, r=camelid
Yuki Okushi [Wed, 28 Sep 2022 04:07:20 +0000 (13:07 +0900)]
Rollup merge of #102380 - notriddle:notriddle/rustdoc-source-sidebar, r=camelid

rustdoc: remove redundant mobile `.source > .sidebar` CSS

When the source sidebar and standard sidebar had most of their code merged in 07e3f998b1ceb4b8d2a7992782e60f5e776aa114, the properties `z-index: 11`, `margin: 0`, and `position: fixed` were already being set on the `.sidebar` class, so no need to repeat them.

https://github.com/rust-lang/rust/blob/57ee5cf5a93923dae9c98bffb11545fc3a31368d/src/librustdoc/html/static/css/rustdoc.css#L1742-L1754

21 months agoRollup merge of #102378 - compiler-errors:issue-102289, r=jackh726
Yuki Okushi [Wed, 28 Sep 2022 04:07:20 +0000 (13:07 +0900)]
Rollup merge of #102378 - compiler-errors:issue-102289, r=jackh726

Use already resolved `self_ty` in `confirm_fn_pointer_candidate`

Fixes #102289

21 months agoRollup merge of #102348 - nnethercote:tweak-FulfillProcessor, r=jackh726
Yuki Okushi [Wed, 28 Sep 2022 04:07:19 +0000 (13:07 +0900)]
Rollup merge of #102348 - nnethercote:tweak-FulfillProcessor, r=jackh726

Tweak `FulfillProcessor`.

Avoids some unnecessary references and lifetimes.

r? `@jackh726`

21 months agoRollup merge of #102347 - nnethercote:unescaping-cleanups, r=matklad
Yuki Okushi [Wed, 28 Sep 2022 04:07:18 +0000 (13:07 +0900)]
Rollup merge of #102347 - nnethercote:unescaping-cleanups, r=matklad

Unescaping cleanups

Some minor improvements.

r? `@matklad`

21 months agoRollup merge of #102338 - compiler-errors:assoc-ty-binding-in-assoc-ty-binding, r...
Yuki Okushi [Wed, 28 Sep 2022 04:07:18 +0000 (13:07 +0900)]
Rollup merge of #102338 - compiler-errors:assoc-ty-binding-in-assoc-ty-binding, r=cjgillot

Deny associated type bindings within associated type bindings

Fixes #102335

This was made worse by #100865, which unified the way we generate substs for GATs and non-generic associated types. However, the issue was not _caused_ by #100865, evidenced by the test I added for GATs:

```rust
trait T {
    type A: S<C<(), i32 = ()> = ()>;
    //~^ ERROR associated type bindings are not allowed here
}

trait Q {}

trait S {
    type C<T>: Q;
}

fn main() {}
```

^ which passes on beta (where GATs are stable) and presumably ever since GATs support was added to `create_substs_for_associated_item` in astconv.

21 months agoRollup merge of #102288 - mejrs:inner, r=compiler-errors
Yuki Okushi [Wed, 28 Sep 2022 04:07:17 +0000 (13:07 +0900)]
Rollup merge of #102288 - mejrs:inner, r=compiler-errors

Suggest unwrapping `???<T>` if a method cannot be found on it but is present on `T`.

This suggests various ways to get inside wrapper types if the method cannot be found on the wrapper type, but is present on the wrappee.

For this PR, those wrapper types include `Localkey`, `MaybeUninit`, `RefCell`, `RwLock` and `Mutex`.

21 months agoRollup merge of #102232 - Urgau:stabilize-bench_black_box, r=TaKO8Ki
Yuki Okushi [Wed, 28 Sep 2022 04:07:17 +0000 (13:07 +0900)]
Rollup merge of #102232 - Urgau:stabilize-bench_black_box, r=TaKO8Ki

Stabilize bench_black_box

This PR stabilize `feature(bench_black_box)`.

```rust
pub fn black_box<T>(dummy: T) -> T;
```

The FCP was completed in https://github.com/rust-lang/rust/issues/64102.

`@rustbot` label +T-libs-api -T-libs

21 months agoRollup merge of #100747 - MatthewPeterKelly:mpk/add-long-error-message-for-E0311...
Yuki Okushi [Wed, 28 Sep 2022 04:07:16 +0000 (13:07 +0900)]
Rollup merge of #100747 - MatthewPeterKelly:mpk/add-long-error-message-for-E0311, r=MatthewPeterKelly

Add long description and test for E0311

Adds a long description and unit test for the E0311 compiler error.

Fixes one line-item in https://github.com/rust-lang/rust/issues/61137.

21 months agofix a ui test
Takayuki Maeda [Wed, 28 Sep 2022 02:42:52 +0000 (11:42 +0900)]
fix a ui test

21 months agoAuto merge of #100996 - m-ou-se:format-args-2, r=estebank
bors [Wed, 28 Sep 2022 01:36:28 +0000 (01:36 +0000)]
Auto merge of #100996 - m-ou-se:format-args-2, r=estebank

Rewrite and refactor format_args!() builtin macro.

This is a near complete rewrite of `compiler/rustc_builtin_macros/src/format.rs`.

This gets rid of the massive unmaintanable [`Context` struct](https://github.com/rust-lang/rust/blob/76531befc4b0352247ada67bd225e8cf71ee5686/compiler/rustc_builtin_macros/src/format.rs#L176-L263), and splits the macro expansion into three parts:

1. First, `parse_args` will parse the `(literal, arg, arg, name=arg, name=arg)` syntax, but doesn't parse the template (the literal) itself.
2. Second, `make_format_args` will parse the template, the format options, resolve argument references, produce diagnostics, and turn the whole thing into a `FormatArgs` structure.
3. Finally, `expand_parsed_format_args` will turn that `FormatArgs` structure into the expression that the macro expands to.

In other words, the `format_args` builtin macro used to be a hard-to-maintain 'single pass compiler', which I've split into a three phase compiler with a parser/tokenizer (step 1), semantic analysis (step 2), and backend (step 3). (It's compilers all the way down. ^^)

This can serve as a great starting point for https://github.com/rust-lang/rust/issues/99012, which will only need to change the implementation of 3, while leaving step 1 and 2 unchanged.

It also makes https://github.com/rust-lang/compiler-team/issues/541 easier, which could then upgrade the new `FormatArgs` struct to an `ast` node and remove step 3, moving that step to later in the compilation process.

It also fixes a few diagnostics bugs.

This also [significantly reduces](https://gist.github.com/m-ou-se/b67b2d54172c4837a5ab1b26fa3e5284) the amount of generated code for cases with arguments in non-default order without formatting options, like `"{1} {0}"` or `"{a} {}"`, etc.

21 months agoAddress review comments.
Nicholas Nethercote [Wed, 28 Sep 2022 00:28:36 +0000 (10:28 +1000)]
Address review comments.

21 months agorustdoc: Queryify `is_notable_trait`
Noah Lev [Wed, 28 Sep 2022 00:06:38 +0000 (17:06 -0700)]
rustdoc: Queryify `is_notable_trait`

This might help with #102375.

21 months agoDon't export `__heap_base` and `__data_end` on wasm32-wasi.
Dan Gohman [Wed, 28 Sep 2022 00:33:59 +0000 (17:33 -0700)]
Don't export `__heap_base` and `__data_end` on wasm32-wasi.

`__heap_base` and `__data_end` are exported for use by wasm-bindgen, which
uses the wasm32-unknown-unknown target. On wasm32-wasi, as a step toward
implementing the Canonical ABI, and as an aid to building speicalized WASI
API polyfill wrappers, don't export `__heap_base` and `__data_end` on
wasm32-wasi.

21 months agoDeduplicate some logic
mejrs [Wed, 28 Sep 2022 00:36:58 +0000 (02:36 +0200)]
Deduplicate some logic

21 months agoreview updates
Matthew Kelly [Tue, 27 Sep 2022 23:23:59 +0000 (19:23 -0400)]
review updates

21 months agoAuto merge of #102377 - matthiaskrgr:rollup-1zvj50t, r=matthiaskrgr
bors [Tue, 27 Sep 2022 22:41:47 +0000 (22:41 +0000)]
Auto merge of #102377 - matthiaskrgr:rollup-1zvj50t, r=matthiaskrgr

Rollup of 9 pull requests

Successful merges:

 - #101555 (Stabilize `#![feature(mixed_integer_ops)]`)
 - #102253 (rustdoc: use CSS containment to speed up render)
 - #102281 (make invalid_value lint a bit smarter around enums)
 - #102284 (Structured suggestion for missing `mut`/`const` in raw pointer)
 - #102330 (rustdoc: remove no-op CSS `.srclink { font-weight; font-size }`)
 - #102337 (Avoid LLVM-deprecated `Optional::hasValue`)
 - #102356 (session: remove now-unnecessary lint `#[allow]`s)
 - #102367 (rustdoc: remove redundant `#help-button` CSS)
 - #102369 (Fix search result colors)

Failed merges:

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

21 months agoSmall cleanups in unescaping code.
Nicholas Nethercote [Tue, 27 Sep 2022 06:32:22 +0000 (16:32 +1000)]
Small cleanups in unescaping code.

- Rename `unescape_raw_str_or_raw_byte_str` as
  `unescape_raw_str_or_byte_str`, which is more accurate.
- Remove the unused `Mode::in_single_quotes` method.
- Make some assertions more precise, and add a missing one to
  `unescape_char_or_byte`.
- Change all the assertions to `debug_assert!`, because this code is
  reasonably hot, and the assertions aren't required for memory safety,
  and any violations are likely to be sufficiently obvious that normal
  tests will trigger them.

21 months agorustdoc: remove redundant mobile `.source > .sidebar` CSS
Michael Howell [Tue, 27 Sep 2022 21:25:48 +0000 (14:25 -0700)]
rustdoc: remove redundant mobile `.source > .sidebar` CSS

When the source sidebar and standard sidebar had most of their code merged in
07e3f998b1ceb4b8d2a7992782e60f5e776aa114, the properties `z-index: 11`,
`margin: 0`, and `position: fixed` were already being set on the `.sidebar`
class, so no need to repeat them.