about summary refs log tree commit diff
path: root/compiler/rustc_infer
AgeCommit message (Collapse)AuthorLines
2022-02-08Rollup merge of #92715 - chordtoll:empty-string, r=davidtwcoMatthias Krüger-1/+1
Do not suggest char literal for zero-length strings PR #92507 adds a hint to switch to single quotes when a char is expected and a single-character string literal is provided. The check to ensure the string literal is one character long missed the 0-char case, and would incorrectly offer the hint. This PR adds the missing check, and a test case to confirm the new behavior.
2022-02-08Rollup merge of #93728 - JulianKnodt:toterm, r=oli-obkMatthias Krüger-43/+63
Add in ValuePair::Term This adds in an enum when matching on positions which can either be types or consts. It will default to emitting old special cased error messages for types. r? `@oli-obk` cc `@matthiaskrgr` Fixes #93578
2022-02-07Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakisbors-283/+602
Lazy type-alias-impl-trait Previously opaque types were processed by 1. replacing all mentions of them with inference variables 2. memorizing these inference variables in a side-table 3. at the end of typeck, resolve the inference variables in the side table and use the resolved type as the hidden type of the opaque type This worked okayish for `impl Trait` in return position, but required lots of roundabout type inference hacks and processing. This PR instead stops this process of replacing opaque types with inference variables, and just keeps the opaque types around. Whenever an opaque type `O` is compared with another type `T`, we make the comparison succeed and record `T` as the hidden type. If `O` is compared to `U` while there is a recorded hidden type for it, we grab the recorded type (`T`) and compare that against `U`. This makes implementing * https://github.com/rust-lang/rfcs/pull/2515 much simpler (previous attempts on the inference based scheme were very prone to ICEs and general misbehaviour that was not explainable except by random implementation defined oddities). r? `@nikomatsakis` fixes #93411 fixes #88236
2022-02-07Rm ValuePairs::Ty/Constkadmin-42/+50
Remove old value pairs which is a strict subset of Terms.
2022-02-07Rollup merge of #91530 - bobrippling:suggest-1-tuple-parens, r=camelidMara Bos-13/+37
Suggest 1-tuple parentheses on exprs without existing parens A follow-on from #86116, split out from #90677. This alters the suggestion to add a trailing comma to create a 1-tuple - previously we would only apply this if the relevant expression was parenthesised. We now make the suggestion regardless of parentheses, which reduces the fragility of the check (w.r.t formatting). e.g. ```rust let a: Option<(i32,)> = Some(3); ``` gets the below suggestion: ```rust let a: Option<(i32,)> = Some((3,)); // ^ ^^ ``` This change also improves the suggestion in other ways, such as by only making the suggestion if the types would match after the suggestion is applied and making the suggestion a multipart suggestion.
2022-02-07Add in ValuePair::Termkadmin-10/+22
This adds in an enum when matching on positions which can either be types or consts. It will default to emitting old special cased error messages for types.
2022-02-06Merge duplicate suggestion stringRob Pilling-7/+4
2022-02-06Factor out emit_tuple_wrap_err, improve ApplicabilityRob Pilling-29/+39
2022-02-03Clean up opaque type obligations in query resultsOli Scherer-8/+7
2022-02-02Only prevent TAITs from defining each other, RPIT and async are fine, they ↵Oli Scherer-1/+8
only ever have one defining site, and it is ordered correctly around expected and actual type in type comparisons
2022-02-02Prevent two opaque types in their defining scopes from being defined via the ↵Oli Scherer-41/+63
other
2022-02-02run rustfmtOli Scherer-7/+9
2022-02-02Simplify diffOli Scherer-2/+2
2022-02-02Undo a diffOli Scherer-2/+2
2022-02-02Inline a function that is only used onceOli Scherer-53/+39
2022-02-02Remove unnecessary fieldOli Scherer-24/+12
2022-02-02Remove unnecessary closure in favour of just passing the argument directlyOli Scherer-17/+20
2022-02-02Remove the `Instantiator` now that we don't recurse within it anymoreOli Scherer-28/+19
2022-02-02Inline a function that is only ever used in one placeOli Scherer-68/+2
2022-02-02Clean up leftovers from eager hidden type mergingOli Scherer-65/+10
2022-02-02Eagerly merge hidden types.Oli Scherer-32/+42
2022-02-02Stop generating inference vars for nested impl trait and let type equality ↵Oli Scherer-16/+0
handle it. This means we stop supporting the case where a locally defined trait has only a single impl so we can always use that impl (see nested-tait-inference.rs).
2022-02-02Register member constraints on the final merged hidden typeOli Scherer-7/+6
Previously we did this per hidden type candiate, which didn't always have all the information available.
2022-02-02Lazily resolve type-alias-impl-trait defining usesOli Scherer-220/+574
by using an opaque type obligation to bubble up comparisons between opaque types and other types Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2022-02-02More sanity checksOli Scherer-2/+7
2022-02-02Expose current span to type equality checking in nllOli Scherer-0/+7
2022-02-02Add some sanity assertions to make sure we use the opaque types correctlyOli Scherer-1/+11
2022-02-02Add roll back infrastructure for opaque type cachesOli Scherer-29/+102
2022-02-01Auto merge of #93285 - JulianKnodt:const_eq_2, r=oli-obkbors-2/+26
Continue work on associated const equality This actually implements some more complex logic for assigning associated consts to values. Inside of projection candidates, it now defers to a separate function for either consts or types. To reduce amount of code, projections are now generic over T, where T is either a Type or a Const. I can add some comments back later, but this was the fastest way to implement it. It also now finds the correct type of consts in type_of. --- The current main TODO is finding the const of the def id for the LeafDef. Right now it works if the function isn't called, but once you use the trait impl with the bound it fails inside projection. I was hoping to get some help in getting the `&'tcx ty::Const<'tcx>`, in addition to a bunch of other `todo!()`s which I think may not be hit. r? `@oli-obk` Updates #92827
2022-02-01Fix w/ commentskadmin-4/+10
2022-02-01add a rustc::query_stability lintlcnr-0/+1
2022-01-31Add ValuePairs::Terms & Fix compile errorkadmin-10/+4
And use correct substs.
2022-01-31Rollup merge of #90277 - pierwill:fix-70258-inference-terms, r=jackh726Matthias Krüger-1/+1
Improve terminology around "after typeck" Closes #70258.
2022-01-28Only suggest 1-tuple if expected and found types matchRob Pilling-20/+28
2022-01-28Handle existing parentheses when suggesting trailing-tuple-commaRob Pilling-8/+21
2022-01-28Replace span suggestion with multipartRob Pilling-12/+8
2022-01-28Suggest 1-tuple parentheses, without existing parensRob Pilling-10/+10
2022-01-28Remove generalization over projectionkadmin-2/+26
Instead, just use a term everywhere.
2022-01-26do not register infer var for GAT projection in opaqueMichael Goulet-7/+9
2022-01-25Auto merge of #93095 - Aaron1011:remove-assoc-ident, r=cjgillotbors-4/+4
Store a `Symbol` instead of an `Ident` in `AssocItem` This is the same idea as #92533, but for `AssocItem` instead of `VariantDef`/`FieldDef`. With this change, we no longer have any uses of `#[stable_hasher(project(...))]`
2022-01-21Remove a span from hir::ExprKind::MethodCallCameron Steffen-5/+5
2022-01-19Store a `Symbol` instead of an `Ident` in `AssocItem`Aaron Hill-4/+4
This is the same idea as #92533, but for `AssocItem` instead of `VariantDef`/`FieldDef`. With this change, we no longer have any uses of `#[stable_hasher(project(...))]`
2022-01-19Simplify error reporting code, remove await point wordingTyler Mandry-131/+33
2022-01-19NiceRegionError: Use written return type for async fnTyler Mandry-25/+34
2022-01-19Properly account for binders in get_impl_future_output_tyTyler Mandry-11/+18
2022-01-18Auto merge of #87648 - JulianKnodt:const_eq_constrain, r=oli-obkbors-6/+7
allow eq constraints on associated constants Updates #70256 (cc `@varkor,` `@Centril)`
2022-01-18Rollup merge of #92640 - compiler-errors:array-deref-on-newtype, r=lcnrMatthias Krüger-6/+3
Fix ICEs related to `Deref<Target=[T; N]>` on newtypes 1. Stash a const infer's type into the canonical var during canonicalization, so we can recreate the fresh const infer with that same type. For example, given `[T; _]` we know `_` is a `usize`. If we go from infer => canonical => infer, we shouldn't forget that variable is a usize. Fixes #92626 Fixes #83704 2. Don't stash the autoderef'd slice type that we get from method lookup, but instead recreate it during method confirmation. We need to do this because the type we receive back after picking the method references a type variable that does not exist after probing is done. Fixes #92637 ... A better solution for the second issue would be to actually _properly_ implement `Deref` for `[T; N]` instead of fixing this autoderef hack to stop leaking inference variables. But I actually looked into this, and there are many complications with const impls.
2022-01-17Add term to ExistentialProjectionkadmin-6/+2
Also prevent ICE when adding a const in associated const equality.
2022-01-17Update term for use in more placeskadmin-8/+3
Replace use of `ty()` on term and use it in more places. This will allow more flexibility in the future, but slightly worried it allows items which are consts which only accept types.
2022-01-17Use Term in ProjectionPredicatekadmin-9/+19
ProjectionPredicate should be able to handle both associated types and consts so this adds the first step of that. It mainly just pipes types all the way down, not entirely sure how to handle consts, but hopefully that'll come with time.