summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty
AgeCommit message (Collapse)AuthorLines
2023-11-09Make sure that predicates with unmentioned bound vars are still considered ↵Michael Goulet-32/+12
global in the old solver (cherry picked from commit 32294fc0ed1810a16fcea649955a9b21ea061734)
2023-11-09only erase param env regions where neededlcnr-1/+1
(cherry picked from commit a582e9638b1653c269a4cba0ed00f78eb138b7e7)
2023-11-09dropck_outlives check generator witness needs_droplcnr-4/+6
(cherry picked from commit 57253552de475856a1f3bddedcd76e775892f770)
2023-09-27Auto merge of #116163 - compiler-errors:lazyness, r=oli-obkbors-10/+10
Don't store lazyness in `DefKind::TyAlias` 1. Don't store lazyness of a type alias in its `DefKind`, but instead via a query. 2. This allows us to treat type aliases as lazy if `#[feature(lazy_type_alias)]` *OR* if the alias contains a TAIT, rather than having checks for both in separate parts of the codebase. r? `@oli-obk` cc `@fmease`
2023-09-26subst -> instantiatelcnr-24/+12
2023-09-26Don't store lazyness in DefKindMichael Goulet-10/+10
2023-09-24Remove span from BrAnon.Camille GILLOT-9/+9
2023-09-23Remove GeneratorWitness and rename GeneratorWitnessMIR.Camille GILLOT-79/+26
2023-09-23Enable drop_tracking_mir by default.Camille GILLOT-75/+2
2023-09-23Auto merge of #116052 - oli-obk:ceci_nest_pas_une_query, r=WaffleLapkinbors-0/+6
Add a way to decouple the implementation and the declaration of a TyCtxt method. properly addresses https://github.com/rust-lang/rust/pull/115819 accepted MCP: https://github.com/rust-lang/compiler-team/issues/395
2023-09-22Auto merge of #115696 - RalfJung:closure-ty-print, r=oli-obkbors-8/+8
adjust how closure/generator types are printed I saw `&[closure@$DIR/issue-20862.rs:2:5]` and I thought it is a slice type, because that's usually what `&[_]` is... it took me a while to realize that this is just a confusing printer and actually there's no slice. Let's use something that cannot be mistaken for a regular type.
2023-09-22Rollup merge of #116041 - compiler-errors:rigid-note, r=RalfJungMatthias Krüger-0/+5
Add note to `is_known_rigid` Adds a note requested by `@RalfJung` in https://github.com/rust-lang/rust/pull/114941#discussion_r1329963704 Let me know if there are any other fns that need documentation, I could throw them into this PR too :)
2023-09-22Add a way to decouple the implementation and the declaration of a TyCtxt method.Oli Scherer-0/+6
2023-09-22Add note to is_known_rigidMichael Goulet-0/+5
2023-09-21Auto merge of #115864 - compiler-errors:rpitit-sugg, r=estebankbors-0/+14
Suggest desugaring to return-position `impl Future` when an `async fn` in trait fails an auto trait bound First commit allows us to store the span of the `async` keyword in HIR. Second commit implements a suggestion to desugar an `async fn` to a return-position `impl Future` in trait to slightly improve the `Send` situation being discussed in #115822. This suggestion is only made when `#![feature(return_type_notation)]` is not enabled -- if it is, we should instead suggest an appropriate where-clause bound.
2023-09-21adjust how closure/generator types and rvalues are printedRalf Jung-8/+8
2023-09-21Record asyncness span in HIRMichael Goulet-0/+14
2023-09-21Auto merge of #114399 - Zalathar:no-renumber, r=jackh726bors-1/+0
coverage: Don't bother renumbering expressions on the Rust side The LLVM API that we use to encode coverage mappings already has its own code for removing unused coverage expressions and renumbering the rest. This lets us get rid of our own complex renumbering code, making it easier to change our coverage code in other ways. --- Now that we have tests for coverage mappings (#114843), I've been able to verify that this PR doesn't make the coverage mappings worse, thanks to an explicit simplification step.
2023-09-21Rollup merge of #115972 - RalfJung:const-consistency, r=oli-obkGuillaume Gomez-11/+6
rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const Also, be more consistent with the `to/eval_bits` methods... we had some that take a type and some that take a size, and then sometimes the one that takes a type is called `bits_for_ty`. Turns out that `ty::Const`/`mir::ConstKind` carry their type with them, so we don't need to even pass the type to those `eval_bits` functions at all. However this is not properly consistent yet: in `ty` we have most of the methods on `ty::Const`, but in `mir` we have them on `mir::ConstKind`. And indeed those two types are the ones that correspond to each other. So `mir::ConstantKind` should actually be renamed to `mir::Const`. But what to do with `mir::Constant`? It carries around a span, that's really more like a constant operand that appears as a MIR operand... it's more suited for `syntax.rs` than `consts.rs`, but the bigger question is, which name should it get if we want to align the `mir` and `ty` types? `ConstOperand`? `ConstOp`? `Literal`? It's not a literal but it has a field called `literal` so it would at least be consistently wrong-ish... ``@oli-obk`` any ideas?
2023-09-21coverage: Don't bother renumbering expressions on the Rust sideZalathar-1/+0
The LLVM API that we use to encode coverage mappings already has its own code for removing unused coverage expressions and renumbering the rest. This lets us get rid of our own complex renumbering code, making it easier to change our coverage code in other ways.
2023-09-20Auto merge of #115870 - RalfJung:const-value-slice, r=oli-obkbors-0/+1
adjust ConstValue::Slice to work for arbitrary slice types valtrees have already been assuming that this works; this PR makes it a reality. Also further restrict `ConstValue::Slice` to what it is actually used for; this even shrinks `ConstValue` from 32 to 24 bytes which is a nice win. :) The alternative to this approach is to make `ConstValue::Slice` work really only for `&str`/`&[u8]` literals, and never return it in `op_to_const`. That would make `op_to_const` very clean. We could then even remove the `meta` field; the length would always be `data.inner().len()`. We could *almost* just use a `Symbol` instead of a `ConstAllocation`, but we have to support byte strings and there doesn't seem to be an interned representation of them (or rather, `ConstAllocation` *is* their interned representation). In this world, valtrees of slice reference types would then become noticeably more expensive to turn into a `ConstValue` -- but does that matter? Specifically for `&str`/`&[u8]` we could still use the optimized representation if we wanted. If byte strings were already interned somewhere I'd gravitate towards the alternative, but the way things stand, we need a `ConstAllocation` case anyway to support byte strings, and then we might as well support arbitrary slices. (Or we say that byte strings don't get an optimized representation at all. Such a performance cliff between `str` and byte strings is probably unexpected, though due to the lack of interning for byte strings I think there might already be a performance cliff there.)
2023-09-20Rollup merge of #115566 - ↵Guillaume Gomez-40/+6
zirconium-n:issue-107250-clean-up-unused-to-predicate, r=oli-obk clean up unneeded `ToPredicate` impls Part of #107250. Removed all totally unused impls. And inlined two impls not need to satisify trait bound. r? `@oli-obk`
2023-09-20the Const::eval_bits methods don't need to be given the TyRalf Jung-11/+6
2023-09-19Auto merge of #113955 - cjgillot:name-apit, r=WaffleLapkinbors-4/+0
Pretty-print argument-position impl trait to name it. This removes a corner case. RPIT and TAIT keep having no name, and it would be wrong to use the one in HIR (Ident::empty), so I make this case ICE.
2023-09-20remove `impl<'tcx> ToPredicate<'tcx, Clause<'tcx>> for ↵Ziru Niu-8/+6
PolyProjectionPredicate<'tcx>`
2023-09-20remove unneeded `ToPredicate` implsZiru Niu-32/+0
2023-09-19Rollup merge of #115499 - msizanoen1:riscv-fix-transparent-union-abi, r=bjorn3Guillaume Gomez-0/+4
rustc_target/riscv: Fix passing of transparent unions with only one non-ZST member This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed through an `extern "C"` function. Fixes https://github.com/rust-lang/rust/issues/115481. r? `@RalfJung`
2023-09-19adjust constValue::Slice to work for arbitrary slice typesRalf Jung-0/+1
2023-09-19Auto merge of #115865 - RalfJung:mir-mod, r=oli-obkbors-0/+15
move things out of mir/mod.rs This moves a bunch of things out of `mir/mod.rs`: - all const-related stuff to a new file consts.rs - all statement/place/operand-related stuff to a new file statement.rs - all pretty-printing related stuff to pretty.rs `mod.rs` started out with 3100 lines and ends up with 1600. :) Also there was some pretty-printing stuff in terminator.rs, that also got moved to pretty.rs, and I reordered things in pretty.rs so that it can be grouped by functionality. Only the commit "use pretty_print_const_value from MIR constant 'extra' printing" has any behavior changes; it resolves the issue of having a fancy and a very crude pretty-printer for `ConstValue`. r? `@oli-obk`
2023-09-19rustc_target/riscv: Fix passing of transparent unions with only one non-ZST ↵msizanoen-0/+4
member This ensures that `MaybeUninit<T>` has the same ABI as `T` when passed through an `extern "C"` function. Fixes https://github.com/rust-lang/rust/issues/115481.
2023-09-19use pretty_print_const_value from MIR constant 'extra' printingRalf Jung-1/+1
2023-09-19move some MIR const pretty-printing into pretty.rsRalf Jung-0/+15
2023-09-19Don't resolve generic instances if they may be shadowed by dynMichael Goulet-0/+27
2023-09-19Rollup merge of #115873 - BoxyUwU:tykind_adt_debug, r=oli-obkMatthias Krüger-0/+1
Make `TyKind::Adt`'s `Debug` impl be more pretty Currently `{:?}` on `Ty` for a `TyKind::Adt` would print as `Adt(Foo, [])`. This PR changes it to be `Foo` when there are no generics or `Foo<T>`/`Foo<T, U>` when there _are_ generics. Example from debug log: `├─0ms DEBUG rustc_hir_analysis::astconv return=Bar<T/#0, U/#1>` I should have done this in my initial PR for a prettier TyKind: Debug impl but I thought I would need to be accessing generics_of to figure out where in the "path" the generics would have to go??? but no, adts literally only have a single place the generics can go (on the end). Feel a bit silly about this :) r? `@oli-obk`
2023-09-18Auto merge of #115748 - RalfJung:post-mono, r=oli-obkbors-5/+5
move required_consts check to general post-mono-check function This factors some code that is common between the interpreter and the codegen backends into shared helper functions. Also as a side-effect the interpreter now uses the same `eval` functions as everyone else to get the evaluated MIR constants. Also this is in preparation for another post-mono check that will be needed for (the current hackfix for) https://github.com/rust-lang/rust/issues/115709: ensuring that all locals are dynamically sized. I didn't expect this to change diagnostics, but it's just cycle errors that change. r? `@oli-obk`
2023-09-18make more prettyBoxy-0/+1
2023-09-18Rollup merge of #115907 - RalfJung:interner-check, r=compiler-errorsMatthias Krüger-0/+24
nop_lift macros: ensure that we are using the right interner Right now someone could put down the wrong list name when using these macros, and everything would still build. Nothing does a type-check to ensure that the `$set` contains element of type `Self::Lifted`. Let's fix that. For lists this is fairly easy; for the other interners we need to unwrap some newtypes which makes this more complicated.
2023-09-18Remove more unused `Lift` impls.Nicholas Nethercote-105/+28
2023-09-18Remove unused `Lift` derives.Nicholas Nethercote-15/+18
I found these by commenting out all `Lift` derives and then adding back the ones that were necessary to successfully compile.
2023-09-18Rename `CloneLiftImpls` as `TrivialLiftImpls`.Nicholas Nethercote-2/+2
To match `TrivialTypeTraversalImpls` and `TrivialTypeTraversalAndLiftImpls`, and because the `Clone` doesn't mean anything.
2023-09-18Remove unused `Display` impls.Nicholas Nethercote-6/+0
2023-09-18Remove `RegionHighlightMode::tcx`.Nicholas Nethercote-14/+9
It's easier to pass it in to the one method that needs it (`highlighting_region_vid`) than to store it in the type. This means `RegionHighlightMode` can impl `Default`.
2023-09-17nop_lift macros: ensure that we are using the right internerRalf Jung-0/+24
2023-09-17Auto merge of #114452 - weiznich:feature/diagnostic_on_unimplemented, ↵bors-0/+16
r=compiler-errors `#[diagnostic::on_unimplemented]` without filters This commit adds support for a `#[diagnostic::on_unimplemented]` attribute with the following options: * `message` to customize the primary error message * `note` to add a customized note message to an error message * `label` to customize the label part of the error message The relevant behavior is specified in [RFC-3366](https://rust-lang.github.io/rfcs/3366-diagnostic-attribute-namespace.html)
2023-09-16Rollup merge of #115884 - RalfJung:const-debug-print, r=oli-obkMatthias Krüger-6/+20
make ty::Const debug printing less verbose Similar in spirit to https://github.com/rust-lang/rust/pull/115873
2023-09-16make ty::Const debug printing less verboseRalf Jung-6/+20
2023-09-15Fix incorrect codeblock attributes in docsGuillaume Gomez-2/+2
2023-09-14move required_consts check to general post-mono-check functionRalf Jung-5/+5
2023-09-14Auto merge of #115848 - matthiaskrgr:rollup-lsul9dz, r=matthiaskrgrbors-15/+45
Rollup of 4 pull requests Successful merges: - #115772 (Improve Span in smir) - #115832 (Fix the error message for `#![feature(no_coverage)]`) - #115834 (Properly consider binder vars in `HasTypeFlagsVisitor`) - #115844 (Paper over an accidental regression) r? `@ghost` `@rustbot` modify labels: rollup
2023-09-14Rollup merge of #115834 - compiler-errors:binder-vars, r=jackh726Matthias Krüger-15/+45
Properly consider binder vars in `HasTypeFlagsVisitor` Given a PolyTraitRef like `for<'a> Ty: Trait` (where neither `Ty` nor `Trait` mention `'a`), we do *not* return true for `.has_type_flags(TypeFlags::HAS_LATE_BOUND)`, even though binders are supposed to act as if they have late-bound vars even if they don't mention them in their bound value: 31ae3b2bdb9376b749fc1d64b531e86806e03c73. This is because we use `HasTypeFlagsVisitor`, which only computes the type flags for `Ty`, `Const` and `Region` and `Predicates`, and we consequently skip any binders (and setting flags for their vars) that are not contained in one of these types. This ends up causing a problem, because when we call `TyCtxt::erase_regions` (which both erases regions *and* anonymizes bound vars), we will skip such a PolyTraitRef, not anonymizing it, and therefore not making it structurally equal to other binders. This breaks vtable computations. This PR computes the flags for all binders we enter in `HasTypeFlagsVisitor` if we're looking for `TypeFlags::HAS_LATE_BOUND` (or `TypeFlags::HAS_{RE,TY,CT}_LATE_BOUND`). Fixes #115807