Commit Graph

28356 Commits

Author SHA1 Message Date
bors
fc61fabc24 Auto merge of #116116 - Nilstrieb:gate-all-__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, r=compiler-errors
Rename the legacy feature gating macro

It had a really confusing name by shadowing the previous name, which has
caused issues in the past where people added their new syntax in the
legacy location.

This makes it clear.

Also adds a comment about the return type notation gating, which confused me why it was here at first before `@compiler-errors` told me why.
2023-09-24 16:59:59 +00:00
bors
26eeea6a1b Auto merge of #116069 - compiler-errors:debug-tuple, r=Nilstrieb
Fix debug printing of tuple

Self-explanatory. Didn't create a UI test, but I guess I could -- not sure where debug output shows up in rustc_attrs to make a sufficient test, tho.
2023-09-24 15:16:18 +00:00
Ralf Jung
b589976606 use a must_hold variant for checking PartialEq 2023-09-24 16:59:47 +02:00
Ralf Jung
c3ed0c454e make sure we always emit the no-PartialEq lint, even if there were other lints 2023-09-24 16:36:26 +02:00
Ralf Jung
c5fccb98ea work towards rejecting consts in patterns that do not implement PartialEq 2023-09-24 16:36:26 +02:00
bors
70a7fe1743 Auto merge of #116076 - chriswailes:android-riscv-extension-update, r=cjgillot
Add Zba, Zbb, and Zbs as target features for riscv64-linux-android

This pull request adds the Zba, Zbb, and Zbs target features to the `riscv64-linux-android` target specification.  These features have been enabled and tested internally in Android infrastructure.
2023-09-24 11:40:45 +00:00
bors
c7224e3c95 Auto merge of #105861 - Ayush1325:uefi-std-minimial, r=workingjubilee
Add Minimal Std implementation for UEFI

# Implemented modules:
1. alloc
2. os_str
3. env
4. math

# Related Links
Tracking Issue: https://github.com/rust-lang/rust/issues/100499
API Change Proposal: https://github.com/rust-lang/libs-team/issues/87

# Additional Information
This was originally part of https://github.com/rust-lang/rust/pull/100316. Since that PR was becoming too unwieldy and cluttered, and with suggestion from `@dvdhrm,` I have extracted a minimal std implementation to this PR.

The example in `src/doc/rustc/src/platform-support/unknown-uefi.md` has been tested for `x86_64-unknown-uefi` and `i686-unknown-uefi` in OVMF. It would be great if someone more familiar with AARCH64 can help with testing for that target.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-24 09:47:30 +00:00
Camille GILLOT
26cb34cd18 Remove span from BrAnon. 2023-09-24 09:46:55 +00:00
Camille GILLOT
b2ff77cb78 Do not clone valtree and slice constants. 2023-09-24 09:09:05 +00:00
Camille GILLOT
5f9d64d72f Embed simplification into VnState. 2023-09-24 09:09:04 +00:00
Camille GILLOT
3311536740 Workaround issue 112651. 2023-09-24 09:09:04 +00:00
Camille GILLOT
db50bd96e5 Add a paragraph about the assume bitwise equal. 2023-09-24 09:09:04 +00:00
Camille GILLOT
1ea9399803 Do not check copiability. 2023-09-24 09:09:04 +00:00
Camille GILLOT
6fa55d0aff Add documentation. 2023-09-24 09:09:04 +00:00
Camille GILLOT
8b848af325 Add global value numbering pass. 2023-09-24 09:09:04 +00:00
Camille GILLOT
ded1a8b026 Remove dead code. 2023-09-24 09:05:31 +00:00
Nilstrieb
845a027ddb Add comment about RTN feature gating 2023-09-24 10:47:57 +02:00
Nilstrieb
073feb5e69 Rename the legacy feature gating macro
It had a really confusing name by shadowing the previous name, which has
caused issues in the past where people added their new syntax in the
legacy location.

This makes it clear.
2023-09-24 10:44:31 +02:00
bors
551c7183f8 Auto merge of #115794 - cjgillot:aggregate-no-box, r=davidtwco
Do not create a DerefLen place for `Box<[T]>`.

Fixes https://github.com/rust-lang/rust/issues/115789
2023-09-24 06:13:17 +00:00
bors
42ca6e4e57 Auto merge of #104385 - BlackHoleFox:apple-minimum-bumps, r=petrochenkov
Raise minimum supported Apple OS versions

This implements the proposal to raise the minimum supported Apple OS versions as laid out in the now-completed MCP (https://github.com/rust-lang/compiler-team/issues/556).

As of this PR, rustc and the stdlib now support these versions as the baseline:
- macOS: 10.12 Sierra
- iOS: 10
- tvOS: 10
- watchOS: 5 (Unchanged)

In addition to everything this breaks indirectly, these changes also erase the `armv7-apple-ios` target (currently tier 3) because the oldest supported iOS device now uses ARMv7s. Not sure what the policy around tier3 target removal is but shimming it is not an option due to the linker refusing.

[Per comment](https://github.com/rust-lang/compiler-team/issues/556#issuecomment-1297175073), this requires a FCP to merge. cc `@wesleywiser.`
2023-09-24 02:35:05 +00:00
BlackHoleFox
2044a2d7fa Raise minimum supported tvOS version to 10.0 2023-09-23 19:14:25 -05:00
BlackHoleFox
3b52befdce Raise minimum supported iOS version to 10.0
Drop the armv7-apple-ios target too because its no longer supported
with the hardware iOS 10 requires.
2023-09-23 19:14:25 -05:00
BlackHoleFox
58bbca958d Raise minimum supported macOS to 10.12 2023-09-23 19:14:25 -05:00
Matthias Krüger
2fd7acf4e3
Rollup merge of #116104 - cjgillot:calculate_debuginfo_offset, r=b-naber
Reuse calculate_debuginfo_offset for fragments.

This removes a little code duplication.
2023-09-24 01:14:07 +02:00
Matthias Krüger
61b38b216a
Rollup merge of #116086 - estebank:issue-115992, r=compiler-errors
More accurate suggestion for `self.` and `Self::`

Detect that we can't suggest `self.` in an associated function without `&self` receiver.

Partially address #115992.

r? ``@compiler-errors``
2023-09-24 01:14:06 +02:00
Matthias Krüger
8c9e516e6e
Rollup merge of #116082 - compiler-errors:default-assoc-ty-msg, r=estebank
Tweak expected message to explain what it's actually signifying

r? ``@estebank`` since you added this
2023-09-24 01:14:06 +02:00
Matthias Krüger
d92a1bd7cc
Rollup merge of #116073 - compiler-errors:poly-sigs, r=b-naber
Allow higher-ranked fn sigs in `ValuePairs`

For better bookkeeping -- only affects diagnostic path. Allow reporting signature mismatches like "signature"s and not "fn pointer"s.

Improves https://github.com/rust-lang/rust/pull/115897#discussion_r1331940846
2023-09-24 01:14:05 +02:00
John Kåre Alsaker
ba8d53dc8f Don't use a thread to load the dep graph 2023-09-24 00:30:43 +02:00
Ralf Jung
ab8307331a also make platform_intrinsics internal 2023-09-23 21:30:45 +02:00
onur-ozkan
bdd66b3f98 allow LTO on proc-macro crates with -Zdylib-lto
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2023-09-23 17:08:43 +03:00
Camille GILLOT
ac0683b783 Use correct offset when codegening mir::Const::Indirect. 2023-09-23 14:07:10 +00:00
Camille GILLOT
6992405674 Tolerate non-ptr indirect scalars in codegen. 2023-09-23 14:07:10 +00:00
Camille GILLOT
8ec5639bc2 Reuse calculate_debuginfo_offset for fragments. 2023-09-23 13:52:35 +00:00
Camille GILLOT
44ac8dcc71 Remove GeneratorWitness and rename GeneratorWitnessMIR. 2023-09-23 13:47:30 +00:00
Camille GILLOT
855a75b6d6 Remove useless wrapper. 2023-09-23 13:47:30 +00:00
Camille GILLOT
baa64b0e77 Remove dead error code. 2023-09-23 13:47:30 +00:00
Camille GILLOT
286502c9ed Enable drop_tracking_mir by default. 2023-09-23 13:34:09 +00:00
Camille GILLOT
ff03204365 Fold lifetimes before substitution. 2023-09-23 13:15:15 +00:00
Camille GILLOT
9450b75986 Do not construct def_path_str for MustNotSuspend. 2023-09-23 13:14:57 +00:00
bors
3050938abd Auto merge of #116081 - compiler-errors:closure-captures-sized, r=cjgillot
Check that closure/generator's interior/capture types are sized

check that closure upvars and generator interiors are sized. this check is only necessary when `unsized_fn_params` or `unsized_locals` is enabled, so only check if those are active.

Fixes #93622
Fixes #61335
Fixes #68543
2023-09-23 10:01:49 +00:00
bors
0237aa3d77 Auto merge of #116045 - notriddle:notriddle/issue-83556, r=cjgillot
diagnostics: avoid mismatch between variance index and hir generic

This happens because variances are constructed from ty generics, and ty generics are always constructed with lifetimes first.

b3aa8e7168/compiler/rustc_hir_analysis/src/collect/generics_of.rs (L248-L269)

Fixes #83556
2023-09-23 08:11:59 +00:00
Ralf Jung
37acbbb4b5 make link_llvm_intrinsics feature internal 2023-09-23 08:39:36 +02:00
bors
136d74fab8 Auto merge of #116071 - estebank:issue-115905, r=compiler-errors
Point at cause of expectation of `break` value when possible

When encountering a type error within the value of a `break` statement, climb the HIR tree to identify if the expectation comes from an assignment or a return type (if the loop is the tail expression of a `fn`).

Fix #115905.
2023-09-23 06:25:41 +00:00
Michael Howell
58ef3a0ec9 diagnostics: simpler 83556 handling by bailing out 2023-09-22 22:41:01 -07:00
bors
bf982631df Auto merge of #116052 - oli-obk:ceci_nest_pas_une_query, r=WaffleLapkin
Add a way to decouple the implementation and the declaration of a TyCtxt method.

properly addresses https://github.com/rust-lang/rust/pull/115819

accepted MCP: https://github.com/rust-lang/compiler-team/issues/395
2023-09-23 04:41:09 +00:00
Michael Goulet
79d685325c Check types live across yields in generators too 2023-09-23 04:19:14 +00:00
Michael Goulet
c21867f9f6 Check that closure's by-value captures are sized 2023-09-23 04:19:14 +00:00
Esteban Küber
ac5e18756a Tweak wording and logic 2023-09-23 01:54:05 +00:00
Esteban Küber
0e98682576 When encountering method on Self that we can't suggest, mention it 2023-09-23 01:47:06 +00:00
Esteban Küber
c4a4926083 More accurate suggestion for self. and Self::
Fix #115992.
2023-09-23 01:34:50 +00:00
Michael Goulet
82e7cec16d Tweak expected message to explain what it's actually signifying 2023-09-23 00:57:17 +00:00
Esteban Küber
d3dea30cb4 Point at cause of expectation of break value when possible
Fix #115905.
2023-09-22 22:20:53 +00:00
bors
e4133ba9b1 Auto merge of #116077 - matthiaskrgr:rollup-2y1buzg, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #115770 (Match on elem first while building move paths)
 - #115999 (Capture scrutinee of if let guards correctly)
 - #116056 (Make unsized casts illegal)
 - #116061 (Remove TaKO8Ki from review rotation)
 - #116062 (Change `start` to `#[start]` in some diagnosis)
 - #116067 (Open the FileEncoder file for reading and writing)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-22 21:46:07 +00:00
Matthias Krüger
efee13ab33
Rollup merge of #116067 - saethlin:meta-stats-ice, r=WaffleLapkin
Open the FileEncoder file for reading and writing

Maybe I just don't know `File` well enough, but the previous comment didn't make it clear enough to me that we can't use `File::create`. This one does.

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

r? `@WaffleLapkin`
2023-09-22 23:12:38 +02:00
Matthias Krüger
952d6608fc
Rollup merge of #116062 - eduardosm:start-fn-diag, r=WaffleLapkin
Change `start` to `#[start]` in some diagnosis

They refer to a function with the `start` attribute, but not necessarily named `start`.
2023-09-22 23:12:37 +02:00
Matthias Krüger
a38f2309fc
Rollup merge of #116056 - ouz-a:wide_ice, r=compiler-errors
Make unsized casts illegal

Weirdly enough this https://github.com/rust-lang/rust/issues/115998 issue seems to exist since Rust 1.0 (couldn't check before that) but it's only recently been noticed. This change makes those casts illegal.

Fixes https://github.com/rust-lang/rust/issues/115998
2023-09-22 23:12:36 +02:00
Matthias Krüger
e6f4b35d9f
Rollup merge of #115999 - matthewjasper:closure-capture-let-guards, r=b-naber
Capture scrutinee of if let guards correctly

Previously we were always capturing by value.

cc #51114
2023-09-22 23:12:35 +02:00
Matthias Krüger
d4d0c840b3
Rollup merge of #115770 - ouz-a:match_elem_builder, r=lcnr
Match on elem first while building move paths

While working on https://github.com/rust-lang/rust/pull/115025 `@lcnr` and I observed "move_paths_for" function matched on the `Ty` instead of `Projection` which seems flawed as it's the `Projection`s that cause the problem not the type.

r? `@lcnr`
2023-09-22 23:12:34 +02:00
Chris Wailes
09c5f983e3 Add Zba, Zbb, and Zbs as target features for riscv64-linux-android 2023-09-22 13:34:05 -07:00
Oli Scherer
4ed4913e67 Merge ExternProviders into the general Providers struct 2023-09-22 20:15:34 +00:00
Ben Kimock
09960e0319 Open the FileEncoder file for reading and writing 2023-09-22 16:13:25 -04:00
bors
aadb5718dd Auto merge of #116001 - fmease:validate-crate-name-extern-cli-opt, r=est31
[breaking change] Validate crate name in `--extern` [MCP 650]

Reject non-ASCII-identifier crate names passed to the CLI option `--extern` (`rustc`, `rustdoc`).
Implements [MCP 650](https://github.com/rust-lang/compiler-team/issues/650) (except that we only allow ASCII identifiers not arbitrary Rust identifiers).
Fixes #113035.

[As mentioned on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Disallow.20non-identifier-valid.20--extern.20cr.E2.80.A6.20compiler-team.23650/near/376826988), doing a crater run probably doesn't make sense since it wouldn't yield anything. Most users don't interact with `rustc` directly but only ever through Cargo which always passes a valid crate name to `--extern` when it invokes `rustc` and `rustdoc`. In any case, the user wouldn't be able to use such a crate name in the source code anyway.

Note that I'm not using [`rustc_session::output::validate_crate_name`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/output/fn.validate_crate_name.html) (used for `--crate-name` and `#![crate_name]`) since the latter doesn't reject non-ASCII crate names and ones that start with a digit.

As an aside, I've also thought about getting rid of `validate_crate_name` entirely in a separate PR (with another MCP) in favor of `is_ascii_ident` to reject more weird `--crate-name`s, `#![crate_name]`s and file names but I think that would lead to a lot of actual breakage, namely because of file names starting with a digit. In `tests/ui` 9 tests would be impacted for example.

CC `@estebank`
r? `@est31`
2023-09-22 19:57:07 +00:00
Michael Goulet
8cfd249198 Allow higher-ranked fn sigs in ValuePairs 2023-09-22 19:47:41 +00:00
Michael Goulet
8568121996 Need to use hybrid param-env to make sure implication is not circular 2023-09-22 19:04:37 +00:00
Michael Goulet
b5a904a9d4 Use placeholders to prevent using inferred RPITIT types to imply their own WF-ness 2023-09-22 18:55:44 +00:00
Michael Goulet
27fe1c380b Fix debug printing of tuple 2023-09-22 17:59:52 +00:00
Oli Scherer
2ba911c832 Have a single struct for queries and hook 2023-09-22 16:26:20 +00:00
ouz-a
861448b426 make unsized cast illegal 2023-09-22 18:57:27 +03:00
bors
959b2c703d Auto merge of #115696 - RalfJung:closure-ty-print, r=oli-obk
adjust how closure/generator types are printed

I saw `&[closure@$DIR/issue-20862.rs:2:5]` and I thought it is a slice type, because that's usually what `&[_]` is... it took me a while to realize that this is just a confusing printer and actually there's no slice. Let's use something that cannot be mistaken for a regular type.
2023-09-22 15:19:38 +00:00
Eduardo Sánchez Muñoz
17dfabff9c Change start to #[start] in some diagnosis
They refer to a function with the `start` attribute, but not necessarily named `start`.
2023-09-22 15:58:43 +02:00
ouz-a
63df126f59 match array for constantindex and subslice 2023-09-22 16:28:45 +03:00
Matthew Jasper
d4ffb3b08a Capture scrutinee of if let guards correctly
Previously we were always capturing by value.
2023-09-22 13:04:44 +00:00
bors
01903944d8 Auto merge of #115690 - ShE3py:Z-treat-err-as-bug, r=petrochenkov
Allow `-Z treat-err-as-bug=0`

Makes `-Z treat-err-as-bug=0` behave as if the option wasn't present instead of asking the value to be &GreaterSlantEqual; 1. This enables a quick on/off of the option, as you only need to change one character instead of removing the whole `-Z`.

Also update some text, e.g.
```bash
$ rustc -Z help | grep treat-err-as-bug
    -Z                      treat-err-as-bug=val -- treat error number `val` that occurs as bug
```
where the value could be interpreted as an error code instead of an ordinal.
2023-09-22 13:01:30 +00:00
Ayush Singh
c7e5f3ca08
Rebase to master
- Update Example
- Add thread_parking to sys::uefi
- Fix unsafe in unsafe errors
- Improve docs
- Improve os/exit
- Some asserts
- Switch back to atomics

Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2023-09-22 17:23:33 +05:30
Ayush Singh
48c6ae0611
Add Minimal Std implementation for UEFI
Implemented modules:
1. alloc
2. os_str
3. env
4. math

Tracking Issue: https://github.com/rust-lang/rust/issues/100499
API Change Proposal: https://github.com/rust-lang/libs-team/issues/87

This was originally part of https://github.com/rust-lang/rust/pull/100316. Since
that PR was becoming too unwieldy and cluttered, and with suggestion
from @dvdhrm, I have extracted a minimal std implementation to this PR.

Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22 17:23:30 +05:30
Lieselotte
3dd0419ea9
Allow -Z treat-err-as-bug=0
Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2023-09-22 13:33:55 +02:00
Matthias Krüger
1a18ec0dcf
Rollup merge of #116049 - RalfJung:future-incompat, r=Nilstrieb
give FutureIncompatibilityReason variants more explicit names

Also make the `reason` field mandatory when declaring a lint, to make sure this is a deliberate decision.
2023-09-22 12:15:28 +02:00
Matthias Krüger
66f272d6ca
Rollup merge of #116041 - compiler-errors:rigid-note, r=RalfJung
Add note to `is_known_rigid`

Adds a note requested by `@RalfJung` in https://github.com/rust-lang/rust/pull/114941#discussion_r1329963704

Let me know if there are any other fns that need documentation, I could throw them into this PR too :)
2023-09-22 12:15:28 +02:00
Matthias Krüger
fc4cfe01f6
Rollup merge of #116039 - estebank:nested-tait, r=compiler-errors
Account for nested `impl Trait` in TAIT

Fix #116031.

r? `@compiler-errors`
2023-09-22 12:15:27 +02:00
Oli Scherer
9defc971f1 Add tracing instrumentation, just like queries automatically add it 2023-09-22 09:25:38 +00:00
Oli Scherer
2157f31731 Add a way to decouple the implementation and the declaration of a TyCtxt method. 2023-09-22 09:23:15 +00:00
ouz-a
442c87a0b0 better bug message 2023-09-22 11:31:45 +03:00
ouz-a
d6efedcaf5 remove inner match 2023-09-22 11:21:55 +03:00
bors
8759de0a49 Auto merge of #114776 - fee1-dead-contrib:enable-effects-in-libcore, r=oli-obk
Enable effects for libcore

~~r? `@oli-obk~~`

forgot you are on vacation, oops
2023-09-22 07:00:52 +00:00
Ralf Jung
5586c2a68f make the reason: field mandatory for @future_incompatible lints 2023-09-22 08:59:32 +02:00
Ralf Jung
e888d470e9 give FutureIncompatibilityReason variants more explicit names 2023-09-22 08:51:18 +02:00
bors
aace2dfa37 Auto merge of #115910 - eduardosm:lang-fns-target-features, r=cjgillot
Prevent using `#[target_feature]` on lang item functions

Fixes https://github.com/rust-lang/rust/issues/109411 and also prevents from using `#[target_feature]` on other `fn` lang items to mitigate the concerns from https://github.com/rust-lang/rust/issues/109411#issuecomment-1477030273.
2023-09-22 05:07:45 +00:00
Michael Goulet
7fc081b4d9 Add note to is_known_rigid 2023-09-22 01:02:38 +00:00
bors
b757318718 Auto merge of #115920 - Zoxc:depkind-u16, r=cjgillot
Move `DepKind` to `rustc_query_system` and define it as `u16`

This moves the `DepKind` type to `rustc_query_system` where it's defined with an inner `u16` field. This decouples it from `rustc_middle` and is a step towards letting other crates define dep kinds. It also allows some type parameters to be removed. The `DepKind` trait is replaced with a `Deps` trait. That's used when some operations or information about dep kinds which is unavailable in `rustc_query_system` are still needed.

r? `@cjgillot`
2023-09-22 00:46:13 +00:00
Michael Howell
3799af3337 diagnostics: avoid mismatch between variance index and hir generic
This happens because variances are constructed from ty generics,
and ty generics are always constructed with lifetimes first.

See compiler/rustc_hir_analysis/src/collect/generics_of.rs:248-269

Fixes #83556
2023-09-21 17:21:07 -07:00
bors
99b63d068b Auto merge of #115897 - eduardosm:check-fn-sig, r=compiler-errors
rustc_hir_analysis: add a helper to check function the signature mismatches

This function is now used to check `#[panic_handler]`, `start` lang item, `main`, `#[start]` and intrinsic functions.

The diagnosis produced are now closer to the ones produced by trait/impl method signature mismatch.

This is the first time I do anything with rustc_hir_analysis/rustc_hir_typeck, so comments and suggestions about things I did wrong or that could be improved will be appreciated.
2023-09-21 22:59:13 +00:00
bors
b3aa8e7168 Auto merge of #115864 - compiler-errors:rpitit-sugg, r=estebank
Suggest desugaring to return-position `impl Future` when an `async fn` in trait fails an auto trait bound

First commit allows us to store the span of the `async` keyword in HIR.

Second commit implements a suggestion to desugar an `async fn` to a return-position `impl Future` in trait to slightly improve the `Send` situation being discussed in #115822.

This suggestion is only made when `#![feature(return_type_notation)]` is not enabled -- if it is, we should instead suggest an appropriate where-clause bound.
2023-09-21 21:12:32 +00:00
Ralf Jung
c4ec12f4b7 adjust how closure/generator types and rvalues are printed 2023-09-21 22:20:58 +02:00
bors
f73d376fb6 Auto merge of #115230 - Vtewari2311:mod-hurd-latest, r=b-naber
added support for GNU/Hurd

adding support for i686-unknown-hurd-gnu
2023-09-21 19:24:01 +00:00
Michael Goulet
9072415252 Suggest desugaring to RPITIT when AFIT is required to be an auto trait 2023-09-21 19:18:14 +00:00
Michael Goulet
087a571e70 Record asyncness span in HIR 2023-09-21 19:18:14 +00:00
Esteban Küber
f2ede49c2f Account for nested impl Trait in TAIT
Fix #116031.
2023-09-21 17:47:09 +00:00
bors
24b45c3bdc Auto merge of #114399 - Zalathar:no-renumber, r=jackh726
coverage: Don't bother renumbering expressions on the Rust side

The LLVM API that we use to encode coverage mappings already has its own code for removing unused coverage expressions and renumbering the rest.

This lets us get rid of our own complex renumbering code, making it easier to change our coverage code in other ways.

---

Now that we have tests for coverage mappings (#114843), I've been able to verify that this PR doesn't make the coverage mappings worse, thanks to an explicit simplification step.
2023-09-21 17:29:30 +00:00
Samuel Thibault
dcea7709f2 added support for GNU/Hurd 2023-09-21 17:31:25 +02:00
John Kåre Alsaker
1806efe7f2 Move DepKind to rustc_query_system and define it as u16 2023-09-21 17:06:14 +02:00
bors
0fd7ce99b0 Auto merge of #116010 - RalfJung:more-typed-immediates, r=oli-obk
interpret: more consistently use ImmTy in operators and casts

The diff in src/tools/miri/src/shims/x86/sse2.rs should hopefully suffice to explain why this is nicer. :)
2023-09-21 14:02:55 +00:00
Guillaume Gomez
208f6ed95c
Rollup merge of #115972 - RalfJung:const-consistency, r=oli-obk
rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const

Also, be more consistent with the `to/eval_bits` methods... we had some that take a type and some that take a size, and then sometimes the one that takes a type is called `bits_for_ty`.

Turns out that `ty::Const`/`mir::ConstKind` carry their type with them, so we don't need to even pass the type to those `eval_bits` functions at all.

However this is not properly consistent yet: in `ty` we have most of the methods on `ty::Const`, but in `mir` we have them on `mir::ConstKind`. And indeed those two types are the ones that correspond to each other. So `mir::ConstantKind` should actually be renamed to `mir::Const`. But what to do with `mir::Constant`? It carries around a span, that's really more like a constant operand that appears as a MIR operand... it's more suited for `syntax.rs` than `consts.rs`, but the bigger question is, which name should it get if we want to align the `mir` and `ty` types? `ConstOperand`? `ConstOp`? `Literal`? It's not a literal but it has a field called `literal` so it would at least be consistently wrong-ish...

``@oli-obk`` any ideas?
2023-09-21 13:25:39 +02:00
Guillaume Gomez
d05c5fecde
Rollup merge of #115936 - oli-obk:inline_const_promotion, r=RalfJung
Prevent promotion of const fn calls in inline consts

We don't wanna make that mistake we did for statics and consts worse by letting more code use it.

r? ``@RalfJung``

cc https://github.com/rust-lang/rust/issues/76001
2023-09-21 13:25:38 +02:00
Guillaume Gomez
9ce64bae94
Rollup merge of #115257 - Urgau:invalid-utf8-walk-up-hir, r=Nilstrieb
Improve invalid UTF-8 lint by finding the expression initializer

This PR introduce a small mechanism to walk up the HIR through bindings, if/else, consts, ... when trying lint on invalid UTF-8.

Fixes https://github.com/rust-lang/rust/issues/115208
2023-09-21 13:25:38 +02:00
Oli Scherer
9c762b58ba Prevent promotion of const fn calls in inline consts 2023-09-21 09:00:22 +00:00
Zalathar
041a232b62 coverage: Don't bother renumbering expressions on the Rust side
The LLVM API that we use to encode coverage mappings already has its own code
for removing unused coverage expressions and renumbering the rest.

This lets us get rid of our own complex renumbering code, making it easier to
change our coverage code in other ways.
2023-09-21 18:32:49 +10:00
Zalathar
527c629cd9 coverage: Explicitly simplify coverage expressions in codegen
After coverage instrumentation and MIR transformations, we can sometimes end up
with coverage expressions that always have a value of zero. Any expression
operand that refers to an always-zero expression can be replaced with a literal
`Operand::Zero`, making the emitted coverage mapping data smaller and simpler.

This simplification step is mostly redundant with the simplifications performed
inline in `expressions_with_regions`, except that it does a slightly more
thorough job in some cases (because it checks for always-zero expressions
*after* other simplifications).

However, adding this simplification step will then let us greatly simplify that
code, without affecting the quality of the emitted coverage maps.
2023-09-21 18:32:49 +10:00
Zalathar
659575aade coverage: Make the zero counter a constant 2023-09-21 18:32:49 +10:00
Urgau
f156d3bc57 Improve invalid UTF-8 lint by finding the expression initializer 2023-09-21 10:16:29 +02:00
lcnr
614760f612 review 2023-09-21 08:57:47 +02:00
lcnr
8167a25e4e w 2023-09-21 08:44:12 +02:00
lcnr
8e139eefaf slight refactor, add comment 2023-09-21 08:40:36 +02:00
lcnr
8024c69c29 HACK: avoid hang in structurally_normalize 2023-09-21 08:17:58 +02:00
lcnr
de53877f8b proof trees: use for intercrate_ambiguity_causes 2023-09-21 08:17:58 +02:00
Ralf Jung
c94410c145 rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const 2023-09-21 08:12:30 +02:00
Ralf Jung
0eff07b748 try to avoid some layout_of calls 2023-09-21 07:26:16 +02:00
bors
4fda889bf8 Auto merge of #115549 - saethlin:include-bytes-resilient, r=jackh726
Fall back to the unoptimized implementation in read_binary_file if File::metadata lies

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

r? `@jackh726` because you approved the previous PR
2023-09-21 02:50:54 +00:00
Ben Kimock
5f33647fb3 Add unit tests based on files that return odd sizes to stat 2023-09-20 21:01:13 -04:00
bors
3223b0b5e8 Auto merge of #115542 - saethlin:fileencoder-is-bufwriter, r=WaffleLapkin
Simplify/Optimize FileEncoder

FileEncoder is basically a BufWriter except that it exposes access to the not-written-to-yet region of the buffer so that some users can write directly to the buffer. This strategy is awesome because it lets us avoid calling memcpy for small copies, but the previous strategy was based on the writer accessing a `&mut [MaybeUninit<u8>; N]` and returning a `&[u8]` which is an API which currently mandates the use of unsafe code, making that interface in general not that appealing.

So this PR cleans up the FileEncoder implementation and builds on that general idea of direct buffer access in order to prevent `memcpy` calls in a few key places when encoding the dep graph and rmeta tables. The interface used here is now 100% safe, but with the caveat that internally we need to avoid trusting the number of bytes that the provided function claims to have written.

The original primary objective of this PR was to clean up the FileEncoder implementation so that the fix for the following issues would be easy to implement. The fix for these issues is to correctly update self.buffered even when writes fail, which I think it's easy to verify manually is now done, because all the FileEncoder methods are small.

Fixes https://github.com/rust-lang/rust/issues/115298
Fixes https://github.com/rust-lang/rust/issues/114671
Fixes https://github.com/rust-lang/rust/issues/114045
Fixes https://github.com/rust-lang/rust/issues/108100
Fixes https://github.com/rust-lang/rust/issues/106787
2023-09-20 21:47:54 +00:00
Ben Kimock
6cee6b0bde PR feedback 2023-09-20 16:49:13 -04:00
Ralf Jung
23fd2860fa stronger consistency check in ImmTy::from_immediate 2023-09-20 22:28:46 +02:00
Ralf Jung
bdbf545f42 interpret: less debug-printing of types 2023-09-20 22:25:42 +02:00
Ralf Jung
da08a3f40c interpret: more consistently use ImmTy in operators and casts 2023-09-20 21:57:54 +02:00
bors
ad36b5a622 Auto merge of #115987 - loongarch-rs:fix-transparent-union-abi, r=bjorn3
rustc_target/loongarch: Fix passing of transparent unions with only one non-ZST member

This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed through an `extern "C"` function.

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

r? `@bjorn3`
2023-09-20 19:55:38 +00:00
bors
9da3e81785 Auto merge of #115870 - RalfJung:const-value-slice, r=oli-obk
adjust ConstValue::Slice to work for arbitrary slice types

valtrees have already been assuming that this works; this PR makes it a reality. Also further restrict `ConstValue::Slice` to what it is actually used for; this even shrinks `ConstValue` from 32 to 24 bytes which is a nice win. :)

The alternative to this approach is to make `ConstValue::Slice` work really only for `&str`/`&[u8]` literals, and never return it in `op_to_const`. That would make `op_to_const` very clean. We could then even remove the `meta` field; the length would always be `data.inner().len()`. We could *almost* just use a `Symbol` instead of a `ConstAllocation`, but we have to support byte strings and there doesn't seem to be an interned representation of them (or rather, `ConstAllocation` *is* their interned representation). In this world, valtrees of slice reference types would then become noticeably more expensive to turn into a `ConstValue` -- but does that matter? Specifically for `&str`/`&[u8]` we could still use the optimized representation if we wanted.

If byte strings were already interned somewhere I'd gravitate towards the alternative, but the way things stand, we need a `ConstAllocation` case anyway to support byte strings, and then we might as well support arbitrary slices. (Or we say that byte strings don't get an optimized representation at all. Such a performance cliff between `str` and byte strings is probably unexpected, though due to the lack of interning for byte strings I think there might already be a performance cliff there.)
2023-09-20 18:06:48 +00:00
León Orell Valerian Liehr
8d81d5a909
Validate crate name in CLI option --extern 2023-09-20 18:50:40 +02:00
Camille GILLOT
e76b7f226a Do not create a DerefLen place for Box<[T]>. 2023-09-20 16:07:03 +00:00
Guillaume Gomez
c5c4e18913
Rollup merge of #115962 - Zalathar:debug, r=oli-obk
coverage: Remove debug code from the instrumentor

The coverage instrumentor has an entire module full of complex code that is only used for debugging.

And as I continue to work on coverage, I keep finding that this debug code is constantly causing more trouble than it's worth. It's deeply entangled with current implementation details, such that making any non-trivial change to the instrumentor usually requires major changes to the debug code. And so far I have personally not found any of this debug code to be *useful*.

In light of that situation, I'd like to try just ripping all of it out. If I spend any more time dealing with coverage debug code, I want it to be because I'm writing new and useful tools, not dutifully maintaining a boat-anchor that quite plausibly isn't being used by anyone at all.

---
r? `@ghost`
`@rustbot` label +A-code-coverage

---

[Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Removing.20debug.20code.20from.20the.20coverage.20instrumentor)
2023-09-20 17:33:17 +02:00
Guillaume Gomez
4e8f637783
Rollup merge of #115566 - zirconium-n:issue-107250-clean-up-unused-to-predicate, r=oli-obk
clean up unneeded `ToPredicate` impls

Part of #107250.
Removed all totally unused impls. And inlined two impls not need to satisify trait bound.

r? `@oli-obk`
2023-09-20 17:33:16 +02:00
bors
78e74d959b Auto merge of #115827 - eduardosm:miri-sse-reduce-code-dup, r=RalfJung
miri: reduce code duplication in some SSE/SSE2 intrinsics

Reduces code duplication in the Miri implementation of some SSE and SSE2 using generics and rustc_const_eval helper functions.

There are also some other minor changes.

r? `@RalfJung`
2023-09-20 12:07:26 +00:00
Obei Sideg
77e205a113 Migrate rustc_hir_analysis to session diagnostic
Part 5: Finishing `coherence/builtin.rs` file
2023-09-20 10:56:44 +03:00
Matthias Krüger
af36ab1a8e
Rollup merge of #115983 - eopb:confusing-if-chain-indent, r=compiler-errors
fix confusing let chain indentation in rustc_resolve

Sorry for opening a PR for such a minor style fix.
This just felt sufficiently misleading to warrant fixing.
2023-09-20 09:24:31 +02:00
Zalathar
e015f5a370 coverage: Remove vestigial counter/expression debug labels 2023-09-20 17:24:10 +10:00
Zalathar
bbd347409f coverage: Remove vestigial format_counter methods 2023-09-20 17:24:10 +10:00
Zalathar
3d66513fe4 coverage: Remove debug code from the instrumentor 2023-09-20 17:24:10 +10:00
Ralf Jung
a2374e65aa the Const::eval_bits methods don't need to be given the Ty 2023-09-20 07:27:21 +02:00
bors
4b91288484 Auto merge of #115486 - compiler-errors:dont-capture-late-pls, r=cjgillot
Correctly deny late-bound lifetimes from parent in anon consts and TAITs

Reuse the `AnonConstBoundary` scope (introduced in #108553, renamed in this PR to `LateBoundary`) to deny late-bound vars of *all* kinds (ty/const/lifetime) in anon consts and TAITs.

Side-note, but I would like to consolidate this with the error reporting for RPITs (E0657):
c4f25777a0/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs (L733-L754) but the semantics about what we're allowed to capture there are slightly different, so I'm leaving that untouched.

Fixes #115474
2023-09-20 03:34:51 +00:00
Deadbeef
7b1b17574b fix bugs with effects fallback 2023-09-20 03:02:14 +00:00
Deadbeef
04eec37dc2 Enable effects for libcore 2023-09-20 03:02:14 +00:00
WANG Rui
0163768e0d rustc_target/loongarch: Fix passing of transparent unions with only one non-ZST member
This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed
through an `extern "C"` function.

Fixes https://github.com/rust-lang/rust/issues/115509
2023-09-20 09:22:02 +08:00
bors
bdb0fa3ee5 Auto merge of #113955 - cjgillot:name-apit, r=WaffleLapkin
Pretty-print argument-position impl trait to name it.

This removes a corner case.

RPIT and TAIT keep having no name, and it would be wrong to use the one in HIR (Ident::empty), so I make this case ICE.
2023-09-19 21:23:39 +00:00
Ethan Brierley
2243872c26 fix confusing let chain indentation in rustc_resolve 2023-09-19 21:21:01 +01:00
Ziru Niu
3c69a107d0 remove impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for PolyProjectionPredicate<'tcx> 2023-09-20 04:03:02 +08:00
Ziru Niu
2694b84fbf remove unneeded ToPredicate impls 2023-09-20 04:02:55 +08:00
Eduardo Sánchez Muñoz
85d61b01ae wrap fn sig binders in fn ptr 2023-09-19 21:15:58 +02:00
bors
ac5ac4754a Auto merge of #115979 - GuillaumeGomez:rollup-06ujzgh, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #113383 (style-guide: Add section on bugs, and resolving bugs)
 - #115499 (rustc_target/riscv: Fix passing of transparent unions with only one non-ZST member)
 - #115801 (Detect cycle errors hidden by opaques during monomorphization)
 - #115947 (Custom code classes in docs warning)
 - #115957 (fix mismatched symbols)
 - #115958 (explain mysterious addition in float minimum/maximum)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-19 18:52:10 +00:00
Guillaume Gomez
0060db74f9
Rollup merge of #115801 - compiler-errors:async-cycle-mono, r=oli-obk
Detect cycle errors hidden by opaques during monomorphization

Opaque types may reveal to projections, which themselves normalize to opaques. We don't currently normalize when checking that opaques are cyclical, and we may also not know that the opaque is cyclical until monomorphization (see `tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs`).

Detect cycle errors in `normalize_projection_ty` and report a fatal overflow (in the old solver). Luckily, this is already detected as a fatal overflow in the new solver.

Fixes #112047
2023-09-19 20:23:19 +02:00
Guillaume Gomez
edd7be59da
Rollup merge of #115499 - msizanoen1:riscv-fix-transparent-union-abi, r=bjorn3
rustc_target/riscv: Fix passing of transparent unions with only one non-ZST member

This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed through an `extern "C"` function.

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

r? `@RalfJung`
2023-09-19 20:23:19 +02:00
Ralf Jung
ea22adbabd adjust constValue::Slice to work for arbitrary slice types 2023-09-19 20:17:43 +02:00
bors
42f5828b01 Auto merge of #115627 - compiler-errors:icedump-no-std, r=m-ou-se
Don't modify libstd to dump rustc ICEs

Do a much simpler thing and just dump a `std::backtrace::Backtrace` to file.

r? `@estebank` `@oli-obk`

Fixes #115610
2023-09-19 16:56:25 +00:00