about summary refs log tree commit diff
path: root/src/librustc_middle/ty
AgeCommit message (Collapse)AuthorLines
2020-06-19Rollup merge of #72689 - lcnr:common_str, r=estebankManish Goregaokar-6/+3
add str to common types I already expected this to be the case and it may slightly improve perf. Afaict if we ever want to change str into a lang item this would have to get reverted. As that would be fairly simple I don't believe this to cause any problems in the future.
2020-06-19Account for multiple impl/dyn Trait in return type when suggesting `'_`Esteban Küber-36/+27
2020-06-19code coverage foundation for hash and num_countersRich Kadel-0/+7
Replaced dummy values for hash and num_counters with computed values, and refactored InstrumentCoverage pass to simplify injecting more counters per function in upcoming versions. Improved usage documentation and error messaging.
2020-06-19Rollup merge of #73357 - petrochenkov:tmap, r=davidtwcoManish Goregaokar-3/+3
Use `LocalDefId` for import IDs in trait map cc https://github.com/rust-lang/rust/pull/73291#discussion_r439734867
2020-06-19Rollup merge of #73257 - davidtwco:issue-73249-improper-ctypes-projection, ↵Manish Goregaokar-23/+13
r=lcnr,varkor ty: projections in `transparent_newtype_field` Fixes #73249. This PR modifies `transparent_newtype_field` so that it handles projections with generic parameters, where `normalize_erasing_regions` would ICE.
2020-06-19pretty/mir: const value enums with no variantsDavid Wood-1/+12
This commit modifies the pretty printer and const eval in the MIR so that `destructure_const` (used in `pretty_print_const_value`) can handle enums with no variants (or types containing enums with no variants). Signed-off-by: David Wood <david@davidtw.co>
2020-06-19ty: simplify `transparent_newtype_field`David Wood-13/+1
This commit removes the normalization from `transparent_newtype_field` - turns out it wasn't necessary and that makes it a bunch simpler - particularly when handling projections. Signed-off-by: David Wood <david@davidtw.co>
2020-06-19lint: unify enum variant, union and struct logicDavid Wood-27/+25
This commit applies the changes introduced in #72890 to both enum variants and unions - where the logic prior to #72890 was duplicated. Signed-off-by: David Wood <david@davidtw.co>
2020-06-19ty: projections in `transparent_newtype_field`David Wood-4/+8
This commit modifies `transparent_newtype_field` so that it handles projections with generic parameters, where `normalize_erasing_regions` would ICE. Signed-off-by: David Wood <david@davidtw.co>
2020-06-19Rollup merge of #72497 - RalfJung:tag-term, r=oli-obkRalf Jung-29/+29
tag/niche terminology cleanup The term "discriminant" was used in two ways throughout the compiler: * every enum variant has a corresponding discriminant, that can be given explicitly with `Variant = N`. * that discriminant is then encoded in memory to store which variant is active -- but this encoded form of the discriminant was also often called "discriminant", even though it is conceptually quite different (e.g., it can be smaller in size, or even use niche-filling). After discussion with @eddyb, this renames the second term to "tag". The way the tag is encoded can be either `TagEncoding::Direct` (formerly `DiscriminantKind::Tag`) or `TagEncoding::Niche` (formerly `DiscrimianntKind::Niche`). This finally resolves some long-standing confusion I had about the handling of variant indices and discriminants, which surfaced in https://github.com/rust-lang/rust/pull/72419. (There is also a `DiscriminantKind` type in libcore, it remains unaffected. I think this corresponds to the discriminant, not the tag, so that seems all right.) r? @eddyb
2020-06-18Rollup merge of #72804 - estebank:opaque-missing-lts-in-fn-2, r=nikomatsakisManish Goregaokar-9/+17
Further tweak lifetime errors involving `dyn Trait` and `impl Trait` in return position * Suggest substituting `'static` lifetime in impl/dyn `Trait + 'static` instead of `Trait + 'static + '_` * When `'static` is explicit, also suggest constraining argument with it * Reduce verbosity of suggestion message and mention lifetime in label * Tweak output for overlapping required/captured spans * Give these errors an error code Follow up to #72543. r? @nikomatsakis
2020-06-18Rollup merge of #70551 - mark-i-m:ty-err-2, r=varkorManish Goregaokar-40/+67
Make all uses of ty::Error delay a span bug r? @eddyb A second attempt at https://github.com/rust-lang/rust/pull/70245 resolves https://github.com/rust-lang/rust/issues/70866
2020-06-18Perform obligation deduplication to avoid buggy `ExistentialMismatch`Esteban Küber-3/+13
Fix #59326.
2020-06-18Add helper method for reusing an existing interned regionMatthew Jasper-0/+7
2020-06-18Use alloc::Layout in DroplessArena APITomasz Miąsko-12/+5
2020-06-17Unify region variables when projecting associated typesmatthewjasper-0/+3
This is required to avoid cycles when evaluating auto trait predicates.
2020-06-16format derivesWho? Me?!-13/+2
Co-authored-by: lzutao <taolzu@gmail.com>
2020-06-16Rollup merge of #73373 - lzutao:bug-trackcaller, r=AmanieuDylan DPC-2/+1
Use track caller for bug! macro
2020-06-16Rollup merge of #73237 - tmiasko:arena, r=nnethercoteDylan DPC-1/+1
Check for overflow in DroplessArena and align returned memory * Check for overflow when calculating the slice start & end position. * Align the pointer obtained from the allocator, ensuring that it satisfies user requested alignment (the allocator is only asked for layout compatible with u8 slice). * Remove an incorrect assertion from DroplessArena::align. * Avoid forming references to an uninitialized memory in DroplessArena. Helps with #73007, #72624.
2020-06-15track caller for delay_span_bugmark-22/+4
2020-06-15make all uses of ty::Error or ConstKind::Error delay a span bugmark-40/+96
2020-06-15typeck: Use `LocalDefId`s for the unused trait import setVadim Petrochenkov-2/+2
2020-06-15Use `LocalDefId` for import IDs in trait mapVadim Petrochenkov-1/+1
2020-06-15When `'static` is explicit, suggest constraining argument with itEsteban Küber-1/+4
2020-06-15Suggest substituting `'static` lifetime in impl/dyn `Trait + 'static` return ↵Esteban Küber-8/+13
types
2020-06-15Join mutiple lines if it is more readableLzu Tao-2/+1
2020-06-15Rollup merge of #72879 - RalfJung:miri-tctx-at, r=oli-obkRalf Jung-0/+1
Miri: avoid tracking current location three times Miri tracks the current instruction to execute in the call stack, but it also additionally has two `TyCtxtAt` that carry a `Span` that also tracks the current instruction. That is quite silly, so this PR uses `TyCtxt` instead, and then uses a method for computing the current span when a `TyCtxtAt` is needed. Having less redundant (semi-)global state seems like a good improvement to me. :D To keep the ConstProp errors the same, I had to add the option to `error_to_const_error` to overwrite the span. Also for some reason this changes cycle errors a bit -- not sure if we are now better or worse as giving those queries the right span. (It is unfortunately quite easy to accidentally use `DUMMY_SP` by calling the query on a `TyCtxt` instead of a `TyCtxtAt`.) r? @oli-obk @eddyb
2020-06-15Rollup merge of #72740 - estebank:recursive-indirection, r=matthewjasperRalf Jung-1/+9
On recursive ADT, provide indirection structured suggestion
2020-06-15Rollup merge of #72707 - matthewjasper:rustc_min_spec, r=oli-obkRalf Jung-118/+147
Use min_specialization in the remaining rustc crates This adds a lot of `transmute` calls to replace the unsound uses of specialization. It's ugly, but at least it's honest about what's going on. cc #71420, @RalfJung
2020-06-15Avoid forming references to an uninitialized memory in DroplessArenaTomasz Miąsko-1/+1
Return a pointer from `alloc_raw` instead of a slice. There is no practical use for slice as a return type and changing it to a pointer avoids forming references to an uninitialized memory.
2020-06-15Auto merge of #72080 - matthewjasper:uniform-impl-trait, r=nikomatsakisbors-21/+3
Clean up type alias impl trait implementation - Removes special case for top-level impl trait - Removes associated opaque types - Forbid lifetime elision in let position impl trait. This is consistent with the behavior for inferred types. - Handle lifetimes in type alias impl trait more uniformly with other parameters cc #69323 cc #63063 Closes #57188 Closes #62988 Closes #69136 Closes #73061
2020-06-14Improve `Instance` docsJonas Schievink-11/+41
2020-06-13Rollup merge of #73194 - lzutao:INT-patterns, r=dtolnayDylan DPC-3/+3
Prefer the associated constants for pattern matching error Resolved this comment: https://github.com/rust-lang/rust/issues/68490#issuecomment-641614383
2020-06-13Rollup merge of #73066 - ecstatic-morse:query-structural-eq2, r=pnkfelixDylan DPC-0/+51
Querify whether a type has structural equality (Take 2) Alternative to #72177. Unlike in #72177, this helper method works for all types, falling back to a query for `TyKind::Adt`s that determines whether the `{Partial,}StructuralEq` traits are implemented. This is my preferred interface for this method. I think this is better than just documenting that the helper only works for ADTs. If others disagree, we can just merge #72177 with the fixes applied. This has already taken far too long.
2020-06-13Prefer the associated consts for pattern matching errorLzu Tao-3/+3
2020-06-12Use "reflexive equality" in docsDylan MacKenzie-2/+2
2020-06-12Helper method for whether type has structural equalityDylan MacKenzie-0/+51
This helper method works for all types, falling back to a query for `TyKind::Adt`s to determine whether the implement the `{Partial,}StructuralEq` traits.
2020-06-12Rollup merge of #73225 - tmandry:issue-73050, r=oli-obkDylan DPC-10/+1
Allow inference regions when relating consts As first noticed by @eddyb, `super_relate_consts` doesn't need to check for inference vars since `eval` does it already (and handles lifetimes correctly by erasing them). Fixes #73050 r? @oli-obk
2020-06-12make miri InterpCx TyCtxtAt a TyCtxt, and separately remember the root span ↵Ralf Jung-0/+1
of the evaluation
2020-06-12Auto merge of #69478 - avr-rust:avr-support-upstream, r=jonas-schievinkbors-0/+2
Enable AVR as a Tier 3 target upstream Tracking issue: #44052. Things intentionally left out of the initial upstream: * The `target_cpu` flag I have made the cleanup suggestions by @jplatte and @jplatte in https://github.com/avr-rust/rust/commit/043550d9db0582add42e5837f636f61acb26b915. Anybody feel free to give the branch a test and see how it fares, or make suggestions on the code patch itself.
2020-06-11Rollup merge of #73012 - Aaron1011:feature/span-debug-ctxt, r=matthewjasperDylan DPC-3/+5
Show `SyntaxContext` in formatted `Span` debug output This is only really useful in debug messages, so I've switched to calling `span_to_string` in any place that causes a `Span` to end up in user-visible output.
2020-06-11Remove associated opaque typesMatthew Jasper-21/+3
They're unused now.
2020-06-11Auto merge of #71896 - spastorino:existential-assoc-types-variance, ↵bors-2/+2
r=nikomatsakis Relate existential associated types with variance Invariant Fixes #71550 #72315 r? @nikomatsakis The test case reported in that issue now errors with the following message ... ``` error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'a in function call due to conflicting requirements --> /tmp/test.rs:25:5 | 25 | bad(&Bar(PhantomData), x) | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined on the function body at 24:11... --> /tmp/test.rs:24:11 | 24 | fn extend<'a, T>(x: &'a T) -> &'static T { | ^^ note: ...so that reference does not outlive borrowed content --> /tmp/test.rs:25:28 | 25 | bad(&Bar(PhantomData), x) | ^ = note: but, the lifetime must be valid for the static lifetime... note: ...so that the types are compatible --> /tmp/test.rs:25:9 | 25 | bad(&Bar(PhantomData), x) | ^^^^^^^^^^^^^^^^^ = note: expected `&'static T` found `&T` error: aborting due to previous error For more information about this error, try `rustc --explain E0495`. ``` I could also add that test case if we want to have a weaponized one too.
2020-06-10Allow inference regions when relating constsTyler Mandry-10/+1
Fixes #73050
2020-06-10On recursive ADT, provide indirection structured suggestionEsteban Küber-1/+9
2020-06-10Rollup merge of #72890 - ↵Dylan DPC-0/+28
davidtwco:issue-66202-normalize-and-transparent-improper-ctypes, r=varkor improper ctypes: normalize return types and transparent structs Fixes #66202. See each commit individually (except the first which adds a test) for more detailed explanations on the changes made. In summary, this PR ensures that return types are normalized before being checked for FFI-safety, and that transparent newtype wrappers are FFI-safe if the type being wrapped is FFI-safe (often true previously, but not if, after substitution, all types in a transparent newtype were zero sized).
2020-06-10Use min_specialization in the remaining rustc cratesMatthew Jasper-118/+147
2020-06-09Relate existential associated types with variance InvariantSantiago Pastorino-2/+2
2020-06-09lint: transitive FFI-safety for transparent typesDavid Wood-0/+28
This commit ensures that if a `repr(transparent)` newtype's only non-zero-sized field is FFI-safe then the newtype is also FFI-safe. Previously, ZSTs were ignored for the purposes of linting FFI-safety in transparent structs - thus, only the single non-ZST would be checked for FFI-safety. However, if the non-zero-sized field is a generic parameter, and is substituted for a ZST, then the type would be considered FFI-unsafe (as when every field is thought to be zero-sized, the type is considered to be "composed only of `PhantomData`" which is FFI-unsafe). In this commit, for transparent structs, the non-zero-sized field is identified (before any substitutions are applied, necessarily) and then that field's type (now with substitutions) is checked for FFI-safety (where previously it would have been skipped for being zero-sized in this case). To handle the case where the non-zero-sized field is a generic parameter, which is substituted for `()` (a ZST), and is being used as a return type - the `FfiUnsafe` result (previously `FfiPhantom`) is caught and silenced. Signed-off-by: David Wood <david@davidtw.co>
2020-06-09Auto merge of #72114 - anyska:vtable-rename, r=nikomatsakisbors-1/+1
Rename traits::Vtable to ImplSource. Originally suggested by @eddyb. r? @nikomatsakis