Commit Graph

227134 Commits

Author SHA1 Message Date
Matthias Krüger
c1b4d075a2
Rollup merge of #112506 - compiler-errors:const-infer-ice, r=b-naber
Properly check associated consts for infer placeholders

We only reported an error if it was in a "suggestable" position (according to `is_suggestable_infer_ty`) -- this isn't correct for infer tys that can show up in other places in the constant's type, like behind a dyn trait.

fixes #112491
2023-06-14 18:10:30 +02:00
Matthias Krüger
7240943b28
Rollup merge of #112605 - compiler-errors:negative-docs, r=spastorino
Improve docs/clean up negative overlap functions

Clean up some functions in ways that should not affect behavior, change some names to be clearer (`negative_impl` and `implicit_negative` are not really clear imo), and add some documentation examples.

r? `@spastorino`
2023-06-14 18:10:30 +02:00
Matthias Krüger
502ac47f8a
Rollup merge of #112600 - celinval:stable-mir-rvalue, r=oli-obk
Introduce a `Stable` trait to translate MIR to SMIR

This PR introduces a trait `Stable` which defines a type `T` and a `stable()` method to convert the current type to its stable MIR version.

This change is just an implementation detail, and I wanted to get some feedback to whether it would be cleaner than having the `rustc_<type>_to_<type>()` methods for every type we translate to SMIR.

r? `@oli-obk`
r? `@spastorino`
2023-06-14 18:10:30 +02:00
Matthias Krüger
38ed4e5a5c
Rollup merge of #112109 - Alexendoo:unsupported-split-debuginfo, r=b-naber
Don't print unsupported split-debuginfo modes with `-Zunstable-options`

Currently unsupported `split-debuginfo` options are enabled by `-Zunstable-options`, for projects that have `-Zunstable-options` for other reasons this can be [an unexpected interaction](https://github.com/rust-lang/rust-clippy/pull/10516#issuecomment-1562604764)

This PR makes it so that `--print split-debuginfo -Zunstable-options` doesn't print unsupported modes, so that a cargo config of e.g.

```toml
[profile.dev]
split-debuginfo = "unpacked"
```

Would not cause an unsupported mode to be enabled on `x86_64-pc-windows-msvc`
2023-06-14 18:10:29 +02:00
Matthias Krüger
2759a7d2f1
Rollup merge of #112584 - loongarch-rs:remove-env, r=petrochenkov
loongarch64-none*: Remove environment component from llvm target

A warning is reported when the LLVM triple-implied ABI conflicts with the provided target-abi.

```
warning: triple-implied ABI conflicts with provided target-abi ‘lp64s', using target-abi
```

Specifically, the ABI hint comes from the environment component of the triple. When only the target-abi is provided and no environment, there is no conflict. This PR removes the environment component from the LLVM target name of the `loongarch64-unknown-none-softfloat` target.
2023-06-14 18:10:29 +02:00
Matthias Krüger
c451f7bedb
Rollup merge of #111974 - Sp00ph:update_guarantees, r=Amanieu
Update runtime guarantee for `select_nth_unstable`

#106933 changed the runtime guarantee for `select_nth_unstable` from O(n) to O(n log n), since the old guarantee wasn't actually met by the implementation at the time. Now with #107522, `select_nth_unstable` should be truly linear in runtime, so we can revert its runtime guarantee to O(n). Since #106933 was considered a bug fix, this will probably need an FCP because it counts as a new API guarantee.

r? `@Amanieu`
2023-06-14 18:10:29 +02:00
Matthias Krüger
b8f71eaf01
Rollup merge of #109814 - est31:stabilize_string_leak, r=Amanieu
Stabilize String::leak

Stabilizes the following API:

```Rust
impl String {
    pub fn leak(self) -> &'static mut str;
}
```

closes #102929

blocked by having an FCP for stabilization.
2023-06-14 18:10:28 +02:00
Matthias Krüger
d54bb505d0
Rollup merge of #107619 - stepancheg:hash-set-insert, r=Amanieu
Specify behavior of HashSet::insert

`HashSet::insert` does not replace the value with equal value.

Fixes #107581.
2023-06-14 18:10:28 +02:00
Matthias Krüger
4efdb5c001
Rollup merge of #98202 - aticu:impl_tryfrom_osstr_for_str, r=Amanieu
Implement `TryFrom<&OsStr>` for `&str`

Recently when trying to work with `&OsStr` I was surprised to find this `impl` missing.

Since the `to_str` method already existed the actual implementation is fairly non-controversial, except for maybe the choice of the error type. I chose an opaque error here instead of something like `std::str::Utf8Error`, since that would already make a number of assumption about the underlying implementation of `OsStr`.

As this is a trait implementation, it is insta-stable, if I'm not mistaken?
Either way this will need an FCP.
I chose "1.64.0" as the version, since this is unlikely to land before the beta cut-off.

`@rustbot` modify labels: +T-libs-api

API Change Proposal: rust-lang/rust#99031 (accepted)
2023-06-14 18:10:27 +02:00
Pavel Grigorenko
cfe2e4660d
Mention env! in option_env!'s docs 2023-06-14 18:29:08 +03:00
danakj
4b83156a5c Move the comment on fixing paths to where it belongs 2023-06-14 10:58:08 -04:00
Antonios Barotsis
cb093fc648 Fix typo 2023-06-14 16:52:29 +02:00
danakj
7e07271eaf Avoid absolute sysroot paths in the MSVC linker command line
When the `--sysroot` is specified as relative to the current working
directory, the sysroot's rlibs should also be specified as relative
paths. Otherwise, the current working directory ends up in the
absolute paths, and in the linker command line. And the entire linker
command line appears in the PDB file generated by the MSVC linker.

When adding an rlib to the linker command line, if the rlib's canonical
path is in the sysroot's canonical path, then use the current sysroot
path + filename instead of the full absolute path to the rlib. This
means that when `--sysroot=foo` is specified, the linker command line
will contain `foo/rustlib/target/lib/lib*.rlib` instead of the full
absolute path to the same.

This addresses https://github.com/rust-lang/rust/issues/112586
2023-06-14 10:44:00 -04:00
bors
9c967d3809 Auto merge of #15053 - Veykril:crate-root-module-id, r=Veykril
internal: Add a CrateRootModuleId that encodes a module id that is always a crate root
2023-06-14 14:41:06 +00:00
Guillaume Gomez
fced6383c2 Fix href attribute value check on Windows (DOC_PATH lacks an extra /) 2023-06-14 16:23:05 +02:00
bors
afa9fef709 Auto merge of #112418 - ferrocene:pa-mir-opt-panic, r=ozkanonur,saethlin
Add support for targets without unwinding in `mir-opt`, and improve `--bless` for it

The main goal of this PR is to add support for targets without unwinding support in the `mir-opt` test suite, by adding the `EMIT_MIR_FOR_EACH_PANIC_STRATEGY` comment. Similarly to 32bit vs 64bit, when that comment is present, blessed output files will have the `.panic-unwind` or `.panic-abort` suffix, and the right one will be chosen depending on the target's panic strategy.

The `EMIT_MIR_FOR_EACH_PANIC_STRATEGY` comment replaced all the `ignore-wasm32` comments in the `mir-opt` test suite, as those comments were added due to `wasm32` being a target without unwinding support. The comment was also added on other tests that were only executed on x86 but were still panic strategy dependent.

The `mir-opt` suite was then blessed, which caused a ton of churn as most of the existing output files had to be renamed and (mostly) duplicated with the abort strategy.

---

After [asking on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/mir-opt.20tests.20and.20panic.3Dabort), the main concern about this change is it'd make blessing the `mir-opt` suite even harder, as you'd need to both bless it with an unwinding target and an aborting target. This exacerbated the current situation, where you'd need to bless it with a 32bit and a 64bit target already.

Because of that, this PR also makes significant enhancements to `--bless` for the `mir-opt` suite, where it will automatically bless the suite four times with different targets, while requiring minimal cross-compilation.

To handle the 32bit vs 64bit blessing, there is now an hardcoded list of target mapping between 32bit and 64bit. The goal of the list is to find a related target that will *probably* work without requiring additional cross-compilation toolchains on the system. If a mapping is found, bootstrap will bless the suite with both targets, otherwise just with the current target.

To handle the panic strategy blessing (abort vs unwind), I had to resort to what I call "synthetic targets". For each of the target we're blessing (so either the current one, or a 32bit and a 64bit depending on the previous paragraph), bootstrap will extract the JSON spec of the target and change it to include `"panic-strategy": "abort"`. It will then build the standard library with this synthetic target, and bless the `mir-opt` suite with it.

As a result of these changes, blessing the `mir-opt` suite will actually bless it two or four times with different targets, ensuring all possible variants are actually blessed.

---

This PR is best reviewed commit-by-commit.

r? `@jyn514`
cc `@saethlin` `@oli-obk`
2023-06-14 14:20:59 +00:00
jyn
be9b1334a0 Suggest bumping download-ci-llvm-stamp if the build config for llvm is changed 2023-06-14 09:01:40 -05:00
Lukas Wirth
cf178cba8f internal: Add a CrateRootModuleId that encodes a module id that is always a crate root 2023-06-14 15:41:06 +02:00
ponyii
b07490ffe9 made the add_missing_impl_members and add_missing_default_members assists transform default generic types 2023-06-14 17:37:34 +04:00
Pietro Albini
f67809ac1d
yet another dry run fix 2023-06-14 15:14:19 +02:00
Rémy Rakic
9395e2771a make mir dataflow graphviz dumps opt-in 2023-06-14 12:30:13 +00:00
bors
51939db8d3 Auto merge of #15052 - lnicola:fmt-arguments, r=Veykril
minor: Rename minicore ArgumentV1 to match libcore
2023-06-14 12:13:58 +00:00
bors
7b0eac438a Auto merge of #112400 - WaffleLapkin:vtable_stats, r=compiler-errors
Collect VTable stats & add `-Zprint-vtable-sizes`

This is a bit hacky/buggy, but I'm not entirely sure how to fix it, so I want to ask reviewers for help...

To try this, use either of those:
- `cargo clean && RUSTFLAGS="-Zprint-vtable-sizes" cargo +toolchain b`
- `cargo clean && cargo rustc +toolchain -Zprint-vtable-sizes`
- `rustc +toolchain -Zprint-vtable-sizes ./file.rs`
2023-06-14 11:24:42 +00:00
Guillaume Gomez
df9a46f60f Replace unicode value with character in shortcuts.goml test 2023-06-14 10:37:56 +02:00
Guillaume Gomez
fd4320ca07 Transform backslash into slashes in DOC_FOLDER variable for browser-ui-test 2023-06-14 10:37:56 +02:00
Guillaume Gomez
2f9fac024c Update browser-ui-test version to 0.16.7 2023-06-14 10:37:56 +02:00
bors
3ed2a10d17 Auto merge of #110662 - bryangarza:safe-transmute-reference-types, r=compiler-errors
Safe Transmute: Enable handling references

This patch enables support for references in Safe Transmute, by generating nested obligations during trait selection. Specifically, when we call `confirm_transmutability_candidate(...)`, we now recursively traverse the `rustc_transmute::Answer` tree and create obligations for all the `Answer` variants, some of which include multiple nested `Answer`s.
2023-06-14 08:26:22 +00:00
The 8472
0c5f442db4 update miri test 2023-06-14 09:28:56 +02:00
The 8472
479be6ac43 update hashbrown and replace Hash{Set,Map}::DrainFilter with ExtractIf 2023-06-14 09:28:56 +02:00
The 8472
18c9a12d13 remove hash_drain_filter feature uses 2023-06-14 09:28:56 +02:00
The 8472
114d5f221c s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedList 2023-06-14 09:28:54 +02:00
The 8472
b7ce7edd87 remove drain-on-drop behavior from linked_list::DrainFilter and add #[must_use] 2023-06-14 09:24:51 +02:00
The 8472
b687e84aeb remove drain-on-drop behavior from BTree{Set,Map}::DrainFilter and add #[must_use] 2023-06-14 09:24:51 +02:00
The 8472
c0df1c8c43 remove drain-on-drop behavior from vec::DrainFilter and add #[must_use] 2023-06-14 09:24:51 +02:00
Sam Ginnett
72531b7463 Fix explicit-outlives-requirements lint span 2023-06-13 23:04:00 -07: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
Michael Goulet
bc78d0cbf1 Error on unconstrained lifetime in RPITIT 2023-06-14 05:20:31 +00:00
Scott McMurray
e94f26a40a Bump stdarch 2023-06-13 21:45:04 -07:00
Laurențiu Nicola
6d6354e5b5 Rename minicore ArgumentV1 to match libcore 2023-06-14 07:33:37 +03: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
Michael Goulet
9e210522bc Improve docs/clean up negative overlap functions 2023-06-14 02:18:30 +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
Celina G. Val
af4040a5c1 Use a Stable trait to translate mir -> smir
I was wondering if this would be a bit cleaner.
2023-06-13 15:17:01 -07:00