about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
AgeCommit message (Collapse)AuthorLines
2022-12-14Ensure no one constructs `AliasTy`s themselvesOli Scherer-2/+2
2022-12-14Auto merge of #104986 - compiler-errors:opaques, r=oli-obkbors-3/+3
Combine `ty::Projection` and `ty::Opaque` into `ty::Alias` Implements https://github.com/rust-lang/types-team/issues/79. This PR consolidates `ty::Projection` and `ty::Opaque` into a single `ty::Alias`, with an `AliasKind` and `AliasTy` type (renamed from `ty::ProjectionTy`, which is the inner data of `ty::Projection`) defined as so: ``` enum AliasKind { Projection, Opaque, } struct AliasTy<'tcx> { def_id: DefId, substs: SubstsRef<'tcx>, } ``` Since we don't have access to `TyCtxt` in type flags computation, and because repeatedly calling `DefKind` on the def-id is expensive, these two types are distinguished with `ty::AliasKind`, conveniently glob-imported into `ty::{Projection, Opaque}`. For example: ```diff match ty.kind() { - ty::Opaque(..) => + ty::Alias(ty::Opaque, ..) => {} _ => {} } ``` This PR also consolidates match arms that treated `ty::Opaque` and `ty::Projection` identically. r? `@ghost`
2022-12-13Rollup merge of #105500 - oli-obk:unhide_unknown_spans, r=estebankMatthias Krüger-8/+16
Make some diagnostics not depend on the source of what they reference being available r? `@estebank` follow up to https://github.com/rust-lang/rust/pull/104449
2022-12-13Account for dereference expressionsEsteban Küber-7/+22
2022-12-13Fix span for `&mut ` removal suggestionEsteban Küber-0/+1
2022-12-13Suggest `ref` for some patterns as a fallbackEsteban Küber-10/+16
2022-12-13Change pattern borrowing suggestions to be verboseEsteban Küber-29/+35
Synthesize a more accurate span and use verbose suggestion output to make the message clearer.
2022-12-13Combine projection and opaque into aliasMichael Goulet-2/+2
2022-12-13squash OpaqueTy and ProjectionTy into AliasTyMichael Goulet-2/+2
2022-12-13Use ty::OpaqueTy everywhereMichael Goulet-3/+3
2022-12-13Stop pointing to operators if their libcore method source is not availableOli Scherer-6/+1
2022-12-13Clarify what "this" meansOli Scherer-2/+15
2022-12-13remove unnecessary uses of `clone`Takayuki Maeda-1/+1
2022-12-09Remove unneeded field from `SwitchTargets`Jakob Degen-19/+4
2022-12-07Rollup merge of #105368 - WaffleLapkin:deref-even-harder, r=TaKO8KiMatthias Krüger-160/+145
Remove more `ref` patterns from the compiler Previous PR: #105045
2022-12-06`rustc_borrowck`: remove `ref` patternsMaybe Waffle-160/+145
2022-12-06drive-by: Default param for ToPredicateMichael Goulet-4/+2
2022-12-01Create `format_args` as late as possibleOli Scherer-6/+4
2022-11-30Auto merge of #104905 - compiler-errors:normalization-changes, r=spastorinobors-4/+4
Some initial normalization method changes 1. Rename `AtExt::normalize` to `QueryNormalizeExt::query_normalize` (using the `QueryNormalizer`) 2. Introduce `NormalizeExt::normalize` to replace `partially_normalize_associated_types_in` (using the `AssocTypeNormalizer`) 3. Rename `FnCtxt::normalize_associated_types_in` to `FnCtxt::normalize` 4. Remove some unused other normalization fns in `Inherited` and `FnCtxt` Also includes one drive-by where we're no longer creating a `FnCtxt` inside of `check_fn`, but passing it in. This means we don't need such weird `FnCtxt` construction logic. Stacked on top of #104835 for convenience. r? types
2022-11-29Rollup merge of #103876 - oli-obk:tait_implications, r=lcnrMatthias Krüger-6/+6
type alias impl trait: add tests showing that hidden type only outlives lifetimes that occur in bounds fixes #103642 https://github.com/rust-lang/rust/pull/102417 only made sure that hidden types cannot outlive lifetimes other than the ones mentioned on bounds, but didn't allow us to actually infer anything from that. cc `@aliemjay`
2022-11-29Rollup merge of #104951 - Swatinem:async-kind, r=compiler-errorsMatthias Krüger-6/+1
Simplify checking for `GeneratorKind::Async` Adds a helper method around `generator_kind` that makes matching async constructs simpler.
2022-11-28Simplify checking for `GeneratorKind::Async`Arpad Borsos-6/+1
Adds a helper method around `generator_kind` that makes matching async constructs simpler.
2022-11-28Make ObligationCtxt::normalize take cause by borrowMichael Goulet-1/+1
2022-11-28partially_normalize_... -> At::normalizeMichael Goulet-3/+3
2022-11-28Rollup merge of #104956 - mucinoab:issue-104870, r=compiler-errorsMatthias Krüger-7/+9
Avoid ICE if the Clone trait is not found while building error suggestions Fixes #104870 r? `@compiler-errors`
2022-11-27Avoid ICE if the Clone trait is not found while building error suggestionsBruno A. Muciño-7/+9
2022-11-27Rollup merge of #104976 - WaffleLapkin:move_comments, r=cjgillotMatthias Krüger-5/+5
Prefer doc comments over `//`-comments in compiler Doc comments are generally nicer: they show up in the documentation, they are shown in IDEs when you hover other mentions of items, etc. Thus it makes sense to use them instead of `//`-comments.
2022-11-27Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errorsbors-27/+7
Separate lifetime ident from lifetime resolution in HIR Drive-by: change how suggested generic args are computed. Fixes https://github.com/rust-lang/rust/issues/103815 I recommend reviewing commit-by-commit.
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-5/+5
2022-11-26Rollup merge of #104786 - WaffleLapkin:amp-mut-help, r=compiler-errorsGuillaume Gomez-16/+9
Use the power of adding helper function to simplify code w/ `Mutability` r? `@compiler-errors`
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