about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty
AgeCommit message (Collapse)AuthorLines
2024-02-12check uniqueness of nested fieldsFrank King-1/+6
2024-02-12Lower anonymous structs or unions to HIRFrank King-5/+41
2024-02-11Auto merge of #120619 - compiler-errors:param, r=lcnrbors-2/+8
Assert that params with the same *index* have the same *name* Found this bug when trying to build libcore with the new solver, since it will canonicalize two params with the same index into *different* placeholders if those params differ by name.
2024-02-11is_closure_likeMichael Goulet-14/+13
2024-02-11Rollup merge of #120896 - compiler-errors:coro-closure-kind, r=oli-obkMatthias Krüger-1/+18
Print kind of coroutine closure Make sure that we print "async closure" when we have an async closure, rather than calling it generically a ["coroutine-closure"](https://github.com/rust-lang/rust/pull/120361). Fixes #120886 r? oli-obk
2024-02-11Rollup merge of #120874 - gurry:120838-extra-where-in-suggestion, r=fmeaseMatthias Krüger-1/+7
Take empty `where` bounds into account when suggesting predicates Fixes #120838
2024-02-10Print kind of coroutine closureMichael Goulet-1/+18
2024-02-10Take empty `where` into account when suggesting predicatesGurinder Singh-1/+7
2024-02-09Rollup merge of #120354 - lukas-code:metadata-normalize, r=lcnrMatthias Krüger-16/+32
improve normalization of `Pointee::Metadata` This PR makes it so that `<Wrapper<Tail> as Pointee>::Metadata` is normalized to `<Tail as Pointee>::Metadata` if we don't know `Wrapper<Tail>: Sized`. With that, the trait solver can prove projection predicates like `<Wrapper<Tail> as Pointee>::Metadata == <Tail as Pointee>::Metadata`, which makes it possible to use the metadata APIs to cast between the tail and the wrapper: ```rust #![feature(ptr_metadata)] use std::ptr::{self, Pointee}; fn cast_same_meta<T: ?Sized, U: ?Sized>(ptr: *const T) -> *const U where T: Pointee<Metadata = <U as Pointee>::Metadata>, { let (thin, meta) = ptr.to_raw_parts(); ptr::from_raw_parts(thin, meta) } struct Wrapper<T: ?Sized>(T); fn cast_to_wrapper<T: ?Sized>(ptr: *const T) -> *const Wrapper<T> { cast_same_meta(ptr) } ``` Previously, this failed to compile: ``` error[E0271]: type mismatch resolving `<Wrapper<T> as Pointee>::Metadata == <T as Pointee>::Metadata` --> src/lib.rs:16:5 | 15 | fn cast_to_wrapper<T: ?Sized>(ptr: *const T) -> *const Wrapper<T> { | - found this type parameter 16 | cast_same_meta(ptr) | ^^^^^^^^^^^^^^ expected `Wrapper<T>`, found type parameter `T` | = note: expected associated type `<Wrapper<T> as Pointee>::Metadata` found associated type `<T as Pointee>::Metadata` = note: an associated type was expected, but a different one was found ``` (Yes, you can already do this with `as` casts. But using functions is so much :sparkles: *safer* :sparkles:, because you can't change the metadata on accident.) --- This PR essentially changes the built-in impls of `Pointee` from this: ```rust // before impl Pointee for u8 { type Metadata = (); } impl Pointee for [u8] { type Metadata = usize; } // ... impl Pointee for Wrapper<u8> { type Metadata = (); } impl Pointee for Wrapper<[u8]> { type Metadata = usize; } // ... // This impl is only selected if `T` is a type parameter or unnormalizable projection or opaque type. fallback impl<T: ?Sized> Pointee for Wrapper<T> where Wrapper<T>: Sized { type Metadata = (); } // This impl is only selected if `T` is a type parameter or unnormalizable projection or opaque type. fallback impl<T /*: Sized */> Pointee for T { type Metadata = (); } ``` to this: ```rust // after impl Pointee for u8 { type Metadata = (); } impl Pointee for [u8] { type Metadata = usize; } // ... impl<T: ?Sized> Pointee for Wrapper<T> { // in the old solver this will instead project to the "deep" tail directly, // e.g. `Wrapper<Wrapper<T>>::Metadata = T::Metadata` type Metadata = <T as Pointee>::Metadata; } // ... // This impl is only selected if `T` is a type parameter or unnormalizable projection or opaque type. fallback impl<T /*: Sized */> Pointee for T { type Metadata = (); } ```
2024-02-08Rollup merge of #120801 - oli-obk:drop_recursion_ice, r=NilstriebMatthias Krüger-0/+1
Avoid ICE in drop recursion check in case of invalid drop impls fixes #120787
2024-02-08Rollup merge of #120590 - compiler-errors:dead, r=NilstriebMatthias Krüger-1/+1
Remove unused args from functions `#[instrument]` suppresses the unused arguments from a function, *and* suppresses unused methods too! This PR removes things which are only used via `#[instrument]` calls, and fixes some other errors (privacy?) that I will comment inline. It's possible that some of these arguments were being passed in for the purposes of being instrumented, but I am unconvinced by most of them.
2024-02-08Avoid ICE in drop recursion check in case of invalid drop implsOli Scherer-0/+1
2024-02-08Auto merge of #120544 - BoxyUwU:enter_forall, r=lcnrbors-0/+1
Introduce `enter_forall` to supercede `instantiate_binder_with_placeholders` r? `@lcnr` Long term we'd like to experiment with decrementing the universe count after "exiting" binders so that we do not end up creating infer vars in non-root universes even when they logically reside in the root universe. The fact that we dont do this currently results in a number of issues in the new trait solver where we consider goals to be ambiguous because otherwise it would require lowering the universe of an infer var. i.e. the goal `?x.0 eq <T as Trait<?y.1>>::Assoc` where the alias is rigid would not be able to instantiate `?x` with the alias as there would be a universe error. This PR is the first-ish sort of step towards being able to implement this as eventually we would want to decrement the universe in `enter_forall`. Unfortunately its Difficult to actually implement decrementing universes nicely so this is a separate step which moves us closer to the long term goal :sparkles:
2024-02-08introduce `enter_forall`Boxy-0/+1
2024-02-08Rollup merge of #120739 - lukas-code:pp-dyn-assoc, r=compiler-errorsMatthias Krüger-13/+47
improve pretty printing for associated items in trait objects * Don't print a binder in front of associated items, because it's not valid syntax. * e.g. print `dyn for<'a> Trait<'a, Assoc = &'a u8>` instead of `dyn for<'a> Trait<'a, for<'a> Assoc = &'a u8>`. * Don't print associated items that are implied by a supertrait bound. * e.g. if we have `trait Sub: Super<Assoc = u8> {}`, then just print `dyn Sub` instead of `dyn Sub<Assoc = u8>`. I've added the test in the first commit, so you can see the diff of the compiler output in the second commit.
2024-02-08Auto merge of #120381 - fee1-dead-contrib:reconstify-add, r=compiler-errorsbors-0/+4
Reconstify `Add` r? project-const-traits I'm not happy with the ui test changes (or failures because I did not bless them and include the diffs in this PR). There is at least some bugs I need to look and try fix: 1. A third duplicated diagnostic when a consumer crate that does not have `effects` enabled has a trait selection error for an upstream const_trait trait. See tests/ui/ufcs/ufcs-qpath-self-mismatch.rs. 2. For some reason, making `Add` a const trait would stop us from suggesting `T: Add` when we try to add two `T`s without that bound. See tests/ui/suggestions/issue-97677.rs
2024-02-07Do not create param types that differ only by name when comparing intrinsic ↵Michael Goulet-1/+1
signatures
2024-02-07Assert that ParamTy and ParamConst have identical names for identical indicesMichael Goulet-2/+8
2024-02-07address review comments and add more testsLukas Markeffsky-10/+15
2024-02-07Record coroutine kind in genericsMichael Goulet-1/+8
2024-02-07improve pretty printing for trait objectsLukas Markeffsky-12/+41
2024-02-06Rollup merge of #120707 - compiler-errors:suitable-region, r=nnethercoteMatthias Krüger-1/+1
Don't expect early-bound region to be local when reporting errors in RPITIT well-formedness The implicit lifetime in the example code gets replaced with `ReError`, which fails a `sub_regions` check in the lexical region solver. Error reporting ends up calling `is_suitable_region` on an early bound region in the *trait* definition. This causes an ICE because we `expect_local()`. This is kind of a bad explanation, but this code just makes diagnostics reporting a bit more gracefully fallible. If the reviewer wants a thorough investigation of exactly where we get this region outlives obligation, I can write one up. Doesn't really seem worth it, though, imo. Fixes #120638 Fixes #120648
2024-02-06Don't expect early-bound region to be local in RPITIT well-formednessMichael Goulet-1/+1
2024-02-06Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closureMichael Goulet-16/+33
2024-02-06More comments, final tweaksMichael Goulet-9/+48
2024-02-06Bless tests, add commentsMichael Goulet-4/+39
2024-02-06Construct body for by-move coroutine closure outputMichael Goulet-13/+56
2024-02-06Build a shim to call async closures with different AsyncFn trait kindsMichael Goulet-1/+23
2024-02-06Teach typeck/borrowck/solvers how to deal with async closuresMichael Goulet-5/+130
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-8/+220
2024-02-05old solver: improve normalization of `Pointee::Metadata`Lukas Markeffsky-16/+32
2024-02-05Rollup merge of #116284 - RalfJung:no-nan-match, r=cjgillotMatthias Krüger-27/+44
make matching on NaN a hard error, and remove the rest of illegal_floating_point_literal_pattern These arms would never be hit anyway, so the pattern makes little sense. We have had a future-compat lint against float matches in general for a *long* time, so I hope we can get away with immediately making this a hard error. This is part of implementing https://github.com/rust-lang/rfcs/pull/3535. Closes https://github.com/rust-lang/rust/issues/41620 by removing the lint. https://github.com/rust-lang/reference/pull/1456 updates the reference to match.
2024-02-05Auto merge of #120497 - compiler-errors:modulize, r=lcnrbors-1456/+1491
Move predicate, region, and const stuff into their own modules in middle This PR mostly moves things around, and in a few cases adds some `ty::` to the beginning of names to avoid one-off imports. I don't mean this to be the most *thorough* move/refactor. I just generally wanted to begin to split up `ty/mod.rs` and `ty/sty.rs` which are huge and hard to distinguish, and have a lot of non-ty stuff in them. r? lcnr
2024-02-04make effect infer variables suggestable in diagnosticsDeadbeef-0/+4
it works when a non-const context that does not enable effects calls into a const effects-enabled trait. We'd simply suggest the non-const trait bound in this case consistent to its fallback.
2024-02-02Remove dead args from functionsMichael Goulet-1/+1
2024-01-31Rollup merge of #120495 - clubby789:remove-amdgpu-kernel, r=oli-obkNadrieril-1/+0
Remove the `abi_amdgpu_kernel` feature The tracking issue (#51575) has been closed for 3 years, with no activity for 5.
2024-01-30Move predicate, region, and const stuff into their own modules in middleMichael Goulet-1456/+1491
2024-01-30Remove the `abi_amdgpu_kernel` featureclubby789-1/+0
2024-01-30Remove the lifetime from `DiagnosticArgValue`.Nicholas Nethercote-13/+13
Because it's almost always static. This makes `impl IntoDiagnosticArg for DiagnosticArgValue` trivial, which is nice. There are a few diagnostics constructed in `compiler/rustc_mir_build/src/check_unsafety.rs` and `compiler/rustc_mir_transform/src/errors.rs` that now need symbols converted to `String` with `to_string` instead of `&str` with `as_str`, but that' no big deal, and worth it for the simplifications elsewhere.
2024-01-26make matching on NaN a hard errorRalf Jung-27/+44
2024-01-26Auto merge of #116167 - RalfJung:structural-eq, r=lcnrbors-5/+4
remove StructuralEq trait The documentation given for the trait is outdated: *all* function pointers implement `PartialEq` and `Eq` these days. So the `StructuralEq` trait doesn't really seem to have any reason to exist any more. One side-effect of this PR is that we allow matching on some consts that do not implement `Eq`. However, we already allowed matching on floats and consts containing floats, so this is not new, it is just allowed in more cases now. IMO it makes no sense at all to allow float matching but also sometimes require an `Eq` instance. If we want to require `Eq` we should adjust https://github.com/rust-lang/rust/pull/115893 to check for `Eq`, and rule out float matching for good. Fixes https://github.com/rust-lang/rust/issues/115881
2024-01-25Auto merge of #120335 - matthiaskrgr:rollup-2a0y3rd, r=matthiaskrgrbors-1/+1
Rollup of 10 pull requests Successful merges: - #119305 (Add `AsyncFn` family of traits) - #119389 (Provide more context on recursive `impl` evaluation overflow) - #119895 (Remove `track_errors` entirely) - #120230 (Assert that a single scope is passed to `for_scope`) - #120278 (Remove --fatal-warnings on wasm targets) - #120292 (coverage: Dismantle `Instrumentor` and flatten span refinement) - #120315 (On E0308 involving `dyn Trait`, mention trait objects) - #120317 (pattern_analysis: Let `ctor_sub_tys` return any Iterator they want) - #120318 (pattern_analysis: Reuse most of the `DeconstructedPat` `Debug` impl) - #120325 (rustc_data_structures: use either instead of itertools) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-25Rollup merge of #119895 - oli-obk:track_errors_3, r=matthewjasperMatthias Krüger-1/+1
Remove `track_errors` entirely follow up to https://github.com/rust-lang/rust/pull/119869 r? `@matthewjasper` There are some diagnostic changes adding new diagnostics or not emitting some anymore. We can improve upon that in follow-up work imo.
2024-01-25Auto merge of #119955 - kamalesh0406:master, r=WaffleLapkinbors-18/+56
Modify GenericArg and Term structs to use strict provenance rules This is the first PR to solve issue #119217 . In this PR, I have modified the GenericArg struct to use the `NonNull` struct as the pointer instead of `NonZeroUsize`. The change were tested by running `./x test compiler/rustc_middle`. Resolves https://github.com/rust-lang/rust/issues/119217 r? `@WaffleLapkin`
2024-01-24remove StructuralEq traitRalf Jung-5/+4
2024-01-23Auto merge of #120283 - fmease:rollup-rk0f6r5, r=fmeasebors-10/+8
Rollup of 9 pull requests Successful merges: - #112806 (Small code improvements in `collect_intra_doc_links.rs`) - #119766 (Split tait and impl trait in assoc items logic) - #120139 (Do not normalize closure signature when building `FnOnce` shim) - #120160 (Manually implement derived `NonZero` traits.) - #120171 (Fix assume and assert in jump threading) - #120183 (Add `#[coverage(off)]` to closures introduced by `#[test]` and `#[bench]`) - #120195 (add several resolution test cases) - #120259 (Split Diagnostics for Uncommon Codepoints: Add List to Display Characters Involved) - #120261 (Provide structured suggestion to use trait objects in some cases of `if` arm type divergence) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-23Rollup merge of #120139 - compiler-errors:fnonce-shim, r=BoxyUwULeón Orell Valerian Liehr-10/+8
Do not normalize closure signature when building `FnOnce` shim It is not necessary to normalize the closure signature when building an `FnOnce` shim for an `Fn`/`FnMut` closure. That closure shim is just calling `FnMut::call_mut(&mut self)` anyways. It's also somewhat sketchy that we were ever doing this to begin with, since we're normalizing with a `ParamEnv::reveal_all()` param-env, which is definitely not right with possibly polymorphic substs. This cuts out a tiny bit of unnecessary work in `Instance::resolve` and simplifies the signature because now we can unconditionally return an `Instance`.
2024-01-23Rollup merge of #120270 - compiler-errors:randos, r=lcnrLeón Orell Valerian Liehr-50/+33
A bunch of random modifications r? oli-obk Kitchen sink of changes that I didn't know where to put elsewhere. Documentation tweaks mostly, but also removing some unreachable code and simplifying the pretty printing for closures/coroutines.
2024-01-23Remove track_errors entirelyOli Scherer-1/+1
2024-01-23Random type checker changesMichael Goulet-50/+33