Commit Graph

219184 Commits

Author SHA1 Message Date
bors
160c2ebeca Auto merge of #108763 - scottmcm:indexing-nuw-lengths, r=cuviper
Use `nuw` when calculating slice lengths from `Range`s

An `assume` would definitely not be worth it, but since the flag is almost free we might as well tell LLVM this, especially on `_unchecked` calls where there's no obvious way for it to deduce it.

(Today neither safe nor unsafe indexing gets it: <https://rust.godbolt.org/z/G1jYT548s>)
2023-03-07 13:17:59 +00:00
Andy Wang
7281cd0c21
Custom MIR: Support as casts 2023-03-07 11:42:34 +01:00
bors
0a3b557d52 Auto merge of #95317 - Jules-Bertholet:round_ties_to_even, r=pnkfelix,m-ou-se,scottmcm
Add `round_ties_even` to `f32` and `f64`

Tracking issue: #96710

Redux of #82273. See also #55107

Adds a new method, `round_ties_even`, to `f32` and `f64`, that rounds the float to the nearest integer , rounding halfway cases to the number with an even least significant bit. Uses the `roundeven` LLVM intrinsic to do this.

Of the five IEEE 754 rounding modes, this is the only one that doesn't already have a round-to-integer function exposed by Rust (others are `round`, `floor`, `ceil`, and `trunc`).  Ties-to-even is also the rounding mode used for int-to-float and float-to-float `as` casts, as well as float arithmentic operations. So not having an explicit rounding method for it seems like an oversight.

Bikeshed: this PR currently uses `round_ties_even` for the name of the method. But maybe `round_ties_to_even` is better, or `round_even`, or `round_to_even`?
2023-03-07 09:43:12 +00:00
bors
8f9e09ac3e Auto merge of #108735 - clubby789:borrowck-unstable, r=Nilstrieb
Remove `allow(potential_query_instability)` from `borrowck`

cc #84447

Replace uses of `FxHash*` with `FxIndex*`. One `#[allow]` for a HashMap in an external crate but the output is sorted afterwards.
2023-03-07 07:01:57 +00:00
Celina G. Val
b66db7e4e0 Create new rustc_smir struct to map future crates
+ Add some information to the README.md
2023-03-06 21:57:46 -08:00
bors
8824994ccd Auto merge of #108691 - aliemjay:closure-subject, r=jackh726
fix multiple issues when promoting type-test subject

Multiple interdependent fixes.  See linked issues for a short description of each.

When Promoting a type-test `T: 'a` from within the closure back to its parent function, there are a couple pre-existing bugs and limitations. They were exposed by the recent changes to opaque types because the type-test subject (`T`) is no longer a simple ParamTy.

Commit 1:
Fixes #108635
Fixes #107426

Commit 2:
Fixes #108639

Commit 3:
Fixes #107516
2023-03-07 03:50:22 +00:00
bors
81be7b86d3 Auto merge of #108821 - matthiaskrgr:rollup-cmkbgpr, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #107801 (const_eval: `implies_by` in `rustc_const_unstable`)
 - #108750 (Fix `ObligationCtxt::sub`)
 - #108780 (Add regression tests for issue 70919)
 - #108786 (Check for free regions in MIR validation)
 - #108790 (Do not ICE when interpreting a cast between non-monomorphic types)
 - #108803 (Do not ICE when failing to normalize in ConstProp.)
 - #108807 (Emit the suspicious_auto_trait_impls for negative impls as well)
 - #108812 (Add regression test for #98444)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-06 22:15:55 +00:00
Wesley Wiser
545fe60519 Add tracking issue for cf-protection to unstable book 2023-03-06 13:03:12 -05:00
Michael Goulet
16e2b9f662 Place binder correctly for arbitrary trait bound suggestion 2023-03-06 16:37:34 +00:00
Nikita Popov
2c7beeda90 Remove references to PassManagerBuilder
This is a legacy PM concept that we no longer use.
2023-03-06 16:55:52 +01:00
Matthias Krüger
567cab93d5
Rollup merge of #108812 - albertlarsan68:test-98444, r=Nilstrieb
Add regression test for #98444

cc #108730 this will need to be changed to a `check-fail` test once it lands.

Fixes #98444
2023-03-06 16:42:01 +01:00
Matthias Krüger
3279f7ed77
Rollup merge of #108807 - MU001999:lint/suspicious_auto_trait_impls, r=lcnr
Emit the suspicious_auto_trait_impls for negative impls as well

Fixes #108804
2023-03-06 16:42:00 +01:00
Matthias Krüger
ab7dd09fc2
Rollup merge of #108803 - cjgillot:const-prop-normalize, r=oli-obk
Do not ICE when failing to normalize in ConstProp.

There is no reason to delay a bug there, as we bubble up the failure as TooGeneric.

Fixes https://github.com/rust-lang/rust/issues/97728
2023-03-06 16:41:59 +01:00
Matthias Krüger
3ae047b8f1
Rollup merge of #108790 - cjgillot:mono-cast, r=oli-obk
Do not ICE when interpreting a cast between non-monomorphic types

Fixes https://github.com/rust-lang/rust/issues/101596
2023-03-06 16:41:59 +01:00
Matthias Krüger
4bd6f7fe16
Rollup merge of #108786 - saethlin:free-regions-check, r=oli-obk
Check for free regions in MIR validation

This turns https://github.com/rust-lang/rust/issues/108720 into a MIR validation failure that will reproduce without debug-assertions enabled.

```
error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:296 ~ futures_util[3805]::future::future::remote_handle::{impl#3}::poll), const_param_did: None }) (after pass ScalarReplacementOfAggregates) at bb0[0]:
                                Free regions in optimized runtime-post-cleanup MIR
  --> /home/ben/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/future/future/remote_handle.rs:96:13
   |
96 |         let this = self.project();
   |             ^^^^
```
2023-03-06 16:41:58 +01:00
Matthias Krüger
1866ea136c
Rollup merge of #108780 - Zeegomo:close-70919, r=WaffleLapkin
Add regression tests for issue 70919

Desugaring DropAndReplace at MIR build (#107844) fixed #70919.
Add regressions tests, borrowed from #102078, to ensure we check for this in the future.

cc ``@Aaron1011``
2023-03-06 16:41:57 +01:00
Matthias Krüger
6240b54966
Rollup merge of #108750 - compiler-errors:aaaaaaaa, r=lcnr
Fix `ObligationCtxt::sub`

typo it seems
2023-03-06 16:41:57 +01:00
Matthias Krüger
9c99a4ca2b
Rollup merge of #107801 - davidtwco:stability-implies-const, r=Nilstrieb
const_eval: `implies_by` in `rustc_const_unstable`

Fixes #107605.

Extend support for `implies_by` (from `#[stable]` and `#[unstable]`) to `#[rustc_const_stable]` and `#[rustc_const_unstable]`.

cc ``@steffahn``
2023-03-06 16:41:56 +01:00
Albert Larsan
33d7fad7e5
Add regression test for 98444 2023-03-06 13:41:07 +00:00
Mu42
717f93cec5 Bless the suspicious-negative-impls-lint.rs 2023-03-06 21:25:43 +08:00
Mu42
23ba4ceb9e Bless the remaining ui tests 2023-03-06 21:05:35 +08:00
Mu42
5c0f55d508 Moves the negative impls into a separate test file 2023-03-06 21:05:23 +08:00
bors
f63ccaf25f Auto merge of #108402 - clubby789:diag-bool-not-unit, r=davidtwco
Allow using `bool` instead of `Option<()>` in diagnostics

~~Disallow the unit type for `#[help]`, `#[note]` etc, instead using `bool` to express optional annotations without a span which I believe is more intuitive.~~

~~Test output ordering has changed in a few places, where a field was of type `()` and the annotation has been moved to the struct itself. If any of these changes are an issue, this can be restricted to allowing specifically `()`, and not `Option<()>`~~

~~Actual changes here: https://github.com/rust-lang/rust/pull/108402/files#diff-815b1d8debfc564112bd51093791d7c3f2ee288a37a8f5c0e89c11d1f609b4c0~~

Allows using `bool` in derive diagnostics to indicate an optional subdiagnostic without a span, where previously `Option<()>` had to be used

`@rustbot` label +A-diagnostics
2023-03-06 13:00:32 +00:00
Mu42
2fe288fd29 emit the suspicious_auto_trait_impls for negative impls as well 2023-03-06 20:04:33 +08:00
Guillaume Gomez
511d2628c0 Update documentation for HTML templates style 2023-03-06 11:38:15 +01:00
Guillaume Gomez
a776c17263 Remove unneeded minus sign in jinja tags 2023-03-06 11:38:15 +01:00
Guillaume Gomez
76714c3731 Update askama version to 0.12 2023-03-06 11:17:11 +01:00
Camille GILLOT
8c0cbd8767 Do not ICE when failing to normalize in ConstProp. 2023-03-06 09:28:49 +00:00
bors
ac4379fea9 Auto merge of #108787 - cjgillot:sroa-lifetime, r=compiler-errors
Erase regions even when failing to normalize type in MIR opts

The first commit just moves the tests around.

Fixes https://github.com/rust-lang/rust/issues/108720

cc `@saethlin`
2023-03-06 08:31:28 +00:00
bors
8c0f83d773 Auto merge of #108789 - matthiaskrgr:rollup-nyurto8, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #108244 (Add test for semicolon recovery ICE)
 - #108746 (Don't project to RPITIT that has no default value)
 - #108764 (Tweaks to -Zdrop-tracking-mir)
 - #108770 (Improve documentation and argument naming of some TyCtxt methods)
 - #108773 (x fmt: Only check modified files locally)
 - #108775 (Use the correct bound vars in return type suggestion.)
 - #108776 (Make `x test tidy` less noisy)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-06 00:43:06 +00:00
clubby789
2632a1c879 Append to PYTHONPATH in compiletest 2023-03-06 00:12:35 +00:00
Scott McMurray
3554036280 Use nuw when calculating slice lengths from Ranges
An `assume` would definitely not be worth it, but since the flag is almost free we might as well tell LLVM this, especially on `_unchecked` calls where there's no obvious way for it to deduce it.

(Today neither safe nor unsafe indexing gets it: <https://rust.godbolt.org/z/G1jYT548s>)
2023-03-05 15:15:22 -08:00
bors
816f958ac3 Auto merge of #108157 - scottmcm:tuple-gt-via-partialcmp, r=dtolnay
Use `partial_cmp` to implement tuple `lt`/`le`/`ge`/`gt`

In today's implementation, `(A, B)::gt` contains calls to *both* `A::eq` *and* `A::gt`.

That's fine for primitives, but for things like `String`s it's kinda weird -- `(String, usize)::gt` has a call to both `bcmp` and `memcmp` (<https://rust.godbolt.org/z/7jbbPMesf>) because when `bcmp` says the `String`s aren't equal, it turns around and calls `memcmp` to find out which one's bigger.

This PR changes the implementation to instead implement `(A, …, C, Z)::gt` using `A::partial_cmp`, `…::partial_cmp`, `C::partial_cmp`, and `Z::gt`.  (And analogously for `lt`, `le`, and `ge`.)  That way expensive comparisons don't need to be repeated.

Technically this is an observable change on stable, so I've marked it `needs-fcp` + `T-libs-api` and will
r? rust-lang/libs-api

I'm hoping that this will be non-controversial, however, since it's very similar to the observable changes that were made to the derives (#81384 #98655) -- like those, this only changes behaviour if a type overrode behaviour in a way inconsistent with the rules for the various traits involved.

(The first commit here is #108156, adding the codegen test, which I used to make sure this doesn't regress behaviour for primitives.)

Zulip conversation about this change: <https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/.60.3E.60.20on.20Tuples/near/328392927>.
2023-03-05 22:02:26 +00:00
Camille GILLOT
858eab6391 Do not ICE when casting polymorphic values. 2023-03-05 20:55:32 +00:00
Camille GILLOT
5d7234abb6 Add test. 2023-03-05 20:55:29 +00:00
Matthias Krüger
c08c69b4b1
Rollup merge of #108776 - jyn514:quiet-tidy, r=ozkanonur
Make `x test tidy` less noisy

Before:
```
Building tool tidy (stage0)
    Finished release [optimized + debuginfo] target(s) in 0.29s
fmt check
skip untracked path chrome_profiler.json during rustfmt invocations
skip untracked path query_impl-default,args.mm_profdata during rustfmt invocations
skip untracked path query_impl-llvm.txt during rustfmt invocations
skip untracked path query_impl-mono_items.txt during rustfmt invocations
skip untracked path query_impl-summarize.txt during rustfmt invocations
skip untracked path rustc.svg during rustfmt invocations
skip untracked path rustc_middle.mono_items.json during rustfmt invocations
skip untracked path rustc_middle.mono_items.md during rustfmt invocations
skip untracked path rustc_query_impl.mono_items-thread_local_attr.json during rustfmt invocations
skip untracked path rustc_query_impl.mono_items-thread_local_macro.json during rustfmt invocations
skip untracked path rustc_query_impl.mono_items.md during rustfmt invocations
tidy check
Found 505 error codes
Highest error code: `E0793`
* 397 features
Ensuring the YAML anchors in the GitHub Actions config were expanded
Building tool expand-yaml-anchors (stage0)
    Finished release [optimized + debuginfo] target(s) in 0.14s
Build completed successfully in 0:00:54
```

After:
```
Building tool tidy (stage0)
    Finished release [optimized + debuginfo] target(s) in 2.24s
fmt check
tidy check
Ensuring the YAML anchors in the GitHub Actions config were expanded
Building tool expand-yaml-anchors (stage0)
    Finished release [optimized + debuginfo] target(s) in 0.14s
Build completed successfully in 0:00:04
```
2023-03-05 20:57:23 +01:00
Matthias Krüger
5c49f0885e
Rollup merge of #108775 - cjgillot:issue-107860, r=compiler-errors
Use the correct bound vars in return type suggestion.

Fixes https://github.com/rust-lang/rust/issues/107860
2023-03-05 20:57:23 +01:00
Matthias Krüger
7125df06c3
Rollup merge of #108773 - jyn514:faster-tidy-fmt, r=albertlarsan68
x fmt: Only check modified files locally

Previously, `x fmt` would only format modified files, while `x fmt .` and `x fmt --check` would still look at all files. After this change, `x fmt --check` only looks at modified files locally.

I feel pretty confident in this change - other than https://github.com/rust-lang/rust/issues/106261, no one has reported bugs in `get_modified_rs_files` since it was added in https://github.com/rust-lang/rust/pull/105702.

Combined with the changes in https://github.com/rust-lang/rust/pull/108772, this brings the time for me to run `x t tidy` with a hot FS cache down from 5 to 2 seconds (and moves the majority of the time spent back to `tidy check`, which means it can be sped up more in the future).
2023-03-05 20:57:22 +01:00
Matthias Krüger
970f263156
Rollup merge of #108770 - GuillaumeGomez:improve-doc-and-naming, r=cjgillot
Improve documentation and argument naming of some TyCtxt methods

I got bit by this recently so better prevent others to end up the same as me.
2023-03-05 20:57:22 +01:00
Matthias Krüger
1c2f641e15
Rollup merge of #108764 - cjgillot:dpm-adapt, r=compiler-errors
Tweaks to -Zdrop-tracking-mir

Split from https://github.com/rust-lang/rust/pull/107421

3 commits: 1 diagnostic improvement and 2 ICEs.
2023-03-05 20:57:21 +01:00
Matthias Krüger
b8762321a2
Rollup merge of #108746 - compiler-errors:rpitit-dont-project-default-w-no-valu, r=cjgillot
Don't project to RPITIT that has no default value

Replicates this behavior, but for RPITIT projection logic (which currently is separate)

b1719530f4/compiler/rustc_trait_selection/src/traits/project.rs (L2105-L2115)

Fixes #108738
2023-03-05 20:57:20 +01:00
Matthias Krüger
ced9cd19c8
Rollup merge of #108244 - lukas-code:semicolon-recovery-span, r=cjgillot
Add test for semicolon recovery ICE

closes https://github.com/rust-lang/rust/issues/108242
2023-03-05 20:57:20 +01:00
bors
7820b62d20 Auto merge of #105117 - pitaj:debug_asserts, r=the8472
Add more debug assertions to unsafe functions

related to #51713
2023-03-05 19:35:44 +00:00
Camille GILLOT
708536bb47 Remove -Zverbose. 2023-03-05 19:18:58 +00:00
clubby789
3eeb3fd05a Remove allow(potential_query_instability) from borrowck 2023-03-05 18:59:19 +00:00
Ben Kimock
cb4ebc1453 Check for free regions in MIR validation 2023-03-05 13:46:20 -05:00
Camille GILLOT
fc1a861558 Erase lifetimes in SROA. 2023-03-05 18:35:30 +00:00
Camille GILLOT
248a5301af Move SROA tests. 2023-03-05 18:15:57 +00:00
Antoni Boucher
2c0c25dcc1 Fix for diagnostics 2023-03-05 12:31:16 -05:00
Antoni Boucher
fce7053567 Update gccjit 2023-03-05 12:16:33 -05:00