Commit Graph

28287 Commits

Author SHA1 Message Date
bors
92009f217a Auto merge of #116093 - RalfJung:link_llvm_intrinsics, r=oli-obk
make link_llvm_intrinsics and platform_intrinsics features internal

These are both a lot like `feature(intrinsics)`, just slightly different syntax, so IMO it should be treated the same (also in terms of: if you get ICEs with this feature, that's on you -- we are not doing "nice" type-checking for intrinsics).
2023-09-27 11:28:36 +00:00
Matthias Krüger
a6f066596b
Rollup merge of #116187 - estebank:small-tweak, r=compiler-errors
Add context to `let: Ty = loop { break };`

We weren't accounting for the case where `break` was immediately within the `loop` block.
2023-09-27 10:42:35 +02:00
Matthias Krüger
50417a5457
Rollup merge of #116149 - compiler-errors:anonymize, r=lcnr
Anonymize binders for `refining_impl_trait` check

We're naively using the equality impl for `ty::Clause` in the refinement check, which is okay *except* for binders, which carry some information about where they come from in the AST. Those locations are not gonna be equal between traits and impls, so anonymize those clauses so that this doesn't matter.

Fixes #116135
2023-09-27 10:42:34 +02:00
Matthias Krüger
d4858878c1
Rollup merge of #115934 - oli-obk:smir_identity, r=spastorino
Split out the stable part of smir into its own crate to prevent accidental usage of forever unstable things

Some groundwork for being able to work on https://github.com/rust-lang/project-stable-mir/issues/27 at all

r? `@spastorino`
2023-09-27 10:42:34 +02:00
bors
376f3f0590 Auto merge of #116166 - Zalathar:unreachable, r=cjgillot
Skip MIR pass `UnreachablePropagation` when coverage is enabled

When coverage instrumentation and MIR opts are both enabled, coverage relies on two assumptions:

- MIR opts that would delete `StatementKind::Coverage` statements instead move them into bb0 and change them to `CoverageKind::Unreachable`.

- MIR opts won't delete all `CoverageKind::Counter` statements from an instrumented function.

Most MIR opts naturally satisfy the second assumption, because they won't remove coverage statements from bb0, but `UnreachablePropagation` can do so if it finds that bb0 is unreachable. If this happens, LLVM thinks the function isn't instrumented, and it vanishes from coverage reports.

A proper solution won't be possible until after per-function coverage info lands in #116046, but for now we can avoid the problem by turning off this particular pass when coverage instrumentation is enabled.

---

cc `@cjgillot` since I found this while investigating coverage problems encountered by #113970
`@rustbot` label +A-code-coverage +A-mir-opt
2023-09-27 05:31:15 +00:00
bors
6b99cf1d35 Auto merge of #116163 - compiler-errors:lazyness, r=oli-obk
Don't store lazyness in `DefKind::TyAlias`

1. Don't store lazyness of a type alias in its `DefKind`, but instead via a query.
2. This allows us to treat type aliases as lazy if `#[feature(lazy_type_alias)]` *OR* if the alias contains a TAIT, rather than having checks for both in separate parts of the codebase.

r? `@oli-obk` cc `@fmease`
2023-09-27 01:48:53 +00:00
bors
e1636a0939 Auto merge of #116156 - oli-obk:opaque_place_unwrap, r=compiler-errors
Only prevent field projections into opaque types, not types containing opaque types

fixes https://github.com/rust-lang/rust/issues/115778

I did not think that original condition through properly... I'll also need to check the similar check around the other `ProjectionKind::OpaqueCast` creation site (this one is in hir, the other one is in mir), but I'll do that change in another PR that doesn't go into a beta backport.
2023-09-27 00:03:53 +00:00
Esteban Küber
4b15959218 Add context to let: Ty = loop { break };
We weren't accounting for the case where `break` was immediately within
the `loop` block.
2023-09-26 23:46:10 +00:00
bors
5ae769f06b Auto merge of #116144 - lcnr:subst-less, r=oli-obk
subst -> instantiate

continues #110793, there are still quite a few uses of `subst` and `substitute`, but changing them all in the same PR was a bit too much, so I've stopped here for now.
2023-09-26 21:32:44 +00:00
bors
5899a80ae6 Auto merge of #116102 - cjgillot:indirect-scalar, r=oli-obk
Correct codegen of `ConstValue::Indirect` scalar and scalar pair

This concerns 3 tricky cases with `ConstValue::Indirect`:
- if we want a non-pointer scalar;
- if we have non-zero offset;
- if offset points to uninit memory => generate `poison` instead of an ICE. This case could happen in unreachable code, trying to extract a field from the wrong variant.

Those cases are not currently emitted by the compiler, but are exercised by https://github.com/rust-lang/rust/pull/116012.
2023-09-26 19:04:32 +00:00
Michael Goulet
305524d1d6 Anonymize binders for refining_impl_trait check 2023-09-26 18:11:12 +00:00
bors
6710e3312d Auto merge of #116154 - cjgillot:retain-cfg, r=oli-obk
Use Vec::retain in remove_dead_blocks.

r? `@ghost`
2023-09-26 17:16:20 +00:00
bors
21627d60cf Auto merge of #116175 - matthiaskrgr:rollup-cwteiwy, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #116099 (Add regression test for issue #79865)
 - #116131 (Rename `cold_path` to `outline`)
 - #116151 (Fix typo in rustdoc unstable features doc)
 - #116153 (Update books)
 - #116162 (Gate and validate `#[rustc_safe_intrinsic]`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-26 15:27:19 +00:00
Matthias Krüger
6f4a0a1eb2
Rollup merge of #116162 - fmease:gate-n-validate-rustc_safe_intrinsic, r=Nilstrieb
Gate and validate `#[rustc_safe_intrinsic]`

Copied over from #116159:

> This was added as ungated in https://github.com/rust-lang/rust/pull/100719/files#diff-09c366d3ad3ec9a42125253b610ca83cad6b156aa2a723f6c7e83eddef7b1e8fR502, probably because the author looked at the surrounding attributes, which are ungated because they are gated specially behind the staged_api feature.
>
> I don't think we need to crater this, the attribute is entirely useless without the intrinsics feature, which is already unstable..

r? ``@Nilstrieb``
2023-09-26 15:57:26 +02:00
Matthias Krüger
4eb72fdb15
Rollup merge of #116131 - Zoxc:cold-path-rename, r=oli-obk
Rename `cold_path` to `outline`

I find this name to be a bit more descriptive.

r? ``@oli-obk``
2023-09-26 15:57:25 +02:00
bors
1f2bacf677 Auto merge of #115893 - RalfJung:match-require-partial-eq, r=oli-obk
lint towards rejecting consts in patterns that do not implement PartialEq

I think we definitely don't want to allow such consts, so even while the general plan around structural matching is up in the air, we can start the process of getting non-PartialEq matches out of the ecosystem.
2023-09-26 13:38:28 +00:00
bors
8bf0dec101 Auto merge of #116109 - Zoxc:no-dep-graph-thread, r=oli-obk
Don't use a thread to load the dep graph

This removes the use of a thread to load the dep graph. It's not currently useful as we immediately block on it.

r? `@oli-obk`
2023-09-26 10:34:57 +00:00
Zalathar
64df5a851e Skip MIR pass UnreachablePropagation when coverage is enabled
When coverage instrumentation and MIR opts are both enabled, coverage relies on
two assumptions:

- MIR opts that would delete `StatementKind::Coverage` statements instead move
  them into bb0 and change them to `CoverageKind::Unreachable`.

- MIR opts won't delete all `CoverageKind::Counter` statements from an
  instrumented function.

Most MIR opts naturally satisfy the second assumption, because they won't
remove coverage statements from bb0, but `UnreachablePropagation` can do so if
it finds that bb0 is unreachable. If this happens, LLVM thinks the function
isn't instrumented, and it vanishes from coverage reports.

A proper solution won't be possible until after per-function coverage info
lands in #116046, but for now we can avoid the problem by turning off this
particular pass when coverage instrumentation is enabled.
2023-09-26 20:18:43 +10:00
lcnr
3c52a3e280 subst -> instantiate 2023-09-26 09:37:55 +02:00
bors
27b4eb96d1 Auto merge of #116125 - RalfJung:const-param-ty-eq, r=compiler-errors
ConstParamTy: require Eq as supertrait

As discussed with `@BoxyUwu` [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/.60ConstParamTy.60.20and.20.60Eq.60).

We want to say that valtree equality on const generic params agrees with `==`, but that only makes sense if `==` actually exists, hence we should have an appropriate bound. Valtree equality is an equivalence relation, so such a type can always be `Eq` and not just `PartialEq`.
2023-09-26 05:33:55 +00:00
Michael Goulet
d6ce9ce115 Don't store lazyness in DefKind 2023-09-26 02:53:59 +00:00
bors
a61f6f3baa Auto merge of #116072 - compiler-errors:rpitit-implied-bounds, r=aliemjay
Use placeholders to prevent using inferred RPITIT types to imply their own well-formedness

The issue here is that we use the same signature to do RPITIT inference as we do to compute implied bounds. To fix this, when gathering the assumed wf types for the method, we replace all of the infer vars (that will be eventually used to infer RPITIT types) with type placeholders, which imply nothing about lifetime bounds.

This solution kind of sucks, but I'm not certain there's another feasible way to fix this. If anyone has a better solution, I'd be glad to hear it.

My naive first solution was, instead of using placeholders, to replace the signature with the RPITIT projections that it originally started out with. But turns out that we can't just use the unnormalized signature of the trait method in `implied_outlives_bounds` since we normalize during WF computation -- that would cause a query cycle in `collect_return_position_impl_trait_in_trait_tys`.

idk who to request review...
r? `@lcnr` or `@aliemjay` i guess.

Fixes #116060
2023-09-26 01:50:12 +00:00
bors
c614c17626 Auto merge of #116080 - estebank:issue-115905-2, r=compiler-errors
Point at more causes of expectation of break value when possible

Follow up to #116071.

r? `@compiler-errors`

Disregard the first commit, which is in the other PR.
2023-09-26 00:03:45 +00:00
Esteban Küber
ddb3b7e70a Use verbose suggestion for break without value 2023-09-25 22:10:08 +00:00
Esteban Küber
3747ef5d6f Handle all arbitrary loop nesting in break type errors 2023-09-25 21:57:22 +00:00
John Kåre Alsaker
2c507cae36 Rename cold_path to outline 2023-09-25 22:54:07 +02:00
León Orell Valerian Liehr
f54db7c3a9
Gate and validate #[rustc_safe_intrinsic] 2023-09-25 22:33:15 +02:00
bors
6f13ea0d1a Auto merge of #115704 - nebulark:s_object, r=nagisa
Pass name of object file to LLVM so it can correctly emit S_OBJNAME in pdb files on Windows

This should be the remaining fix to close https://github.com/rust-lang/rust/issues/96475
Setting ObjectFilenameForDebug in llvm::TargetOptions, so llvm it can emit S_OBJNAME  in pdb files on Windows.

Without a proper pdb parsing I am not able to add a unit test for this. The string is already appearing in the pdb file so I cannot just use grep.

`@rustbot` label: +A-debuginfo
2023-09-25 20:17:01 +00:00
Esteban Küber
58adfd84e2 Account for more cases of nested loops for break type mismatches 2023-09-25 18:21:52 +00:00
Oli Scherer
17b313fb57 Only prevent field projections into opaque types, not types containing opaque types 2023-09-25 17:41:08 +00:00
Florian Schmiderer
91544e6a93 Pass name of object file to LLVM so it can correctly emit S_OBJNAME 2023-09-25 19:31:58 +02:00
Camille GILLOT
1092849967 Use Vec::retain in remove_dead_blocks. 2023-09-25 17:08:40 +00:00
Ralf Jung
a1d6fc4340 rename lint; add tracking issue 2023-09-25 19:05:10 +02:00
Esteban Küber
2e0ad2025f Handle yet another case of break type mismatch 2023-09-25 15:55:59 +00:00
Esteban Küber
f6d4950fee Point at previous breaks that have the expected type 2023-09-25 15:55:59 +00:00
Oli Scherer
411e431c70 Rebase fallout 2023-09-25 15:02:10 +00:00
Oli Scherer
a38e98371b Split out the stable part of smir into its own crate to prevent accidental usage of forever unstable things 2023-09-25 14:38:27 +00:00
Oli Scherer
19f1d782d5 Move Opaque to stable_mir 2023-09-25 14:38:27 +00:00
Oli Scherer
33998a9751 Fix test by adding a stable way to get an opaque DefKind 2023-09-25 14:38:27 +00:00
Oli Scherer
55b6f64902 Eliminate escape hatch 2023-09-25 14:38:26 +00:00
Oli Scherer
e02a139a23 Eliminate with_tables helper 2023-09-25 14:38:26 +00:00
Lenko Donchev
a1d181d740 Added additional visit steps to visit_generic_param() in order to avoid ICE on no bound vars. 2023-09-24 23:39:33 -05:00
bors
91958e0a74 Auto merge of #116117 - cjgillot:drop-tracking-mir-noscope, r=compiler-errors
Remove dead diagnostic code for generators

This code has become unreachable with #107421.
2023-09-24 22:25:15 +00:00
Ralf Jung
ad509633a2 ConstParamTy: require Eq 2023-09-24 23:38:07 +02:00
Ralf Jung
4f86c69184 fix ICE due to empty span and empty suggestions 2023-09-24 23:32:36 +02:00
Florian Schmiderer
3409ca65d8 Add OwnedTargetMachine to manage llvm:TargetMachine. Uses pointers
instead of &'static mut and provides safe interface to create/dispose
it.
2023-09-24 21:11:37 +02:00
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