Commit Graph

229941 Commits

Author SHA1 Message Date
Jhonny Bill Mena
051615e198 UPDATE - replace gcc monomorphization errors with ssa ones
Reduces error duplication and makes it more consistent across backends
2023-07-19 23:40:08 -04:00
bors
39f42ad9e8 Auto merge of #113865 - Dylan-DPC:rollup-pt960bk, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #113444 (add tests for alias bound preference)
 - #113716 (Add the `no-builtins` attribute to functions when `no_builtins` is applied at the crate level.)
 - #113754 (Simplify native_libs query)
 - #113765 (Make it clearer that edition functions are `>=`, not `==`)
 - #113774 (Improve error message when closing bracket interpreted as formatting fill character)
 - #113785 (Fix invalid display of inlined re-export when both local and foreign items are inlined)
 - #113803 (Fix inline_const with interpolated block)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-19 18:17:59 +00:00
Dylan DPC
6c3cbcd333
Rollup merge of #113803 - compiler-errors:const-interp-block, r=fee1-dead
Fix inline_const with interpolated block

Interpolation already worked when we had a `const $block` that wasn't a statement expr:

```
fn foo() {
  let _ = const $block;
}
```

But it was failing when the const block was in statement expr position:

```
fn foo() {
  const $block;
}
```

... because of a bug in a check for const items. This fixes that.

---

cc https://github.com/rust-lang/rust/pull/112953#issuecomment-1631354481, though I don't think this requires an FCP since it's already supported in exprs and seems to me to be fully a parser bug.
2023-07-19 22:37:08 +05:30
Dylan DPC
c7c89140b0
Rollup merge of #113785 - GuillaumeGomez:tests/rustdoc/issue-105735-fix, r=notriddle,aDotInTheVoid
Fix invalid display of inlined re-export when both local and foreign items are inlined

Fixes #105735.

The bug is actually quite interesting: at the `clean` pass, local inlined items have their `use` item removed, however foreign items don't have their `use` item removed because it's in the `clean` pass that we handle them. So when a `use` inlines both a local and a foreign item, it will work as expected for the foreign one, but not for the local as its `use` should not be around anymore.

To prevent this, I created a new `inlined_foreigns` field into the `Module` struct to allow to remove the `use` item early on for foreign items as well. Then we iterate it in the `clean` pass directly.

r? ``@notriddle``
2023-07-19 22:37:08 +05:30
Dylan DPC
444ac1a6df
Rollup merge of #113774 - compiler-errors:fill-expr-bracket, r=eholk
Improve error message when closing bracket interpreted as formatting fill character

Fixes #112732 by explaining why it's erroring in the way it is.
2023-07-19 22:37:07 +05:30
Dylan DPC
a47b7b013f
Rollup merge of #113765 - compiler-errors:at-least, r=oli-obk
Make it clearer that edition functions are `>=`, not `==`

r? `@Nilstrieb`

We could also perhaps derive `Ord` on `Edition` and use comparison operators.
2023-07-19 22:37:07 +05:30
Dylan DPC
dbb6b1ac31
Rollup merge of #113754 - cjgillot:simplify-foreign, r=petrochenkov
Simplify native_libs query

Drive-by cleanup I saw while implementing https://github.com/rust-lang/rust/pull/113734
2023-07-19 22:37:07 +05:30
Dylan DPC
c1d6d322f4
Rollup merge of #113716 - DianQK:add-no_builtins-to-function, r=pnkfelix
Add the `no-builtins` attribute to functions when `no_builtins` is applied at the crate level.

**When `no_builtins` is applied at the crate level, we should add the `no-builtins` attribute to each function to ensure it takes effect in LTO.**

This is also the reason why no_builtins does not take effect in LTO as mentioned in #35540.

Now, `#![no_builtins]` should be similar to `-fno-builtin` in clang/gcc, see https://clang.godbolt.org/z/z4j6Wsod5.

Next, we should make `#![no_builtins]` participate in LTO again. That makes sense, as LTO also takes into consideration function-level instruction optimizations, such as the MachineOutliner. More importantly, when a user writes a large `#![no_builtins]` crate, they would like this crate to participate in LTO as well.

We should also add a function-level no_builtins attribute to allow users to have more control over it. This is similar to Clang's `__attribute__((no_builtin))` feature, see https://clang.godbolt.org/z/Wod6KK6eq. Before implementing this feature, maybe we should discuss whether to support more fine-grained control, such as `__attribute__((no_builtin("memcpy")))`.

Related discussions:
- #109821
- #35540

Next (a separate pull request?):
- [ ] Revert #35637
- [ ] Add a function-level `no_builtin` attribute?
2023-07-19 22:37:06 +05:30
Dylan DPC
c2257b9412
Rollup merge of #113444 - lcnr:alias-bound-test, r=compiler-errors
add tests for alias bound preference

cc https://github.com/rust-lang/trait-system-refactor-initiative/issues/45

r? ``@compiler-errors``
2023-07-19 22:37:06 +05:30
Michael Goulet
846cc63e38 Make it clearer that edition functions are >=, not == 2023-07-19 16:38:35 +00:00
Michael Goulet
e02119146f Fix unit tests 2023-07-19 16:37:09 +00:00
Michael Goulet
a872762151 Improve error message when closing bracket interpreted as formatting fill character 2023-07-19 16:37:09 +00:00
Michael Goulet
fe4d1f9fe9 Fix quotes in output 2023-07-19 16:27:28 +00:00
bors
fdfcdad4fa Auto merge of #113850 - cjgillot:span-shorthand, r=compiler-errors
Encode shorthands for spans in metadata.

Spans occupy a typically large proportion of metadata.
This PR deduplicates encoded spans in order to reduce encoded length.
2023-07-19 16:26:29 +00:00
Michael Goulet
719797949a Fix inline_const with interpolated block 2023-07-19 16:24:58 +00:00
Camille GILLOT
186be726d6 Encode shorthands for spans in metadata. 2023-07-19 12:22:11 +00:00
bors
77e24f90f5 Auto merge of #112591 - jfgoog:better-dlltool-diagnostics, r=WaffleLapkin
Better diagnostics for dlltool errors.

When dlltool fails, show the full command that was executed. In particular, llvm-dlltool is not very helpful, printing a generic usage message rather than what actually went wrong, so stdout and stderr aren't of much use when troubleshooting.
2023-07-19 07:27:50 +00:00
bors
b657dc555b Auto merge of #113690 - aliemjay:opaque-defined-by-trait, r=compiler-errors
allow opaques to be defined by trait queries, again

This basically reverts #112963.

Moreover, all call-sites of `enter_canonical_trait_query` can now define opaque types, see the ui test `defined-by-user-annotation.rs`.

Fixes #113689

r? `@compiler-errors` `@oli-obk`
2023-07-19 05:40:58 +00:00
bors
0d6a9b2bf7 Auto merge of #113777 - nnethercote:overlap-based-cgu-merging, r=pnkfelix
Inline overlap based CGU merging

Introduce a new CGU merging algorithm that aims to minimize the number of duplicated inlined items.

r? `@wesleywiser`
2023-07-18 22:36:17 +00:00
Nicholas Nethercote
05de5d6f64 Change the primary CGU merging algorithm.
Instead of repeatedly merging the two smallest CGUs, we now use a
merging algorithm that aims to minimize the duplication of inlined
functions.

`exa-0.10.1` was one benchmark that saw particularly good results. The
old CGU stats:
```
INTERNALIZE
- unique items: 2774 (1216 root + 1558 inlined), unique size: 122065 (77219 root + 44846 inlined)
- placed items: 3834 (1216 root + 2618 inlined), placed size: 154552 (77219 root + 77333 inlined)
- placed/unique items ratio: 1.38, placed/unique size ratio: 1.27
- CGUs: 16, mean size: 9659.5, sizes: [11791, 11634, 11173, 10987, 10939, 10507, 9992, 9813, 9593, 9580, 9030, 8447, 7975, 7961, 7876, 7254]
```
The new CGU stats:
```
INTERNALIZE
- unique items: 2774 (1216 root + 1558 inlined), unique size: 122065 (77219 root + 44846 inlined)
- placed items: 3626 (1216 root + 2410 inlined), placed size: 147201 (77219 root + 69982 inlined)
- placed/unique items ratio: 1.31, placed/unique size ratio: 1.21
- CGUs: 16, mean size: 9200.1, sizes: [11634, 10939, 10227, 9555, 9178, 9167, 8879, 8804, 8604, 8603 (x3), 8602 (x2), 8601, 8600]
```
The difference is in the number of inlined items. There are 1558 unique
inlined items. With the old algorithm these were placed 2618 times,
resulting in 1060 duplicates. With the new algorithm these were placed
2410 times, resulting in 852 duplicates. Also, the mean CGU size dropped
from 9659.5 to 9200.1, and the CGU size distribution tightened, with the
biggest one a little smaller and the smallest ones a little bigger.
2023-07-19 07:23:11 +10:00
Nicholas Nethercote
017c0b5a01 Add a useful comment. 2023-07-19 07:23:11 +10:00
Nicholas Nethercote
b2c3948892 Split the CGU merging loop.
It has two conditions. This commit splits it in two, one per condition.
The next commit will change the first loop.
2023-07-19 07:23:11 +10:00
Nicholas Nethercote
77b053a2dd Add MonoItemData::inlined. 2023-07-19 07:23:09 +10:00
bors
903e279f46 Auto merge of #113841 - weihanglo:update-cargo, r=weihanglo
Update cargo

11 commits in 694a579566a9a1482b20aff8a68f0e4edd99bd28..1b15556767f4b78a64e868eedf4073c423f02b93
2023-07-11 22:28:29 +0000 to 2023-07-18 14:44:47 +0000
- Fix "cargo doc --open" crash on WSL2 (rust-lang/cargo#12373)
- fix(git): respect scp-like URL for nested submodules (rust-lang/cargo#12359)
- Upgrade to indexmap v2 (rust-lang/cargo#12368)
- refactor: Clean up package metadata (rust-lang/cargo#12352)
- Correct unspecifiead to unspecified (rust-lang/cargo#12363)
- Replace invalid `panic_unwind` std feature with `panic-unwind` (rust-lang/cargo#12364)
- Bump to 0.74.0; update changelog (rust-lang/cargo#12361)
- Bump version of crates-io due to unintentional semver-breaking change (rust-lang/cargo#12357)
- chore: Automatically update dependencies monthly (rust-lang/cargo#12341)
- docs: Use heading attributes to control the fragment. (rust-lang/cargo#12339)
- Rustfmt with latest nightly. (rust-lang/cargo#12351)

r? ghost
2023-07-18 20:49:30 +00:00
bors
d351515521 Auto merge of #113636 - compiler-errors:opaque-recursive-check-bad, r=oli-obk
Restrict recursive opaque type check

We have a recursive opaque check in writeback to avoid inferring the hidden of an opaque type to be itself:

33a2c2487a/compiler/rustc_hir_typeck/src/writeback.rs (L556-L575)

Issue #113619 treats `make_option2` as not defining the TAIT `TestImpl` since it is inferred to have the definition `TestImpl := B<TestImpl>`, which fails this check. This regressed in #102700 (5d15beb591), I think due to the refactoring that made us record the hidden types of TAITs during writeback.

However, nothing actually seems to go bad if we relax this recursion checker to only check for directly recursive definitions. This PR fixes #113619 by changing this recursive check from being a visitor to just checking that the hidden type is exactly the same as the opaque being inferred.

Alternatively, we may be able to fix #113619 by restricting this recursion check only to RPITs/async fns. It seems to only be possible to use misuse the recursion check to cause ICEs for TAITs (though I didn't try too hard to create a bad RPIT example... may be possible, actually.)

r? `@oli-obk`

--

Fixes #113314
2023-07-18 18:53:42 +00:00
Weihang Lo
3c7469eb5c
Update cargo 2023-07-18 19:45:12 +01:00
Camille GILLOT
09743b9ebf Bless ui tests. 2023-07-18 18:15:45 +00:00
bors
42a982d367 Auto merge of #113837 - matthiaskrgr:rollup-v4xud4s, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #113811 (Fix removal span calculation of `unused_qualifications` suggestion)
 - #113812 (docs(release): Remove nightly-only cargo item)
 - #113823 (Fix results search alias display)
 - #113824 (a small `fn needs_drop` refactor)
 - #113828 (Ping spastorino on changes to SMIR)
 - #113832 (Add `#[track_caller]` to lint related diagnostic functions)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-07-18 17:08:28 +00:00
Matthias Krüger
4bbd7818b5
Rollup merge of #113832 - WaffleLapkin:track_lint_caller, r=compiler-errors
Add `#[track_caller]` to lint related diagnostic functions

This fixes locations reported by `-Ztrack-diagnostics`.
2023-07-18 19:06:04 +02:00
Matthias Krüger
dd8fabb7a1
Rollup merge of #113828 - spastorino:ping-spastorino-smir, r=oli-obk
Ping spastorino on changes to SMIR

r? `@oli-obk`
2023-07-18 19:06:04 +02:00
Matthias Krüger
994e2e4fac
Rollup merge of #113824 - lcnr:exhaustive-match, r=wesleywiser
a small `fn needs_drop` refactor

I am generally a fan of exhaustively matching on `TyKind` once we care about more than 1 variant
2023-07-18 19:06:03 +02:00
Matthias Krüger
1b07da1d52
Rollup merge of #113823 - GuillaumeGomez:fix-results-search-alias-display, r=notriddle
Fix results search alias display

Currently it's displayed like this:

![Screenshot from 2023-07-18 14-23-35](https://github.com/rust-lang/rust/assets/3050060/119d8f18-b298-4e6f-9571-9f678fc19126)

With this fix:

![Screenshot from 2023-07-18 14-23-29](https://github.com/rust-lang/rust/assets/3050060/679d6241-420e-4f13-be78-dc061cbc488a)

r? `@notriddle`
2023-07-18 19:06:03 +02:00
Matthias Krüger
c88864cbde
Rollup merge of #113812 - epage:change, r=ehuss
docs(release): Remove nightly-only cargo item

See rust-lang/cargo#12343
2023-07-18 19:06:02 +02:00
Matthias Krüger
931d9f099a
Rollup merge of #113811 - jieyouxu:fix-unused-qualifications-suggestion, r=oli-obk
Fix removal span calculation of `unused_qualifications` suggestion

Given a path such as `std::ops::Index<str>`, calculate the unnecessary qualification removal span by computing the beginning of the entire span until the ident span of the last path segment, which handles generic arguments and lifetime arguments in the last path segment. Previous logic only kept the ident span of the last path segment which is incorrect.

Closes #113808.
2023-07-18 19:06:02 +02:00
Michael Goulet
6875589924 Add additional test 2023-07-18 15:56:03 +00:00
Michael Goulet
7db5f81853 Relax recursive opaque type check 2023-07-18 15:56:03 +00:00
Maybe Waffle
3dd5413bfd Add #[track_caller] to lint related diagnostic functions 2023-07-18 15:48:07 +00:00
Santiago Pastorino
1f9fa18e90
Ping spastorino on changes to SMIR 2023-07-18 11:23:28 -03:00
DianQK
cc08749df2
Add the no-builtins attribute to functions when no_builtins is applied at the crate level.
When `no_builtins` is applied at the crate level, we should add the
`no-builtins` attribute to each function to ensure it takes effect in LTO.
2023-07-18 22:15:47 +08:00
lcnr
d1b4b458c0 some additional refactor
also, treat placeholders equal to params
2023-07-18 15:50:34 +02:00
bors
8d361cbd91 Auto merge of #112374 - chenx97:better-mips64r6, r=jackh726
add mips64r6 and mips32r6 as target_arch values

This PR introduces `"mips32r6"` and `"mips64r6"` as valid `target_arch` values, and would be the arch value used by Tier-3 targets `mipsisa32r6-unknown-linux-gnu`, `mipsisa32r6el-unknown-linux-gnu`, `mipsisa64r6-unknown-linux-gnuabi64` and `mipsisa64r6el-unknown-linux-gnuabi64`.

This PR was inspired by `rustix` attempting to link traditional mips64el objects with mips64r6el objects when building for mips64r6, even though `rustix` recently removed outline assembly support. This is because currently this target's `target_arch` is `"mips64"` and rustix has its respective assembly implementation as well as a pre-compiled little-endian static library prepared for mips64el, a tier-2 target with the same `target_arch`. After some [discussions on zulip](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Add.20New.20Values.20To.20MIPS_ALLOWED_FEATURES.20compiler-team.23595), I decided to treat mips64r6 as an independent architecture from Rust's POV, since these two architectures are incompatible anyway.

This PR is now waiting for `libc` to release a new version with [support](https://github.com/rust-lang/libc/pull/3268) for these `target_arch` values. It is not expected to introduce changes to any other target, especially Tier-1 and Tier-2 targets.

This PR has its corresponding [MCP](https://github.com/rust-lang/compiler-team/issues/632) approved.
2023-07-18 13:42:14 +00:00
Guillaume Gomez
8f5787abba Update rustdoc GUI tests 2023-07-18 14:34:24 +02:00
Guillaume Gomez
3dec71ea8f Fix display of aliases in rustdoc search results 2023-07-18 14:34:24 +02:00
bors
f0580df0d5 Auto merge of #113706 - Alexendoo:compiletest-backslash-re, r=oli-obk
Fix compiletest windows path finding with spaces

With `(?x)` enabled spaces are ignored unless you escape them, so the space wasn't being added to the character class

I don't think this makes any difference to the current test suite, but it could save someone a headache in the future
2023-07-18 11:33:02 +00:00
chenx97
d3727148a0 support for mips32r6 as a target_arch value 2023-07-18 18:58:18 +08:00
chenx97
a132b3ec03 merge patterns 2023-07-18 18:58:18 +08:00
chenx97
c6e03cd951 support for mips64r6 as a target_arch value 2023-07-18 18:58:18 +08:00
bors
c44324a4fe Auto merge of #113677 - bryangarza:unevaluated-const-ice_issue-110892, r=davidtwco
Safe Transmute: Fix ICE (due to UnevaluatedConst)

This patch updates the code that looks at the `Assume` type when evaluating if transmutation is possible. An ICE was being triggered in the case that the `Assume` parameter contained an unevaluated const (in this test case, due to a function with missing parameter names).

Fixes #110892
2023-07-18 09:07:32 +00:00
Guillaume Gomez
afec6d242b Remove unneeded Option<Symbol> in foreign_items 2023-07-18 10:41:16 +02:00
Guillaume Gomez
c845a53aa2 Add regression test for #105735 2023-07-18 10:41:16 +02:00