summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/coherence
AgeCommit message (Collapse)AuthorLines
2023-09-29Auto merge of #115821 - obeis:hir-analysis-migrate-diagnostics-5, ↵bors-122/+78
r=compiler-errors Migrate `rustc_hir_analysis` to session diagnostic [Part 5] Finishing `coherence/builtin.rs` file
2023-09-23Remove GeneratorWitness and rename GeneratorWitnessMIR.Camille GILLOT-2/+0
2023-09-20Migrate `rustc_hir_analysis` to session diagnosticObei Sideg-122/+78
Part 5: Finishing `coherence/builtin.rs` file
2023-09-14Migrate `rustc_hir_analysis` to session diagnosticObei Sideg-77/+16
Part 6: Finish `coherence/inherent_impls.rs`
2023-09-11explain why DispatchFromDyn does the check it doesRalf Jung-0/+8
2023-08-29some more is_zst that should be is_1zstRalf Jung-2/+2
2023-07-25inline format!() args from rustc_codegen_llvm to the end (4)Matthias Krüger-17/+12
r? @WaffleLapkin
2023-07-23fix clippy::useless_formatMatthias Krüger-1/+1
2023-07-20XSimplifiedType to SimplifiedType::Xlcnr-5/+5
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-37/+33
2023-07-05Move `TyCtxt::mk_x` to `Ty::new_x` where applicableBoxy-5/+9
2023-06-27Simplify some conditionsMaybe Waffle-5/+5
2023-06-21Rollup merge of #112772 - compiler-errors:clauses-1, r=lcnrNilstrieb-1/+1
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind` Does two basic things before I put up a more delicate set of PRs (along the lines of #112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`). 1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`. 2. Add a new `Clause` type which is parallel to `Predicate`. * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸 The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] that this is not negative performance-wise, which is wonderful, since this a much simpler design than something that requires encoding the discriminant into the alignment bits of a predicate kind, or something else like that... r? ``@lcnr`` or ``@oli-obk`` [^1]: https://github.com/rust-lang/rust/pull/112714#issuecomment-1595653910
2023-06-20Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnrbors-2/+1
Add `implement_via_object` to `rustc_deny_explicit_impl` to control object candidate assembly Some built-in traits are special, since they are used to prove facts about the program that are important for later phases of compilation such as codegen and CTFE. For example, the `Unsize` trait is used to assert to the compiler that we are able to unsize a type into another type. It doesn't have any methods because it doesn't actually *instruct* the compiler how to do this unsizing, but this is later used (alongside an exhaustive match of combinations of unsizeable types) during codegen to generate unsize coercion code. Due to this, these built-in traits are incompatible with the type erasure provided by object types. For example, the existence of `dyn Unsize<T>` does not mean that the compiler is able to unsize `Box<dyn Unsize<T>>` into `Box<T>`, since `Unsize` is a *witness* to the fact that a type can be unsized, and it doesn't actually encode that unsizing operation in its vtable as mentioned above. The old trait solver gets around this fact by having complex control flow that never considers object bounds for certain built-in traits: https://github.com/rust-lang/rust/blob/2f896da247e0ee8f0bef7cd7c54cfbea255b9f68/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L61-L132 However, candidate assembly in the new solver is much more lovely, and I'd hate to add this list of opt-out cases into the new solver. Instead of maintaining this complex and hard-coded control flow, instead we can make this a property of the trait via a built-in attribute. We already have such a build attribute that's applied to every single trait that we care about: `rustc_deny_explicit_impl`. This PR adds `implement_via_object` as a meta-item to that attribute that allows us to opt a trait out of object-bound candidate assembly as well. r? `@lcnr`
2023-06-20Make rustc_deny_explicit_impl only local as wellMichael Goulet-2/+1
2023-06-19s/Clause/ClauseKindMichael Goulet-1/+1
2023-06-16Add `AliasKind::Weak` for type aliases.Oli Scherer-0/+3
Only use it when the type alias contains an opaque type. Also does wf-checking on such type aliases.
2023-06-16Merge the orphan logic for all alias kindsOli Scherer-29/+23
2023-05-17Rollup merge of #111648 - Nilstrieb:language-items, r=WaffleLapkinDylan DPC-3/+1
Remove `LangItems::require` It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
2023-05-16Remove `LangItems::require`Nilstrieb-3/+1
It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff.
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-1/+1
2023-05-12Invert `IgnoreRegions` to `CheckRegions`Oli Scherer-2/+2
2023-05-04IAT: Introduce AliasKind::InherentLeón Orell Valerian Liehr-0/+13
2023-05-04Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnrbors-4/+9
Replace `tcx.mk_trait_ref` with `TraitRef::new` First step in implementing https://github.com/rust-lang/compiler-team/issues/616 r? `@lcnr`
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-10/+10
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-05-02Rollup merge of #108161 - WaffleLapkin:const_param_ty, r=BoxyUwUDylan DPC-107/+148
Add `ConstParamTy` trait This is a bit sketch, but idk. r? `@BoxyUwU` Yet to be done: - [x] ~~Figure out if it's okay to implement `StructuralEq` for primitives / possibly remove their special casing~~ (it should be okay, but maybe not in this PR...) - [ ] Maybe refactor the code a little bit - [x] Use a macro to make impls a bit nicer Future work: - [ ] Actually™ use the trait when checking if a `const` generic type is allowed - [ ] _Really_ refactor the surrounding code - [ ] Refactor `marker.rs` into multiple modules for each "theme" of markers
2023-04-27Add a `ConstParamTy` traitMaybe Waffle-107/+148
2023-04-27rename `needs_subst` to `has_param`Boxy-1/+1
2023-04-25Fix static string lintsclubby789-7/+2
2023-04-25Remove some useless `ty::Binder::dummy` callsMaybe Waffle-2/+2
2023-04-25Replace `tcx.mk_trait_ref` with `ty::TraitRef::new`Maybe Waffle-3/+8
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-21Allow `LocalDefId` as the argument to `def_path_str`Oli Scherer-1/+1
2023-04-18Rollup merge of #110417 - jsoref:spelling-compiler, r=NilstriebGuillaume Gomez-1/+1
Spelling compiler This is per https://github.com/rust-lang/rust/pull/110392#issuecomment-1510193656 I'm going to delay performing a squash because I really don't expect people to be perfectly happy w/ my changes, I really am a human and I really do make mistakes. r? Nilstrieb I'm going to be flying this evening, but I should be able to squash / respond to reviews w/in a day or two. I tried to be careful about dropping changes to `tests`, afaict only two files had changes that were likely related to the changes for a given commit (this is where not having eagerly squashed should have given me an advantage), but, that said, picking things apart can be error prone.
2023-04-17Spelling - compilerJosh Soref-1/+1
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-17Use `Item::expect_*` and `ImplItem::expect_*` moreMaybe Waffle-4/+3
2023-04-12region error cleanuplcnr-4/+2
- require `TypeErrCtxt` to always result in an error - move `resolve_regions_and_report_errors` to the `ObligationCtxt` - merge `process_registered_region_obligations` into `resolve_regions`
2023-04-09Small clippy::correctness fixesNilstrieb-1/+1
Nothing was really incorrect before, but it did get nicer.
2023-03-30Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray-2/+1
And while doing the updates for that, also uses `FieldIdx` in `ProjectionKind::Field` and `TypeckResults::field_indices`. There's more places that could use it (like `rustc_const_eval` and `LayoutS`), but I tried to keep this PR from exploding to *even more* places. Part 2/? of https://github.com/rust-lang/compiler-team/issues/606
2023-03-23Auto merge of #109202 - compiler-errors:new-solver-fast-reject-faster-2, r=lcnrbors-13/+3
Don't pass `TreatProjections` separately to `fast_reject` Don't pass `TreatProjections` separately to `fast_reject`, and instead use the original approach of switching on two variants of `TreatParams` (undoes this: https://github.com/rust-lang/rust/pull/108830#pullrequestreview-1330371417). Fixes the regression introduced in https://github.com/rust-lang/rust/pull/108830#issuecomment-1468116419
2023-03-23Don't split up TreatProjections and TreatParams anymoreMichael Goulet-13/+3
2023-03-23Rollup merge of #107718 - Zoxc:z-time, r=nnethercoteMatthias Krüger-2/+2
Add `-Z time-passes-format` to allow specifying a JSON output for `-Z time-passes` This adds back the `-Z time` option as that is useful for [my rustc benchmark tool](https://github.com/Zoxc/rcb), reverting https://github.com/rust-lang/rust/pull/102725. It now uses nanoseconds and bytes as the units so it is renamed to `time-precise`.
2023-03-22Auto merge of #109119 - lcnr:trait-system-cleanup, r=compiler-errorsbors-15/+18
a general type system cleanup removes the helper functions `traits::fully_solve_X` as they add more complexity then they are worth. It's confusing which of these helpers should be used in which context. changes the way we deal with overflow to always add depth in `evaluate_predicates_recursively`. It may make sense to actually fully transition to not have `recursion_depth` on obligations but that's probably a bit too much for this PR. also removes some other small - and imo unnecessary - helpers. r? types
2023-03-21Reduce output spamJohn Kåre Alsaker-2/+2
2023-03-21Use local key in providersMichael Goulet-9/+4
2023-03-21remove some trait solver helperslcnr-15/+18
they add more complexity then they are worth. It's confusing which of these helpers should be used in which context.
2023-03-15always make `define_opaque_types` explicitlcnr-4/+7
2023-03-13Better names?Michael Goulet-5/+8
2023-03-13Treat projections with infer as placeholder during fast reject in new solverMichael Goulet-3/+10
2023-03-09Remove body_def_id from InheritedMichael Goulet-2/+2