Commit Graph

226636 Commits

Author SHA1 Message Date
Guillaume Gomez
7dc684f173 Add "vec new" test 2023-06-14 14:22:17 +02:00
Guillaume Gomez
b5f8258497 Update rustdoc-js-std tests 2023-06-14 14:22:17 +02:00
Guillaume Gomez
b99bf4677b Use whitespace as path separator like double colon 2023-06-14 14:22:17 +02:00
bors
57c215b08e Auto merge of #112609 - matthiaskrgr:rollup-er6weld, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #112197 (Erase regions even if normalization fails in writeback (in new solver))
 - #112495 (fix(resolve): update shadowed_glob more precision)
 - #112520 (Fix the overflow issue for transmute_generic_consts)
 - #112571 (rustdoc-search: search never type with `!`)
 - #112581 ([rustdoc] Fix URL encoding of % sign)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-14 05:37:08 +00:00
Matthias Krüger
623b1d4b62
Rollup merge of #112581 - TumoiYorozu:fix_url_encoding_of_percent_sign, r=notriddle
[rustdoc] Fix URL encoding of % sign

Fix #112580

The % is encoded as %%, but the correct encoding is %25.
2023-06-14 06:25:50 +02:00
Matthias Krüger
e3021b4a42
Rollup merge of #112571 - notriddle:notriddle/never-search, r=GuillaumeGomez
rustdoc-search: search never type with `!`

This feature extends rustdoc to support the syntax that most users will naturally attempt to use to search for diverging functions. Part of #60485

It's already possible to do this search with `primitive:never`, but that's not what the Rust language itself uses, so nobody will try it if they aren't told or helped along.
2023-06-14 06:25:49 +02:00
Matthias Krüger
269ea4bd6b
Rollup merge of #112520 - chenyukang:yukang-fix-112505, r=fee1-dead
Fix the overflow issue for transmute_generic_consts

Fixes #112505
2023-06-14 06:25:49 +02:00
Matthias Krüger
98f6e9644b
Rollup merge of #112495 - bvanjoi:fix-109153, r=petrochenkov
fix(resolve): update shadowed_glob more precision

- Fixes #109153
- Fixes #109962

## Why does it panic?

We use #109153 as an illustration.

The process of `resolve_imports` is:

| Iter | resolve     | resolution of **`(Mod(root), Ident(bar) in type ns)`** |
| -    | -           | -      |
| 0 | `use foo::*`   | `binding` -> foo::bar, `shallowed_glob` -> `None` |
| 1 | `use bar::bar` | `binding` -> foo::bar::bar, `shallowed_glob` -> foo::bar    |
| 2 | `use bar::*`   | `binding` -> foo::bar::bar, `shallowed_glob` -> foo::bar::bar::bar |

So during `finalize_import`, the `root::bar` in `use bar::bar` had been pointed to `foo::bar::bar::bar`, which is different from the `initial_module` valued of `foo::bar`, therefore, the panic had been triggered.

## Try to solve it

~I think #109153 should check-pass rather than throw an ambiguous error. Following this idea, there are two ways to solve this problem:~

~1. Give up the `initial_module` and update `import.imported_module` after each resolution update. However, I think this method may have too much impact.~
~2. Do not update the `shadowed_glob` when it is defined.~

~To be honest, I am not sure if this is the right way to solve this ICE. Perhaps there is a better resolution.~

Edit: we had made the `resolution.shadowed_glob` update more detailed.

r? `@petrochenkov`
2023-06-14 06:25:48 +02:00
Matthias Krüger
6fc50dacd4
Rollup merge of #112197 - compiler-errors:next-solver-erase, r=lcnr
Erase regions even if normalization fails in writeback (in new solver)

Or else we ICE during writeback on some programs that error
2023-06-14 06:25:48 +02:00
bors
fa8762b7b6 Auto merge of #112448 - nnethercote:no-tiny-cgus, r=wesleywiser
Introduce a minimum CGU size in non-incremental builds.

Because tiny CGUs slow down compilation *and* result in worse generated code.

r? `@wesleywiser`
2023-06-14 02:34:17 +00:00
Nicholas Nethercote
7c3ce02a11 Introduce a minimum CGU size in non-incremental builds.
Because tiny CGUs make compilation less efficient *and* result in worse
generated code.

We don't do this when the number of CGUs is explicitly given, because
there are times when the requested number is very important, as
described in some comments within the commit. So the commit also
introduces a `CodegenUnits` type that distinguishes between default
values and user-specified values.

This change has a roughly neutral effect on walltimes across the
rustc-perf benchmarks; there are some speedups and some slowdowns. But
it has significant wins for most other metrics on numerous benchmarks,
including instruction counts, cycles, binary size, and max-rss. It also
reduces parallelism, which is good for reducing jobserver competition
when multiple rustc processes are running at the same time. It's smaller
benchmarks that benefit the most; larger benchmarks already have CGUs
that are all larger than the minimum size.

Here are some example before/after CGU sizes for opt builds.

- html5ever
  - CGUs: 16, mean size: 1196.1, sizes: [3908, 2992, 1706, 1652, 1572,
    1136, 1045, 948, 946, 938, 579, 471, 443, 327, 286, 189]
  - CGUs: 4, mean size: 4396.0, sizes: [6706, 3908, 3490, 3480]

- libc
  - CGUs: 12, mean size: 35.3, sizes: [163, 93, 58, 53, 37, 8, 2 (x6)]
  - CGUs: 1, mean size: 424.0, sizes: [424]

- tt-muncher
  - CGUs: 5, mean size: 1819.4, sizes: [8508, 350, 198, 34, 7]
  - CGUs: 1, mean size: 9075.0, sizes: [9075]

Note that CGUs of size 100,000+ aren't unusual in larger programs.
2023-06-14 10:57:44 +10:00
Nicholas Nethercote
95d85899ce Add more measurements to the CGU debug printing.
For example, we go from this:
```
FINAL (4059 items, total_size=232342; 16 CGUs, max_size=39608,
min_size=5468, max_size/min_size=7.2):
- CGU[0] regex.f2ff11e98f8b05c7-cgu.0 (318 items, size=39608):
  - fn ...
  - fn ...
```
to this:
```
FINAL
- unique items: 2726 (1459 root + 1267 inlined), unique size: 201214 (146046 root + 55168 inlined)
- placed items: 4059 (1459 root + 2600 inlined), placed size: 232342 (146046 root + 86296 inlined)
- placed/unique items ratio: 1.49, placed/unique size ratio: 1.15
- CGUs: 16, mean size: 14521.4, sizes: [39608, 31122, 20318, 20236, 16268, 13777, 12310, 10531, 10205, 9810, 9250, 9065 (x2), 7785, 7524, 5468]

- CGU[0]
  - regex.f2ff11e98f8b05c7-cgu.0, size: 39608
  - items: 318, mean size: 124.6, sizes: [28395, 3418, 558, 485, 259, 228, 176, 166, 146, 118, 117 (x3), 114 (x5), 113 (x3), 101, 84, 82, 77, 76, 72, 71 (x2), 66, 65, 62, 61, 59 (x2), 57, 55, 54 (x2), 53 (x4), 52 (x5), 51 (x4), 50, 48, 47, 46, 45 (x3), 44, 43 (x5), 42, 40, 38 (x4), 37, 35, 34 (x2), 32 (x2), 31, 30, 28 (x2), 27 (x2), 26 (x3), 24 (x2), 23 (x3), 22 (x2), 21, 20, 16 (x4), 15, 13 (x7), 12 (x3), 11 (x6), 10, 9 (x2), 8 (x4), 7 (x8), 6 (x38), 5 (x21), 4 (x7), 3 (x45), 2 (x63), 1 (x13)]
  - fn ...
  - fn ...
```
This is a lot more information, distinguishing between root items and
inlined items, showing how much duplication there is of inlined items,
plus the full range of sizes for CGUs and items within CGUs. All of
which is really helpful when analyzing this stuff and trying different
CGU formation algorithms.
2023-06-14 10:15:59 +10:00
bors
6330daade9 Auto merge of #112062 - lukas-code:unsized-layout, r=wesleywiser
Make struct layout not depend on unsizeable tail

fixes (after backport) https://github.com/rust-lang/rust/issues/112048

Since unsizing `Ptr<Foo<T>>` -> `Ptr<Foo<U>` just copies the pointer and adds the metadata, the layout of `Foo` must not depend on niches in and alignment of the tail `T`.

Nominating for beta 1.71, because it will have this issue: `@rustbot` label beta-nominated
2023-06-13 22:34:59 +00:00
Michael Goulet
7ff79cf4aa Move test 2023-06-13 21:54:11 +00:00
Michael Goulet
c92342d58d Erase regions even if normalization fails in writeback 2023-06-13 21:53:01 +00:00
Wesley Wiser
b982f3a988 Add test case for unsizing with niche 2023-06-13 15:32:42 -04:00
bors
371994e0d8 Auto merge of #112314 - ferrocene:pa-core-alloc-abort, r=bjorn3
Ignore `core`, `alloc` and `test` tests that require unwinding on `-C panic=abort`

Some of the tests for `core` and `alloc` require unwinding through their use of `catch_unwind`. These tests fail when testing using `-C panic=abort` (in my case through a target without unwinding support, and `-Z panic-abort-tests`), while they should be ignored as they don't indicate a failure.

This PR marks all of these tests with this attribute:

```rust
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
```

I'm not aware of a way to test this on rust-lang/rust's CI, as we don't test any target with `-C panic=abort`, but I tested this locally on a Ferrocene target and it does indeed make the test suite pass.
2023-06-13 19:03:27 +00:00
bohan
f7330eb752 fix(resolve): update shadowed_glob more precision 2023-06-14 01:38:35 +08:00
bors
5683791ebb Auto merge of #112017 - Nemo157:unsafe-block-rustfix, r=eholk
Add MVP suggestion for `unsafe_op_in_unsafe_fn`

Rebase of https://github.com/rust-lang/rust/pull/99827

cc tracking issue https://github.com/rust-lang/rust/issues/71668

No real changes since the original PR, just migrated the new suggestion to use fluent messages and added a couple more testcases, AFAICT from the discussion there were no outstanding changes requested.
2023-06-13 15:57:59 +00:00
yukang
3bbc598d16 use bug! for overflow of u128 2023-06-13 22:14:05 +08:00
Pietro Albini
a988dc2711
remove patch from cranelift backend to ignore unwinding tests 2023-06-13 15:53:26 +02:00
Pietro Albini
44556eed36
ignore core, alloc and test tests that require unwinding on panic=abort 2023-06-13 15:53:24 +02:00
Wim Looman
802c1d5979
Add test cases for suggestions with unsafe operations contained inside macros 2023-06-13 15:48:57 +02:00
Wim Looman
8f3e876e52
Add note about unsafe functions body not being unsafe 2023-06-13 15:48:57 +02:00
Wim Looman
62a712a8bb
Hide suggestion to wrap function in unsafe block 2023-06-13 15:48:55 +02:00
Wim Looman
aca61b2c07
Test that a couple more types of unsafe-ops get a wrapping unsafe block added 2023-06-13 15:47:02 +02:00
Léo Lanteri Thauvin
975152ce30
Add MVP suggestion for unsafe_op_in_unsafe_fn
Nemo157 rebase notes: Migrated the changes to the lint into fluent
2023-06-13 15:46:54 +02:00
bors
2ca8d358e5 Auto merge of #112549 - jieyouxu:fix-tests-for-unit-bindings, r=Nilstrieb
Adjust UI tests for `unit_bindings` lint

- Explicitly annotate `let x: () = expr;` where `x` has unit type, or remove the unit binding to leave only `expr;` instead.
- Use `let () = init;` or `let pat = ();` where appropriate.
- Fix disjoint-capture-in-same-closure test which wasn't actually testing a closure: `tests/ui/closures/2229_closure_analysis/run_pass/disjoint-capture-in-same-closure.rs`.

Note that unfortunately there's *a lot* of UI tests, there are a couple of places where I may have left something like `let (): ()` (this is not needed but is left over from an ealier version of the lint) which is bad style.

This PR is to help with the `unit_bindings` lint at #112380.
2023-06-13 13:07:43 +00:00
TumoiYorozu
7b55f08516 Fix URL encoding of % sign in Rust Doc. 2023-06-13 20:14:50 +09:00
bors
4bd4e2ea82 Auto merge of #112386 - loongarch-rs:reloc-static, r=eholk
loongarch64-unknown-none*: Set default relocation model to static

This PR sets the default relocation model to `static` for `loongarch64-unknown-none*` targets. This change aims to streamline the development of the bare-metal project by removing the need for the executable program loader to implement relocation.
2023-06-13 09:13:03 +00:00
Nicholas Nethercote
51821515b3 Remove PartitioningCx::target_cgu_count.
Because that value can be easily obtained from `Partitioning::tcx`.
2023-06-13 16:47:09 +10:00
bors
caeea3f0a2 Auto merge of #112575 - matthiaskrgr:rollup-7a8d7tg, r=matthiaskrgr
Rollup of 2 pull requests

Successful merges:

 - #111885 (Don't ICE on unsized `extern "rust-call"` call)
 - #112558 (Fix typo in mod.rs)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-13 06:13:43 +00:00
Matthias Krüger
aee8e10a26
Rollup merge of #112558 - eltociear:patch-21, r=thomcc
Fix typo in mod.rs

assoicated -> associated
2023-06-13 07:02:28 +02:00
Matthias Krüger
b7706e891d
Rollup merge of #111885 - compiler-errors:rust-call-abi-sized, r=eholk
Don't ICE on unsized `extern "rust-call"` call

Conceptually builds on #111864, but doesn't depend on it.
2023-06-13 07:02:28 +02:00
bors
de1ff0a8b5 Auto merge of #99339 - yanchith:binary-heap-ta, r=Amanieu
Make BinaryHeap parametric over Allocator

Tracking issue: #32838
Related: https://github.com/rust-lang/wg-allocators/issues/7

This parametrizes `BinaryHeap` with `A`, similarly to how other collections are parametrized.

A couple things I left out:

```
BinaryHeap::append

    Currently requires both structures to have the same allocator type. Could
    change, but depends on Vec::append, which has the same constraints.

impl<T: Ord> Default for BinaryHeap<T>

    Not parametrized, because there's nowhere to conjure the allocator from.

impl<T: Ord> FromIterator<T> for BinaryHeap<T>

    Not parametrized, because there's nowhere to conjure the allocator from.

impl<T: Ord, const N: usize> From<[T; N]> for BinaryHeap<T>

    Not parametrized, because there's nowhere to conjure the allocator from.

unsafe impl<I> AsVecIntoIter for IntoIter<I>

    AsVecIntoIter is not allocator aware, and I didn't dare change it without guidance. Is this something important?
```

I've seen very few tests for allocator_api in general, but I'd like to at least test this on some usage code in my projects before moving forward.

EDIT: Updated the list of impls and functions that are not affected by this. `BinaryHeap` no longer has a `SpecExtend` impl, and prior work made implementing `Extend` possible.
2023-06-13 03:23:12 +00:00
bors
5e8c53f1f6 Auto merge of #112524 - GuillaumeGomez:migrate-gui-test-color-14, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

r? `@notriddle`
2023-06-13 00:35:32 +00:00
Michael Howell
db277f5284 rustdoc-search: search never type with !
This feature extends rustdoc to support the syntax that most users will
naturally attempt to use to search for diverging functions.
Part of #60485

It's already possible to do this search with `primitive:never`, but
that's not what the Rust language itself uses, so nobody will try it if
they aren't told or helped along.
2023-06-12 17:30:23 -07:00
bors
df77afbcaf Auto merge of #112563 - matthiaskrgr:rollup-ebetrzi, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #112302 (Suggest using `ptr::null_mut` when user provided `ptr::null` to a function expecting `ptr::null_mut`)
 - #112416 (Fix debug ICE for extern type with where clauses)
 - #112527 (Add windows_sys type definitions for ARM32 manually)
 - #112546 (new solver: extend assert to other aliases)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-12 17:23:48 +00:00
Matthias Krüger
9cb785b9d3
Rollup merge of #112546 - lcnr:opaque-type-cleanup, r=compiler-errors
new solver: extend assert to other aliases
2023-06-12 17:44:39 +02:00
Matthias Krüger
9c4cff424e
Rollup merge of #112527 - bdbai:fix/winarm32, r=ChrisDenton
Add windows_sys type definitions for ARM32 manually

`windows_sys` bindings do not include platform-specific type definitions for ARM 32 architecture, so it breaks `thumbv7a-pc-windows-msvc` and `thumbv7a-uwp-windows-msvc` targets. This PR tries to add them back by manually inserting them together with the generated ones.

`WSADATA` is copied from the generated definition for `x86`. `CONTEXT` is copied from the definition before `windows_sys` is introduced (which is just an empty enum): 4a18324a4d/library/std/src/sys/windows/c.rs (L802).

Fixes #112265.
2023-06-12 17:44:38 +02:00
Matthias Krüger
8475a88d67
Rollup merge of #112416 - jieyouxu:issue-112363, r=wesleywiser
Fix debug ICE for extern type with where clauses

Fixes #112363.
2023-06-12 17:44:38 +02:00
Matthias Krüger
a5245b5894
Rollup merge of #112302 - jieyouxu:issue-85184, r=WaffleLapkin
Suggest using `ptr::null_mut` when user provided `ptr::null` to a function expecting `ptr::null_mut`

```
error[E0308]: mismatched types
  --> $DIR/ptr-null-mutability-suggestions.rs:9:24
   |
LL |     expecting_null_mut(ptr::null());
   |     ------------------ ^^^^^^^^^^^
   |     |                  |
   |     |                  types differ in mutability
   |     |                  help: consider using `core::ptr::null_mut` instead: `core::ptr::null_mut()`
   |     arguments to this function are incorrect
   |
   = note: expected raw pointer `*mut u8`
              found raw pointer `*const _`
note: function defined here
  --> $DIR/ptr-null-mutability-suggestions.rs:6:4
   |
LL | fn expecting_null_mut(_: *mut u8) {}
   |    ^^^^^^^^^^^^^^^^^^ ----------
```

Closes #85184.
2023-06-12 17:44:37 +02:00
Ikko Eltociear Ashimine
69de7ca199
Fix typo in mod.rs
assoicated -> associated
2023-06-13 00:09:13 +09:00
bdbai
df08f56b08 Add comment for arm_shim in generate-windows-sys 2023-06-12 22:40:30 +08:00
bdbai
f7f25b0e2f Add windows_sys typedef for Win ARM32 2023-06-12 22:40:30 +08:00
bors
b963a57205 Auto merge of #112541 - ozkanonur:gtfx, r=clubby789
implement stdout streaming in `render_tests::Renderer`

This way, we can show the test dot characters on the console immediately, without having to wait for the entire line to finish.

cc `@GuillaumeGomez`
2023-06-12 14:34:20 +00:00
许杰友 Jieyou Xu (Joe)
edafbaffb2
Adjust UI tests for unit_bindings
- Either explicitly annotate `let x: () = expr;` where `x` has unit
  type, or remove the unit binding to leave only `expr;` instead.
- Fix disjoint-capture-in-same-closure test
2023-06-12 20:24:48 +08:00
lcnr
e74d1cd581 update comment 2023-06-12 12:47:09 +02:00
bors
cb882fa998 Auto merge of #112543 - GuillaumeGomez:revert-112429, r=lcnr
[rustdoc] Fix infinite loop when retrieving impls for type alias

Fixes #112515.
Reverts #112429.

r? `@lcnr`
2023-06-12 10:08:45 +00:00
ozkanonur
6c966dc656 implement stdout streaming in render_tests::Renderer
Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-06-12 13:03:00 +03:00