about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
AgeCommit message (Collapse)AuthorLines
2022-11-23OpaqueCast projections are always overlapping, they can't possibly be disjointOli Scherer-10/+4
2022-11-23Fix #104639, find the right lower bound region in the scenario of partial ↵yukang-20/+7
order relations
2022-11-22Rollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnrManish Goregaokar-14/+2
Allow opaque types in trait impl headers and rely on coherence to reject unsound cases r? ````@lcnr```` fixes #99840
2022-11-23Rollup merge of #104728 - WaffleLapkin:require-lang-items-politely, ↵Yuki Okushi-2/+2
r=compiler-errors Use `tcx.require_lang_item` instead of unwrapping lang items I clearly remember esteban telling me that there is `require_lang_item` but he was from a phone atm and I couldn't find it, so I didn't use it. Stumbled on it today, so here we are :)
2022-11-22Use `tcx.require_lang_item` instead of unwrappingMaybe Waffle-2/+2
2022-11-22Auto merge of #103578 - petrochenkov:nofict, r=nagisabors-1/+1
Unreserve braced enum variants in value namespace With this PR braced enum variants (`enum E { V { /*...*/ } }`) no longer take a slot in value namespace, so the special case mentioned in the note in https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md#braced-structs is removed. Report - https://github.com/rust-lang/rust/pull/103578#issuecomment-1292594900.
2022-11-21Stop passing the self-type as a separate argument.Oli Scherer-18/+10
2022-11-21Add helper to create the trait ref for a lang itemOli Scherer-28/+9
2022-11-21Allow iterators instead of requiring slices that will get turned into iteratorsOli Scherer-6/+6
2022-11-21Assert that various types have the right amount of generic args and fix the ↵Oli Scherer-23/+28
sites that used the wrong amount
2022-11-21Add more regression testsOli Scherer-6/+6
2022-11-21Unreserve braced enum variants in value namespaceVadim Petrochenkov-1/+1
2022-11-21Remove a function that doesn't actually do anythingOli Scherer-8/+1
2022-11-21Register obligations from type relationOli Scherer-1/+1
2022-11-21Add an always-ambiguous predicate to make sure that we don't accidentlally ↵Oli Scherer-6/+1
allow trait resolution to prove false things during coherence
2022-11-21Auto merge of #103491 - cjgillot:self-rpit, r=oli-obkbors-11/+40
Support using `Self` or projections inside an RPIT/async fn I reuse the same idea as https://github.com/rust-lang/rust/pull/103449 to use variances to encode whether a lifetime parameter is captured by impl-trait. The current implementation of async and RPIT replace all lifetimes from the parent generics by `'static`. This PR changes the scheme ```rust impl<'a> Foo<'a> { fn foo<'b, T>() -> impl Into<Self> + 'b { ... } } opaque Foo::<'_a>::foo::<'_b, T>::opaque<'b>: Into<Foo<'_a>> + 'b; impl<'a> Foo<'a> { // OLD fn foo<'b, T>() -> Foo::<'static>::foo::<'static, T>::opaque::<'b> { ... } ^^^^^^^ the `Self` becomes `Foo<'static>` // NEW fn foo<'b, T>() -> Foo::<'a>::foo::<'b, T>::opaque::<'b> { ... } ^^ the `Self` stays `Foo<'a>` } ``` There is the same issue with projections. In the example, substitute `Self` by `<T as Trait<'b>>::Assoc` in the sugared version, and `Foo<'_a>` by `<T as Trait<'_b>>::Assoc` in the desugared one. This allows to support `Self` in impl-trait, since we do not replace lifetimes by `'static` any more. The same trick allows to use projections like `T::Assoc` where `Self` is allowed. The feature is gated behind a `impl_trait_projections` feature gate. The implementation relies on 2 tweaking rules for opaques in 2 places: - we only relate substs that correspond to captured lifetimes during TypeRelation; - we only list captured lifetimes in choice region computation. For simplicity, I encoded the "capturedness" of lifetimes as a variance, `Bivariant` vs `Invariant` for unused vs captured lifetimes. The `variances_of` query used to ICE for opaques. Impl-trait that do not reference `Self` or projections will have their variances as: - `o` (invariant) for each parent type or const; - `*` (bivariant) for each parent lifetime --> will not participate in borrowck; - `o` (invariant) for each own lifetime. Impl-trait that does reference `Self` and/or projections will have some parent lifetimes marked as `o` (as the example above), and participate in type relation and borrowck. In the example above, `variances_of(opaque) = ['_a: o, '_b: *, T: o, 'b: o]`. r? types cc `@compiler-errors` , as you asked about the issue with `Self` and projections.
2022-11-20Factor out conservative_is_privately_uninhabitedCameron Steffen-4/+1
2022-11-18require an `ErrorGuaranteed` to taint infcx with errorsBoxy-2/+5
2022-11-18rename `is_tainted_by_errors` Boxy-4/+8
2022-11-18`InferCtxt::is_tainted_by_errors` returns `ErrorGuaranteed`Boxy-3/+3
2022-11-18dont unchecked create `ErrorGuaranteed` in `BorrowckErrors`Boxy-10/+12
2022-11-17Rollup merge of #104483 - oli-obk:santa-clauses-make-goals, r=compiler-errorsMatthias Krüger-16/+11
Convert predicates into Predicate in the Obligation constructor instead of having almost all callers do that. This reduces a bit of boilerplate, and also paves the way for my work towards https://github.com/rust-lang/compiler-team/issues/531 (as it makes it easier to accept both goals and clauses where right now it only accepts predicates).
2022-11-16Convert predicates into Predicate in the Obligation constructorOli Scherer-16/+11
2022-11-16Generalize the `ToPredicate` traitOli Scherer-1/+1
Its name is now not accurate anymore, but we'll adjust that later
2022-11-14Give precendence to regions from member constaints when inferring concrete ↵Camille GILLOT-11/+40
types.
2022-11-13Make user_provided_sigs a LocalDefIdMap.Camille GILLOT-4/+3
2022-11-11Rollup merge of #103960 - AndyJado:var_path_only_diag, r=davidtwcoManish Goregaokar-60/+207
piece of diagnostic migrate r? `@davidtwco`
2022-11-09Rollup merge of #102763 - compiler-errors:nits, r=cjgillotMichael Goulet-14/+7
Some diagnostic-related nits 1. Use `&mut Diagnostic` instead of `&mut DiagnosticBuilder<'_, T>` 2. Make `diag.span_suggestions` take an `IntoIterator` instead of `Iterator`, just to remove some `.into_iter` calls on the caller. idk if I should add a lint to make sure people use `&mut Diagnostic` instead of `&mut DiagnosticBuilder<'_, T>` in cases where we're just, e.g., adding subdiagnostics to the diagnostic... maybe a followup.
2022-11-09Rollup merge of #103464 - JakobDegen:mir-parsing, r=oli-obkManish Goregaokar-0/+14
Add support for custom mir This implements rust-lang/compiler-team#564 . Details about the design, motivation, etc. can be found in there. r? ```@oli-obk```
2022-11-09Rollup merge of #103307 - b4den:master, r=estebankManish Goregaokar-1/+1
Add context to compiler error message Changed `creates a temporary which is freed while still in use` to `creates a temporary value which is freed while still in use`.
2022-11-09Make span_suggestions take IntoIteratorMichael Goulet-1/+1
2022-11-09DiagnosticBuilder -> DiagnosticMichael Goulet-13/+6
2022-11-09struct error E0505AndyJado-6/+31
2022-11-09var_subdiag refinementAndyJado-57/+64
trim old
2022-11-09remove old var_span_path_onlyAndyJado-17/+75
doc comment
2022-11-09lint auto passAndyJado-0/+57
Revert "lint auto pass" This reverts commit e58e4466384924c491a932d3f18ef50ffa5a5065.
2022-11-08Add support for custom MIR parsingJakob Degen-0/+14
2022-11-09Auto merge of #104179 - Manishearth:rollup-yvsx5hh, r=Manishearthbors-4/+60
Rollup of 7 pull requests Successful merges: - #100508 (avoid making substs of type aliases late bound when used as fn args) - #101381 (Test that target feature mix up with homogeneous floats is sound) - #103353 (Fix Access Violation when using lld & ThinLTO on windows-msvc) - #103521 (Avoid possible infinite loop when next_point reaching the end of file) - #103559 (first move on a nested span_label) - #103778 (Update several crates for improved support of the new targets) - #103827 (Properly remap and check for substs compatibility in `confirm_impl_trait_in_trait_candidate`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-08Rollup merge of #103559 - AndyJado:var_span_label, r=davidtwcoManish Goregaokar-4/+60
first move on a nested span_label trying not to be smart this time.
2022-11-09Auto merge of #103171 - jackh726:gen-interior-hrtb-error, r=cjgillotbors-1/+4
Better error for HRTB error from generator interior cc #100013 This is just a first pass at an error. It could be better, and shouldn't really be emitted in the first place. But this is better than what was being emitted before.
2022-11-08add 'ty_error_with_guaranteed' and 'const_error_with_guaranteed'yukang-6/+7
2022-11-08Rollup merge of #103865 - compiler-errors:fallback-has-occurred-tracking, ↵Dylan DPC-1/+1
r=eholk Move `fallback_has_occurred` state tracking to `FnCtxt` Removes a ton of callsites that defaulted to `false`
2022-11-07Add an optional Span to BrAnon and use it to print better error for HRTB ↵Jack Huey-1/+4
error from generator interior
2022-11-07Auto merge of #103218 - CastilloDel:infer, r=jackh726bors-4/+4
Remove #![allow(rustc::potential_query_instability)] from rustc_infer Related to #84447 This PR probably needs to be benchmarked to check for regressions.
2022-11-06Auto merge of #102618 - aliemjay:simplify-closure-promote, r=compiler-errorsbors-258/+103
rework applying closure requirements in borrowck Previously the promoted closure constraints were registered under the category `ConstraintCategory::ClosureBounds` in `type_check::prove_closure_bounds()` and then mapped back their original category in `regions_infer::best_blame_constraint` using the complicated map `closure_bounds_mapping`. Now we're registering promoted constraints under their original category and span earlier in `type_check::prove_closure_bounds`. See commit messages. Fixes #99245
2022-11-06Move fallback_has_occurred to FnCtxtMichael Goulet-1/+1
2022-11-05first move on a nested span_labelAndyJado-4/+60
Apply suggestions from code review Co-authored-by: David Wood <agile.lion3441@fuligin.ink>
2022-11-05use spans in TypeTest rather than mir::LocationAli MJ Al-Nasrawy-23/+11
Spans are independent of the body being borrow-checked, so they don't need remapping when promoting type-tests and they yield more specific error spans inside bodies of closures/inline consts.
2022-11-05simplify applying closure requirementsAli MJ Al-Nasrawy-235/+92
Don't use `ConstraintCategory::ClosureBounds`! Set the category and the span for the promoted constraints to that of the original constraint earlier than before. This eliminates the need for `closure_bounds_mapping`.
2022-11-05Rollup merge of #103868 - compiler-errors:trait-engine-less, r=jackh726Matthias Krüger-35/+27
Use `TraitEngine` (by itself) less Replace `TraitEngine` in favor of `ObligationCtxt` or `fully_solve_*`, improving code readability.