about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2022-04-23Compute has_pub_restricted in the resolver.Camille GILLOT-0/+2
2022-04-23Drop vis in Item.Camille GILLOT-17/+1
2022-04-23Stop visiting visibility.Camille GILLOT-8/+0
2022-04-22Relax restrictions for copy operandsJakob Degen-2/+6
2022-04-22Auto merge of #96226 - xldenis:thir-clone, r=oli-obkbors-12/+12
Make all thir types implement clone This PR adds `Clone` impl to all of the `Thir<'tcx>` types. I would like to be able to clone a `Thir` body so that I can make a copy in my rustc driver without breaking further compilation. Without this my driver is forced to run in the `after_expansion` callback and thus doesn't benefit from running all the safety checks that `rustc` usually does, instead i need to do them all myself.
2022-04-22Auto merge of #96197 - erikdesjardins:scalarpairenum, r=oli-obkbors-16/+21
Mark payload fields of ScalarPair enums as Scalar::Union when they're not always initialized Fixes #96158 r? `@RalfJung`
2022-04-21deduplicate a lot of codeb-naber-5/+1
2022-04-21implement (as of now still unused) query for valtree -> constvalue conversionb-naber-0/+5
2022-04-21implement valtree -> constvalue conversionb-naber-1/+9
2022-04-21add helper methods on ValTreeb-naber-0/+16
2022-04-21add some helper methods to ScalarIntb-naber-0/+92
2022-04-20Rollup merge of #96160 - RalfJung:interpret-debug, r=oli-obkDylan DPC-0/+8
Miri/interpreter debugging tweaks Some changes I made to make debugging Miri with trace logging less terrible. r? ``@oli-obk``
2022-04-20Auto merge of #96022 - martingms:inline-const-getters, r=nnethercotebors-0/+2
Inline `ty::Const::ty()` and `ty::Const::val()` getters These were not inlined into `super_relate_consts`, which is one of the hottest functions in a callgrind profile of compiling `bitmaps-3.1.0`. Yields some small speedups across various benchmarks locally: #### Primary benchmarks Benchmark | Profile | Scenario | % Change | Significance Factor? -- | -- | -- | -- | -- unicode-normalization-0.1.19 | check | full | -0.56% | 2.78x unicode-normalization-0.1.19 | check | incr-full | -0.43% | 2.15x unicode-normalization-0.1.19 | opt | full | -0.35% | 1.77x unicode-normalization-0.1.19 | debug | incr-full | -0.31% | 1.56x unicode-normalization-0.1.19 | debug | full | -0.30% | 1.51x #### Secondary benchmarks Benchmark | Profile | Scenario | % Change | Significance Factor? -- | -- | -- | -- | -- bitmaps-3.1.0 | check | full | -1.88% | 9.39x bitmaps-3.1.0 | debug | full | -1.79% | 8.96x bitmaps-3.1.0 | opt | full | -1.69% | 8.43x bitmaps-3.1.0 | check | incr-full | -1.54% | 7.68x bitmaps-3.1.0 | debug | incr-full | -1.45% | 7.27x bitmaps-3.1.0 | opt | incr-full | -1.39% | 6.96x tt-muncher | opt | full | 1.28% | 6.38x nalgebra-0.30.1 | check | full | -0.96% | 4.81x nalgebra-0.30.1 | debug | full | -0.91% | 4.54x nalgebra-0.30.1 | opt | full | -0.90% | 4.52x nalgebra-0.30.1 | check | incr-full | -0.77% | 3.86x nalgebra-0.30.1 | opt | incr-full | -0.76% | 3.79x nalgebra-0.30.1 | debug | incr-full | -0.74% | 3.72x hex-0.4.3 | check | full | -0.70% | 3.50x hex-0.4.3 | debug | full | -0.59% | 2.95x hex-0.4.3 | check | incr-full | -0.56% | 2.80x hex-0.4.3 | opt | full | -0.56% | 2.78x wf-projection-stress-65510 | opt | full | -0.48% | 2.42x hex-0.4.3 | opt | incr-full | -0.48% | 2.40x hex-0.4.3 | debug | incr-full | -0.45% | 2.24x wf-projection-stress-65510 | check | full | -0.44% | 2.18x wf-projection-stress-65510 | debug | full | -0.42% | 2.08x wf-projection-stress-65510 | check | incr-full | -0.40% | 2.01x deep-vector | debug | incr-patched: add vec item | -0.38% | 1.88x wf-projection-stress-65510 | debug | incr-full | -0.37% | 1.86x wf-projection-stress-65510 | opt | incr-full | -0.36% | 1.81x deep-vector | debug | incr-patched: println | 0.33% | 1.63x r? `@nnethercote`
2022-04-20Make all thir types implement cloneXavier Denis-12/+12
2022-04-19Rollup merge of #96165 - RalfJung:miri-provenance-cleanup, r=oli-obkDylan DPC-0/+17
Miri provenance cleanup Reviewing https://github.com/rust-lang/rust/pull/95826 by ``@carbotaniuman`` made me realize that we could clean things up a little here. ``@carbotaniuman`` please let me know if you're okay with landing this (it will create a lot of conflicts with your PR), or if you'd prefer incorporating the ideas from this PR into yours. I think we want to end up in a situation where the function you called `ptr_reify_alloc` returns just two things, a concrete tag and an offset. Getting an `AllocId` from a concrete tag should be infallible like now. However a concrete tag and `Tag` don't have to be the same type. r? ``@oli-obk``
2022-04-19Rollup merge of #96162 - RalfJung:mark-uninit, r=oli-obkDylan DPC-8/+28
interpret: Fix writing uninit to an allocation When calling `mark_init`, we need to also be mindful of what happens with the relocations! Specifically, when we de-init memory, we need to clear relocations in that range as well or else strange things will happen (and printing will not show the de-init, since relocations take precedence there). Fixes https://github.com/rust-lang/miri/issues/2068. Here's the Miri testcase that this fixes (requires `-Zmiri-disable-validation`): ```rust use std::mem::MaybeUninit; fn main() { unsafe { let mut x = MaybeUninit::<i64>::uninit(); // Put in a ptr. x.as_mut_ptr().cast::<&i32>().write_unaligned(&0); // Overwrite parts of that pointer with 'uninit' through a Scalar. let ptr = x.as_mut_ptr().cast::<i32>(); *ptr = MaybeUninit::uninit().assume_init(); // Reading this back should hence work fine. let _c = *ptr; } } ``` Previously this failed with ``` error: unsupported operation: unable to turn pointer into raw bytes --> ../miri/uninit.rs:11:14 | 11 | let _c = *ptr; | ^^^^ unable to turn pointer into raw bytes | = help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support = note: inside `main` at ../miri/uninit.rs:11:14 ```
2022-04-19Fix a bug in the ptx-kernel calling convention where structs was passed ↵Kjetil Kjeka-0/+20
indirectly Structs being passed indirectly is suprpising and have a high chance not to work as the device and host usually do not share memory.
2022-04-19Auto merge of #96214 - Dylan-DPC:rollup-a5b4fow, r=Dylan-DPCbors-28/+63
Rollup of 6 pull requests Successful merges: - #94493 (Improved diagnostic on failure to meet send bound on future in a foreign crate) - #95809 (Fix typo in bootstrap.py) - #96086 (Remove `--extern-location` and all associated code) - #96089 (`alloc`: make `vec!` unavailable under `no_global_oom_handling`) - #96122 (Fix an invalid error for a suggestion to add a slice in pattern-matching) - #96142 (Stop using CRATE_DEF_INDEX outside of metadata encoding.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-19Rollup merge of #96142 - cjgillot:no-crate-def-index, r=petrochenkovDylan DPC-21/+17
Stop using CRATE_DEF_INDEX outside of metadata encoding. `CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want. We should not manipulate raw `DefIndex` outside of metadata encoding.
2022-04-19Rollup merge of #94493 - ↵Dylan DPC-7/+46
oribenshir:feature/ISSUE-78543_async_fn_in_foreign_crate_diag_2, r=davidtwco Improved diagnostic on failure to meet send bound on future in a foreign crate Provide a better diagnostic on failure to meet send bound on futures in a foreign crate. fixes #78543
2022-04-19Auto merge of #96020 - martingms:optimize-relate_substs, r=nnethercotebors-22/+27
Micro-optimize `ty::relate::relate_substs` by avoiding `match` Was a top-20 hot function in a callgrind profile of compiling `bitmaps-3.1.0`. Yields some small speedups on that crate and some others according to local benching: Benchmark | Profile | Scenario | % Change | Significance Factor? -- | -- | -- | -- | -- bitmaps-3.1.0 | check | full | -1.88% | 9.42x bitmaps-3.1.0 | debug | full | -1.80% | 8.99x bitmaps-3.1.0 | opt | full | -1.70% | 8.49x bitmaps-3.1.0 | check | incr-full | -1.54% | 7.68x deep-vector | debug | full | 1.52% | 7.61x bitmaps-3.1.0 | debug | incr-full | -1.45% | 7.26x bitmaps-3.1.0 | opt | incr-full | -1.39% | 6.95x nalgebra-0.30.1 | check | full | -0.68% | 3.42x nalgebra-0.30.1 | debug | full | -0.64% | 3.22x nalgebra-0.30.1 | opt | full | -0.64% | 3.20x projection-caching | check | full | -0.61% | 3.05x nalgebra-0.30.1 | check | incr-full | -0.56% | 2.78x nalgebra-0.30.1 | opt | incr-full | -0.54% | 2.72x nalgebra-0.30.1 | debug | incr-full | -0.54% | 2.69x projection-caching | check | incr-full | -0.50% | 2.51x tt-muncher | opt | full | -0.48% | 2.42x projection-caching | opt | full | -0.47% | 2.37x projection-caching | debug | full | -0.47% | 2.35x projection-caching | opt | incr-full | -0.44% | 2.21x projection-caching | debug | incr-full | -0.42% | 2.08x deeply-nested-multi | check | incr-full | 0.37% | 1.87x wf-projection-stress-65510 | opt | full | -0.37% | 1.84x deep-vector | debug | incr-patched: add vec item | -0.32% | 1.61x projection-caching | debug | incr-unchanged | -0.32% | 1.60x wf-projection-stress-65510 | check | full | -0.31% | 1.55x projection-caching | opt | incr-unchanged | -0.31% | 1.53x wf-projection-stress-65510 | debug | incr-full | -0.30% | 1.51x wf-projection-stress-65510 | opt | incr-full | -0.30% | 1.51x r? `@nnethercote`
2022-04-18mark payload fields of ScalarPair enums as Scalar::Union when they're not ↵Erik Desjardins-16/+21
always initialized
2022-04-18Remove unused macro rulesest31-3/+0
2022-04-18Synthesis object file for `#[used]` and exported symbolsGary Guo-0/+10
2022-04-18Add `SymbolExportInfo`Gary Guo-3/+10
This is currently a wrapper to `SymbolExportLevel` but it allows later addition of extra information.
2022-04-18replace iter with into_iter()ouz-a-2/+2
2022-04-18avoid an unnecessary call to Pointer::into_parts, and caution against ↵Ralf Jung-0/+4
into_pointer_or_addr
2022-04-18add method to get absolute address of a pointer (useful only for Miri)Ralf Jung-0/+10
2022-04-18avoid pairing up AllocId and PointerTag, which is redundantRalf Jung-0/+3
2022-04-17check Allocation invariant during printingRalf Jung-0/+1
2022-04-17explain why prepare_relocation_copy works the way it doesRalf Jung-4/+11
2022-04-17add caution to some commentsRalf Jung-1/+7
2022-04-17when writing uninit to an allocation, also clear relocations like other ↵Ralf Jung-3/+9
writes do
2022-04-17add log warnings for when we overwrite parts of a pointer, and de-init the restRalf Jung-0/+8
2022-04-17fat vecouz-a-7/+5
2022-04-17format errouz-a-5/+3
2022-04-17little changesouz-a-7/+5
2022-04-17Stop using CRATE_DEF_INDEX.Camille GILLOT-21/+17
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-04-17Split relate_substs into two functionsMartin Gammelsæter-28/+33
One for the case with variances, and one without. All callers use an explicit Option for the variable anyway.
2022-04-17Auto merge of #95655 - kckeiks:create-hir-crate-items-query, r=cjgillotbors-17/+108
Refactor HIR item-like traversal (part 1) Issue #95004 - 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 - use tcx.hir_crate_items to introduce a tcx.hir().par_items(impl Fn(hir::ItemId)) to traverse all items in parallel; Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com> cc `@cjgillot`
2022-04-16Rollup merge of #95426 - b-naber:valtrees-slice, r=RalfJung,oli-obkDylan DPC-1/+1
Include Refs in Valtree Creation This adds references to `const_to_valtree`, which isn't used in the compiler yet, but after the previous changes we made to the thir and mir representations and this change we should be able to finally introduce them in the next PR. I wasn't able to properly test this code, except indirectly by including a call of `const_to_valtree` in the code that currently creates constants (`turn_into_const_value`). r? `@lcnr` cc `@oli-obk` `@RalfJung`
2022-04-16Optimize relate_substs by extracting matchMartin Gammelsæter-12/+12
There was no need to keep doing the match inside the iterator.
2022-04-16Make derefer work everwhereouz-a-0/+26
Co-Authored-By: Oli Scherer <332036+oli-obk@users.noreply.github.com>
2022-04-16Provide a better diagnostic on failure to meet send bound on futures in a ↵oribenshir-7/+46
foreign crate Adding diagnostic data on generators to the crate metadata and using it to provide a better diagnostic on failure to meet send bound on futures originated from a foreign crate
2022-04-16Auto merge of #96108 - Dylan-DPC:rollup-t5f2fc9, r=Dylan-DPCbors-1/+2
Rollup of 9 pull requests Successful merges: - #93969 (Only add codegen backend to dep info if -Zbinary-dep-depinfo is used) - #94605 (Add missing links in platform support docs) - #95372 (make unaligned_references lint deny-by-default) - #95859 (Improve diagnostics for unterminated nested block comment) - #95961 (implement SIMD gather/scatter via vector getelementptr) - #96004 (Consider lifetimes when comparing types for equality in MIR validator) - #96050 (Remove some now-dead code that was only relevant before deaggregation.) - #96070 ([test] Add test cases for untested functions for BTreeMap) - #96099 (MaybeUninit array cleanup) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-16Rollup merge of #96004 - JakobDegen:fix-validator-ice, r=petrochenkovDylan DPC-1/+2
Consider lifetimes when comparing types for equality in MIR validator Closes #95978 .
2022-04-16Auto merge of #94468 - Amanieu:global_asm_sym, r=nagisabors-3/+4
Implement sym operands for global_asm! Tracking issue: #93333 This PR is pretty much a complete rewrite of `sym` operand support for inline assembly so that the same implementation can be shared by `asm!` and `global_asm!`. The main changes are: - At the AST level, `sym` is represented as a special `InlineAsmSym` AST node containing a path instead of an `Expr`. - At the HIR level, `sym` is split into `SymStatic` and `SymFn` depending on whether the path resolves to a static during AST lowering (defaults to `SynFn` if `get_early_res` fails). - `SymFn` is just an `AnonConst`. It runs through typeck and we just collect the resulting type at the end. An error is emitted if the type is not a `FnDef`. - `SymStatic` directly holds a path and the `DefId` of the `static` that it is pointing to. - The representation at the MIR level is mostly unchanged. There is a minor change to THIR where `SymFn` is a constant instead of an expression. - At the codegen level we need to apply the target's symbol mangling to the result of `tcx.symbol_name()` depending on the target. This is done by calling the LLVM name mangler, which handles all of the details. - On Mach-O, all symbols have a leading underscore. - On x86 Windows, different mangling is used for cdecl, stdcall, fastcall and vectorcall. - No mangling is needed on other platforms. r? `@nagisa` cc `@eddyb`
2022-04-15Rollup merge of #96026 - matthiaskrgr:clippy_compl_1304, r=Dylan-DPCDylan DPC-1/+1
couple of clippy::complexity fixes
2022-04-15Rollup merge of #95194 - kckeiks:update-algo-in-find-use-placement, r=pnkfelixDylan DPC-2/+2
remove find_use_placement A more robust solution to finding where to place use suggestions was added in #94584. The algorithm uses the AST to find the span for the suggestion so we pass this span down to the HIR during lowering and use it instead of calling `find_use_placement` Fixes #94941
2022-04-15Rollup merge of #94849 - ouz-a:master4, r=oli-obkDylan DPC-6/+3
Check var scope if it exist Fixes #92893. Added helper function to check the scope of a variable, if it doesn't have a scope call delay_span_bug, which avoids us trying to get a block/scope that doesn't exist. Had to increase `ROOT_ENTRY_LIMIT` was getting tidy error