summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
AgeCommit message (Collapse)AuthorLines
2023-03-11Retry pred_known_to_hold_modulo_regions with fulfillment if ambiguousMichael Goulet-3/+5
2023-03-11fix: evaluate with wrong obligation stackyifei-2/+2
2023-03-03Auto merge of #108709 - matthiaskrgr:rollup-j2tjbyx, r=matthiaskrgrbors-24/+32
Rollup of 8 pull requests Successful merges: - #104549 (add -Zexport-executable-symbols to unstable book) - #108292 (Label opaque type for 'captures lifetime' error message) - #108540 (Add `Atomic*::from_ptr`) - #108634 (Add link to component dashboard) - #108647 (Remove dead pgo.sh file) - #108678 (Use `Option::as_slice` where applicable) - #108681 (Improve comments in `needs_process_obligation`.) - #108688 (Match unmatched backticks in library/) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-03Rollup merge of #108681 - nnethercote:needs_process_obligation-comments, r=lqdMatthias Krüger-24/+32
Improve comments in `needs_process_obligation`. And a couple of other places. r? `@lqd`
2023-03-03Match unmatched backticks in comments in compiler/est31-2/+2
2023-03-03Match unmatched backticks in compiler/ that are part of rustdocest31-2/+2
2023-03-03Improve comments in `needs_process_obligation`.Nicholas Nethercote-24/+32
And a couple of other places.
2023-02-28Descriptive error when users try to combine RPITIT/AFIT with specializationMichael Goulet-20/+4
2023-02-27Rollup merge of #108319 - ↵Matthias Krüger-5/+22
compiler-errors:dont-project-to-specializable-rpitits, r=lcnr Don't project specializable RPITIT projection This effective rejects specialization + RPITIT/AFIT (usages of `impl Trait` in traits) because the implementation is significantly complicated over making regular "default" trait method bodies work. I have another PR that experimentally fixes all this, but the code may not be worth investing in.
2023-02-25Special note for str in auto traitsMichael Goulet-0/+1
2023-02-25Treat `str` as containing `[u8]` for auto trait purposesMichael Goulet-1/+3
2023-02-24Rename many interner functions.Nicholas Nethercote-23/+24
(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-17/+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-23Rollup merge of #108350 - compiler-errors:assoc-type-bound-dogfooding, r=oli-obkMatthias Krüger-2/+2
Use associated type bounds in some places in the compiler Use associated type bounds for some nested `impl Trait<Assoc = impl Trait2>` cases. I'm generally keen to introduce new lang features that are more mature into the compiler, but maybe let's see what others think? Side-note: I was surprised that the only use-cases of nested impl trait in the compiler are just iterator related?!
2023-02-23Don't project specializable RPITIT projectionMichael Goulet-5/+22
2023-02-23Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, ↵bors-2/+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-12/+9
2023-02-22Use ty_error_with_guaranteed in many more placesMichael Goulet-11/+16
2023-02-22Remove type-traversal trait aliasesAlan Egerton-64/+70
2023-02-22diagnostics: if AssocFn has self argument, describe as methodMichael Howell-2/+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-21Rollup merge of #108295 - compiler-errors:wtf-is-this, r=cjgillotMatthias Krüger-1/+7
Use DefKind to give more item kind information during BindingObligation note The current label says "required by a bound in this". When I see that label, my immediate impression is "this... **what**?". It feels like it was cut short. Alternative to this would be saying "in this item", but adding the item kind is strictly more informational and adds very little overhead to the existing error presentation.
2023-02-21Make hidden type registration opt-in, so that each site can be reviewed on ↵Oli Scherer-9/+13
its own and we have the right defaults for trait solvers
2023-02-21Specify what 'this' actually isMichael Goulet-1/+7
2023-02-21Associated type bounds in some places in the compilerMichael Goulet-2/+2
2023-02-19Auto merge of #108128 - clubby789:builtin-derived-attr, r=jackh726bors-1/+1
Properly check for builtin derived code Fixes #108122
2023-02-19Rollup merge of #108203 - compiler-errors:rpitit-fix-defaults-2, r=jackh726Guillaume Gomez-33/+3
Fix RPITITs in default trait methods (by assuming projection predicates in param-env) Instead of having special projection logic that allows us to turn `ProjectionTy(RPITIT, [Self#0, ...])` into `OpaqueTy(RPITIT, [Self#0, ...])`, we can instead augment the param-env of default trait method bodies to assume these as projection predicates. This should allow us to only project where we're allowed to! In order to make this work without introducing a bunch of cycle errors, we additionally tweak the `OpaqueTypeExpander` used by `ParamEnv::with_reveal_all_normalized` to not normalize the right-hand side of projection predicates. This should be fine, because if we use the projection predicate to normalize some other projection type, we'll continue to normalize the opaque that it gets projected to. This also makes it possible to support default trait methods with RPITITs in an associated-type based RPITIT lowering strategy without too much extra effort. Fixes #107002 Alternative to #108142
2023-02-18Don't ICE on bound types in sized conditionsMichael Goulet-4/+5
2023-02-18Remove default trait RPITIT candidatesMichael Goulet-33/+3
2023-02-18Auto merge of #108112 - nnethercote:clarify-iterator-interners, ↵bors-6/+4
r=oli-obk,compiler-errors Clarify iterator interners I found the iterator interners very confusing. This PR clarifies things. r? `@compiler-errors`
2023-02-17Auto merge of #108075 - WaffleLapkin:de-arena-allocates-you-OwO, r=Nilstriebbors-12/+12
Remove `arena_cache` modifier from `associated_item` query & copy `ty::AssocItem` instead of passing by ref r? `@ghost`
2023-02-17Avoid double-interning some `BoundVariableKind`s.Nicholas Nethercote-2/+0
This function has this line twice: ``` let bound_vars = tcx.intern_bound_variable_kinds(&bound_vars); ``` The second occurrence is effectively a no-op, because the first occurrence interned any that needed it.
2023-02-17Replace more `mk_foo` calls with `infer_foo`.Nicholas Nethercote-2/+2
2023-02-17Use `IntoIterator` for `mk_fn_sig`.Nicholas Nethercote-2/+2
This makes a lot of call sites nicer.
2023-02-17Replace `mk_foo` calls with `infer_foo` where possible.Nicholas Nethercote-1/+1
There are several `mk_foo`/`intern_foo` pairs, where the former takes an iterator and the latter takes a slice. (This naming convention is bad, but that's a fix for another PR.) This commit changes several `mk_foo` occurrences into `intern_foo`, avoiding the need for some `.iter()`/`.into_iter()` calls. Affected cases: - mk_type_list - mk_tup - mk_substs - mk_const_list
2023-02-17add predicate evaluation logicBoxy-7/+25
2023-02-17Add `Clause::ConstArgHasType` variantBoxy-0/+23
2023-02-17Auto merge of #107753 - kylematsuda:type-of, r=BoxyUwUbors-15/+32
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-1/+3
2023-02-16remove bound_type_of query; make type_of return EarlyBinder; change type_of ↵Kyle Matsuda-15/+15
in metadata
2023-02-16change usages of type_of to bound_type_ofKyle Matsuda-9/+24
2023-02-17Rollup merge of #108136 - eggyal:unmet_trait_alias_bound_on_generic_impl, ↵Matthias Krüger-3/+3
r=compiler-errors Do not ICE on unmet trait alias impl bounds Fixes #108132 I've also added some documentation to the `impl_def_id` field of `DerivedObligationCause` to try and minimise the risk of such errors in future. r? `@compiler-errors`
2023-02-17Rollup merge of #107489 - compiler-errors:non_lifetime_binders, r=cjgillotMatthias Krüger-3/+10
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-16Clarify `DerivedObligationCause` may hold alias idAlan Egerton-3/+3
2023-02-16Properly check for builtin derivesclubby789-1/+1
2023-02-16Auto merge of #108127 - matthiaskrgr:rollup-kpzfc6j, r=matthiaskrgrbors-30/+16
Rollup of 7 pull requests Successful merges: - #106347 (More accurate spans for arg removal suggestion) - #108057 (Prevent some attributes from being merged with others on reexports) - #108090 (`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`) - #108092 (note issue for feature(packed_bundled_libs)) - #108099 (use chars instead of strings where applicable) - #108115 (Do not ICE on unmet trait alias bounds) - #108125 (Add new people to the compiletest review rotation) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-16Auto merge of #108020 - nnethercote:opt-mk_region, r=compiler-errorsbors-7/+6
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-16Replace some `then`s with some `then_some`sMaybe Waffle-4/+4
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-30/+16
2023-02-16Rollup merge of #108101 - matthiaskrgr:noclonecopy, r=compiler-errorsDylan DPC-1/+1
don't clone types that are copy
2023-02-16Be better about bound varsMichael Goulet-3/+10