about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2022-04-15Rollup merge of #94457 - jhpratt:stabilize-derive_default_enum, r=davidtwcoDylan DPC-1/+1
Stabilize `derive_default_enum` This stabilizes `#![feature(derive_default_enum)]`, as proposed in [RFC 3107](https://github.com/rust-lang/rfcs/pull/3107) and tracked in #87517. In short, it permits you to `#[derive(Default)]` on `enum`s, indicating what the default should be by placing a `#[default]` attribute on the desired variant (which must be a unit variant in the interest of forward compatibility). ```````@rustbot``````` label +S-waiting-on-review +T-lang
2022-04-14Error on `#[rustc_deprecated]`Jacob Pratt-3/+2
2022-04-14Update issue-92893.stderrouz-a-6/+3
2022-04-14Reimplement lowering of sym operands for asm! so that it also works with ↵Amanieu d'Antras-3/+4
global_asm!
2022-04-13couple of clippy::complexity fixesMatthias Krüger-1/+1
2022-04-13Inline Const::ty() and Const::val() gettersMartin Gammelsæter-0/+2
2022-04-13Auto merge of #95656 - cjgillot:no-id-hashing-mode, r=Aaron1011bors-96/+10
Remove NodeIdHashingMode. r? `@ghost`
2022-04-13Consider lifetimes when comparing types for equality in MIR validatorJakob Degen-1/+2
2022-04-13Auto merge of #94255 - b-naber:use-mir-constant-in-thir, r=oli-obkbors-14/+177
Use mir constant in thir instead of ty::Const This is blocked on https://github.com/rust-lang/rust/pull/94059 (does include its changes, the first two commits in this PR correspond to those changes) and https://github.com/rust-lang/rust/pull/93800 being reinstated (which had to be reverted). Mainly opening since `@lcnr` offered to give some feedback and maybe also for a perf-run (if necessary). This currently contains a lot of duplication since some of the logic of `ty::Const` had to be copied to `mir::ConstantKind`, but with the introduction of valtrees a lot of that functionality will disappear from `ty::Const`. Only the last commit contains changes that need to be reviewed here. Did leave some `FIXME` comments regarding future implementation decisions and some things that might be incorrectly implemented. r? `@oli-obk`
2022-04-12Rollup merge of #95970 - WaffleLapkin:nicer_trait_suggestions, r=compiler-errorsDylan DPC-7/+28
Fix suggestions in case of `T:` bounds This PR fixes a corner case in `suggest_constraining_type_params` that was causing incorrect suggestions. For the following functions: ```rust fn a<T:>(t: T) { [t, t]; } fn b<T>(t: T) where T: { [t, t]; } ``` We previously suggested the following: ```text ... help: consider restricting type parameter `T` | 1 | fn a<T: Copy:>(t: T) { [t, t]; } | ++++++ ... help: consider further restricting this bound | 2 | fn b<T>(t: T) where T: + Copy { [t, t]; } | ++++++ ``` Note that neither `T: Copy:` not `where T: + Copy` is a correct bound. With this commit the suggestions are correct: ```text ... help: consider restricting type parameter `T` | 1 | fn a<T: Copy>(t: T) { [t, t]; } | ++++ ... help: consider further restricting this bound | 2 | fn b<T>(t: T) where T: Copy { [t, t]; } | ++++ ``` r? `@compiler-errors` I've tried fixing #95898 here too, but got too confused with how `suggest_traits_to_import` works and what it does :sweat_smile:
2022-04-12Remove NodeIdHashingMode.Camille GILLOT-96/+10
2022-04-12Fix wrong suggestions for `T:`Maybe Waffle-7/+28
This commit fixes a corner case in `suggest_constraining_type_params` that was causing incorrect suggestions. For the following functions: ```rust fn a<T:>(t: T) { [t, t]; } fn b<T>(t: T) where T: { [t, t]; } ``` We previously suggested the following: ```text ... help: consider restricting type parameter `T` | 1 | fn a<T: Copy:>(t: T) { [t, t]; } | ++++++ ... help: consider further restricting this bound | 2 | fn b<T>(t: T) where T: + Copy { [t, t]; } | ++++++ ``` Note that neither `T: Copy:` not `where T: + Copy` is a correct bound. With this commit the suggestions are correct: ```text ... help: consider restricting type parameter `T` | 1 | fn a<T: Copy>(t: T) { [t, t]; } | ++++ ... help: consider further restricting this bound | 2 | fn b<T>(t: T) where T: Copy { [t, t]; } | ++++ ```
2022-04-11Remove rule that place loads may not happen with variant index setJakob Degen-5/+4
2022-04-11Add more clarifications in response to Ralf's commentsJakob Degen-102/+84
2022-04-11Address various comments and change some details around place to value ↵Jakob Degen-35/+36
conversions
2022-04-11Improve MIR phases documentation with summaries of changesJakob Degen-1/+23
2022-04-11Improve documentation for MIR terminatorsJakob Degen-27/+121
2022-04-11Improve documentation for MIR statement kinds.Jakob Degen-16/+76
2022-04-11Add documentation for the semantics of MIR rvaluesJakob Degen-23/+101
2022-04-11Adjust computation of place types to detect more invalid placesJakob Degen-0/+3
2022-04-11Improve documentation of `Place` and `Operand`Jakob Degen-13/+121
2022-04-11Auto merge of #95125 - JakobDegen:uninit-variant-rvalue, r=oli-obkbors-1/+23
Add new `Deinit` statement This rvalue replaces `SetDiscriminant` for ADTs. This PR is an alternative to #94590 , which only specifies that the behavior of `SetDiscriminant` is the same as what this rvalue would do. The motivation for this change are discussed in that PR and [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/SetDiscriminant.20and.20aggregate.20initialization.20.2394590) r? `@oli-obk`
2022-04-11Add new `MutatatingUseContext`s for deinit and `SetDiscriminant`Jakob Degen-2/+6
2022-04-11Document semantics of `Deinit` and `SetDiscriminant` MIR statementsJakob Degen-0/+7
2022-04-11Add new `Deinit` statement kindJakob Degen-0/+11
2022-04-11Rollup merge of #95907 - compiler-errors:diag, r=Dylan-DPCMatthias Krüger-61/+63
address fixme for diagnostic variable name quick rename
2022-04-10FIXME for diagnostic variable nameMichael Goulet-61/+63
2022-04-10Store LocalDefId in is_late_bound_map.Camille GILLOT-8/+2
This allows to avoid looking at HIR from borrowck.
2022-04-09Auto merge of #95435 - cjgillot:one-name, r=oli-obkbors-36/+32
Make def names and HIR names consistent. The name in the `DefKey` is interned to create the `DefId`, so it does not require any query to access. This can be leveraged to avoid a few useless HIR accesses for names. ~In order to achieve that, generic parameters created from universal impl-trait are given the pretty-printed ast as a name, instead of `{{opaque}}`.~ ~Drive-by: the `TyCtxt::opt_item_name` used a dummy span for non-local definitions. We have access to `def_ident_span`, so we use it.~
2022-04-09rename to par_for_each_itemMiguel Guarniz-1/+1
2022-04-09use copied() and avoid creating a vector in items and par_itemsMiguel Guarniz-8/+11
2022-04-09avoid accessing the interner by comparing the Symbol directlyMiguel Guarniz-1/+1
2022-04-09avoid creating vec in methods in ModuleItemsMiguel Guarniz-2/+2
2022-04-09Auto merge of #95697 - klensy:no-strings, r=petrochenkovbors-3/+3
refactor: simplify few string related interactions Few small optimizations: check_doc_keyword: don't alloc string for emptiness check check_doc_alias_value: get argument as Symbol to prevent needless string convertions check_doc_attrs: don't alloc vec, iterate over slice. replace as_str() check with symbol check get_single_str_from_tts: don't prealloc string trivial string to str replace LifetimeScopeForPath::NonElided use Vec<Symbol> instead of Vec<String> AssertModuleSource use FxHashSet<Symbol> instead of BTreeSet<String> CrateInfo.crate_name replace FxHashMap<CrateNum, String> with FxHashMap<CrateNum, Symbol>
2022-04-09Rollup merge of #95785 - RalfJung:interpret-size-mismatch, r=oli-obkDylan DPC-16/+46
interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internal We did this a while ago already for `to_i32()` and friends, but missed this one. That became quite annoying when I was debugging an ICE caused by `read_pointer` in a Miri shim where the code was passing an argument at the wrong type. Having `scalar_to_ptr` be fallible is consistent with all the other `Scalar::to_*` methods being fallible. I added `unwrap` only in code outside the interpreter, which is no worse off than before now in terms of panics. r? ````@oli-obk````
2022-04-09Use def_key in `tcx.item_name` when possible.Camille GILLOT-28/+25
2022-04-09Auto merge of #95524 - oli-obk:cached_stable_hash_cleanups, r=nnethercotebors-188/+157
Cached stable hash cleanups r? `@nnethercote` Add a sanity assertion in debug mode to check that the cached hashes are actually the ones we get if we compute the hash each time. Add a new data structure that bundles all the hash-caching work to make it easier to re-use it for different interned data structures
2022-04-08remove ItemLikeVisitor impls and add fast paths using DefKindMiguel Guarniz-2/+5
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08remove some uses of visit_all_item_likes in incremental, metadata and ↵Miguel Guarniz-0/+15
interface crates Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08Refactor HIR item-like traversal (part 1)Miguel Guarniz-15/+85
- Create hir_crate_items query which traverses tcx.hir_crate(()).owners to return a hir::ModuleItems - use tcx.hir_crate_items in tcx.hir().items() to return an iterator of hir::ItemId - add par_items(impl Fn(hir::ItemId)) to traverse all items in parallel Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-04-08Avoid looking at the internals of Interned directlyOli Scherer-165/+124
2022-04-08create leafs for slicesb-naber-29/+1
2022-04-08dont make lit_to_mir_constant a queryb-naber-4/+0
2022-04-08check_doc_keyword: don't alloc string for emptiness checkklensy-3/+3
check_doc_alias_value: get argument as Symbol to prevent needless string convertions check_doc_attrs: don't alloc vec, iterate over slice. Vec introduced in #83149, but no perf run posted on merge replace as_str() check with symbol check get_single_str_from_tts: don't prealloc string trivial string to str replace LifetimeScopeForPath::NonElided use Vec<Symbol> instead of Vec<String> AssertModuleSource use BTreeSet<Symbol> instead of BTreeSet<String> CrateInfo.crate_name replace FxHashMap<CrateNum, String> with FxHashMap<CrateNum, Symbol>
2022-04-07Stabilize `derive_default_enum`Jacob Pratt-1/+1
2022-04-07Compute `ty_param_owner` using DefIdTree.Camille GILLOT-8/+7
2022-04-07interpret: err instead of ICE on size mismatches in to_bits_or_ptr_internalRalf Jung-16/+46
2022-04-07Deduplicate the error printing code for hidden type mismatchesOli Scherer-0/+20
2022-04-07Report opaque type mismatches directly during borrowck of the function ↵Oli Scherer-2/+1
instead of within the `type_of` query. This allows us to only store a single hidden type per opaque type instead of having to store one per set of substitutions.
2022-04-07Document and rename the new wrapper typeOli Scherer-23/+37