Commit Graph

876 Commits

Author SHA1 Message Date
Oli Scherer
ec8d01fdcc Allow iterators instead of requiring slices that will get turned into iterators 2022-11-21 20:33:55 +00:00
Oli Scherer
6f77c97b38 Assert that various types have the right amount of generic args and fix the sites that used the wrong amount 2022-11-21 20:31:59 +00:00
Oli Scherer
0c47deed9f Reduce the amount of passed-around arguments that will get merged into one later anyway 2022-11-21 20:28:48 +00:00
Cameron Steffen
cc8dddbac9 Factor out conservative_is_privately_uninhabited 2022-11-20 19:04:11 -06:00
Cameron Steffen
34cbe72780 Change to Ty::is_inhabited_from 2022-11-20 19:04:11 -06:00
Matthias Krüger
820a41580e
Rollup merge of #104564 - RalfJung:either, r=oli-obk
interpret: use Either over Result when it is not representing an error condition

r? `@oli-obk`
2022-11-20 18:21:48 +01:00
Ralf Jung
09a887cebf review feedback 2022-11-18 14:24:48 +01:00
Ralf Jung
4101889786 interpret: use Either over Result when it is not representing an error condition 2022-11-18 10:18:32 +01:00
Deadbeef
bc51f8783c rename to string_deref_patterns 2022-11-18 06:16:20 +00:00
Deadbeef
b2cb42d6a7 Minimal implementation of implicit deref patterns 2022-11-17 12:46:43 +00:00
bors
7c75fe4c85 Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-dead
Record `LocalDefId` in HIR nodes instead of a side table

This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR.
This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed.

This first part adds the information to HIR nodes themselves instead of a table.
The second part is https://github.com/rust-lang/rust/pull/103902
The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter.
The fourth part will be to completely remove the side table.
2022-11-17 07:42:27 +00:00
Matthias Krüger
5763fa74f0
Rollup merge of #104349 - rustaceanclub:master, r=oli-obk
fix some typos in comments
2022-11-14 19:26:18 +01:00
Camille GILLOT
607d0c2a14 Store a LocalDefId in hir::AnonConst. 2022-11-13 14:06:11 +00:00
Camille GILLOT
18482f7b23 Store a LocalDefId in hir::GenericParam. 2022-11-13 14:05:30 +00:00
cui fliter
442f848d74 fix some typos in comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2022-11-13 15:26:17 +08:00
Michael Goulet
93921dd16d Don't ICE with inline const errors during MIR build 2022-11-11 17:21:58 +00:00
Michael Goulet
0f89fb1791 Use const_error_with_guaranteed more 2022-11-10 05:39:15 +00:00
Jakob Degen
ba359d8a51 Add support for custom MIR parsing 2022-11-08 23:13:15 -08:00
Matthias Krüger
b101f3a865
Rollup merge of #103984 - V0ldek:103974-refactor-mk_const, r=BoxyUwU
Refactor tcx mk_const parameters.

Unroll the `ty::ConstS` parameter to `TyCtxt::mk_const` into separate `ty::ConstKind` and `Ty` parameters.

Signature change is in:

c97fd8183a/compiler/rustc_middle/src/ty/context.rs (L2234)

and

c97fd8183a/compiler/rustc_middle/src/ty/context.rs (L2572-L2575)

the rest is callsites.

Closes #103974

r? `@oli-obk`
2022-11-05 00:02:06 +01:00
Mateusz
c97fd8183a
Refactor tcx mk_const parameters. 2022-11-04 20:33:32 +00:00
Cameron Steffen
e7bae89a3c Cleanup bind_pattern args 2022-11-03 19:33:59 -05:00
Dylan DPC
94241e7eaf
Rollup merge of #103584 - ouz-a:issue-102303, r=oli-obk
Remove bounds check when array is indexed by enum

As the title says, this reverts the behavior introduced with 1.64.

Fixes #102303

r? `@oli-obk`
2022-11-01 14:12:25 +05:30
Yuki Okushi
2a6a8f4d30
Rollup merge of #103749 - est31:reduce_irrefutable_let_else_span, r=cjgillot
Reduce span of let else irrefutable_let_patterns warning

Huge spans aren't good for IDE users as they underline constructs that are possibly multiline.

Similar PR to #90761 which did the same for the `unused_macros` lint.
2022-11-01 12:03:41 +09:00
ouz-a
a1672ad5b8 Remove bounds check with enum cast 2022-10-31 14:10:37 +03:00
est31
7b55d17a2f Reduce span of let else irrefutable_let_patterns warning
Huge spans aren't good for IDE users as they underline constructs that
are possibly multiline.
2022-10-30 05:05:21 +01:00
Matthias Krüger
2bff9e2193
Rollup merge of #103726 - TaKO8Ki:avoid-&str-to-string-conversions, r=compiler-errors
Avoid unnecessary `&str` to `String` conversions
2022-10-30 00:09:26 +02:00
Takayuki Maeda
a3a3f4d840 avoid unnecessary &str to String conversions 2022-10-29 17:14:44 +09:00
Maybe Waffle
a17ccfa621 Accept TyCtxt instead of TyCtxtAt in Ty::is_* functions
Functions in answer:

- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`
2022-10-27 15:06:08 +04:00
Michael Goulet
6e6fe30d0f Comment why normalization is needed for debug assertions 2022-10-23 17:23:35 +00:00
Cameron Steffen
2928e9ef2c Introduce InhabitedPredicate 2022-10-22 13:20:06 -05:00
bors
b15e2c129e Auto merge of #101832 - compiler-errors:dyn-star-plus, r=eholk
Make `dyn*` casts into a coercion, allow `dyn*` upcasting

I know that `dyn*` is likely not going to be a feature exposed to surface Rust, but this makes it slightly more ergonomic to write tests for these types anyways. ... and this was just fun to implement anyways.

1. Make `dyn*` into a coercion instead of a cast
2. Enable `dyn*` upcasting since we basically get it for free
3. Simplify some of the cast checking code since we're using the coercion path now

r? `@eholk` but feel free to reassign
cc `@nikomatsakis` and `@tmandry` who might care about making `dyn*` casts into a coercion
2022-10-15 07:36:38 +00:00
Dylan DPC
7cf09c57a2
Rollup merge of #103031 - est31:match_guard_irrefutable_let, r=oli-obk
Suppress irrefutable let patterns lint for prefixes in match guards

In match guards, irrefutable prefixes might use the bindings created by the match pattern. Ideally, we check for this, but we can do the next best thing and just not lint for irrefutable prefixes in match guards.

Fixes #98361
2022-10-14 16:19:16 +05:30
Dylan DPC
77064b7f0a
Rollup merge of #103018 - Rageking8:more-dupe-word-typos, r=TaKO8Ki
More dupe word typos

I only picked those changes (from the regex search) that I am pretty certain doesn't change meaning and is just a typo fix. Do correct me if any fix is undesirable and I can revert those. Thanks.
2022-10-14 16:19:15 +05:30
Rageking8
7122abaddf more dupe word typos 2022-10-14 12:57:56 +08:00
Michael Goulet
76386bd65e Make dyn* cast into a coercion 2022-10-14 04:27:01 +00:00
est31
eab41a136a Suppress irrefutable let patterns lint for prefixes in match guards
In match guards, irrefutable prefixes might use the bindings created
by the match pattern. Ideally, we check for this, but we can do the
next best thing and just not lint for irrefutable prefixes in match
guards.
2022-10-14 02:16:40 +02:00
Gary Guo
de0396c718 Ensure enum cast moves 2022-10-13 16:44:47 +01:00
Dylan DPC
5a09b72156
Rollup merge of #102853 - cjgillot:skip-opaque-cast, r=jackh726
Skip chained OpaqueCast when building captures.

Fixes https://github.com/rust-lang/rust/issues/102089
2022-10-10 13:43:42 +05:30
Camille GILLOT
e828ce53b9 Skip chained OpaqueCast when building captures. 2022-10-09 16:18:16 +00:00
Eric Huss
be1c7aad72 Show let-else suggestion on stable. 2022-10-08 14:39:25 -07:00
Matthias Krüger
c731646d6a
Rollup merge of #102675 - ouz-a:mir-technical-debt, r=oli-obk
Remove `mir::CastKind::Misc`

As discussed in #97649 `mir::CastKind::Misc` is not clear, this PR addresses that by creating a new enum variant for every valid cast.

r? ````@oli-obk````
2022-10-08 14:38:18 +02:00
Cameron Steffen
283abbf0e7 Change InferCtxtBuilder from enter to build 2022-10-07 07:10:40 -05:00
Cameron Steffen
349415d1c6 Remove TypeckResults from InferCtxt 2022-10-07 07:06:19 -05:00
ouz-a
d59c7ff000 Remove mir::CastKind::Misc 2022-10-06 15:32:41 +03:00
bors
0152393048 Auto merge of #99324 - reez12g:issue-99144, r=jyn514
Enable doctests in compiler/ crates

Helps with https://github.com/rust-lang/rust/issues/99144
2022-10-06 03:01:57 +00:00
bors
c97d02cdb5 Auto merge of #102394 - dingxiangfei2009:issue-102317, r=oli-obk
Fix unwind drop glue for if-then scopes

cc `@est31`

Fix #102317
Fix #99852

This PR fixes the drop glue for unwinding from a panic originated in a drop while breaking out for the else block in an `if-then` scope.
MIR validation does not fail for the synchronous versions of the test program, because `StorageDead` statements are skipped over in the unwinding process. It is only becoming a problem when it is inside a generator where `StorageDead` must be kept around.
2022-10-05 20:47:39 +00:00
Ding Xiang Fei
565c35aa5c
fix doc and dedup diverge_cleanup 2022-10-05 22:24:12 +08:00
bors
744e397d88 Auto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebank
Move lint level source explanation to the bottom

So, uhhhhh

r? `@estebank`

## User-facing change

"note: `#[warn(...)]` on by default" and such are moved to the bottom of the diagnostic:
```diff
-   = note: `#[warn(unsupported_calling_conventions)]` on by default
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678>
+   = note: `#[warn(unsupported_calling_conventions)]` on by default
```

Why warning is enabled is the least important thing, so it shouldn't be the first note the user reads, IMO.

## Developer-facing change

`struct_span_lint` and similar methods have a different signature.

Before: `..., impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>)`
After: `..., impl Into<DiagnosticMessage>, impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>`

The reason for this is that `struct_span_lint` needs to edit the diagnostic _after_ `decorate` closure is called. This also makes lint code a little bit nicer in my opinion.

Another option is to use `impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>) -> DiagnosticBuilder<'a, ()>` altough I don't _really_ see reasons to do `let lint = lint.build(message)` everywhere.

## Subtle problem

By moving the message outside of the closure (that may not be called if the lint is disabled) `format!(...)` is executed earlier, possibly formatting `Ty` which may call a query that trims paths that crashes the compiler if there were no warnings...

I don't think it's that big of a deal, considering that we move from `format!(...)` to `fluent` (which is lazy by-default) anyway, however this required adding a workaround which is unfortunate.

## P.S.

I'm sorry, I do not how to make this PR smaller/easier to review. Changes to the lint API affect SO MUCH 😢
2022-10-01 10:44:25 +00:00
Maybe Waffle
a8f7e244b7 Refactor rustc lint API 2022-10-01 10:03:06 +00:00
X
fb52dc7c3b
apply suggestion
Co-authored-by: SafariMonkey <charlton.rodda@gmail.com>
2022-09-30 21:03:08 +08:00