Commit Graph

206480 Commits

Author SHA1 Message Date
Colin Baumgarten
b9e85bf60a Detect and reject out-of-range integers in format string literals
Until now out-of-range integers in format string literals
were silently ignored. They wrapped around to zero at
usize::MAX, producing unexpected results.

When using debug builds of rustc, such integers in format string
literals even cause an 'attempt to add with overflow' panic in
rustc.

Fix this by producing an error diagnostic for integers in format
string literals which do not fit into usize.

Fixes #102528
2022-10-01 01:05:01 +02:00
bors
75d3027fb5 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.
2022-09-30 14:16:57 +00:00
bors
f914b82a75 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
2022-09-30 10:39:09 +00:00
Matthias Krüger
588a25a6f8
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`
2022-09-30 10:22:39 +02:00
Matthias Krüger
e36c3c12cc
Rollup merge of #102491 - notriddle:notriddle/sidebar-opacity, r=GuillaumeGomez
rustdoc: remove no-op source sidebar `opacity`

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

dc2c972334/src/librustdoc/html/static/css/rustdoc.css (L350-L354)

The transition was remove with 237d62588d, but the now-redundant `opacity` property was not.
2022-09-30 10:22:38 +02:00
Matthias Krüger
c4a1876900
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.
2022-09-30 10:22:38 +02:00
Matthias Krüger
6906e64c30
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.
2022-09-30 10:22:37 +02:00
Matthias Krüger
25017f8bce
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
2022-09-30 10:22:36 +02:00
bors
4a0ee3cdc6 Auto merge of #102387 - nnethercote:inline-Token-PartialEq, r=lqd
Inline a few functions.

r? `@ghost`
2022-09-30 07:57:12 +00:00
bors
b3aa4997d4 Auto merge of #102164 - compiler-errors:rpitit-foreign, r=TaKO8Ki
Serialize return-position `impl Trait` in trait hidden values in foreign libraries

Fixes #101630
2022-09-30 04:24:14 +00:00
bors
d45feb3ad2 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`
2022-09-30 01:32:15 +00:00
Josh Stone
2e7a964485 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
2022-09-29 18:18:26 -07:00
bors
1bb8d276c9 Auto merge of #101887 - nnethercote:shrink-Res, r=spastorino
Shrink `hir::def::Res`

r? `@spastorino`
2022-09-29 22:45:24 +00:00
Michael Howell
db376ee7ab rustdoc: update test case now that the UI animation is removed 2022-09-29 15:40:24 -07:00
Michael Howell
6d02a4dc33 rustdoc: remove no-op source sidebar opacity
These rules were added in dc2c972334 to work
with CSS transitions. They're otherwise redundant, since the `visibility`
property already hides everything.

dc2c972334/src/librustdoc/html/static/css/rustdoc.css (L350-L354)

The transition was remove with 237d62588d, but
the now-redundant `opacity` property was not.
2022-09-29 15:33:02 -07:00
beetrees
e409ce2159
Fix integer overflow in format!("{:.0?}", Duration::MAX) 2022-09-29 23:06:22 +01:00
bors
9c56d9d6fe 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
2022-09-29 19:52:48 +00:00
Michael Howell
98075708dd
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.
2022-09-29 10:15:20 -07:00
Michael Howell
af33587fc5
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.
2022-09-29 10:15:20 -07:00
Michael Howell
8a73397a62
Rollup merge of #102447 - notriddle:notriddle/method-toggle, r=jsha
rustdoc: add method spacing to trait methods

More cleanup for 8846c0853d, 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)
2022-09-29 10:15:19 -07:00
Michael Howell
e5fffbeeb4
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 c494a06064, 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.
2022-09-29 10:15:19 -07:00
Michael Howell
565d3a8c89
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 8846c0853d, 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)
2022-09-29 10:15:18 -07:00
Michael Howell
3cecc78694
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]: 7c064f3048/Linking.md (shared-memory-and-passive-segments)
2022-09-29 10:15:18 -07:00
Michael Howell
0878bee38a
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.
2022-09-29 10:15:17 -07:00
Michael Howell
52a71698fe 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.
2022-09-29 10:08:12 -07:00
bors
9f1a21ae2b 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.
2022-09-29 17:05:00 +00:00
Oli Scherer
aa3fbf8795 Split out the error reporting logic into a separate function 2022-09-29 14:29:36 +00:00
Ralf Jung
79ad594488 more clear function and variable names 2022-09-29 16:09:14 +02:00
bors
65445a571c 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
2022-09-29 13:27:28 +00:00
Dylan DPC
f4e7094ffc
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`
2022-09-29 18:13:22 +05:30
Dylan DPC
34f02c3e8d
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.
2022-09-29 18:13:21 +05:30
Dylan DPC
5f18c2bd10
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
2022-09-29 18:13:21 +05:30
Dylan DPC
b6d1c15076
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`
2022-09-29 18:13:20 +05:30
Dylan DPC
33553e1a28
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.
2022-09-29 18:13:20 +05:30
Dylan DPC
609152aa8a
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
2022-09-29 18:13:19 +05:30
Dylan DPC
1be9ec5443
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
2022-09-29 18:13:19 +05:30
Ralf Jung
1377bab12e make tidy dependency error less confusing 2022-09-29 13:42:57 +02:00
bors
c5bbf36a31 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)
2022-09-29 10:44:29 +00:00
Oli Scherer
f22f149dbd Some path updates 2022-09-29 09:33:30 +00:00
Oli Scherer
6367e69929 Split collect.rs 2022-09-29 09:31:46 +00:00
bors
8a497b7181 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
2022-09-29 08:00:54 +00:00
bors
1536a53ea4 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
2022-09-29 05:12:30 +00:00
Gabe Koss
06624e8c5a fix minor ungrammatical sentence 2022-09-29 00:20:05 -04:00
Michael Howell
0b9b4b7068 rustdoc: add method spacing to trait methods
More cleanup for 8846c0853d, this time in trait
layouts when things are collapsed.
2022-09-28 21:11:40 -07:00
Yuki Okushi
5c731cd796
Rollup merge of #102433 - RalfJung:temp-dir-typo, r=thomcc
env::temp_dir: fix a typo
2022-09-29 11:42:06 +09:00
Yuki Okushi
80e009ceba
Rollup merge of #102416 - lcnr:specialization-fixme, r=compiler-errors
remove FIXME, improve documentation

r? types
2022-09-29 11:42:06 +09:00
Yuki Okushi
039e9e2160
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```
2022-09-29 11:42:06 +09:00
Yuki Okushi
cf158a410a
Rollup merge of #102393 - Rageking8:add-regression-test-for-issue-94923, r=JohnTitor
Add regression test for issue 94923

Fixes #94923
2022-09-29 11:42:05 +09:00
Yuki Okushi
8e4869e862
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```
2022-09-29 11:42:05 +09:00
Yuki Okushi
19e84b91e5
Rollup merge of #102351 - Rageking8:improve-E0585, r=wesleywiser
Improve E0585 help
2022-09-29 11:42:04 +09:00