summaryrefslogtreecommitdiff
path: root/compiler/rustc_ty_utils
Commit message (Collapse)AuthorAgeFilesLines
* Rollup merge of #111578 - Zoxc:query-macro-move, r=cjgillotMatthias Krüger2023-05-1513-29/+33
|\ | | | | | | | | | | | | | | Move expansion of query macros in rustc_middle to rustc_middle::query This moves the expansion of `define_callbacks!` and `define_feedable!` from `rustc_middle::ty::query` to `rustc_middle::query`. This means that types used in queries are both imported and used in `rustc_middle::query` instead of being split between these modules. It also decouples `rustc_middle::ty::query` further from `rustc_middle` which is helpful since we want to move `rustc_middle::ty::query` to the query system crates.
| * Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker2023-05-1513-29/+33
| |
* | Auto merge of #111570 - compiler-errors:ct-err, r=BoxyUwUbors2023-05-151-3/+1
|\ \ | |/ |/| | | | | | | | | | | Rename const error methods for consistency renames `ty::Const`'s methods for creating a `ConstKind::Error` to be in the same naming style as `ty::Ty`'s equivalent methods. r? `@BoxyUwU`
| * Rename const error methods for consistencyMichael Goulet2023-05-141-3/+1
| |
* | Use the opaque_types_defined_by query to cheaply check for whether a hidden ↵Oli Scherer2023-05-123-25/+172
| | | | | | | | type may be registered for an opaque type
* | add `query opaque_types_defined_by`lcnr2023-05-122-0/+82
|/
* Rollup merge of #106038 - aliemjay:opaque-implied, r=lcnrMichael Goulet2023-05-111-1/+12
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | use implied bounds when checking opaque types During opaque type inference, we check for the well-formedness of the hidden type in the opaque type's own environment, not the one of the defining site, which are different in the case of TAIT. However in the case of associated-type-impl-trait, we don't use implied bounds from the impl header. This caused us to reject the following: ```rust trait Service<Req> { type Output; fn call(req: Req) -> Self::Output; } impl<'a, Req> Service<&'a Req> for u8 { type Output= impl Sized; // we can't prove WF of hidden type `WF(&'a Req)` although it's implied by the impl //~^ ERROR type parameter Req doesn't live long enough fn call(req: &'a Req) -> Self::Output { req } } ``` although adding an explicit bound would make it pass: ```diff - impl<'a, Req> Service<&'a Req> for u8 { + impl<'a, Req> Service<&'a Req> for u8 where Req: 'a, { ``` I believe it should pass as we already allow the concrete type to be used: ```diff impl<'a, Req> Service<&'a Req> for u8 { - type Output= impl Sized; + type Output= &'a Req; ``` Fixes #95922 Builds on #105982 cc ``@lcnr`` (because implied bounds) r? ``@oli-obk``
| * use implied bounds when checking opaque typesAli MJ Al-Nasrawy2023-05-071-1/+12
| |
* | add EarlyBinder to thir_abstract_const; remove tcx.bound_abstract_constKyle Matsuda2023-05-091-2/+2
| |
* | Fix miscompilation when adding default method to `Future`Jonas Schievink2023-05-081-14/+11
| |
* | Rollup merge of #111265 - spastorino:has_self-opaque_ty, r=compiler-errorsDylan DPC2023-05-081-1/+1
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | Make generics_of has_self on RPITITs delegate to the opaque r? `@compiler-errors` I couldn't come up with a test case and none of the ones in the `tests` folder is impacted by this change, but I still think is the right thing to do. Michael, let me know if you have ideas on how to add a test that's affected by this change.
| * | Make generics_of has_self on RPITITs delegate to the opaqueSantiago Pastorino2023-05-051-1/+1
| |/
* | make (try_)subst_and_normalize_erasing_regions take EarlyBinderKyle Matsuda2023-05-061-2/+1
| |
* | Rollup merge of #111279 - compiler-errors:core-item-resolve, r=cjgillotMatthias Krüger2023-05-061-13/+71
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | More robust debug assertions for `Instance::resolve` on built-in traits with non-standard trait items In #111264, a user added a new item to the `Future` trait, but the code in [`resolve_associated_item`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_ty_utils/instance/fn.resolve_associated_item.html) implicitly assumes that the `Future` trait is defined with only one method (`Future::poll`) and treats the generator body as the implementation of that method. This PR adds some debug assertions to make sure that that new methods defined on `Future`/`Generator`/etc. don't accidentally resolve to the wrong item when they are added, and adds a helpful comment guiding a compiler dev (or curious `#![no_core]` user) to what must be done to support adding new associated items to these built-in implementations. I am open to discuss whether a test should be added, but I chose against it because I opted to make these `bug!()`s instead of, e.g., diagnostics or fatal errors. Arguably it doesn't need a test because it's not a bug that can be triggered by an end user, and internal-facing misuses of core kind of touch on rust-lang/compiler-team#620 -- however, I think the assertions I added in this PR are still a very useful way to make sure this bug doesn't waste debugging resources down the line. Fixes #111264
| * | More robust debug assertions for `Instance::resolve` on built-in traits with ↵Michael Goulet2023-05-061-13/+71
| | | | | | | | | | | | custom items
* | | Factor out checks in layout check and add helper inherent_size.Luqman Aden2023-05-052-54/+41
| |/ |/|
* | Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnrbors2023-05-041-3/+2
|\ \ | |/ |/| | | | | | | | | Replace `tcx.mk_trait_ref` with `TraitRef::new` First step in implementing https://github.com/rust-lang/compiler-team/issues/616 r? `@lcnr`
| * Add new `ToPredicate` impls and `TraitRef` methods to remove some ↵Maybe Waffle2023-04-261-3/+2
| | | | | | | | `ty::Binber::dummy` calls
| * Replace `tcx.mk_trait_ref` with `ty::TraitRef::new`Maybe Waffle2023-04-251-1/+1
| |
* | Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote2023-05-032-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | rename `needs_infer` to `has_infer`Boxy2023-04-271-2/+2
|/
* Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle2023-04-241-1/+1
|
* Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkinbors2023-04-221-0/+2
|\ | | | | | | | | | | | | | | | | | | | | | | | | Add offset_of! macro (RFC 3308) Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented: * Nested field accesses (without array indexing) * DST support (for `Sized` fields) I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it. cc `@thomcc` (RFC author)
| * offset_ofDrMeepster2023-04-211-0/+2
| |
* | Remove WithOptconstParam.Camille GILLOT2023-04-202-76/+33
| |
* | Feed type_of query instead of using WithOptconstParam.Camille GILLOT2023-04-201-6/+0
|/
* Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwcobors2023-04-192-1/+2
|\ | | | | | | | | | | Add `rustc_fluent_macro` to decouple fluent from `rustc_macros` Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
| * Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`Nilstrieb2023-04-182-1/+2
| | | | | | | | | | | | | | | | | | | | Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
* | Spelling - compilerJosh Soref2023-04-172-2/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* fix clippy::toplevel_ref_arg and ::manual_mapMatthias Krüger2023-04-162-8/+5
|
* Update ty_utils_never_to_any_not_supported diagnostic messageDaniPopes2023-04-101-1/+1
|
* Fix typos in compilerDaniPopes2023-04-103-4/+4
|
* Update compiler/rustc_ty_utils/src/layout.rs matthewjasper2023-04-081-1/+1
| | | | | Fix formatting that rustfmt can't handle currently. Co-authored-by: Michael Goulet <michael@errs.io>
* Move SIMD layout errors to `SessionDiagnostic`Matthew Jasper2023-04-084-20/+55
|
* Move `FnPtrAddr` error to `SessionDiagnostic`Matthew Jasper2023-04-073-4/+14
|
* Use `FieldIdx` in `FieldsShape`Scott McMurray2023-04-042-47/+41
| | | | Finally got to the main motivating example from the MCP :)
* Auto merge of #109762 - scottmcm:variantdef-indexvec, r=WaffleLapkinbors2023-03-312-4/+5
|\ | | | | | | | | | | | | | | | | | | Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>` 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
| * Update `ty::VariantDef` to use `IndexVec<FieldIdx, FieldDef>`Scott McMurray2023-03-302-4/+5
| | | | | | | | | | | | | | | | 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
* | Auto merge of #109499 - spastorino:new-rpitit-19, r=compiler-errorsbors2023-03-301-16/+19
|\ \ | |/ |/| | | | | | | | | | | | | | | Give return-position impl traits in trait a (synthetic) name to avoid name collisions with new lowering strategy The only needed commit from this PR is the last one. r? `@compiler-errors` Needs #109455.
| * Walk return-position impl trait in trait deeply in associated_item_def_idsMichael Goulet2023-03-291-16/+19
| |
* | Support TLS access into dylibs on WindowsJohn Kåre Alsaker2023-03-291-1/+11
|/
* Add a builtin `FnPtr` traitlcnr2023-03-271-1/+18
|
* Refactor: `VariantIdx::from_u32(0)` -> `FIRST_VARIANT`Scott McMurray2023-03-252-7/+7
| | | | | | Since structs are always `VariantIdx(0)`, there's a bunch of files where the only reason they had `VariantIdx` or `vec::Idx` imported at all was to get the first variant. So this uses a constant for that, and adds some doc-comments to `VariantIdx` while I'm there, since it doesn't have any today.
* Auto merge of #109503 - matthiaskrgr:rollup-cnp7kdd, r=matthiaskrgrbors2023-03-231-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rollup of 9 pull requests Successful merges: - #108954 (rustdoc: handle generics better when matching notable traits) - #109203 (refactor/feat: refactor identifier parsing a bit) - #109213 (Eagerly intern and check CrateNum/StableCrateId collisions) - #109358 (rustc: Remove unused `Session` argument from some attribute functions) - #109359 (Update stdarch) - #109378 (Remove Ty::is_region_ptr) - #109423 (Use region-erased self type during IAT selection) - #109447 (new solver cleanup + implement coherence) - #109501 (make link clickable) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
| * Rollup merge of #109378 - MU001999:master, r=scottmcmMatthias Krüger2023-03-221-1/+1
| |\ | | | | | | | | | | | | | | | Remove Ty::is_region_ptr Fixes #109372
| | * Remove Ty::is_region_ptrMu422023-03-201-1/+1
| | |
* | | Auto merge of #109497 - matthiaskrgr:rollup-6txuxm0, r=matthiaskrgrbors2023-03-222-5/+3
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rollup of 10 pull requests Successful merges: - #109373 (Set LLVM `LLVM_UNREACHABLE_OPTIMIZE` to `OFF`) - #109392 (Custom MIR: Allow optional RET type annotation) - #109394 (adapt tests/codegen/vec-shrink-panik for LLVM 17) - #109412 (rustdoc: Add GUI test for "Auto-hide item contents for large items" setting) - #109452 (Ignore the vendor directory for tidy tests.) - #109457 (Remove comment about reusing rib allocations) - #109461 (rustdoc: remove redundant `.content` prefix from span/a colors) - #109477 (`HirId` to `LocalDefId` cleanup) - #109489 (More general captures) - #109494 (Do not feed param_env for RPITITs impl side) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
| * | Do not feed param_env for RPITITs impl sideSantiago Pastorino2023-03-222-5/+3
| | |
* | | Rollup merge of #109405 - compiler-errors:rpitit-as-opaques, r=spastorinoDylan DPC2023-03-231-11/+13
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | RPITITs are `DefKind::Opaque` with new lowering strategy r? `@spastorino` Kinda cherry-picked #109400
| * | RPITITs are DefKind::Opaque with new lowering strategyMichael Goulet2023-03-211-11/+13
| | |