about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils
AgeCommit message (Collapse)AuthorLines
2023-06-17Simplify even more candidatesMichael Goulet-21/+19
2023-06-17Simplify some impl source candidatesMichael Goulet-4/+2
2023-06-02Separate AnonConst from ConstBlock in HIR.Camille GILLOT-0/+1
2023-06-01Rename `impl_defaultness` to `defaultness`Deadbeef-8/+8
2023-05-30Rollup merge of #112060 - lcnr:early-binder, r=jackh726Nilstrieb-5/+5
`EarlyBinder::new` -> `EarlyBinder::bind` for consistency with `Binder::bind`. it may make sense to also add `EarlyBinder::dummy` in places where we know that no parameters exist, but I left that out of this PR. r? `@jackh726` `@kylematsuda`
2023-05-29Rename `tcx.mk_re_*` => `Region::new_*`Maybe Waffle-4/+5
2023-05-29EarlyBinder::new -> EarlyBinder::bindlcnr-5/+5
2023-05-28Make EarlyBinder's inner value private; and fix all of the resulting errorsKyle Matsuda-3/+1
2023-05-28Replace EarlyBinder(x) with EarlyBinder::new(x)Kyle Matsuda-5/+5
2023-05-25Ensure Fluent messages are in alphabetical orderclubby789-34/+34
2023-05-20ensure !Unpin types do not get noaliasErik Desjardins-17/+19
2023-05-20improve code checking for drop_in_place lang itemErik Desjardins-4/+2
2023-05-20Apply `noalias`, `nonnull`, `dereferenceable`, and `align` attributes ↵Patrick Walton-17/+10
unconditionally. We've done measurements with Miri and have determined that `noalias` shouldn't break code. The requirements that allow us to add dereferenceable and align have been long documented in the standard library documentation.
2023-05-20[rustc_ty_utils] Add the LLVM `noalias` parameter attribute to ↵Patrick Walton-1/+35
`drop_in_place` in certain cases. LLVM can make use of the `noalias` parameter attribute on the parameter to `drop_in_place` in areas like argument promotion. Because the Rust compiler fully controls the code for `drop_in_place`, it can soundly deduce parameter attributes on it. In the case of a value that has a programmer-defined Drop implementation, we know that the first thing `drop_in_place` will do is pass a pointer to the object to `Drop::drop`. `Drop::drop` takes `&mut`, so it must be guaranteed that there are no pointers to the object upon entering that function. Therefore, it should be safe to mark `noalias` there. With this patch, we mark `noalias` only when the type is a value with a programmer-defined Drop implementation. This is possibly overly conservative, but I thought that proceeding cautiously was best in this instance.
2023-05-15Rollup merge of #111578 - Zoxc:query-macro-move, r=cjgillotMatthias Krüger-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.
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-29/+33
2023-05-15Auto merge of #111570 - compiler-errors:ct-err, r=BoxyUwUbors-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`
2023-05-14Rename const error methods for consistencyMichael Goulet-3/+1
2023-05-12Use the opaque_types_defined_by query to cheaply check for whether a hidden ↵Oli Scherer-25/+172
type may be registered for an opaque type
2023-05-12add `query opaque_types_defined_by`lcnr-0/+82
2023-05-11Rollup merge of #106038 - aliemjay:opaque-implied, r=lcnrMichael Goulet-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``
2023-05-09add EarlyBinder to thir_abstract_const; remove tcx.bound_abstract_constKyle Matsuda-2/+2
2023-05-08Fix miscompilation when adding default method to `Future`Jonas Schievink-14/+11
2023-05-08Rollup merge of #111265 - spastorino:has_self-opaque_ty, r=compiler-errorsDylan DPC-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.
2023-05-06make (try_)subst_and_normalize_erasing_regions take EarlyBinderKyle Matsuda-2/+1
2023-05-07use implied bounds when checking opaque typesAli MJ Al-Nasrawy-1/+12
2023-05-06Rollup merge of #111279 - compiler-errors:core-item-resolve, r=cjgillotMatthias Krüger-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
2023-05-06More robust debug assertions for `Instance::resolve` on built-in traits with ↵Michael Goulet-13/+71
custom items
2023-05-05Factor out checks in layout check and add helper inherent_size.Luqman Aden-54/+41
2023-05-05Make generics_of has_self on RPITITs delegate to the opaqueSantiago Pastorino-1/+1
2023-05-04Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnrbors-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`
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-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.
2023-04-27rename `needs_infer` to `has_infer`Boxy-2/+2
2023-04-26Add new `ToPredicate` impls and `TraitRef` methods to remove some ↵Maybe Waffle-3/+2
`ty::Binber::dummy` calls
2023-04-25Replace `tcx.mk_trait_ref` with `ty::TraitRef::new`Maybe Waffle-1/+1
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-22Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkinbors-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)
2023-04-21offset_ofDrMeepster-0/+2
2023-04-20Remove WithOptconstParam.Camille GILLOT-76/+33
2023-04-20Feed type_of query instead of using WithOptconstParam.Camille GILLOT-6/+0
2023-04-19Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwcobors-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`).
2023-04-18Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`Nilstrieb-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`).
2023-04-17Spelling - compilerJosh Soref-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>
2023-04-16fix clippy::toplevel_ref_arg and ::manual_mapMatthias Krüger-8/+5
2023-04-10Update ty_utils_never_to_any_not_supported diagnostic messageDaniPopes-1/+1
2023-04-10Fix typos in compilerDaniPopes-4/+4
2023-04-08Update compiler/rustc_ty_utils/src/layout.rs matthewjasper-1/+1
Fix formatting that rustfmt can't handle currently. Co-authored-by: Michael Goulet <michael@errs.io>
2023-04-08Move SIMD layout errors to `SessionDiagnostic`Matthew Jasper-20/+55
2023-04-07Move `FnPtrAddr` error to `SessionDiagnostic`Matthew Jasper-4/+14
2023-04-04Use `FieldIdx` in `FieldsShape`Scott McMurray-47/+41
Finally got to the main motivating example from the MCP :)