Commit Graph

33 Commits

Author SHA1 Message Date
Matthias Krüger 51c686f32b
Rollup merge of #128701 - veera-sivarajan:fix-128604, r=estebank
Don't Suggest Labeling `const` and `unsafe` Blocks

Fixes #128604

Previously, both anonymous constant blocks (E.g. The labeled block
inside `['_'; 'block: { break 'block 1 + 2; }]`) and inline const
blocks (E.g. `const { ... }`) were considered to be the same
kind of blocks. This caused the compiler to incorrectly suggest
labeling both the blocks when only anonymous constant blocks can be
labeled.

This PR adds an other enum variant to `Context` so that both the
blocks can be handled appropriately.

Also, adds some doc comments and removes unnecessary `&mut` in a
couple of places.
2024-09-03 19:13:23 +02:00
tiif 8eaef3eca0 Add test 2024-08-08 00:41:39 +08:00
Veera f003e92a5b Don't Suggest Labeling `const` and `unsafe` Blocks 2024-08-06 14:50:09 -04:00
Veera 764675e01a Add Tests 2024-08-06 14:06:29 -04:00
Ralf Jung 67c99d6338 avoid creating an Instance only to immediately disassemble it again 2024-07-18 11:58:16 +02:00
Oli Scherer bbcd8794d0 Add regression test 2024-06-07 08:33:58 +00:00
bors d43930dab3 Auto merge of #125711 - oli-obk:const_block_ice2, r=Nadrieril
Make `body_owned_by` return the `Body` instead of just the `BodyId`

fixes #125677

Almost all `body_owned_by` callers immediately called `body`, too, so just return `Body` directly.

This makes the inline-const query feeding more robust, as all calls to `body_owned_by` will now yield a body for inline consts, too.

I have not yet figured out a good way to make `tcx.hir().body()` return an inline-const body, but that can be done as a follow-up
2024-05-30 08:00:11 +00:00
Oli Scherer a34c26e7ec Make `body_owned_by` return the body directly.
Almost all callers want this anyway, and now we can use it to also return fed bodies
2024-05-29 10:04:08 +00:00
Oli Scherer bcfefe1c7e Reintroduce name resolution check for trying to access locals from an inline const 2024-05-29 08:28:44 +00:00
Ross Smyth 6967d1c0fc Stabilize exclusive_range 2024-05-02 19:42:31 -04:00
Gary Guo cfee72aa24 Fix tests and bless 2024-04-24 13:12:33 +01:00
Ralf Jung 48f2f0d725 preserve span when evaluating mir::ConstOperand 2024-03-14 21:55:07 +01:00
Ralf Jung c1d0e489e5 fix use of platform_intrinsics in tests 2024-02-25 08:15:44 +01:00
许杰友 Jieyou Xu (Joe) ec2cc761bc
[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives 2024-02-16 20:02:50 +00:00
Matthew Jasper 4feec41e05 `#![feature(inline_const_pat)]` is no longer incomplete 2024-02-01 10:27:54 +00:00
Matthew Jasper 44824e0bce Enable tests for unsafe blocks in inline const patterns 2024-01-29 09:17:00 +00:00
Matthew Jasper 83fa46fe5b Borrow check inline const patterns
Add type annotations to MIR so that borrowck can pass constraints from
inline constants in patterns to the containing function.
2024-01-29 09:17:00 +00:00
Matthew Jasper 26f48b4cba Stabilize THIR unsafeck 2024-01-05 10:00:59 +00:00
Matthew Jasper 982b49494e Remove revisions for THIR unsafeck
This is to make the diff when stabilizing it easier to review.
2024-01-05 09:30:27 +00:00
Nilstrieb 41e8d152dc Show number in error message even for one error
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
2023-11-24 19:15:52 +01:00
Matthew Jasper dc3d428a8a Make THIR unused_unsafe lint consistent with MIR
Updates THIR behavior to match the changes from #93678
2023-10-25 10:10:13 +00:00
Matthew Jasper 5cc83fd4a5 Fix inline const pattern unsafety checking in THIR
THIR unsafety checking was getting a cycle of
function unsafety checking
-> building THIR for the function
-> evaluating pattern inline constants in the function
-> building MIR for the inline constant
-> checking unsafety of functions (so that THIR can be stolen)
This is fixed by not stealing THIR when generating MIR but instead when
unsafety checking.
This leaves an issue with pattern inline constants not being unsafety
checked because they are evaluated away when generating THIR.
To fix that we now represent inline constants in THIR patterns and
visit them in THIR unsafety checking.
2023-10-16 15:57:59 +00:00
Oli Scherer 9c762b58ba Prevent promotion of const fn calls in inline consts 2023-09-21 09:00:22 +00:00
Oli Scherer 44e199bf30 Add regression test 2023-09-21 08:50:08 +00:00
Gary Guo 26fe88fedb Add a test to check that inline const is in required_consts
Suggested in
https://github.com/rust-lang/rust/issues/76001#issuecomment-1315975027
2023-08-18 17:07:07 +01:00
Michael Goulet 1f42be6f55 Deny FnDef in patterns 2023-08-15 04:03:04 +00:00
Michael Goulet d8e3986d42 Don't use type_of to determine if item has intrinsic shim 2023-08-09 20:00:38 +00:00
Michael Goulet 719797949a Fix inline_const with interpolated block 2023-07-19 16:24:58 +00:00
Ziru Niu e8c831a03b add inline-const test for elided lifetimes being infer vars 2023-06-01 02:28:31 +08:00
Eric Huss a4e851cf62 Add some reasons why tests are ignored. 2023-04-15 16:11:42 -07:00
Camille GILLOT 05082f57af Perform match checking on THIR. 2023-04-03 15:59:21 +00:00
Esteban Küber 656db98bd9 Tweak E0597
CC #99430
2023-01-15 19:46:20 +00:00
Albert Larsan cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00