summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/astconv
AgeCommit message (Collapse)AuthorLines
2023-03-02Rollup merge of #108575 - compiler-errors:erase, r=estebankMatthias Krüger-2/+4
Erase **all** regions when probing for associated types on ambiguity in astconv Fixes #108562
2023-03-01Rollup merge of #108520 - compiler-errors:one-bound-nit, r=jackh726Matthias Krüger-20/+16
Small cleanup to `one_bound_for_assoc_type` Use fewer closures :)
2023-02-28Erase **all** regions when probing for associated types in astconvMichael Goulet-2/+4
2023-02-26Small cleanup to one_bound_for_assoc_typeMichael Goulet-20/+16
2023-02-25Add ErrorGuaranteed to HIR TyKind::ErrMichael Goulet-1/+1
2023-02-24Replace a `mk_ty` call with `mk_bound`.Nicholas Nethercote-1/+1
2023-02-24Rename many interner functions.Nicholas Nethercote-7/+9
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup
2023-02-23Auto merge of #108369 - compiler-errors:ty-error-more, r=BoxyUwUbors-20/+19
Use `tcx.ty_error_with_guaranteed` in more places, rename variants 1. Use `ty_error_with_guaranteed` more so we don't delay so many span bugs 2. Rename `ty_error_with_guaranteed` to `ty_error`, `ty_error` to `ty_error_misc`. This is to incentivize using the former over the latter in cases where we already are witness to a `ErrorGuaranteed` token. Second commit is just name replacement, so the first commit can be reviewed on its own with more scrutiny.
2023-02-23Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, ↵bors-8/+5
r=compiler-errors,davidtwco,estebank,oli-obk diagnostics: if AssocFn has self argument, describe as method Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods. For anyone not sure why this is being done, see the Reference definitions of these terms in <https://doc.rust-lang.org/1.67.1/reference/items/associated-items.html#methods> > Associated functions whose first parameter is named `self` are called methods and may be invoked using the [method call operator](https://doc.rust-lang.org/1.67.1/reference/expressions/method-call-expr.html), for example, `x.foo()`, as well as the usual function call notation. In particular, while this means it's technically correct for rustc to refer to a method as an associated function (and there are a few cases where it'll still do so), rustc *must never* use the term "method" to refer to an associated function that does not have a `self` parameter.
2023-02-22Rename ty_error_with_guaranteed to ty_error, ty_error to ty_error_miscMichael Goulet-17/+15
2023-02-22Use ty_error_with_guaranteed in many more placesMichael Goulet-5/+6
2023-02-22Remove type-traversal trait aliasesAlan Egerton-1/+1
2023-02-22diagnostics: if AssocFn has self argument, describe as methodMichael Howell-8/+5
Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515 This commit also changes the tooltips on rustdoc intra-doc links targeting methods.
2023-02-20Rollup merge of #108265 - lcnr:cg-error-msg, r=BoxyUwUMatthias Krüger-6/+6
"`const` generic" -> "const parameter"
2023-02-20Rollup merge of #108200 - jhpratt:restricted-damerau-levenshtein-distance, ↵Matthias Krüger-2/+2
r=tmiasko Use restricted Damerau-Levenshtein distance for diagnostics This replaces the existing Levenshtein algorithm with the Damerau-Levenshtein algorithm. This means that "ab" to "ba" is one change (a transposition) instead of two (a deletion and insertion). More specifically, this is a _restricted_ implementation, in that "ca" to "abc" cannot be performed as "ca" → "ac" → "abc", as there is an insertion in the middle of a transposition. I believe that errors like that are sufficiently rare that it's not worth taking into account. This was first brought up [on IRLO](https://internals.rust-lang.org/t/18227) when it was noticed that the diagnostic for `prinltn!` (transposed L and T) was `print!` and not `println!`. Only a single existing UI test was effected, with the result being an objective improvement. ~~I have left the method name and various other references to the Levenshtein algorithm untouched, as the exact manner in which the edit distance is calculated should not be relevant to the caller.~~ r? ``@estebank`` ``@rustbot`` label +A-diagnostics +C-enhancement
2023-02-20`const` generic -> const parameter in err msglcnr-6/+6
2023-02-19Add some FIXMEs for follow-up PRsLeón Orell Valerian Liehr-4/+9
2023-02-19Collect fulfillment errors across implsLeón Orell Valerian Liehr-2/+2
2023-02-19Deduplicate fresh_item_substsLeón Orell Valerian Liehr-31/+34
2023-02-19Fix substitution bugLeón Orell Valerian Liehr-17/+14
2023-02-19Use InferCtxt::probe to properly detect ambiguous candidatesLeón Orell Valerian Liehr-21/+26
2023-02-19Switch from for-loop to filter_mapLeón Orell Valerian Liehr-27/+26
2023-02-19Groundwork for detecting ambiguous candidatesLeón Orell Valerian Liehr-2/+85
NB: Since we are using the same InferCtxt in each iteration, we essentially *spoil* the inference variables and we only ever get at most *one* applicable candidate (only the 1st candidate has clean variables that can still unify correctly).
2023-02-19Make use of ObligationCtxtLeón Orell Valerian Liehr-54/+33
2023-02-19Use the correct ParamEnvLeón Orell Valerian Liehr-1/+1
2023-02-19Type-directed probing for inherent associated typesLeón Orell Valerian Liehr-54/+369
2023-02-19Make public API, docs algorithm-agnosticJacob Pratt-2/+2
2023-02-18Rollup merge of #108186 - ↵Matthias Krüger-46/+8
compiler-errors:closures-with-late-bound-types-r-bad, r=cjgillot Deny non-lifetime bound vars in `for<..> ||` closure binders Moves the check for illegal bound var types from astconv to resolve_bound_vars. If a binder is defined to have a type or const late-bound var that's not allowed, we'll resolve any usages to ty error or const error values, so we shouldn't ever see late-bound types or consts in places they aren't expected. Fixes #108184 Fixes #108181 Fixes #108192
2023-02-18Move late-bound arg type checks to resolve_bound_varsMichael Goulet-46/+8
2023-02-18Auto merge of #108112 - nnethercote:clarify-iterator-interners, ↵bors-2/+2
r=oli-obk,compiler-errors Clarify iterator interners I found the iterator interners very confusing. This PR clarifies things. r? `@compiler-errors`
2023-02-17Replace more `mk_foo` calls with `infer_foo`.Nicholas Nethercote-1/+1
2023-02-17Use `IntoIterator` for `mk_fn_sig`.Nicholas Nethercote-1/+1
This makes a lot of call sites nicer.
2023-02-17Add `Clause::ConstArgHasType` variantBoxy-1/+1
2023-02-17Auto merge of #107753 - kylematsuda:type-of, r=BoxyUwUbors-12/+20
Switch to `EarlyBinder` for `type_of` query Part of the work to finish #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 adds `EarlyBinder` to the return type of the `type_of` query and removes `bound_type_of`. r? `@lcnr`
2023-02-16changes from reviewKyle Matsuda-2/+10
2023-02-16remove bound_type_of query; make type_of return EarlyBinder; change type_of ↵Kyle Matsuda-11/+11
in metadata
2023-02-16change usages of type_of to bound_type_ofKyle Matsuda-8/+8
2023-02-17Rollup merge of #107489 - compiler-errors:non_lifetime_binders, r=cjgillotMatthias Krüger-16/+75
Implement partial support for non-lifetime binders This implements support for non-lifetime binders. It's pretty useless currently, but I wanted to put this up so the implementation can be discussed. Specifically, this piggybacks off of the late-bound lifetime collection code in `rustc_hir_typeck::collect::lifetimes`. This seems like a necessary step given the fact we don't resolve late-bound regions until this point, and binders are sometimes merged. Q: I'm not sure if I should go along this route, or try to modify the earlier nameres code to compute the right bound var indices for type and const binders eagerly... If so, I'll need to rename all these queries to something more appropriate (I've done this for `resolve_lifetime::Region` -> `resolve_lifetime::ResolvedArg`) cc rust-lang/types-team#81 r? `@ghost`
2023-02-16Auto merge of #108020 - nnethercote:opt-mk_region, r=compiler-errorsbors-9/+12
Optimize `mk_region` PR #107869 avoiding some interning under `mk_ty` by special-casing `Ty` variants with simple (integer) bodies. This PR does something similar for regions. r? `@compiler-errors`
2023-02-16Rollup merge of #108103 - matthiaskrgr:lice, r=compiler-errorsDylan DPC-2/+2
be nice and don't slice These are already slices, no need to slice them again
2023-02-16Deny some late-bound ty/ct in some positions, add testsMichael Goulet-3/+47
2023-02-16Make things actually workMichael Goulet-6/+21
2023-02-16Rename some region-specific stuffMichael Goulet-7/+7
2023-02-16be nice and don't sliceMatthias Krüger-2/+2
These are already slices, no need to slice them again
2023-02-15Add specialized variants of `mk_region`.Nicholas Nethercote-9/+12
Much like there are specialized variants of `mk_ty`. This will enable some optimization in the next commit. Also rename the existing `re_error*` functions as `mk_re_error*`, for consistency.
2023-02-13Make can_eq and can_sub return booleansMichael Goulet-1/+0
2023-02-13Reduce direct `mk_ty` usage.Nicholas Nethercote-2/+2
We use more specific `mk_*` functions in most places, might as well use them as much as possible.
2023-02-11Auto merge of #107507 - BoxyUwU:deferred_projection_equality, r=lcnrbors-0/+1
Implement `deferred_projection_equality` for erica solver Somewhat of a revival of #96912. When relating projections now emit an `AliasEq` obligation instead of attempting to determine equality of projections that may not be as normalized as possible (i.e. because of lazy norm, or just containing inference variables that prevent us from resolving an impl). Only do this when the new solver is enabled
2023-02-10add `AliasEq` to `PredicateKind`Boxy-0/+1
2023-02-09Use `ErrorGuaranteed` more in `ReError`Esteban Küber-5/+5