about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
AgeCommit message (Collapse)AuthorLines
2024-01-16borrowck: use implied bounds from impl headerAli MJ Al-Nasrawy-1/+24
2024-01-16borrowck: wf-check fn item argsAli MJ Al-Nasrawy-0/+10
2024-01-15compiler: Lower fn call arg spans down to MIRMartin Nordholts-12/+18
To enable improved accuracy of diagnostics in upcoming commits.
2024-01-15Rollup merge of #119971 - compiler-errors:zip-eq, r=nnethercoteMatthias Krüger-3/+10
Use `zip_eq` to enforce that things being zipped have equal sizes Some `zip`s are best enforced to be equal, since size mismatches suggest deeper bugs in the compiler.
2024-01-15Rollup merge of #119897 - compiler-errors:fulfillment-errors, r=lcnrMatthias Krüger-2/+2
`OutputTypeParameterMismatch` -> `SignatureMismatch` I'm probably missing something that made this rename more complicated. What did you end up getting stuck on when renaming this selection error, `@lcnr?` **also** I renamed the `FulfillmentErrorCode` variants. This is just churn but I wanted to do it forever. I can move it out of this PR if desired. r? lcnr
2024-01-14Use zip_eq to enforce that things being zipped have equal sizesMichael Goulet-3/+10
2024-01-14Simplify closure_env_ty and closure_env_paramMichael Goulet-1/+5
2024-01-13Make InferCtxtExt::could_impl_trait less messed upMichael Goulet-13/+18
2024-01-12Remove redundant Code from FulfillmentErrorCode variantsMichael Goulet-2/+2
2024-01-11Stop using `DiagnosticBuilder::buffer` in `BorrowckErrors`.Nicholas Nethercote-9/+10
But we can't easily switch from `Vec<Diagnostic>` to `Vec<DiagnosticBuilder<G>>` because there's a mix of errors and warnings which result in different `G` types. So we must make `DiagnosticBuilder::into_diagnostic` public, but that's ok, and it will get more use in subsequent commits.
2024-01-11Rollup merge of #118915 - compiler-errors:alias-nits, r=lcnrMatthias Krüger-2/+2
Add some comments, add `can_define_opaque_ty` check to `try_normalize_ty_recur` Follow-up from #117278, since I was recently re-reviewing this code.
2024-01-10Simplify some redundant namesMichael Goulet-2/+2
2024-01-10Rename consuming chaining methods on `DiagnosticBuilder`.Nicholas Nethercote-19/+19
In #119606 I added them and used a `_mv` suffix, but that wasn't great. A `with_` prefix has three different existing uses. - Constructors, e.g. `Vec::with_capacity`. - Wrappers that provide an environment to execute some code, e.g. `with_session_globals`. - Consuming chaining methods, e.g. `Span::with_{lo,hi,ctxt}`. The third case is exactly what we want, so this commit changes `DiagnosticBuilder::foo_mv` to `DiagnosticBuilder::with_foo`. Thanks to @compiler-errors for the suggestion.
2024-01-10Add `DiagCtxt::delayed_bug`.Nicholas Nethercote-2/+2
We have `span_delayed_bug` and often pass it a `DUMMY_SP`. This commit adds `delayed_bug`, which matches pairs like `err`/`span_err` and `warn`/`span_warn`.
2024-01-10Rename `struct_span_err!` as `struct_span_code_err!`.Nicholas Nethercote-27/+46
Because it takes an error code after the span. This avoids the confusing overlap with the `DiagCtxt::struct_span_err` method, which doesn't take an error code.
2024-01-08Use chaining in `DiagnosticBuilder` construction.Nicholas Nethercote-67/+49
To avoid the use of a mutable local variable, and because it reads more nicely.
2024-01-08Make `DiagnosticBuilder::emit` consuming.Nicholas Nethercote-2/+2
This works for most of its call sites. This is nice, because `emit` very much makes sense as a consuming operation -- indeed, `DiagnosticBuilderState` exists to ensure no diagnostic is emitted twice, but it uses runtime checks. For the small number of call sites where a consuming emit doesn't work, the commit adds `DiagnosticBuilder::emit_without_consuming`. (This will be removed in subsequent commits.) Likewise, `emit_unless` becomes consuming. And `delay_as_bug` becomes consuming, while `delay_as_bug_without_consuming` is added (which will also be removed in subsequent commits.) All this requires significant changes to `DiagnosticBuilder`'s chaining methods. Currently `DiagnosticBuilder` method chaining uses a non-consuming `&mut self -> &mut Self` style, which allows chaining to be used when the chain ends in `emit()`, like so: ``` struct_err(msg).span(span).emit(); ``` But it doesn't work when producing a `DiagnosticBuilder` value, requiring this: ``` let mut err = self.struct_err(msg); err.span(span); err ``` This style of chaining won't work with consuming `emit` though. For that, we need to use to a `self -> Self` style. That also would allow `DiagnosticBuilder` production to be chained, e.g.: ``` self.struct_err(msg).span(span) ``` However, removing the `&mut self -> &mut Self` style would require that individual modifications of a `DiagnosticBuilder` go from this: ``` err.span(span); ``` to this: ``` err = err.span(span); ``` There are *many* such places. I have a high tolerance for tedious refactorings, but even I gave up after a long time trying to convert them all. Instead, this commit has it both ways: the existing `&mut self -> Self` chaining methods are kept, and new `self -> Self` chaining methods are added, all of which have a `_mv` suffix (short for "move"). Changes to the existing `forward!` macro lets this happen with very little additional boilerplate code. I chose to add the suffix to the new chaining methods rather than the existing ones, because the number of changes required is much smaller that way. This doubled chainging is a bit clumsy, but I think it is worthwhile because it allows a *lot* of good things to subsequently happen. In this commit, there are many `mut` qualifiers removed in places where diagnostics are emitted without being modified. In subsequent commits: - chaining can be used more, making the code more concise; - more use of chaining also permits the removal of redundant diagnostic APIs like `struct_err_with_code`, which can be replaced easily with `struct_err` + `code_mv`; - `emit_without_diagnostic` can be removed, which simplifies a lot of machinery, removing the need for `DiagnosticBuilderState`.
2024-01-07Move PointIndex to mir_dataflow.Camille GILLOT-114/+32
2024-01-05Rollup merge of #119563 - compiler-errors:coroutine-resume, r=oli-obkMatthias Krüger-26/+46
Check yield terminator's resume type in borrowck In borrowck, we didn't check that the lifetimes of the `TerminatorKind::Yield`'s `resume_place` were actually compatible with the coroutine's signature. That means that the lifetimes were totally going unchecked. Whoops! This PR implements this checking. Fixes #119564 r? types
2024-01-05Remove `hir::Guard`Matthew Jasper-1/+1
Use Expr instead. Use `ExprKind::Let` to represent if let guards.
2024-01-04Check yield terminator's resume type in borrowckMichael Goulet-26/+46
2023-12-30is_coroutine -> is_coroutine_or_closureMichael Goulet-3/+3
2023-12-28Movability doesn't need to be a query anymoreMichael Goulet-1/+1
2023-12-28Remove movability from TyKind::CoroutineMichael Goulet-26/+23
2023-12-28Fix some commentscuishuang-1/+1
Signed-off-by: cuishuang <imcusg@gmail.com>
2023-12-26Auto merge of #119258 - compiler-errors:closure-kind, r=eholkbors-102/+149
Make closures carry their own ClosureKind Right now, we use the "`movability`" field of `hir::Closure` to distinguish a closure and a coroutine. This is paired together with the `CoroutineKind`, which is located not in the `hir::Closure`, but the `hir::Body`. This is strange and redundant. This PR introduces `ClosureKind` with two variants -- `Closure` and `Coroutine`, which is put into `hir::Closure`. The `CoroutineKind` is thus removed from `hir::Body`, and `Option<Movability>` no longer needs to be a stand-in for "is this a closure or a coroutine". r? eholk
2023-12-25Flatten matchMichael Goulet-47/+67
2023-12-25Only regular coroutines have movabilityMichael Goulet-28/+28
2023-12-25Make closures carry their own ClosureKind, rather than deducing what it is ↵Michael Goulet-89/+116
from movability
2023-12-24Remove `MirBorrowckCtxt` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-22/+14
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-55/+58
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-22Rollup merge of #119198 - compiler-errors:desugaring, r=eholkMichael Goulet-40/+55
Split coroutine desugaring kind from source What a coroutine is desugared from (gen/async gen/async) should be separate from where it comes (fn/block/closure).
2023-12-23Give `DiagnosticBuilder` a default type.Nicholas Nethercote-109/+70
`IntoDiagnostic` defaults to `ErrorGuaranteed`, because errors are the most common diagnostic level. It makes sense to do likewise for the closely-related (and much more widely used) `DiagnosticBuilder` type, letting us write `DiagnosticBuilder<'a, ErrorGuaranteed>` as just `DiagnosticBuilder<'a>`. This cuts over 200 lines of code due to many multi-line things becoming single line things.
2023-12-22Split coroutine desugaring kind from sourceMichael Goulet-40/+55
2023-12-22Auto merge of #118824 - aliemjay:perf-region-cons, r=compiler-errorsbors-7/+12
use Vec for region constraints instead of BTreeMap ~1% perf gain Diagnostic regressions need more investigation. r? `@ghost`
2023-12-19Remove unnecessary param-env from lexical region resolution and fully ↵Michael Goulet-23/+6
structural relations
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-2/+2
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-11/+11
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-1/+1
2023-12-17fix diagnostic regresssionAli MJ Al-Nasrawy-7/+12
2023-12-15banish hir::GenericBound::LangItemTraitMichael Goulet-20/+10
2023-12-14Rollup merge of #118933 - nnethercote:cleanup-errors-even-more, ↵Jubilee-2/+2
r=compiler-errors Cleanup errors handlers even more A sequel to #118587. r? `@compiler-errors`
2023-12-15Split `Handler::emit_diagnostic` in two.Nicholas Nethercote-2/+2
Currently, `emit_diagnostic` takes `&mut self`. This commit changes it so `emit_diagnostic` takes `self` and the new `emit_diagnostic_without_consuming` function takes `&mut self`. I find the distinction useful. The former case is much more common, and avoids a bunch of `mut` and `&mut` occurrences. We can also restrict the latter with `pub(crate)` which is nice.
2023-12-14consistently use "next solver" instead of "new solver"lcnr-2/+2
2023-12-14update use of feature flagslcnr-2/+2
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-47/+48
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`
2023-12-11remove some redundant clonesMatthias Krüger-1/+1
2023-12-10remove redundant importssurechen-3/+1
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-09Rollup merge of #118638 - nnethercote:rustc_mir_dataflow-more, r=cjgillotGuillaume Gomez-83/+70
More `rustc_mir_dataflow` cleanups r? `@cjgillot`
2023-12-08Implement `async gen` blocksMichael Goulet-4/+30