Jack Huey
8033c3c27d
Various changes to logging of borrowck-related code
2022-08-29 10:59:21 -04:00
Dylan DPC
5555e13a6e
Rollup merge of #99821 - cjgillot:ast-lifetimes-2, r=compiler-errors
...
Remove separate indexing of early-bound regions
~Based on https://github.com/rust-lang/rust/pull/99728.~
This PR copies some modifications from https://github.com/rust-lang/rust/pull/97839 around object lifetime defaults.
These modifications allow to stop counting generic parameters during lifetime resolution, and rely on the indexing given by `rustc_typeck::collect`.
2022-08-29 16:49:39 +05:30
Matthias Krüger
a3c965f5fe
Rollup merge of #100843 - IntQuant:issue-100717-infer, r=compiler-errors
...
Migrate part of rustc_infer to session diagnostic
2022-08-29 06:34:45 +02:00
Matthias Krüger
26c86c6993
Rollup merge of #100437 - compiler-errors:better-const-mismatch-err, r=oli-obk
...
Improve const mismatch `FulfillmentError`
Fixes #100414
2022-08-29 06:34:44 +02:00
Michael Goulet
48b3d8aa82
Drive-by: same_type_modulo_infer should handle ReVar == ReVar
2022-08-26 04:42:53 +00:00
Michael Goulet
075b3ce89d
Attempt to normalize FnDef signature in InferCtxt::cmp
2022-08-25 23:32:46 +00:00
Yuki Okushi
f4550a6edf
Rollup merge of #99332 - jyn514:stabilize-label-break-value, r=petrochenkov
...
Stabilize `#![feature(label_break_value)]`
See the stabilization report in https://github.com/rust-lang/rust/issues/48594#issuecomment-1186213313 .
2022-08-25 08:50:54 +09:00
Michael Goulet
4e976262a1
Call them constants instead of types
2022-08-24 17:53:35 +00:00
IQuant
e1765a9c56
Remove commented lines
2022-08-24 17:09:07 +03:00
Nikita Tomashevich
3fae3904b1
Use IntoDiagnosticArg
where it makes sense
2022-08-24 15:46:29 +03:00
Joshua Nelson
31e39446ec
Stabilize #![feature(label_break_value)]
...
# Stabilization proposal
The feature was implemented in https://github.com/rust-lang/rust/pull/50045 by est31 and has been in nightly since 2018-05-16 (over 4 years now).
There are [no open issues][issue-label] other than the tracking issue. There is a strong consensus that `break` is the right keyword and we should not use `return`.
There have been several concerns raised about this feature on the tracking issue (other than the one about tests, which has been fixed, and an interaction with try blocks, which has been fixed).
1. nrc's original comment about cost-benefit analysis: https://github.com/rust-lang/rust/issues/48594#issuecomment-422235234
2. joshtriplett's comments about seeing use cases: https://github.com/rust-lang/rust/issues/48594#issuecomment-422281176
3. withoutboats's comments that Rust does not need more control flow constructs: https://github.com/rust-lang/rust/issues/48594#issuecomment-450050630
Many different examples of code that's simpler using this feature have been provided:
- A lexer by rpjohnst which must repeat code without label-break-value: https://github.com/rust-lang/rust/issues/48594#issuecomment-422502014
- A snippet by SergioBenitez which avoids using a new function and adding several new return points to a function: https://github.com/rust-lang/rust/issues/48594#issuecomment-427628251 . This particular case would also work if `try` blocks were stabilized (at the cost of making the code harder to optimize).
- Several examples by JohnBSmith: https://github.com/rust-lang/rust/issues/48594#issuecomment-434651395
- Several examples by Centril: https://github.com/rust-lang/rust/issues/48594#issuecomment-440154733
- An example by petrochenkov where this is used in the compiler itself to avoid duplicating error checking code: https://github.com/rust-lang/rust/issues/48594#issuecomment-443557569
- Amanieu recently provided another example related to complex conditions, where try blocks would not have helped: https://github.com/rust-lang/rust/issues/48594#issuecomment-1184213006
Additionally, petrochenkov notes that this is strictly more powerful than labelled loops due to macros which accidentally exit a loop instead of being consumed by the macro matchers: https://github.com/rust-lang/rust/issues/48594#issuecomment-450246249
nrc later resolved their concern, mostly because of the aforementioned macro problems.
joshtriplett suggested that macros could be able to generate IR directly
(https://github.com/rust-lang/rust/issues/48594#issuecomment-451685983 ) but there are no open RFCs,
and the design space seems rather speculative.
joshtriplett later resolved his concerns, due to a symmetry between this feature and existing labelled break: https://github.com/rust-lang/rust/issues/48594#issuecomment-632960804
withoutboats has regrettably left the language team.
joshtriplett later posted that the lang team would consider starting an FCP given a stabilization report: https://github.com/rust-lang/rust/issues/48594#issuecomment-1111269353
[issue-label]: https://github.com/rust-lang/rust/issues?q=is%3Aissue+is%3Aopen+label%3AF-label_break_value+
## Report
+ Feature gate:
- d695a497bb/src/test/ui/feature-gates/feature-gate-label_break_value.rs
+ Diagnostics:
- 6b2d3d5f3c/compiler/rustc_parse/src/parser/diagnostics.rs (L2629)
- f65bf0b2bb/compiler/rustc_resolve/src/diagnostics.rs (L749)
- f65bf0b2bb/compiler/rustc_resolve/src/diagnostics.rs (L1001)
- 111df9e6ed/compiler/rustc_passes/src/loops.rs (L254)
- d695a497bb/compiler/rustc_parse/src/parser/expr.rs (L2079)
- d695a497bb/compiler/rustc_parse/src/parser/expr.rs (L1569)
+ Tests:
- https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_continue.rs
- https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_unlabeled_break.rs
- https://github.com/rust-lang/rust/blob/master/src/test/ui/label/label_break_value_illegal_uses.rs
- https://github.com/rust-lang/rust/blob/master/src/test/ui/lint/unused_labels.rs
- https://github.com/rust-lang/rust/blob/master/src/test/ui/run-pass/for-loop-while/label_break_value.rs
## Interactions with other features
Labels follow the hygiene of local variables.
label-break-value is permitted within `try` blocks:
```rust
let _: Result<(), ()> = try {
'foo: {
Err(())?;
break 'foo;
}
};
```
label-break-value is disallowed within closures, generators, and async blocks:
```rust
'a: {
|| break 'a
//~^ ERROR use of unreachable label `'a`
//~| ERROR `break` inside of a closure
}
```
label-break-value is disallowed on [_BlockExpression_]; it can only occur as a [_LoopExpression_]:
```rust
fn labeled_match() {
match false 'b: { //~ ERROR block label not supported here
_ => {}
}
}
macro_rules! m {
($b:block) => {
'lab: $b; //~ ERROR cannot use a `block` macro fragment here
unsafe $b; //~ ERROR cannot use a `block` macro fragment here
|x: u8| -> () $b; //~ ERROR cannot use a `block` macro fragment here
}
}
fn foo() {
m!({});
}
```
[_BlockExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/block-expr.html
[_LoopExpression_]: https://doc.rust-lang.org/nightly/reference/expressions/loop-expr.html
2022-08-23 21:14:12 -05:00
Dylan DPC
f42cdf76e1
Rollup merge of #100368 - chenyukang:fix-100321, r=lcnr
...
InferCtxt tainted_by_errors_flag should be Option<ErrorGuaranteed>
Fixes #100321 .
Use Cell<Option<ErrorGuaranteed>> to guarantee that we emit an error when that flag is set.
2022-08-23 20:40:03 +05:30
Nikita Tomashevich
f50d1713fd
Migrate note_region_origin function
2022-08-23 14:47:08 +03:00
Nikita Tomashevich
3f6cb475f7
Use GeneratorKind::descr() instead of it's Display impl
...
Those are basically the same but the first one seems to fit better
2022-08-23 14:47:08 +03:00
Nikita Tomashevich
7e4f433720
Actually migrate OpaqueHiddenType
2022-08-23 14:47:08 +03:00
Nikita Tomashevich
313d474b35
Migrate OpaqueHiddenType, E0282, E0283, E0284, E0698
2022-08-23 14:47:07 +03:00
yukang
8be37644db
InferCtxt emit error when incorrectly tainted by errors
2022-08-22 22:15:23 +08:00
SparrowLii
a01ac5a699
re-base and use OutlivesEnvironment::with_bounds
2022-08-22 18:36:02 +08:00
SparrowLii
d037f1843e
add with_bounds
to OutlivesEnvironment
and implied_bounds_tys
to outlives_bounds::InferCtxtExt
2022-08-22 18:09:59 +08:00
SparrowLii
5d9e4d07fc
get rid of RefCell
in TransitiveRelation
2022-08-22 18:08:46 +08:00
Michael Goulet
c005e760f5
Rework point-at-arg
2022-08-21 02:34:52 +00:00
Matthias Krüger
51769af6ea
Rollup merge of #100691 - compiler-errors:issue-100690, r=estebank
...
Make `same_type_modulo_infer` a proper `TypeRelation`
Specifically, this fixes #100690 because we no longer consider a `ReLateBound` and a `ReVar` to be equal. `ReVar` can only be equal to free regions or static.
2022-08-20 19:32:11 +02:00
Matthias Krüger
61a529d902
Rollup merge of #100617 - chenyukang:fix-100605, r=compiler-errors
...
Suggest the right help message for as_ref
Fixes #100605
2022-08-20 07:09:00 +02:00
yukang
3de74f7e2b
Suggest the right help message for as_ref
2022-08-20 09:43:37 +08:00
bors
8064a49508
Auto merge of #99860 - oli-obk:revert_97346, r=pnkfelix
...
Revert "Rollup merge of #97346 - JohnTitor:remove-back-compat-hacks, …
…r=oli-obk"
This reverts commit c703d11dccb4a895c7aead3b2fcd8cea8c483184, reversing
changes made to 64eb9ab869bc3f9ef3645302fbf22e706eea16cf.
it didn't apply cleanly, so now it works the same for RPIT and for TAIT instead of just working for RPIT, but we should keep those in sync anyway. It also exposed a TAIT bug (see the feature gated test that now ICEs).
r? `@pnkfelix`
fixes #99536
2022-08-18 15:41:30 +00:00
Michael Goulet
64bd8c1dc4
Make same_type_modulo_infer a proper TypeRelation
2022-08-17 19:02:55 +00:00
Michael Goulet
fc7fc0fae5
ty::Error does not match other types for region constraints
2022-08-17 17:23:52 +00:00
Michael Goulet
8b64988575
Fix error message with non-tupled bare fn trait
2022-08-16 01:21:11 +00:00
Michael Goulet
75dfe55a5d
TypeError can be Copy
2022-08-14 19:58:46 +00:00
Michael Goulet
aa1a07f114
Do not inline non-simple argument type errors into labels
2022-08-13 18:24:36 +00:00
Mark Rousskov
154a09dd91
Adjust cfgs
2022-08-12 16:28:15 -04:00
Michael Goulet
534426d0f3
Delay a bug if we try and fail to relate an opaque to itself in TypeRelating
2022-08-10 03:36:05 +00:00
Michael Goulet
28b6373b1d
Fall back when relating two opaques by substs in MIR typeck
2022-08-10 03:27:41 +00:00
lcnr
f25cb83296
don't normalize wf predicates
...
this allows us to soundly use unnormalized projections for wf
2022-08-09 12:54:32 +02:00
Matthias Krüger
6919a07eb8
Rollup merge of #100102 - b-naber:typo-higher-ranked-sub, r=Dylan-DPC
...
Fix typo
r? ```@jackh726```
2022-08-03 22:30:46 +02:00
Camille GILLOT
421bb6ac62
Remove index from Region::EarlyBound.
2022-08-03 18:44:18 +02:00
b-naber
1405ce35ac
fix typo
2022-08-03 11:04:10 +02:00
bors
b759b2efad
Auto merge of #99509 - lcnr:commit_unconditionally, r=jackh726
...
remove `commit_unconditionally`
`commit_unconditionally` is a noop unless we somehow inspect the current state of our snapshot. The only thing which does that is the leak check which was only used in one place where `commit_if_ok` is probably at least as, or even more, correct.
r? rust-lang/types
2022-08-03 01:55:20 +00:00
bors
06f4950cbd
Auto merge of #100032 - BoxyUwU:no_ty_in_placeholder_const, r=compiler-errors
...
make `PlaceholderConst` not store the type of the const
Currently the `Placeholder` variant on `ConstKind` is 28 bytes when with this PR its 8 bytes, i am not sure this is really useful at all rn since `Unevaluated` and `Value` variants are huge still but eventually it should be possible to get both down to 16 bytes 🤔 . Mostly opening this to see if this change has any perf impact when done before it can make `ConstKind`/`ConstS` smaller
2022-08-02 13:10:49 +00:00
Matthias Krüger
0629445300
Rollup merge of #99156 - lcnr:omoe-wa, r=wesleywiser
...
`codegen_fulfill_obligation` expect erased regions
it's a query, so by erasing regions before calling it, we get better caching.
This doesn't actually change anything as its already the status quo.
2022-08-02 07:30:39 +02:00
Camille GILLOT
d7ea161b7e
Remove DefId from AssocItemContainer.
2022-08-01 21:38:45 +02:00
Ellen
49d001c5f3
fmt...
2022-08-01 20:15:58 +01:00
Ellen
825a7cc65c
make PlaceholderConst
not store the type of the const
2022-08-01 15:42:38 +01:00
Takayuki Maeda
03622552ec
use appropriate HirID
for finding else_span
2022-07-31 11:33:01 +09:00
Dylan DPC
c668820365
Rollup merge of #99311 - kckeiks:clean-up-body-owner-methods, r=cjgillot
...
change maybe_body_owned_by to take local def id
Issue https://github.com/rust-lang/rust/issues/96341
r? `@cjgillot`
2022-07-30 20:39:46 +05:30
bors
110777b60c
Auto merge of #99796 - compiler-errors:issue-53475, r=oli-obk
...
use `check_region_obligations_and_report_errors` to avoid ICEs
If we don't call `process_registered_region_obligations` before `resolve_regions_and_report_errors` then we'll ICE if we have any region obligations, and `check_region_obligations_and_report_errors` just does both of these for us in a nice convenient function.
Fixes #53475
r? types
2022-07-30 09:35:22 +00:00
Michael Goulet
fb12f40f3b
Do not leak type variables from opaque type relation
2022-07-30 00:41:39 +00:00
Miguel Guarniz
16513d689e
Rename local_did to def_id
...
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:26:10 -04:00
Miguel Guarniz
25bdc8965e
Change maybe_body_owned_by to take local def id
...
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29 18:25:58 -04:00
lcnr
1436fa9e90
optimize bound vars replacement :3
2022-07-29 08:45:06 +02:00