summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src/instance.rs
AgeCommit message (Collapse)AuthorLines
2022-10-27Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functionsMaybe Waffle-2/+2
Functions in answer: - `Ty::is_freeze` - `Ty::is_sized` - `Ty::is_unpin` - `Ty::is_copy_modulo_regions`
2022-10-10Rollup merge of #102786 - compiler-errors:no-tuple-candidate, r=lcnrDylan DPC-2/+1
Remove tuple candidate, nothing special about it r? `@lcnr` you mentioned this during the talk you gave i think
2022-10-07Remove tuple candidate, nothing special about itMichael Goulet-2/+1
2022-10-07Change InferCtxtBuilder from enter to buildCameron Steffen-13/+11
2022-10-06Rollup merge of #98496 - BoxyUwU:instancers_bad_equality, r=lcnrMatthias Krüger-31/+5
make `compare_const_impl` a query and use it in `instance.rs` Fixes #88365 the bug in #88365 was caused by some `instance.rs` code using the `PartialEq` impl on `Ty` to check that the type of the associated const in an impl is the same as the type of the associated const in the trait definition. This was wrong for two reasons: - the check typeck does is that the impl type is a subtype of the trait definition's type (see `mismatched_impl_ty_2.rs` which [was ICEing](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f6d60ebe6745011f0d52ab2bc712025d) before this PR on stable) - it assumes that if two types are equal then the `PartialEq` impl will reflect that which isnt true for higher ranked types or type level constants when `feature(generic_const_exprs)` is enabled (see `mismatched_impl_ty_3.rs` for higher ranked types which was [ICEing on stable](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d7af131a655ed515b035624626c62c71)) r? `@lcnr`
2022-10-04missing value to delay_span_buglcnr-2/+6
2022-09-30make query take `(LocalDefId, DefId)`Boxy-7/+3
2022-09-30make `compare_const_impl` a query and use it in `instance.rs`Boxy-30/+8
2022-09-27rustc_typeck to rustc_hir_analysislcnr-1/+1
2022-09-12Auto merge of #100251 - compiler-errors:tuple-trait-2, r=jackh726bors-1/+2
Implement `std::marker::Tuple` Split out from #99943 (https://github.com/rust-lang/rust/pull/99943#pullrequestreview-1064459183). Implements part of rust-lang/compiler-team#537 r? `@jackh726`
2022-09-11Apply formatting fixesAndrew Cann-4/+4
2022-09-11implement Copy/Clone for generatorsAndrew Cann-1/+4
2022-09-09rename `codegen_fulfill_obligation`lcnr-4/+2
2022-09-09`resolve_instance`: remove `BoundVarsCollector`lcnr-108/+3
2022-09-01Always import all tracing macros for the entire crate instead of piecemeal ↵Oli Scherer-2/+0
by module
2022-08-07Built-in implementation of Tuple traitMichael Goulet-1/+2
2022-08-01Store associated item defaultness in impl_defaultness.Camille GILLOT-1/+1
2022-07-22Do not resolve associated const when there is no provided valueMichael Goulet-0/+5
2022-07-06Update TypeVisitor pathsAlan Egerton-1/+1
2022-07-05Relax constrained generics to TypeVisitableAlan Egerton-2/+2
2022-06-30Recover when failing to normalize closure signature.Camille GILLOT-2/+2
2022-06-14implement valtrees as the type-system representation for constant valuesb-naber-2/+0
2022-06-08Auto merge of #97860 - Dylan-DPC:rollup-t3vxos8, r=Dylan-DPCbors-5/+9
Rollup of 5 pull requests Successful merges: - #97595 (Remove unwrap from get_vtable) - #97597 (Preserve unused pointer to address casts) - #97819 (Recover `import` instead of `use` in item) - #97823 (Recover missing comma after match arm) - #97851 (Use repr(C) when depending on struct layout in ptr tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-06-08Folding revamp.Nicholas Nethercote-1/+3
This commit makes type folding more like the way chalk does it. Currently, `TypeFoldable` has `fold_with` and `super_fold_with` methods. - `fold_with` is the standard entry point, and defaults to calling `super_fold_with`. - `super_fold_with` does the actual work of traversing a type. - For a few types of interest (`Ty`, `Region`, etc.) `fold_with` instead calls into a `TypeFolder`, which can then call back into `super_fold_with`. With the new approach, `TypeFoldable` has `fold_with` and `TypeSuperFoldable` has `super_fold_with`. - `fold_with` is still the standard entry point, *and* it does the actual work of traversing a type, for all types except types of interest. - `super_fold_with` is only implemented for the types of interest. Benefits of the new model. - I find it easier to understand. The distinction between types of interest and other types is clearer, and `super_fold_with` doesn't exist for most types. - With the current model is easy to get confused and implement a `super_fold_with` method that should be left defaulted. (Some of the precursor commits fixed such cases.) - With the current model it's easy to call `super_fold_with` within `TypeFolder` impls where `fold_with` should be called. The new approach makes this mistake impossible, and this commit fixes a number of such cases. - It's potentially faster, because it avoids the `fold_with` -> `super_fold_with` call in all cases except types of interest. A lot of the time the compile would inline those away, but not necessarily always.
2022-06-05get_vtable returns opt instd of unwrppingouz-a-5/+9
2022-05-16Add a query for checking whether a function is an intrinsic.Oli Scherer-7/+1
2022-05-11Gracefully fail to resolve associated items instead of `delay_span_bug`.Camille GILLOT-1/+17
2022-03-21Rename `~const Drop` to `~const Destruct`Deadbeef-1/+1
2022-03-16rustc_error: make ErrorReported impossible to constructmark-2/+2
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-7/+7
2022-02-15Overhaul `RegionKind` and `Region`.Nicholas Nethercote-2/+2
Specifically, change `Region` from this: ``` pub type Region<'tcx> = &'tcx RegionKind; ``` to this: ``` pub struct Region<'tcx>(&'tcx Interned<RegionKind>); ``` This now matches `Ty` and `Predicate` more closely. Things to note - Regions have always been interned, but we haven't been using pointer-based `Eq` and `Hash`. This is now happening. - I chose to impl `Deref` for `Region` because it makes pattern matching a lot nicer, and `Region` can be viewed as just a smart wrapper for `RegionKind`. - Various methods are moved from `RegionKind` to `Region`. - There is a lot of tedious sigil changes. - A couple of types like `HighlightBuilder`, `RegionHighlightMode` now have a `'tcx` lifetime because they hold a `Ty<'tcx>`, so they can call `mk_region`. - A couple of test outputs change slightly, I'm not sure why, but the new outputs are a little better.
2022-01-15initial revertEllen-4/+0
2022-01-07Add query to avoid name comparison in `leaf_def`Matthew Jasper-24/+19
2021-11-08impl Copy/Clone for arrays in std, not in compilerbstrie-1/+1
2021-09-09Const drop selection candidatesDeadbeef-1/+2
2021-08-26make unevaluated const substs optionallcnr-2/+3
2021-08-26require a `tcx` for `TypeVisitor`lcnr-0/+3
2021-08-18Fold `vtable_trait_upcasting_coercion_new_vptr_slot` logic into obligation ↵Charles Lew-1/+2
processing.
2021-07-03Simplify `visit_region` implementationYuki Okushi-13/+4
2021-07-03Correct `visit_region` implementationYuki Okushi-1/+26
2021-07-03Use `BoundVarsCollector` for nowYuki Okushi-9/+91
2021-07-03Fix const-generics ICE related to bindingYuki Okushi-1/+8
2021-03-31Track bound varsJack Huey-1/+1
2021-02-18Auto merge of #81172 - SimonSapin:ptr-metadata, r=oli-obkbors-1/+2
Implement RFC 2580: Pointer metadata & VTable RFC: https://github.com/rust-lang/rfcs/pull/2580 ~~Before merging this PR:~~ * [x] Wait for the end of the RFC’s [FCP to merge](https://github.com/rust-lang/rfcs/pull/2580#issuecomment-759145278). * [x] Open a tracking issue: https://github.com/rust-lang/rust/issues/81513 * [x] Update `#[unstable]` attributes in the PR with the tracking issue number ---- This PR extends the language with a new lang item for the `Pointee` trait which is special-cased in trait resolution to implement it for all types. Even in generic contexts, parameters can be assumed to implement it without a corresponding bound. For this I mostly imitated what the compiler was already doing for the `DiscriminantKind` trait. I’m very unfamiliar with compiler internals, so careful review is appreciated. This PR also extends the standard library with new unstable APIs in `core::ptr` and `std::ptr`: ```rust pub trait Pointee { /// One of `()`, `usize`, or `DynMetadata<dyn SomeTrait>` type Metadata: Copy + Send + Sync + Ord + Hash + Unpin; } pub trait Thin = Pointee<Metadata = ()>; pub const fn metadata<T: ?Sized>(ptr: *const T) -> <T as Pointee>::Metadata {} pub const fn from_raw_parts<T: ?Sized>(*const (), <T as Pointee>::Metadata) -> *const T {} pub const fn from_raw_parts_mut<T: ?Sized>(*mut (),<T as Pointee>::Metadata) -> *mut T {} impl<T: ?Sized> NonNull<T> { pub const fn from_raw_parts(NonNull<()>, <T as Pointee>::Metadata) -> NonNull<T> {} /// Convenience for `(ptr.cast(), metadata(ptr))` pub const fn to_raw_parts(self) -> (NonNull<()>, <T as Pointee>::Metadata) {} } impl<T: ?Sized> *const T { pub const fn to_raw_parts(self) -> (*const (), <T as Pointee>::Metadata) {} } impl<T: ?Sized> *mut T { pub const fn to_raw_parts(self) -> (*mut (), <T as Pointee>::Metadata) {} } /// `<dyn SomeTrait as Pointee>::Metadata == DynMetadata<dyn SomeTrait>` pub struct DynMetadata<Dyn: ?Sized> { // Private pointer to vtable } impl<Dyn: ?Sized> DynMetadata<Dyn> { pub fn size_of(self) -> usize {} pub fn align_of(self) -> usize {} pub fn layout(self) -> crate::alloc::Layout {} } unsafe impl<Dyn: ?Sized> Send for DynMetadata<Dyn> {} unsafe impl<Dyn: ?Sized> Sync for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Debug for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Unpin for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Copy for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Clone for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Eq for DynMetadata<Dyn> {} impl<Dyn: ?Sized> PartialEq for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Ord for DynMetadata<Dyn> {} impl<Dyn: ?Sized> PartialOrd for DynMetadata<Dyn> {} impl<Dyn: ?Sized> Hash for DynMetadata<Dyn> {} ``` API differences from the RFC, in areas noted as unresolved questions in the RFC: * Module-level functions instead of associated `from_raw_parts` functions on `*const T` and `*mut T`, following the precedent of `null`, `slice_from_raw_parts`, etc. * Added `to_raw_parts`
2021-02-15Add `ptr::Pointee` trait (for all types) and `ptr::metadata` functionSimon Sapin-1/+2
RFC: https://github.com/rust-lang/rfcs/pull/2580
2021-02-14param_env debugs are instrumental to rustc's successEllen-6/+3
2021-02-13debug!("paramenv={}paramenv={}paramenv={}paramenv={}")Ellen-2/+6
2020-11-19Move `rustc_ty` -> `rustc_ty_utils`LeSeulArtichaut-0/+284