about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2022-07-06Allow to create definitions inside the query system.Camille GILLOT-62/+137
2022-07-06Auto merge of #98987 - GuillaumeGomez:rollup-bcy32bp, r=GuillaumeGomezbors-3/+6
Rollup of 7 pull requests Successful merges: - #96935 (Allow arithmetic and certain bitwise ops on AtomicPtr) - #98519 (Replace some `guess_head_span` with `def_span`) - #98911 (rustdoc: filter '_ lifetimes from ty::Generics) - #98939 (rustdoc: Add more semantic information to impl IDs) - #98971 (Fix typo in file descriptor docs) - #98983 (docs: Add overview of `rustc_middle::mir::TerminatorKind`) - #98984 (Remove erroneous doc comment) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-06Rollup merge of #98984 - pierwill:patch-4, r=RalfJungGuillaume Gomez-1/+1
Remove erroneous doc comment Fixes the formatting issue shown here: <img width="803" alt="Screen Shot 2022-07-06 at 12 50 56 PM" src="https://user-images.githubusercontent.com/19642016/177612734-2d881c6a-2850-4c1b-8f1a-08339ad5bfbc.png">
2022-07-06Rollup merge of #98983 - pierwill:patch-3, r=RalfJungGuillaume Gomez-0/+2
docs: Add overview of `rustc_middle::mir::TerminatorKind`
2022-07-06Rollup merge of #98519 - TaKO8Ki:add-head-span-field-to-item-and-impl-item, ↵Guillaume Gomez-2/+3
r=cjgillot Replace some `guess_head_span` with `def_span` This patch fixes a part of #97417. r? `@cjgillot`
2022-07-06Remove erroneous doc commentpierwill-1/+1
2022-07-06docs: Add overview of `rustc_middle::mir::TerminatorKind`pierwill-0/+2
2022-07-06Auto merge of #98959 - cjgillot:late-bound-order, r=michaelwoeristerbors-1/+2
Return a FxIndexSet in is_late_bound query. This return value is iterated upon by borrowck, hence the need to preserve a deterministic iteration order. Fixes https://github.com/rust-lang/rust/issues/98890 Affects https://github.com/rust-lang/rust/issues/96655 I don't know if this supersedes https://github.com/rust-lang/rust/pull/98924 or fixes an unrelated bug. r? `@michaelwoerister` This may deserve a backport.
2022-07-06interpret: use AllocRange in UninitByteAccessRalf Jung-60/+51
also use nice new format string syntax in interpret/error.rs
2022-07-06use `named_span` in case of tuple variantTakayuki Maeda-6/+1
2022-07-06add `Node::Variant` to `Map::opt_span`Takayuki Maeda-1/+7
2022-07-06replace `guess_head_span` with `def_span`Takayuki Maeda-1/+1
2022-07-06Rollup merge of #98968 - RalfJung:scalar-sanity, r=oli-obkDylan DPC-3/+2
assert Scalar sanity With https://github.com/rust-lang/rust/pull/96814 having landed, finally our `Scalar` layouts have the invariants they deserve. :)
2022-07-06Rollup merge of #98884 - davidtwco:translation-on-lints-derive, r=oli-obkDylan DPC-28/+26
macros: `LintDiagnostic` derive - Move `LintDiagnosticBuilder` into `rustc_errors` so that a diagnostic derive can refer to it. - Introduce a `DecorateLint` trait, which is equivalent to `SessionDiagnostic` or `AddToDiagnostic` but for lints. Necessary without making more changes to the lint infrastructure as `DecorateLint` takes a `LintDiagnosticBuilder` and re-uses all of the existing logic for determining what type of diagnostic a lint should be emitted as (e.g. error/warning). - Various refactorings of the diagnostic derive machinery (extracting `build_field_mapping` helper and moving `sess` field out of the `DiagnosticDeriveBuilder`). - Introduce a `LintDiagnostic` derive macro that works almost exactly like the `SessionDiagnostic` derive macro except that it derives a `DecorateLint` implementation instead. A new derive is necessary for this because `SessionDiagnostic` is intended for when the generated code creates the diagnostic. `AddToDiagnostic` could have been used but it would have required more changes to the lint machinery. ~~At time of opening this pull request, ignore all of the commits from #98624, it's just the last few commits that are new.~~ r? `@oli-obk`
2022-07-06Rollup merge of #98881 - cjgillot:q-def-kind, r=fee1-deadDylan DPC-1/+2
Only compute DefKind through the query.
2022-07-06Fix double spacefee1-dead-1/+1
2022-07-06Auto merge of #98206 - eggyal:align-to-chalk-folding-api, r=jackh726bors-1154/+1279
Split TypeVisitable from TypeFoldable Impl of rust-lang/compiler-team#520 following MCP approval. r? `@ghost`
2022-07-06Update TypeVisitor pathsAlan Egerton-23/+25
2022-07-05finally enable Scalar layout sanity checksRalf Jung-3/+2
2022-07-05Rollup merge of #96814 - RalfJung:enum-repr-align, r=oli-obkGuillaume Gomez-3/+3
Fix repr(align) enum handling `enum`, for better or worse, supports `repr(align)`. That has already caused a bug in https://github.com/rust-lang/rust/issues/92464, which was "fixed" in https://github.com/rust-lang/rust/pull/92932, but it turns out that that fix is wrong and caused https://github.com/rust-lang/rust/issues/96185. So this reverts #92932 (which fixes #96185), and attempts another strategy for fixing #92464: special-case enums when doing a cast, re-using the code to load the discriminant rather than assuming that the enum has scalar layout. This works fine for the interpreter. However, #92464 contained another testcase that was previously not in the test suite -- and after adding it, it ICEs again. This is not surprising; codegen needs the same patch that I did in the interpreter. Probably this has to happen [around here](https://github.com/rust-lang/rust/blob/d32ce37a171663048a4c4a536803434e40f52bd6/compiler/rustc_codegen_ssa/src/mir/rvalue.rs#L276). Unfortunately I don't know how to do that -- the interpreter can load a discriminant from an operand, but codegen can only do that from a place. `@oli-obk` `@eddyb` `@bjorn3` any idea?
2022-07-05Relax constrained generics to TypeVisitableAlan Egerton-14/+14
2022-07-05Explicit TypeVisitable implementationsAlan Egerton-152/+266
2022-07-05impl TypeVisitable in type traversal macrosAlan Egerton-35/+57
2022-07-05Add #[derive(TypeVisitable)]Alan Egerton-202/+142
2022-07-05Return a FxIndexSet in is_late_bound query.Camille GILLOT-1/+2
This return value is iterated upon by borrowck, hence the need to preserve a deterministic iteration order.
2022-07-05Split TypeVisitable from TypeFoldableAlan Egerton-736/+783
2022-07-05fix the layout of repr(align) enumsRalf Jung-3/+3
2022-07-05Rollup merge of #98888 - RalfJung:interpret-checked-bin, r=oli-obkMatthias Krüger-2/+3
interpret: fix CheckedBinOp behavior when overflow checking is disabled Adjusts the interpreter to https://github.com/rust-lang/rust/pull/98738. r? `@oli-obk`
2022-07-05Rollup merge of #98860 - RalfJung:dangling-int-ptr, r=davidtwcoMatthias Krüger-12/+25
adjust dangling-int-ptr error message based on suggestions by `@saethlin` in https://github.com/rust-lang/miri/issues/2163 Fixes https://github.com/rust-lang/miri/issues/2163 I also did a bit of refactoring on this, so we have a helper method to create a `Pointer` with `None` provenance.
2022-07-05errors: introduce `DecorateLint`David Wood-1/+24
Add a new trait to be generated by diagnostic derives which uses a `LintDiagnosticBuilder`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-05lint: `LintDiagnosticBuilder` into `rustc_errors`David Wood-28/+3
Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-05Auto merge of #98925 - Dylan-DPC:rollup-9185c9y, r=Dylan-DPCbors-2/+9
Rollup of 5 pull requests Successful merges: - #97712 (ptr::copy and ptr::swap are doing untyped copies) - #98624 (lints: mostly translatable diagnostics) - #98776 (rustdoc: improve click behavior of the source code mobile full-screen "sidebar") - #98856 (Remove FIXME from rustdoc intra-doc test) - #98913 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-05adjust dangling-int-ptr error messageRalf Jung-12/+25
2022-07-05always check overflow in CheckedBinOp in CTFERalf Jung-2/+3
2022-07-05Rollup merge of #98624 - davidtwco:translation-on-lints, r=compiler-errorsDylan DPC-2/+9
lints: mostly translatable diagnostics As lints are created slightly differently than other diagnostics, intended to try make them translatable first and then look into the applicability of diagnostic structs but ended up just making most of the diagnostics in the crate translatable (which will still be useful if I do make a lot of them structs later anyway). r? ``@compiler-errors``
2022-07-05Auto merge of #96862 - oli-obk:enum_cast_mir, r=RalfJungbors-0/+6
Change enum->int casts to not go through MIR casts. follow-up to https://github.com/rust-lang/rust/pull/96814 this simplifies all backends and even gives LLVM more information about the return value of `Rvalue::Discriminant`, enabling optimizations in more cases.
2022-07-05Add a helper method with an explicit name instead of hand rolling a match 3xOli Scherer-0/+6
2022-07-05Auto merge of #98910 - Dylan-DPC:rollup-9x82wdg, r=Dylan-DPCbors-27/+27
Rollup of 6 pull requests Successful merges: - #97300 (Implement `FusedIterator` for `std::net::[Into]Incoming`) - #98761 (more `need_type_info` improvements) - #98811 (Interpret: AllocRange Debug impl, and use it more consistently) - #98847 (fix interpreter validity check on Box) - #98854 (clean up the borrowing in rustc_hir_pretty) - #98873 (Suggest `#[derive(Default)]` to enums with `#[default]`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-05Rollup merge of #98811 - RalfJung:interpret-alloc-range, r=oli-obkDylan DPC-27/+27
Interpret: AllocRange Debug impl, and use it more consistently The two commits are pretty independent but it did not seem worth having two PRs for them. r? ``@oli-obk``
2022-07-05Auto merge of #98872 - JakobDegen:no-invalidate, r=davidtwcobors-9/+35
Add method to mutate MIR body without invalidating CFG caches. In addition to adding this method, a handful of passes are updated to use it. There's still quite a few passes that could in principle make use of this as well, but do not at the moment because they use `VisitorMut` or `MirPatch`, which needs additional support for this. The method name is slightly unwieldy, but I don't expect anyone to be writing it a lot, and at least it says what it does. If anyone has a suggestion for a better name though, would be happy to rename. r? rust-lang/mir-opt
2022-07-04Rollup merge of #98878 - lcnr:more-rustc_pass_by_value, r=oli-obkMatthias Krüger-13/+13
add more `rustc_pass_by_value` r? ```@oli-obk``` cc #98766
2022-07-04Rollup merge of #98738 - tmiasko:checked-binop, r=oli-obkMatthias Krüger-4/+12
Clarify MIR semantics of checked binary operations
2022-07-04Only compute DefKind through the query.Camille GILLOT-1/+2
2022-07-04fully move dropck to mirlcnr-1/+2
2022-07-04more `rustc_pass_by_value`lcnr-13/+13
2022-07-03Add method to mutate MIR body without invalidating CFG caches.Jakob Degen-9/+35
In addition to adding this method, a handful of passes are updated to use it.
2022-07-02more use of format! variable captureRalf Jung-2/+2
Co-authored-by: Joe ST <joe@fbstj.net>
2022-07-02Auto merge of #97585 - lqd:const-alloc-intern, r=RalfJungbors-6/+11
CTFE interning: don't walk allocations that don't need it The interning of const allocations visits the mplace looking for references to intern. Walking big aggregates like big static arrays can be costly, so we only do it if the allocation we're interning contains references or interior mutability. Walking ZSTs was avoided before, and this optimization is now applied to cases where there are no references/relocations either. --- While initially looking at this in the context of #93215, I've been testing with smaller allocations than the 16GB one in that issue, and with different init/uninit patterns (esp. via padding). In that example, by default, `eval_to_allocation_raw` is the heaviest query followed by `incr_comp_serialize_result_cache`. So I'll show numbers when incremental compilation is disabled, to focus on the const allocations themselves at 95% of the compilation time, at bigger array sizes on these minimal examples like `static ARRAY: [u64; LEN] = [0; LEN];`. That is a close construction to parts of the `ctfe-stress-test-5` benchmark, which has const allocations in the megabytes, while most crates usually have way smaller ones. This PR will have the most impact in these situations, as the walk during the interning starts to dominate the runtime. Unicode crates (some of which are present in our benchmarks) like `ucd`, `encoding_rs`, etc come to mind as having bigger than usual allocations as well, because of big tables of code points (in the hundreds of KB, so still an order of magnitude or 2 less than the stress test). In a check build, for a single static array shown above, from 100 to 10^9 u64s (for lengths in powers of ten), the constant factors are lowered: (log scales for easier comparisons) ![plot_log](https://user-images.githubusercontent.com/247183/171422958-16f1ea19-3ed4-4643-812c-1c7c60a97e19.png) (linear scale for absolute diff at higher Ns) ![plot_linear](https://user-images.githubusercontent.com/247183/171401886-2a869a4d-5cd5-47d3-9a5f-8ce34b7a6917.png) For one of the alternatives of that issue ```rust const ROWS: usize = 100_000; const COLS: usize = 10_000; static TWODARRAY: [[u128; COLS]; ROWS] = [[0; COLS]; ROWS]; ``` we can see a similar reduction of around 3x (from 38s to 12s or so). For the same size, the slowest case IIRC is when there are uninitialized bytes e.g. via padding ```rust const ROWS: usize = 100_000; const COLS: usize = 10_000; static TWODARRAY: [[(u64, u8); COLS]; ROWS] = [[(0, 0); COLS]; ROWS]; ``` then interning/walking does not dominate anymore (but means there is likely still some interesting work left to do here). Compile times in this case rise up quite a bit, and avoiding interning walks has less impact: around 23%, from 730s on master to 568s with this PR.
2022-07-02add AllocRange Debug impl; remove redundant AllocId Display implRalf Jung-27/+27
2022-07-02Auto merge of #97235 - nbdd0121:unwind, r=Amanieubors-2/+6
Fix FFI-unwind unsoundness with mixed panic mode UB maybe introduced when an FFI exception happens in a `C-unwind` foreign function and it propagates through a crate compiled with `-C panic=unwind` into a crate compiled with `-C panic=abort` (#96926). To prevent this unsoundness from happening, we will disallow a crate compiled with `-C panic=unwind` to be linked into `panic-abort` *if* it contains a call to `C-unwind` foreign function or function pointer. If no such call exists, then we continue to allow such mixed panic mode linking because it's sound (and stable). In fact we still need the ability to do mixed panic mode linking for std, because we only compile std once with `-C panic=unwind` and link it regardless panic strategy. For libraries that wish to remain compile-once-and-linkable-to-both-panic-runtimes, a `ffi_unwind_calls` lint is added (gated under `c_unwind` feature gate) to flag any FFI unwind calls that will cause the linkable panic runtime be restricted. In summary: ```rust #![warn(ffi_unwind_calls)] mod foo { #[no_mangle] pub extern "C-unwind" fn foo() {} } extern "C-unwind" { fn foo(); } fn main() { // Call to Rust function is fine regardless ABI. foo::foo(); // Call to foreign function, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`. unsafe { foo(); } //~^ WARNING call to foreign function with FFI-unwind ABI let ptr: extern "C-unwind" fn() = foo::foo; // Call to function pointer, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`. ptr(); //~^ WARNING call to function pointer with FFI-unwind ABI } ``` Fix #96926 `@rustbot` label: T-compiler F-c_unwind