summary refs log tree commit diff
path: root/compiler/rustc_infer/src
AgeCommit message (Collapse)AuthorLines
2022-04-02Rollup merge of #95560 - lcnr:obligation-cause, r=oli-obkDylan DPC-13/+17
convert more `DefId`s to `LocalDefId`
2022-04-02Rollup merge of #95559 - lcnr:inferctxt-typeck, r=oli-obkDylan DPC-20/+10
small type system refactoring
2022-04-01convert more `DefId`s to `LocalDefId`lcnr-13/+17
2022-04-01remove `unify_key::replace_if_possible`lcnr-16/+7
2022-04-01update commentslcnr-4/+3
2022-04-01Rollup merge of #95260 - compiler-errors:fn, r=davidtwcoMatthias Krüger-1/+5
Better suggestions for `Fn`-family trait selection errors 1. Suppress suggestions to add `std::ops::Fn{,Mut,Once}` bounds when a type already implements `Fn{,Mut,Once}` 2. Add a note that points out that a type does in fact implement `Fn{,Mut,Once}`, but the arguments vary (either by number or by actual arguments) 3. Add a note that points out that a type does in fact implement `Fn{,Mut,Once}`, but not the right one (e.g. implements `FnMut`, but `Fn` is required). Fixes #95147
2022-03-31remove unused field from `infcx`lcnr-26/+2
2022-03-30Addressed comments by @compiler-errors and @bjorn3Yuri Astrakhan-2/+2
2022-03-30Spellchecking compiler commentsYuri Astrakhan-16/+16
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-30Auto merge of #94081 - oli-obk:lazy_tait_take_two, r=nikomatsakisbors-307/+603
Lazy type-alias-impl-trait take two ### user visible change 1: RPIT inference from recursive call sites Lazy TAIT has an insta-stable change. The following snippet now compiles, because opaque types can now have their hidden type set from wherever the opaque type is mentioned. ```rust fn bar(b: bool) -> impl std::fmt::Debug { if b { return 42 } let x: u32 = bar(false); // this errors on stable 99 } ``` The return type of `bar` stays opaque, you can't do `bar(false) + 42`, you need to actually mention the hidden type. ### user visible change 2: divergence between RPIT and TAIT in return statements Note that `return` statements and the trailing return expression are special with RPIT (but not TAIT). So ```rust #![feature(type_alias_impl_trait)] type Foo = impl std::fmt::Debug; fn foo(b: bool) -> Foo { if b { return vec![42]; } std::iter::empty().collect() //~ ERROR `Foo` cannot be built from an iterator } fn bar(b: bool) -> impl std::fmt::Debug { if b { return vec![42] } std::iter::empty().collect() // Works, magic (accidentally stabilized, not intended) } ``` But when we are working with the return value of a recursive call, the behavior of RPIT and TAIT is the same: ```rust type Foo = impl std::fmt::Debug; fn foo(b: bool) -> Foo { if b { return vec![]; } let mut x = foo(false); x = std::iter::empty().collect(); //~ ERROR `Foo` cannot be built from an iterator vec![] } fn bar(b: bool) -> impl std::fmt::Debug { if b { return vec![]; } let mut x = bar(false); x = std::iter::empty().collect(); //~ ERROR `impl Debug` cannot be built from an iterator vec![] } ``` ### user visible change 3: TAIT does not merge types across branches In contrast to RPIT, TAIT does not merge types across branches, so the following does not compile. ```rust type Foo = impl std::fmt::Debug; fn foo(b: bool) -> Foo { if b { vec![42_i32] } else { std::iter::empty().collect() //~^ ERROR `Foo` cannot be built from an iterator over elements of type `_` } } ``` It is easy to support, but we should make an explicit decision to include the additional complexity in the implementation (it's not much, see a721052457cf513487fb4266e3ade65c29b272d2 which needs to be reverted to enable this). ### PR formalities previous attempt: #92007 This PR also includes #92306 and #93783, as they were reverted along with #92007 in #93893 fixes #93411 fixes #88236 fixes #89312 fixes #87340 fixes #86800 fixes #86719 fixes #84073 fixes #83919 fixes #82139 fixes #77987 fixes #74282 fixes #67830 fixes #62742 fixes #54895
2022-03-28Also use the RPIT back compat hack in trait projectionOli Scherer-4/+9
2022-03-28Fix mixing lazy TAIT and RPIT in their defining scopesOli Scherer-39/+40
2022-03-28Merge two duplicates of the same logic into a common functionOli Scherer-1/+44
2022-03-28Remove opaque type obligation and just register opaque types as they are ↵Oli Scherer-109/+81
encountered. This also registers obligations for the hidden type immediately.
2022-03-28Revert to inference variable based hidden type computation for RPITOli Scherer-1/+1
2022-03-28Have the spans of TAIT type conflict errors point to the actual site instead ↵Oli Scherer-38/+6
of the owning function
2022-03-28Remove some dead codeOli Scherer-14/+2
2022-03-28Revert "Auto merge of #93893 - oli-obk:sad_revert, r=oli-obk"Oli Scherer-283/+602
This reverts commit 6499c5e7fc173a3f55b7a3bd1e6a50e9edef782d, reversing changes made to 78450d2d602b06d9b94349aaf8cece1a4acaf3a8.
2022-03-27suggest wrapping patterns with compatible enum variantsMichael Goulet-0/+69
2022-03-27review comments and rebaseEsteban Kuber-9/+9
2022-03-27Drive by: handle references in `same_type_modulo_infer`Esteban Kuber-0/+3
2022-03-27Point (again) to more expressions with their type, even if not fully resolvedEsteban Kuber-1/+2
2022-03-27Eagerly replace `{integer}`/`{float}` with `i32`/`f64` for suggestionEsteban Kuber-0/+31
2022-03-25Auto merge of #95082 - spastorino:overlap-inherent-impls, r=nikomatsakisbors-1/+24
Overlap inherent impls r? `@nikomatsakis` Closes #94526
2022-03-25Rollup merge of #95179 - b-naber:eval-in-try-unify, r=lcnrDylan DPC-6/+22
Try to evaluate in try unify and postpone resolution of constants that contain inference variables We want code like that in [`ui/const-generics/generic_const_exprs/eval-try-unify.rs`](https://github.com/rust-lang/rust/compare/master...b-naber:eval-in-try-unify?expand=1#diff-8027038201cf07a6c96abf3cbf0b0f4fdd8a64ce6292435f01c8ed995b87fe9b) to compile. To do that we need to try to evaluate constants in `try_unify_abstract_consts`, this requires us to be more careful about what constants we try to resolve, specifically we cannot try to resolve constants that still contain inference variables. r? `@lcnr`
2022-03-24Extract impl_subject_and_oglibations fn and make equate receive subjectsSantiago Pastorino-1/+24
2022-03-23Better suggestions for Fn trait selection errorsMichael Goulet-1/+5
2022-03-24Properly track `ImplObligation`sEsteban Kuber-1/+1
Instead of probing for all possible impls that could have caused an `ImplObligation`, keep track of its `DefId` and obligation spans for accurate error reporting. Follow up to #89580. Addresses #89418. Remove some unnecessary clones. Tweak output for auto trait impl obligations.
2022-03-22erase region in ParamEnvAnd and make ConstUnifyCtxt privateb-naber-4/+4
2022-03-22dont canonicalize in try_unify_abstract_consts and erase regions insteadb-naber-8/+10
2022-03-22fix previous failures and address reviewb-naber-7/+6
2022-03-21dont try to unify unevaluated constants that contain infer varsb-naber-1/+15
2022-03-21try to evaluate in try_unifyb-naber-1/+2
2022-03-16rustc_error: make ErrorReported impossible to constructmark-21/+24
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-12Auto merge of #94733 - nnethercote:fix-AdtDef-interning, r=fee1-deadbors-9/+11
Improve `AdtDef` interning. This commit makes `AdtDef` use `Interned`. Much of the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`. r? `@fee1-dead`
2022-03-11update commentlcnr-7/+4
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-9/+11
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-03-10Auto merge of #94737 - lcnr:pass-stuff-by-value, r=davidtwcobors-4/+4
add `#[rustc_pass_by_value]` to more types the only interesting changes here should be to `TransitiveRelation`, but I believe to be highly unlikely that we will ever use a non `Copy` type with this type.
2022-03-09Rollup merge of #94312 - pierwill:fix-94311-lattice-docs, r=jackh726Dylan DPC-12/+20
Edit `rustc_trait_selection::infer::lattice` docs Closes #94311. Removes mentions of outdated/missing type and filename (`infer.rs` and `LatticeValue`).
2022-03-08add `#[rustc_pass_by_value]` to more typeslcnr-4/+4
2022-03-03Rollup merge of #94555 - cuishuang:master, r=oli-obkMatthias Krüger-2/+2
all: fix some typos Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-03all: fix some typoscuishuang-2/+2
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-03-028 - Make more use of `let_chains`Caio-185/+145
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-44/+44
2022-03-01add suggestion to update trait if error is in implFausto-2/+8
2022-02-28Suggest adding a new lifetime parameter when two elided lifetimes should ↵Fausto-52/+48
match up for traits and impls. Issue #94462
2022-02-28Edit `rustc_trait_selection::infer::lattice` docspierwill-12/+20
Remove mentions of outdated/missing type and filename (`infer.rs` and `LatticeValue`).
2022-02-25Auto merge of #94290 - Mark-Simulacrum:bump-bootstrap, r=pietroalbinibors-1/+1
Bump bootstrap to 1.60 This bumps the bootstrap compiler to 1.60 and cleans up cfgs and Span's rustc_pass_by_value (enabled by the bootstrap bump).
2022-02-25Rollup merge of #93845 - compiler-errors:in-band-lifetimes, r=cjgillotMatthias Krüger-8/+8
Remove in band lifetimes As discussed in t-lang backlog bonanza, the `in_band_lifetimes` FCP closed in favor for the feature not being stabilized. This PR removes `#![feature(in_band_lifetimes)]` in its entirety. Let me know if this PR is too hasty, and if we should instead do something intermediate for deprecate the feature first. r? `@scottmcm` (or feel free to reassign, just saw your last comment on #44524) Closes #44524
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1