Commit Graph

5020 Commits

Author SHA1 Message Date
bors
1393ef1fa0 Auto merge of #116199 - Urgau:simplify-invalid_ref_casting, r=cjgillot
Simplify some of the logic in the `invalid_reference_casting` lint

This PR simplifies 2 areas of the logic for the `invalid_reference_casting` lint:
 - The init detection: we now use the newly added `expr_or_init` function instead of a manual detection
 - The ref-to-mut-ptr casting detection logic: I simplified this logic by caring less hardly about the order of the casting operations

Those two simplifications permits us to detect more cases, as can be seen in the test output changes.
2023-09-28 19:44:14 +00:00
Matthias Krüger
efc938312c
Rollup merge of #116214 - notriddle:master, r=aDotInTheVoid
rustdoc: rename `issue-\d+.rs` tests to have meaningful names
2023-09-28 15:58:44 +02:00
Matthias Krüger
ba0d97797a
Rollup merge of #116191 - apekros:issue-56098, r=petrochenkov
Add regression test for rust-lang#56098

Closes #56098
2023-09-28 15:58:43 +02:00
Matthias Krüger
86d5939aba
Rollup merge of #116215 - estebank:parse-type-angle-bracket-tweak, r=compiler-errors
Tweak wording of missing angle backets in qualified path
2023-09-28 09:14:07 +02:00
Esteban Küber
3848ffcee7 Tweak wording of missing angle backets in qualified path 2023-09-28 00:37:20 +00:00
Michael Howell
0487237f12 rustdoc: add URLs for test issues 2023-09-27 17:22:18 -07:00
Michael Howell
7cd8b2c925 Rename issue-\d+.rs tests to have meaningful names 2023-09-27 17:15:37 -07:00
Michael Howell
79195d5cbb Add crate_name to test so that it can be renamed 2023-09-27 16:51:21 -07:00
bors
e7c502d930 Auto merge of #109597 - cjgillot:gvn, r=oli-obk
Implement a global value numbering MIR optimization

The aim of this pass is to avoid repeated computations by reusing past assignments. It is based on an analysis of SSA locals, in order to perform a restricted form of common subexpression elimination.

By opportunity, this pass allows for some simplifications by combining assignments. For instance, this pass could be able to see through projections of aggregates to directly reuse the aggregate field (not in this PR).

We handle references by assigning a different "provenance" index to each `Ref`/`AddressOf` rvalue. This ensure that we do not spuriously merge borrows that should not be merged. Meanwhile, we consider all the derefs of an immutable reference to a freeze type to give the same value:
```rust
_a = *_b // _b is &Freeze
_c = *_b // replaced by _c = _a
```
2023-09-27 21:06:30 +00:00
Urgau
1b2c1a8583 Fix ICE by introducing an expr_or_init variant for outside bodies 2023-09-27 18:59:24 +02:00
Urgau
bd360472b1 Simplify casting logic of the invalid_reference_casting lint 2023-09-27 18:50:26 +02:00
Urgau
e577dcdd4d Prefer expr_or_init over manual init detection 2023-09-27 15:09:30 +02: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
243ce35b9f
Rollup merge of #116178 - Milo123459:milo/add-test-for-const-async-function-in-main, r=wesleywiser
Add test for `const async fn`

This adds a test for #102796
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
apekros
ac9707d25c Add regression test for rust-lang#56098 2023-09-27 18:05:14 +10: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
Milo
35f9345076 add test
fix tidy

remove dir
2023-09-26 20:15:28 +00:00
Michael Goulet
305524d1d6 Anonymize binders for refining_impl_trait check 2023-09-26 18:11:12 +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
b9caba610e
Rollup merge of #116099 - eduardosm:issue-79865-regression, r=oli-obk
Add regression test for issue #79865

Closes https://github.com/rust-lang/rust/issues/79865
2023-09-26 15:57:24 +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
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
bors
a6dce3bac5 Auto merge of #116124 - WaffleLapkin:fix-proc-macro-literal-to-string, r=compiler-errors
Properly print cstr literals in `proc_macro::Literal::to_string`

Previously we printed the contents of the string, rather than the actual string literal (e.g. `the c string` instead of `c"the c string"`).

Fixes #112820
cc #105723
2023-09-26 03:39:25 +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
bors
0288f2e195 Auto merge of #116084 - fmease:rustdoc-fix-x-crate-async-fn, r=GuillaumeGomez
rustdoc: correctly render the return type of cross-crate async fns

Fixes #115760.
2023-09-25 22:04:53 +00:00
Esteban Küber
3747ef5d6f Handle all arbitrary loop nesting in break type errors 2023-09-25 21:57:22 +00:00
León Orell Valerian Liehr
f54db7c3a9
Gate and validate #[rustc_safe_intrinsic] 2023-09-25 22:33:15 +02: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
Ralf Jung
a1d6fc4340 rename lint; add tracking issue 2023-09-25 19:05:10 +02:00
bors
1cbfeabfa9 Auto merge of #113396 - lenko-d:dont_ICE_when_no_bound_vars_for_lifetime_binders, r=compiler-errors
Don't ICE when no bound vars found while doing closure hir type check

The problem was that we were not visiting the const generic default argument in a bound where predicate when the HIR gets traversed in hir_analysis -> collect -> resolve_bound_vars.

Fixes [112574](https://github.com/rust-lang/rust/issues/112574)
2023-09-25 16:32:34 +00: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
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
33998a9751 Fix test by adding a stable way to get an opaque DefKind 2023-09-25 14:38:27 +00:00
León Orell Valerian Liehr
025a2cda0e
rustdoc: correctly render ret ty of cross-crate async fns 2023-09-25 15:57:04 +02:00
bors
67ad3c2394 Auto merge of #116078 - eduardosm:closure-inherit-target-feature, r=Mark-Simulacrum
Add assembly test to make sure that inlining works as expected when closures inherit target features

Closes https://github.com/rust-lang/rust/issues/108338 (the added test proves that it is working correctly)
2023-09-25 05:39:09 +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
Maybe Waffle
99a2fa17e6 Add a test for printing literals via proc-macro 2023-09-24 20:24:33 +00:00
bors
a1c7a1c89f Auto merge of #116120 - GuillaumeGomez:regression-102467, r=compiler-errors
Add regression test for #102467

Fixes #102467.

r? `@compiler-errors`
2023-09-24 18:47:52 +00:00