about summary refs log tree commit diff
path: root/compiler/rustc_infer
AgeCommit message (Collapse)AuthorLines
2023-01-28Rollup merge of #107339 - aliemjay:covariant, r=lcnrMatthias Krüger-7/+10
internally change regions to be covariant Surprisingly, we consider the reference type `&'a T` to be contravaraint in its lifetime parameter. This is confusing and conflicts with the documentation we have in the reference, rustnomicon, and rustc-dev-guide. This also arguably not the correct use of terminology since we can use `&'static u8` in a place where `&' a u8` is expected, this implies that `&'static u8 <: &' a u8` and consequently `'static <: ' a`, hence covariance. Because of this, when relating two types, we used to switch the argument positions in a confusing way: `Subtype(&'a u8 <: &'b u8) => Subtype('b <: 'a) => Outlives('a: 'b) => RegionSubRegion('b <= 'a)` The reason for the current behavior is probably that we wanted `Subtype('b <: 'a)` and `RegionSubRegion('b <= 'a)` to be equivalent, but I don' t think this is a good reason since these relations are sufficiently different in that the first is a relation in the subtyping lattice and is intrinsic to the type-systems, while the the second relation is an implementation detail of regionck. This PR changes this behavior to use covariance, so.. `Subtype(&'a u8 <: &'b u8) => Subtype('a <: 'b) => Outlives('a: 'b) => RegionSubRegion('b <= 'a) ` Resolves #103676 r? `@lcnr`
2023-01-27Pacify tidy.Camille GILLOT-1/+1
2023-01-27Compute generator saved locals on MIR.Camille GILLOT-0/+8
2023-01-27yeetBoxy-88/+26
2023-01-27Introduce GeneratorWitnessMIR.Camille GILLOT-1/+3
2023-01-27Separate trait selection from ambiguity reporting.Camille GILLOT-3/+14
2023-01-26fixup new usages of fn_sig, bound_fn_sig after rebasingKyle Matsuda-5/+5
2023-01-26change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add ↵Kyle Matsuda-5/+5
EarlyBinder to fn_sig in metadata
2023-01-26replace usages of fn_sig query with bound_fn_sigKyle Matsuda-1/+1
2023-01-27internally change regions to be covariantAli MJ Al-Nasrawy-7/+10
2023-01-26Intern CanonicalVarValuesMichael Goulet-18/+15
2023-01-26Rollup merge of #107304 - ↵Matthias Krüger-1/+657
Nilstrieb:ᐸTy as PartialEqᐳ::eq because what else are we gonna use in rustc_middle, r=compiler-errors Use `can_eq` to compare types for default assoc type error This correctly handles inference variables like `{integer}`. I had to move all of this `note_and_explain` code to `rustc_infer`, it made no sense for it to be in `rustc_middle` anyways. The commits are reviewed separately. Fixes #106968
2023-01-26improve fn pointer notesMatthew J Perez-8/+44
- add note and suggestion for casting both expected and found fn items to fn pointers - add note for casting expected fn item to fn pointer
2023-01-25Use `can_eq` to compare types for default assoc type errorNilstrieb-3/+9
This works correctly with inference variables.
2023-01-25Move `note_and_explain_type_err` from `rustc_middle` to `rustc_infer`Nilstrieb-1/+651
This way we can properly deal with the types.
2023-01-25Auto merge of #103902 - vincenzopalazzo:macros/obligation_rulesv2, r=oli-obkbors-14/+6
use `LocalDefId` instead of `HirId` in trait resolution to simplify the obligation clause resolution This commit introduces a refactoring suggested by `@lcnr` to simplify the obligation clause resolution. This is just the first PR that introduces a type of refactoring, but others PRs will follow this to introduce name changing to change from the variable name from `body_id` to something else. Fixes https://github.com/rust-lang/rust/issues/104827 Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> `@rustbot` r? `@lcnr`
2023-01-24Add suggestions for function pointersMatthew J Perez-2/+79
- On compiler-error's suggestion of moving this lower down the stack, along the path of `report_mismatched_types()`, which is used by `rustc_hir_analysis` and `rustc_hir_typeck`. - update ui tests, add test - add suggestions for references to fn pointers - modify `TypeErrCtxt::same_type_modulo_infer` to take `T: relate::Relate` instead of `Ty`
2023-01-23Point at specific field in struct literal when trait fulfillment failsNathan Fenner-24/+26
2023-01-23fix: use LocalDefId instead of HirId in trait resVincenzo Palazzo-14/+6
use LocalDefId instead of HirId in trait resolution to simplify the obligation clause resolution Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-01-23Rollup merge of #104926 - spastorino:calculate_diverging_fallback-cleanups, ↵Dylan DPC-3/+0
r=lcnr Move relationships from FulfillmentContext to Inherited r? `@lcnr`
2023-01-22Remove confusing 'while checking' note from opaque future type mismatchesMichael Goulet-46/+16
2023-01-22Store relationships on InherentSantiago Pastorino-3/+0
2023-01-22Rollup merge of #107111 - chenyukang:yukang/fix-107090-fluent-parameters, ↵Matthias Krüger-1/+6
r=petrochenkov Fix missing arguments issues and copy-paste bug for fluent Fixes #107090
2023-01-20Fix typo in opaque_types.rsIkko Eltociear Ashimine-2/+2
paramters -> parameters
2023-01-20Auto merge of #106090 - WaffleLapkin:dereffffffffff, r=Nilstriebbors-11/+11
Remove some `ref` patterns from the compiler Previous PR: https://github.com/rust-lang/rust/pull/105368 r? `@Nilstrieb`
2023-01-19even more unify Projection/Opaque in outlives codeAli MJ Al-Nasrawy-139/+65
2023-01-18Fix #107090, fix missing arguments for fluentyukang-1/+6
2023-01-17Stop using `BREAK` & `CONTINUE` in compilerScott McMurray-10/+10
Switching them to `Break(())` and `Continue(())` instead. libs-api would like to remove these constants, so stop using them in compiler to make the removal PR later smaller.
2023-01-17Rollup merge of #106970 - kylematsuda:earlybinder-item-bounds, r=lcnrMatthias Krüger-1/+1
Switch to `EarlyBinder` for `item_bounds` query Part of the work to finish #105779 (also see https://github.com/rust-lang/types-team/issues/78). Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This adds `EarlyBinder` to the return type of the `item_bounds` query and removes `bound_item_bounds`. r? `@lcnr`
2023-01-17Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726Matthias Krüger-18/+18
Remove double spaces after dots in comments Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17change item_bounds query to return EarlyBinder; remove bound_item_bounds queryKyle Matsuda-1/+1
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-18/+18
2023-01-17Don't call closures immediately, use `try{}` blocksMaybe Waffle-11/+11
2023-01-17Rollup merge of #106829 - compiler-errors:more-alias-combine, r=spastorinoMatthias Krüger-86/+41
Unify `Opaque`/`Projection` handling in region outlives code They share basically identical paths in most places which are even easier to unify now that they're both `ty::Alias` r? types
2023-01-15Remove bound_{explicit,}_item_boundsMichael Goulet-3/+2
2023-01-15Rollup merge of #106859 - tialaramex:master, r=NilstriebMatthias Krüger-0/+16
Suggestion for type mismatch when we need a u8 but the programmer wrote a char literal Today Rust just points out that we have a char and we need a u8, but if I wrote 'A' then I could fix this by just writing b'A' instead. This code should detect the case where we're about to report a type mismatch of this kind, and the programmer wrote a char literal, and the char they wrote is ASCII, so therefore just prefixing b to make a byte literal will do what they meant. I have definitely written this mistake more than once, it's not difficult to figure out what to do, but the compiler might as well tell us anyway. I provided a test with two simple examples where the suggestion is appropriate, and one where it is not because the char literal is not ASCII, showing that the suggestion is only triggered in the former cases. I have contributed only a small typo doc fix before, so this is my first substantive rustc change.
2023-01-14Improve E0308: suggest user meant to use byte literal, w/ tests and fixNick Lamb-0/+16
suggested by Nilstrieb Co-authored-by: nils <48135649+Nilstrieb@users.noreply.github.com>
2023-01-14Auto merge of #106696 - kylematsuda:early-binder, r=lcnrbors-0/+1
Switch to `EarlyBinder` for `const_param_default` and `impl_trait_ref` queries Part of the work to close #105779 and implement https://github.com/rust-lang/types-team/issues/78. Several queries `X` have a `bound_X` variant that wraps the output in `EarlyBinder`. This PR adds `EarlyBinder` to the return type of `const_param_default` and `impl_trait_ref`, and removes their `bound_X` variants. r? `@lcnr`
2023-01-14change impl_trait_ref query to return EarlyBinder; remove ↵Kyle Matsuda-1/+1
bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata
2023-01-14change usages of impl_trait_ref to bound_impl_trait_refKyle Matsuda-1/+2
2023-01-13Unify Opaque/Projection handling in region outlives codeMichael Goulet-86/+41
2023-01-13Keep obligation chain when elaborating obligationsEsteban Küber-3/+15
2023-01-12is_ty_infer -> is_ty_or_numeric_inferMichael Goulet-7/+7
2023-01-12Rollup merge of #106714 - Ezrashaw:remove-e0490, r=davidtwconils-61/+3
remove unreachable error code `E0490` AFAIK, the untested and undocumented error code `E0490` is now unreachable, it was from the days of the original borrow checker. cc ``@GuillaumeGomez`` #61137
2023-01-12Auto merge of #106760 - compiler-errors:rollup-0bogyco, r=compiler-errorsbors-1/+10
Rollup of 8 pull requests Successful merges: - #103236 (doc: rewrite doc for signed int::{carrying_add,borrowing_sub}) - #103800 (Stabilize `::{core,std}::pin::pin!`) - #106097 (Migrate mir_build diagnostics 2 of 3) - #106170 (Move autoderef to `rustc_hir_analysis`) - #106323 (Stabilize f16c_target_feature) - #106360 (Tweak E0277 `&`-removal suggestions) - #106524 (Label `struct/enum constructor` instead of `fn item`, mention that it should be called on type mismatch) - #106739 (Remove `<dyn AstConv<'tcx>>::fun(c, ...)` calls in favour of `c.astconv().fun(...)`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-01-12remove unreachable error code `E0490`Ezra Shaw-61/+3
2023-01-11Fix invalid syntax in impl Trait parameter type suggestions for E0311yanchen4791-17/+77
2023-01-11Move autoderef to rustc_hir_analysisMichael Goulet-1/+10
2023-01-11Change `src/test` to `tests` in source files, fix tidy and testsAlbert Larsan-3/+3
2023-01-10Rollup merge of #106204 - compiler-errors:no-take-opaques-in-compare, r=oli-obkYuki Okushi-9/+7
No need to take opaques in `check_type_bounds` `InferCtxt` already has its defining use anchor set to err r? ``@oli-obk``