Add howto for adding new targets
When new targets are added, often a reviewer finds out that e.g. the target-3-tier-policy is not filled out (missing), there is no description etc.
This change adds a description of what I've learned while working on #102701. It should make reviews easier in the future with less rework.
r? compiler-team
Add visit_fn_ret_ty to hir intravisit
I'm working on some RPITIT changes and I need to specialize `visit_fn_ret_ty` in my visitor impl. So I guess it's better to land it separately.
r? `@compiler-errors`
Elaborate supertrait obligations when deducing closure signatures
We elaborate the supertrait obligations of any registered predicates for a closure to see if we can infer a closure signature.
This is not as general of a fix as it *could* be, since we just elaborate supertrait bounds instead of doing a theoretical walk of _all_ registered predicates that might cause us to deduce `Fn` trait information for a closure infer var. I don't even know how to come up with an example that fails here but would work with a more general system.
Fixes#23012
Also fixes the existing compile failure in #57611
r? `@ghost` for now until I do a perf run
cc `@nikomatsakis` since you commented on https://github.com/rust-lang/rust/issues/23012#issuecomment-1152397290
Ban dashes in miropt test file names
Dashes in miropt test file names are annoying - specifically, they cause the test files to not be sorted next to their outputs, which makes it very difficult to tell what goes with what. This PR changes all files to use underscores and adds a blessable tidy check that enforces this.
r? `@jyn514`
This PR is obviously going to bitrot very quickly. Because of this, I'm going to wait at least 48 hours and until review comes back to allow people from `@rust-lang/wg-mir-opt` or elsewhere to lodge complaints if there are any. If not, I'll rebase the branch on Friday afternoon PST and ask that it be `r+`'d with `p=1` at that time.
Fixed consistency of Apple simulator target's ABI
Currently there's a few Apple device simulator targets that are inconsistent since some set `target_abi = "sim"` (the correct thing to do) while a bunch of others don't set anything (`""`). Due to this its very hard to reliability check if some Rust code is running inside a simulator. This changes all of them to do the same thing and set `sim` as their `target_abi`.
The new way to identity a simulator during compilation is as simple as `cfg(all(target_vendor="apple", target_abi = "sim"))` or even `cfg(target_abi = "sim")` being less pedantic about it.
The issues with the current form (and inspiration for this) are also summarized in `@thomcc's` [Tweet](https://twitter.com/at_tcsc/status/1576685244702691328).
Rollup of 6 pull requests
Successful merges:
- #99801 (fix(generic_const_exprs): Fix predicate inheritance for children of opaque types)
- #103610 (Allow use of `-Clto=thin` with `-Ccodegen-units=1` in general)
- #103870 (Fix `inferred_kind` ICE)
- #103875 (Simplify astconv item def id handling)
- #103886 (rustdoc: Fix merge of attributes for reexports of local items)
- #103890 (rustdoc: remove unused mobile CSS `.rustdoc { padding-top: 0 }`)
Failed merges:
- #103884 (Add visit_fn_ret_ty to hir intravisit)
r? `@ghost`
`@rustbot` modify labels: rollup
rustdoc: remove unused mobile CSS `.rustdoc { padding-top: 0 }`
When this rule was added in dd437ee6ed, as `body { padding-top: 0 }`, the desktop body tag had non-zero top padding. This padding was removed in 135281ed15.
This rule no longer overrides a rule in rustdoc's desktop styles, and also doesn't override the UA stylesheet, since the [HTML standard] has only margin, not padding, on the page body.
[HTML standard]: https://html.spec.whatwg.org/multipage/rendering.html#the-page
rustdoc: Fix merge of attributes for reexports of local items
Fixes https://github.com/rust-lang/rust/issues/84619.
The problem was that we didn't merge attributes between the the reexport and the item.
r? `@notriddle`
Allow use of `-Clto=thin` with `-Ccodegen-units=1` in general
The current logic to ignore ThinLTO when `-Ccodegen-units=1` makes sense for local ThinLTO but even in this scenario, a user may still want (non-local) ThinLTO for the purpose of optimizing dependencies into the final crate which is being compiled with 1 CGU.
The previous behavior was even more confusing because if you were generating a binary (`--emit=link`), then you would get ThinLTO but if you asked for LLVM IR or bytecode, then it would silently change to using regular LTO.
With this change, we only override the defaults for local ThinLTO if you ask for a single output such as LLVM IR or bytecode and in all other cases honor the requested LTO setting.
r? `@michaelwoerister`
fix(generic_const_exprs): Fix predicate inheritance for children of opaque types
Fixes#99705
We currently have a special case to perform predicate inheritance when the const item is in the generics. I think we're also going to need this for opaque return types. When evaluating the predicates applied to the associated item, it'll inherit from its parent, the opaque type, which will never have predicates applied. This PR bypass the opaque typed parent and inherit predicates directly from the function itself.
When this rule was added in dd437ee6ed, as
`body { padding-top: 0 }`, the desktop body tag had non-zero top padding.
This padding was removed in 135281ed15.
This rule no longer overrides a rule in rustdoc's desktop styles, and also
doesn't override the UA stylesheet, since the [HTML standard] has only
margin, not padding, on the page body.
[HTML standard]: https://html.spec.whatwg.org/multipage/rendering.html#the-page
Reorder `walk_` functions in intravisit.rs
Reorder the `walk_` functions to match the order of the `visit_` methods. This is a follow up to https://github.com/rust-lang/rust/pull/103692.
Note that there are some oddballs. I put them where I thought made the most sense:
```diff
$ diff \
<(sed -n 's/^.*\<fn visit_\([^(]*\).*$/\1/;T;p' compiler/rustc_hir/src/intravisit.rs) \
<(sed -n 's/^.*\<fn walk_\([^<]*\).*$/\1/;T;p' compiler/rustc_hir/src/intravisit.rs)
1,5d0
< nested_item
< nested_trait_item
< nested_impl_item
< nested_foreign_item
< nested_body
9,10d3
< id
< name
20c13
< array_length
---
> array_len
30a24
> fn_ret_ty
31a26
> fn_kind
41c36
< variant_data
---
> struct_def
46c41
< infer
---
> inf
54d48
< attribute
```
Also, as some weak evidence that i did things correctly, I get the following before and after the change:
```sh
$ sort compiler/rustc_hir/src/intravisit.rs | openssl sha256
SHA256(stdin)= cac13d2545731ef442f318e2b4286490d7ac5494f4ad10c4cf4c5d4f50d21641
```
r? `@fee1-dead`
rustdoc: simplify mobile item-table CSS
Using flexbox in column direction is needlessly complicated, since no special flex powers are being used here. Just use regular block layout.
This should result in no visible changes.
Gate some parser recovery behind the check
Mainly in `expr.rs`. `may_recover` doesn't do anything useful yet until I implement that on top of #103439.
r? `@compiler-errors`
rustdoc: Do not add external traits to the crate in `register_res`
It's not clear why it was done, and apparently it's no longer necessary now.
Such additions are unpredictable for early doc link resolution and would force us to collect all doc links from all external traits.
Fixes https://github.com/rust-lang/rust/issues/103463
Rollup of 8 pull requests
Successful merges:
- #103072 (compiletest: set the dylib path when gathering target cfg)
- #103084 (Derive `Eq` and `Hash` for `ControlFlow`)
- #103575 (Change #[suggestion_*] attributes to use style="...")
- #103637 (Use stdio in UWP apps)
- #103638 (Add `multivalue` target feature to WASM target)
- #103781 (Detect unused files in `src/test/mir-opt` and error on them in tidy.)
- #103837 (Migrate sidebar-links-color GUI test to functions)
- #103839 (Print valid `--print` requests if request is invalid)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup