about summary refs log tree commit diff
path: root/compiler/rustc_borrowck
AgeCommit message (Collapse)AuthorLines
2022-11-25Introduce PredicateKind::ClauseSantiago Pastorino-18/+22
2022-11-24Rollup merge of #104773 - oli-obk:overlap, r=lcnrMatthias Krüger-10/+4
OpaqueCast projections are always overlapping, they can't possibly be disjoint r? ``@lcnr``
2022-11-24Auto merge of #104321 - Swatinem:async-gen, r=oli-obkbors-5/+11
Avoid `GenFuture` shim when compiling async constructs Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through. --- Given this demo code: ```rust pub async fn a(arg: u32) -> Backtrace { let bt = b().await; let _arg = arg; bt } pub async fn b() -> Backtrace { Backtrace::force_capture() } ``` I would get the following with the latest stable compiler (on Windows): ``` 4: async_codegen::b::async_fn$0 at .\src\lib.rs:10 5: core::future::from_generator::impl$1::poll<enum2$<async_codegen::b::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 6: async_codegen::a::async_fn$0 at .\src\lib.rs:4 7: core::future::from_generator::impl$1::poll<enum2$<async_codegen::a::async_fn_env$0> > at /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\future\mod.rs:91 ``` whereas now I get a much cleaner stack trace: ``` 3: async_codegen::b::async_fn$0 at .\src\lib.rs:10 4: async_codegen::a::async_fn$0 at .\src\lib.rs:4 ```
2022-11-24Avoid `GenFuture` shim when compiling async constructsArpad Borsos-5/+11
Previously, async constructs would be lowered to "normal" generators, with an additional `from_generator` / `GenFuture` shim in between to convert from `Generator` to `Future`. The compiler will now special-case these generators internally so that async constructs will *directly* implement `Future` without the need to go through the `from_generator` / `GenFuture` shim. The primary motivation for this change was hiding this implementation detail in stack traces and debuginfo, but it can in theory also help the optimizer as there is less abstractions to see through.
2022-11-23Fix rebaseEsteban Küber-2/+1
2022-11-23Add `Mutability::mutably_str`Maybe Waffle-4/+1
2022-11-23Add `Mutability::{is_mut,is_not}`Maybe Waffle-1/+1
2022-11-23Account for closuresEsteban Küber-5/+9
2022-11-23Account for `x @ y` and suggest `ref x @ ref y`Esteban Küber-8/+22
2022-11-23review comments: inline bindings and fix typoEsteban Küber-5/+9
2022-11-23Tweak output to account for alternative bindings in the same patternEsteban Küber-22/+17
2022-11-23Fix wordingEsteban Küber-1/+1
2022-11-23Tweak output in for loopsEsteban Küber-3/+11
Do not suggest `.clone()` as we already suggest borrowing the iterated value.
2022-11-23Remove logic duplicationEsteban Küber-33/+18
2022-11-23Extract suggestion logic to its own methodEsteban Küber-140/+156
2022-11-23Use `type_implements_trait`Esteban Küber-20/+5
2022-11-23Do not suggest `ref` multiple times for the same bindingEsteban Küber-1/+3
2022-11-23Suggest `.clone()` or `ref binding` on E0382Esteban Küber-19/+173
2022-11-23Add `Mutability::ref_prefix_str`, order `Mutability`, simplify codeMaybe Waffle-12/+8
2022-11-23Separate lifetime ident from resolution in HIR.Camille GILLOT-27/+7
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`.