Commit graph

217624 commits

Author SHA1 Message Date
Jacob Pratt 20282c1b20
Reduce limit on macro_rules! diagnostic 2023-02-19 04:17:58 +00:00
Jacob Pratt 378c4ab9ab
Make public API, docs algorithm-agnostic 2023-02-19 04:11:10 +00:00
Jacob Pratt c2f2a3cff2
Add test for println! typo 2023-02-19 03:46:03 +00:00
Jacob Pratt ff052eec80
Use restricted Damerau-Levenshtein algorithm 2023-02-19 03:46:03 +00:00
bors 231bcd131d Auto merge of #105274 - saethlin:instcombine-mut-ref, r=cjgillot
Enable instcombine for mutable reborrows

`instcombine` used to contain this comment, which is no longer accurate because there it is fine to copy `&mut _` in MIR:
```rust
// The dereferenced place must have type `&_`, so that we don't copy `&mut _`.
```
So let's try replacing that check with something much more permissive...
2023-02-17 20:50:11 +00:00
bors 9aa5c24b7d Auto merge of #108075 - WaffleLapkin:de-arena-allocates-you-OwO, r=Nilstrieb
Remove `arena_cache` modifier from `associated_item` query & copy `ty::AssocItem` instead of passing by ref

r? `@ghost`
2023-02-17 17:42:51 +00:00
bors f722b24eb9 Auto merge of #108159 - matthiaskrgr:rollup-5k2j7cx, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #107592 (Default `repr(C)` enums to `c_int` size)
 - #107956 (Copy `bin/*` and `lib/*.dylib` files to `stage0-sysroot`)
 - #108126 (fix a line, and do a consistency fix)
 - #108144 (Add compiler-errors to a few more triagebot groups)
 - #108149 (typo)
 - #108154 (`BasicBlock::new(0)` -> `START_BLOCK` [no functional changes])

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-17 14:27:28 +00:00
Matthias Krüger ae5473c969
Rollup merge of #108154 - scottmcm:start-block-cleanup, r=compiler-errors
`BasicBlock::new(0)` -> `START_BLOCK` [no functional changes]
2023-02-17 12:39:07 +01:00
Matthias Krüger 392b150011
Rollup merge of #108149 - tshepang:typo, r=Dylan-DPC
typo
2023-02-17 12:39:07 +01:00
Matthias Krüger a8685ebf4d
Rollup merge of #108144 - compiler-errors:triagebot-more, r=Mark-Simulacrum
Add compiler-errors to a few more triagebot groups

Self-explanatory
2023-02-17 12:39:07 +01:00
Matthias Krüger e53bd4c282
Rollup merge of #108126 - tshepang:nits, r=lcnr
fix a line, and do a consistency fix
2023-02-17 12:39:06 +01:00
Matthias Krüger 99567662ab
Rollup merge of #107956 - KittyBorgX:master, r=ozkanonur
Copy `bin/*` and `lib/*.dylib` files to `stage0-sysroot`

Fixes #101691
2023-02-17 12:39:06 +01:00
Matthias Krüger e0aa5613d8
Rollup merge of #107592 - workingjubilee:use-16-bit-enum-on-16-bit-targets, r=WaffleLapkin
Default `repr(C)` enums to `c_int` size

This is what ISO C strongly implies this is correct, and
many processor-specific ABIs imply or mandate this size, so
"everyone" (LLVM, gcc...) defaults to emitting enums this way.
However, this is by no means guaranteed by ISO C,
and the bare-metal Arm targets show it can be overridden,
which rustc supports via `c-enum-min-bits` in a target.json.

The override is a flag named `-fshort-enums` in clang and gcc,
but introducing a CLI flag is probably unnecessary for rustc.
This flag can be used by non-Arm microcontroller targets,
like AVR and MSP430, but it is not enabled for them by default.
Rust programmers who know the size of a target's enums
can use explicit reprs, which also lets them match C23 code.

This change is most relevant to 16-bit targets: AVR and MSP430.
Most of rustc's targets use 32-bit ints, but ILP64 does exist.
Regardless, rustc should now correctly handle enums for
both very small and very large targets.

Thanks to William for confirming MSP430 behavior,
and to Waffle for better style and no-core `size_of` asserts.

Fixes rust-lang/rust#107361
Fixes rust-lang/rust#77806
2023-02-17 12:39:05 +01:00
bors f4f5fc3e5c Auto merge of #107965 - BoxyUwU:add_const_arg_has_type_predicate, r=compiler-errors
Add `Clause::ConstArgHasType`

Currently the way that we check that a const arg has the correct type for the const param it is an argument for is by setting the expected type of `typeck` on the anon const of the argument to be the const param's type.

In the future for a potential `min_generic_const_exprs` we will allow providing const arguments that do not have an associated anon const that can be typeck'd which will require us to actually check that  the const argument has the correct type. While it would potentially be possible to just call `eq` when creating substs this would not work if we support generics of the form `const N: T, T` (the const parameters type referencing generics declared after itself).

Additionally having `ConstArgHasType` will allow us to potentially make progress on removing the `ty` field of `Const` which may be desirable. Once progress has been made on this, `ConstArgHasType` will also be helpful in ensuring we do not make mistakes in trait/impl checking by declaring functions with the wrong const parameter types as the checks that the param env is compatible would catch it. (We have messed this up in the past, and with generic const parameter types these checks will get more complex)

There is a [document](https://hackmd.io/wuCS6CJBQ9-fWbwaW7nQRw?view) about the types of const generics that may provide some general information on this subject

---

This PR shouldn't have any impact on whether code compiles or not on stable, it primarily exists to make progress on unstable const generics features that are desirable.
2023-02-17 11:27:21 +00:00
Boxy 90c8d6bbe4 add predicate evaluation logic 2023-02-17 09:32:39 +00:00
Boxy e919d7e348 Add Clause::ConstArgHasType variant 2023-02-17 09:30:33 +00:00
bors b5c8c329a7 Auto merge of #108058 - Zoxc:query-ctxtx-byval, r=cjgillot
Pass `DepContext` and `QueryContext` by value when practical

This removes some indirections for a minor performance improvement.

<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.8294s</td><td align="right">1.8255s</td><td align="right"> -0.21%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2667s</td><td align="right">0.2669s</td><td align="right"> 0.07%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">1.0080s</td><td align="right">1.0063s</td><td align="right"> -0.17%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.6335s</td><td align="right">1.6295s</td><td align="right"> -0.24%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">6.3633s</td><td align="right">6.3344s</td><td align="right"> -0.45%</td></tr><tr><td>Total</td><td align="right">11.1009s</td><td align="right">11.0627s</td><td align="right"> -0.34%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9980s</td><td align="right"> -0.20%</td></tr></table>
2023-02-17 08:23:53 +00:00
Scott McMurray c946494c34 BasicBlock::new(0) -> START_BLOCK [no functional changes] 2023-02-16 21:33:19 -08:00
bors 9556b56dbd Auto merge of #107753 - kylematsuda:type-of, r=BoxyUwU
Switch to `EarlyBinder` for `type_of` query

Part of the work to finish #105779 and implement https://github.com/rust-lang/types-team/issues/78.

Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `type_of` query and removes `bound_type_of`.

r? `@lcnr`
2023-02-17 04:45:15 +00:00
Tshepang Mbambo ad8947c32b typo 2023-02-17 03:45:48 +02:00
KittyBorgX 6990ab9ad2 Copy bin/* and lib/*.dylib files to stage0-sysroot 2023-02-17 06:49:55 +05:30
bors ea218392a4 Auto merge of #108145 - matthiaskrgr:rollup-bgadak1, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #104068 (rustdoc: Add PartialOrd trait to doc comment explanation)
 - #107489 (Implement partial support for non-lifetime binders)
 - #107905 (Pass arguments to `x` subcommands with `--`)
 - #108009 (Move some tests)
 - #108086 (wasm: Register the `relaxed-simd` target feature)
 - #108104 (don't into self)
 - #108133 (Small cleanups around `EarlyBinder`)
 - #108136 (Do not ICE on unmet trait alias impl bounds)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-17 01:14:39 +00:00
Kyle Matsuda f6c3469aa2 fix new usage of type_of 2023-02-16 17:05:59 -07:00
Kyle Matsuda 8e92849cbb changes from review 2023-02-16 17:05:59 -07:00
Kyle Matsuda c183110cc2 remove bound_type_of query; make type_of return EarlyBinder; change type_of in metadata 2023-02-16 17:05:56 -07:00
Kyle Matsuda d822b97a27 change usages of type_of to bound_type_of 2023-02-16 17:01:52 -07:00
Matthias Krüger ecdb7bcee8
Rollup merge of #108136 - eggyal:unmet_trait_alias_bound_on_generic_impl, r=compiler-errors
Do not ICE on unmet trait alias impl bounds

Fixes #108132

I've also added some documentation to the `impl_def_id` field of `DerivedObligationCause` to try and minimise the risk of such errors in future.

r? `@compiler-errors`
2023-02-17 00:19:37 +01:00
Matthias Krüger e1e58fc1d3
Rollup merge of #108133 - kylematsuda:earlybinder-cleanups, r=compiler-errors
Small cleanups around `EarlyBinder`

Cleaning up a few things that were brought up by `@lcnr` in reviewing #106696:

- [make `issue33140_self_ty` query return `Option<EarlyBinder<Ty>>`](https://github.com/rust-lang/rust/pull/106696#discussion_r1067821423)
- [small style improvement](https://github.com/rust-lang/rust/pull/106696#discussion_r1067816772)
2023-02-17 00:19:37 +01:00
Matthias Krüger 9b2ee4192e
Rollup merge of #108104 - matthiaskrgr:into, r=compiler-errors
don't into self

don't into()-convert types to themselves
2023-02-17 00:19:36 +01:00
Matthias Krüger 1fac415997
Rollup merge of #108086 - alexcrichton:wasm-relaxed-simd-feature, r=eholk
wasm: Register the `relaxed-simd` target feature

This WebAssembly proposal is likely to reach stage 4 soon so this starts the support in Rust for the proposal by adding a target feature that can be enabled via attributes for the stdarch project to bind the intrinsics.
2023-02-17 00:19:36 +01:00
Matthias Krüger ee07df9c50
Rollup merge of #108009 - c410-f3r:moar-tests, r=petrochenkov
Move some tests

r? `@petrochenkov`
2023-02-17 00:19:35 +01:00
Matthias Krüger 42f2303c67
Rollup merge of #107905 - clubby789:x-free-args, r=albertlarsan68
Pass arguments to `x` subcommands with `--`

Fixes #107375

Any arguments passed to `x` following `--` are removed and not parsed, instead passed down to subcommands (just the ones listed in the issue, not sure if more are needed). This does not remove the existing `--args` and `--test-args` behaviour, just extends it. It's also not documented in the help, not sure of the best way to format it.

r? `@jyn514`
2023-02-17 00:19:35 +01:00
Matthias Krüger 089e8c03bc
Rollup merge of #107489 - compiler-errors:non_lifetime_binders, r=cjgillot
Implement partial support for non-lifetime binders

This implements support for non-lifetime binders. It's pretty useless currently, but I wanted to put this up so the implementation can be discussed.

Specifically, this piggybacks off of the late-bound lifetime collection code in `rustc_hir_typeck::collect::lifetimes`. This seems like a necessary step given the fact we don't resolve late-bound regions until this point, and binders are sometimes merged.

Q: I'm not sure if I should go along this route, or try to modify the earlier nameres code to compute the right bound var indices for type and const binders eagerly... If so, I'll need to rename all these queries to something more appropriate (I've done this for `resolve_lifetime::Region` -> `resolve_lifetime::ResolvedArg`)

cc rust-lang/types-team#81

r? `@ghost`
2023-02-17 00:19:34 +01:00
Matthias Krüger 6379c727ac
Rollup merge of #104068 - yancyribbens:partial-cmp-doc-update, r=scottmcm
rustdoc: Add PartialOrd trait to doc comment explanation

The doc comments for [partial_cmp](https://github.com/rust-lang/rust/blob/master/library/core/src/iter/traits/iterator.rs#L3478) is the exact same as the doc comment for [cmp](https://github.com/rust-lang/rust/blob/master/library/core/src/iter/traits/iterator.rs#L3413).  This PR adds to the description `partial_cmp` to disambiguate the description from `cmp.`
2023-02-17 00:19:33 +01:00
Jubilee Young 2edf6c8784 Default repr(C) enums to c_int size
This is what ISO C strongly implies this is correct, and
many processor-specific ABIs imply or mandate this size, so
"everyone" (LLVM, gcc...) defaults to emitting enums this way.
However, this is by no means guaranteed by ISO C,
and the bare-metal Arm targets show it can be overridden,
which rustc supports via `c-enum-min-bits` in a target.json.

The override is a flag named `-fshort-enums` in clang and gcc,
but introducing a CLI flag is probably unnecessary for rustc.
This flag can be used by non-Arm microcontroller targets,
like AVR and MSP430, but it is not enabled for them by default.
Rust programmers who know the size of a target's enums
can use explicit reprs, which also lets them match C23 code.

This change is most relevant to 16-bit targets: AVR and MSP430.
Most of rustc's targets use 32-bit ints, but ILP64 does exist.
Regardless, rustc should now correctly handle enums for
both very small and very large targets.

Thanks to William for confirming MSP430 behavior,
and to Waffle for better style and no-core size_of asserts.

Co-authored-by: William D. Jones <thor0505@comcast.net>
Co-authored-by: Waffle Maybe <waffle.lapkin@gmail.com>
2023-02-16 15:06:17 -08:00
Michael Goulet 09359d2aa5 Add compiler-errors to a few more triagebot groups 2023-02-16 22:52:41 +00:00
Alan Egerton 55d449fe0a
Clarify DerivedObligationCause may hold alias id 2023-02-16 22:12:15 +00:00
Alan Egerton a1468ae00d
Do not ICE on unmet trait alias impl bounds 2023-02-16 22:10:29 +00:00
bors 947b696ce0 Auto merge of #107833 - Zoxc:arena-query-clean, r=cjgillot
Factor query arena allocation out from query caches

This moves the logic for arena allocation out from the query caches into conditional code in the query system. The specialized arena caches are removed. A new `QuerySystem` type is added in `rustc_middle` which contains the arenas, providers and query caches.

Performance seems to be slightly regressed:
<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check</td><td align="right">1.8053s</td><td align="right">1.8109s</td><td align="right"> 0.31%</td></tr><tr><td>🟣 <b>hyper</b>:check</td><td align="right">0.2600s</td><td align="right">0.2597s</td><td align="right"> -0.10%</td></tr><tr><td>🟣 <b>regex</b>:check</td><td align="right">0.9973s</td><td align="right">1.0006s</td><td align="right"> 0.34%</td></tr><tr><td>🟣 <b>syn</b>:check</td><td align="right">1.6048s</td><td align="right">1.6051s</td><td align="right"> 0.02%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check</td><td align="right">6.2992s</td><td align="right">6.3159s</td><td align="right"> 0.26%</td></tr><tr><td>Total</td><td align="right">10.9664s</td><td align="right">10.9922s</td><td align="right"> 0.23%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">1.0017s</td><td align="right"> 0.17%</td></tr></table>

Incremental performance is a bit worse:
<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check:initial</td><td align="right">2.2103s</td><td align="right">2.2247s</td><td align="right"> 0.65%</td></tr><tr><td>🟣 <b>hyper</b>:check:initial</td><td align="right">0.3335s</td><td align="right">0.3349s</td><td align="right"> 0.41%</td></tr><tr><td>🟣 <b>regex</b>:check:initial</td><td align="right">1.2597s</td><td align="right">1.2650s</td><td align="right"> 0.42%</td></tr><tr><td>🟣 <b>syn</b>:check:initial</td><td align="right">2.0521s</td><td align="right">2.0613s</td><td align="right"> 0.45%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check:initial</td><td align="right">7.8275s</td><td align="right">7.8583s</td><td align="right"> 0.39%</td></tr><tr><td>Total</td><td align="right">13.6832s</td><td align="right">13.7442s</td><td align="right"> 0.45%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">1.0046s</td><td align="right"> 0.46%</td></tr></table>

It does seem like LLVM optimizers struggle a bit with the current state of the query system.

Based on top of https://github.com/rust-lang/rust/pull/107782 and https://github.com/rust-lang/rust/pull/107802.

r? `@cjgillot`
2023-02-16 22:10:10 +00:00
bors 9a7cc6c32f Auto merge of #108127 - matthiaskrgr:rollup-kpzfc6j, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #106347 (More accurate spans for arg removal suggestion)
 - #108057 (Prevent some attributes from being merged with others on reexports)
 - #108090 (`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`)
 - #108092 (note issue for feature(packed_bundled_libs))
 - #108099 (use chars instead of strings where applicable)
 - #108115 (Do not ICE on unmet trait alias bounds)
 - #108125 (Add new people to the compiletest review rotation)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-16 19:21:02 +00:00
yancy ced962975b rustdoc: Update the description to include PartialOrd elements 2023-02-16 19:46:11 +01:00
Kyle Matsuda 382ade6a60 fix ugly skip_binder 2023-02-16 10:52:57 -07:00
Kyle Matsuda d659c7c343 make issue33140_self_ty return Option<EarlyBinder<Ty>> 2023-02-16 10:52:57 -07:00
Matthias Krüger a1a6588162 don't into self
don't into()-convert types to themselves
2023-02-16 18:30:25 +01:00
Tshepang Mbambo f9972313ae fix some lines, and do a consistency fix 2023-02-16 18:58:08 +02:00
Matthias Krüger eb9f9c7085
Rollup merge of #108125 - albertlarsan68:moar-compiletest-reviewers, r=wesleywiser
Add new people to the compiletest review rotation

`@oli-obk` and `@wesleywiser` volunteered to be part of the review rotation of compiletest in https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202023-02-16/near/328274017
2023-02-16 17:51:27 +01:00
Matthias Krüger d77b0221f8
Rollup merge of #108115 - eggyal:unmet_trait_alias_bound, r=compiler-errors
Do not ICE on unmet trait alias bounds

Rework of #108093 following feedback on that PR.

Fixes #108072

r? `@compiler-errors`
2023-02-16 17:51:26 +01:00
Matthias Krüger 09a2267e1d
Rollup merge of #108099 - matthiaskrgr:str_to_char, r=GuillaumeGomez
use chars instead of strings where applicable
2023-02-16 17:51:26 +01:00
Matthias Krüger 2dc21c0a10
Rollup merge of #108092 - BelovDV:fix-feature-description-pbl, r=petrochenkov
note issue for feature(packed_bundled_libs)

Add to feature (introduced in #105601) gate description number of issue created for it.

r? `@petrochenkov`
2023-02-16 17:51:25 +01:00
Matthias Krüger 64a4f70c17
Rollup merge of #108090 - WaffleLapkin:if_not_now_then_when…, r=oli-obk
`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`

Resurrection of #108079
2023-02-16 17:51:25 +01:00