about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2022-05-09Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errorsbors-3/+2
Remove `#[rustc_deprecated]` This removes `#[rustc_deprecated]` and introduces diagnostics to help users to the right direction (that being `#[deprecated]`). All uses of `#[rustc_deprecated]` have been converted. CI is expected to fail initially; this requires #95958, which includes converting `stdarch`. I plan on following up in a short while (maybe a bootstrap cycle?) removing the diagnostics, as they're only intended to be short-term.
2022-05-08Remove subst_spannedJack Huey-38/+10
2022-05-08Use sparse representation of switch sourcesTomasz Miąsko-9/+7
to avoid quadratic space overhead
2022-05-08Avoid constructing switch sources unless necessaryTomasz Miąsko-0/+2
Switch sources are used by backward analysis with a custom switch int edge effects, but are otherwise unnecessarily computed. Delay the computation until we know that switch sources are indeed required and avoid the computation otherwise.
2022-05-08Fixed typo in docs and correct doc linksFridtjof Stoldt-3/+3
Co-authored-by: Philipp Krones <hello@philkrones.com>
2022-05-08Move lint expectation checking into a separate query (RFC 2383)xFrednet-1/+25
2022-05-07Rollup merge of #96581 - RalfJung:debug-size-align, r=oli-obkGuillaume Gomez-2/+8
make Size and Align debug-printing a bit more compact In particular in `{:#?}`-mode, these take up a lot of space, so I think this is the better alternative (even though it is a bit longer in `{:?}` mode, I think it is still more readable). We could make it even smaller by deviating further from what the actual code looks like, e.g. via something like `Size(4 bytes)`. Not sure what people would think about that? Cc `````@oli-obk`````
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-138/+152
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-07Auto merge of #96531 - kckeiks:remove-item-like-visitor-from-rustc-typeck, ↵bors-6/+1
r=cjgillot Remove ItemLikeVisitor impls from rustc_typeck Issue #95004 cc `@cjgillot`
2022-05-06Rollup merge of #96557 - nbdd0121:const, r=oli-obkGuillaume Gomez-0/+4
Allow inline consts to reference generic params Tracking issue: #76001 The RFC says that inline consts cannot reference to generic parameters (for now), same as array length expressions. And expresses that it's desirable for it to reference in-scope generics, when array length expressions gain that feature as well. However it is possible to implement this for inline consts before doing this for all anon consts, because inline consts are only used as values and they won't be used in the type system. So we can have: ```rust fn foo<T>() { let x = [4i32; std::mem::size_of::<T>()]; // NOT ALLOWED (for now) let x = const { std::mem::size_of::<T>() }; // ALLOWED with this PR! let x = [4i32; const { std::mem::size_of::<T>() }]; // NOT ALLOWED (for now) } ``` This would make inline consts super useful for compile-time checks and assertions: ```rust fn assert_zst<T>() { const { assert!(std::mem::size_of::<T>() == 0) }; } ``` This would create an error during monomorphization when `assert_zst` is instantiated with non-ZST `T`s. A error during mono might sound scary, but this is exactly what a "desugared" inline const would do: ```rust fn assert_zst<T>() { struct F<T>(T); impl<T> F<T> { const V: () = assert!(std::mem::size_of::<T>() == 0); } let _ = F::<T>::V; } ``` It should also be noted that the current inline const implementation can already reference the type params via type inference, so this resolver-level restriction is not any useful either: ```rust fn foo<T>() -> usize { let (_, size): (PhantomData<T>, usize) = const { const fn my_size_of<T>() -> (PhantomData<T>, usize) { (PhantomData, std::mem::size_of::<T>()) } my_size_of() }; size } ``` ```@rustbot``` label: F-inline_const
2022-05-06remove all usages of hir().def_kindMiguel Guarniz-6/+1
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-06don't debug-print ConstValue in MIR pretty-printerRalf Jung-2/+8
2022-05-05Allow unused rules in some places in the compiler, library and toolsest31-0/+3
2022-05-05Auto merge of #91779 - ridwanabdillahi:natvis, r=michaelwoeristerbors-0/+6
Add a new Rust attribute to support embedding debugger visualizers Implemented [this RFC](https://github.com/rust-lang/rfcs/pull/3191) to add support for embedding debugger visualizers into a PDB. Added a new attribute `#[debugger_visualizer]` and updated the `CrateMetadata` to store debugger visualizers for crate dependencies. RFC: https://github.com/rust-lang/rfcs/pull/3191
2022-05-05Rollup merge of #96628 - joshtriplett:stabilize-then-some, r=m-ou-seYuki Okushi-1/+0
Stabilize `bool::then_some` FCP completed in https://github.com/rust-lang/rust/issues/80967
2022-05-04Stabilize `bool::then_some`Josh Triplett-1/+0
2022-05-03Update `ProjectionElem::Downcast` documentationTomasz Miąsko-4/+2
`ProjectionElem:::Downcast` is used when downcasting to a variant of an enum or a generator, regardless of the number of variants.
2022-05-03Add support for a new attribute `#[debugger_visualizer]` to support ↵ridwanabdillahi-0/+6
embedding debugger visualizers into a generated PDB. Cleanup `DebuggerVisualizerFile` type and other minor cleanup of queries. Merge the queries for debugger visualizers into a single query. Revert move of `resolve_path` to `rustc_builtin_macros`. Update dependencies in Cargo.toml for `rustc_passes`. Respond to PR comments. Load visualizer files into opaque bytes `Vec<u8>`. Debugger visualizers for dynamically linked crates should not be embedded in the current crate. Update the unstable book with the new feature. Add the tracking issue for the debugger_visualizer feature. Respond to PR comments and minor cleanups.
2022-05-03Hide InlineConst's generic arg during printGary Guo-0/+4
The generic arg is for type inference only and shouldn't be exposed to users.
2022-05-03Rollup merge of #96599 - tmiasko:discriminant-docs, r=estebankYuki Okushi-5/+1
Update `RValue::Discriminant` documentation `RValue::Discriminant` returns zero for types without discriminant. This guarantee is already documented for `discriminant_value` intrinsics which is implemented in terms of `RValue::Discriminant`.
2022-05-02fix most compiler/ doctestsElliot Roberts-138/+152
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-23/+39
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-05-01Auto merge of #96549 - ouz-a:mir-opt, r=oli-obkbors-2/+15
Move Derefer before Retag _Follow up work to #96116 #95857 #95649_ This moves `Derefer` before `Retag` and creates a new `LocalInfo` called `Temp` to avoid retagging created temp values. Zulip discussion [link](https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/deref.20as.20first.20and.20only.20projection) r? `@oli-obk`
2022-05-01re-name stuffouz-a-7/+9
2022-05-01Update `RValue::Discriminant` documentationTomasz Miąsko-5/+1
`RValue::Discriminant` returns zero for types without discriminant. This guarantee is already documented for `discriminant_value` intrinsics which is implemented in terms of `RValue::Discriminant`.
2022-04-30Save colon span to suggest bounds.Camille GILLOT-0/+13
2022-04-30Store all generic bounds as where predicates.Camille GILLOT-283/+110
2022-04-30Inline WhereClause into Generics.Camille GILLOT-24/+15
2022-04-30Auto merge of #96500 - SparrowLii:rpo, r=tmiaskobors-4/+94
Reduce duplication of RPO calculation of mir Computing the RPO of mir is not a low-cost thing, but it is duplicate in many places. In particular the `iterate_to_fixpoint` method which is called multiple times when computing the data flow. This PR reduces the number of times the RPO is recalculated as much as possible, which should save some compile time.
2022-04-30Eliminate duplication of RPO calculation for mirSparrowLii-4/+94
add `postorder_cache` to mir Body add `ReversePostorderCache` struct correct struct name and comments
2022-04-29remove and blessouz-a-4/+0
2022-04-29exp-stuff-dirtyouz-a-0/+15
2022-04-28Auto merge of #95976 - b-naber:valtree-constval-conversion, r=oli-obkbors-4/+129
Implement Valtree to ConstValue conversion Once we start to use `ValTree`s in the type system we will need to be able to convert them into `ConstValue` instances, which we want to continue to use after MIR construction. r? `@oli-obk` cc `@RalfJung`
2022-04-27combine all unsized types and add another recursive call to process nested ↵b-naber-1/+1
unsized types correctly
2022-04-26TAITs are suggestableMichael Goulet-14/+24
2022-04-26Auto merge of #96425 - oli-obk:fix_incremental_regression_unsafety_checking, ↵bors-49/+19
r=compiler-errors Fix incremental perf regression unsafety checking Perf regression introduced in #96294 We will simply avoid emitting the name of the unsafe function in MIR unsafeck, since we're moving to THIR unsafeck anyway.
2022-04-26Revert "add `DefId` to unsafety violations and display function path in E0133"Oli Scherer-49/+19
This reverts commit 8b8f6653cfd54525714f02efe7af0a0f830e185c.
2022-04-26Rollup merge of #96400 - JakobDegen:shallow-init-docs, r=Dylan-DPCGuillaume Gomez-2/+0
Correct documentation for `Rvalue::ShallowInitBox` As a part of the big MIR docs PR, I had added a comment indicating that `Rvalue::ShallowInitBox` is disallowed after drop elaboration, but this is not true (no idea why I thought it was). Codegen has support for it, and trying to enforce this rule in the validator causes compiling core to ICE on the very first `box` statement. That being said, this `Rvalue` probably *should* be banned after drop elaboration - it doesn't seem like it's still useful for much. However, I do not have time right now to actually go investigate how difficult a change that is to make, so in the meantime fixing the docs to reflect the current situation seems like the right step. r? rust-lang/mir-opt
2022-04-26Rollup merge of #94703 - kjetilkjeka:nvptx-kernel-args-abi2, r=nagisaGuillaume Gomez-0/+20
Fix codegen bug in "ptx-kernel" abi related to arg passing I found a codegen bug in the nvptx abi related to that args are passed as ptrs ([see comment](https://github.com/rust-lang/rust/issues/38788#issuecomment-1048999928)), this is not as specified in the [ptx-interoperability doc](https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/) or how C/C++ does it. It will also almost always fail in practice since device/host uses different memory spaces for most hardware. This PR fixes the bug and add tests for passing structs to ptx kernels. I observed that all nvptx assembly tests had been marked as [ignore a long time ago](https://github.com/rust-lang/rust/pull/59752#issuecomment-501713428). I'm not sure if the new one should be marked as ignore, it passed on my computer but it might fail if ptx-linker is missing on the server? I guess this is outside scope for this PR and should be looked at in a different issue/PR. I only fixed the nvptx64-nvidia-cuda target and not the potential code paths for the non-existing 32bit target. Even though 32bit nvptx is not a supported target there are still some code under the hood supporting codegen for 32 bit ptx. I was advised to create an MCP to find out if this code should be removed or updated. Perhaps ``@RDambrosio016`` would have interest in taking a quick look at this.
2022-04-26add hacky closure to struct_tail_with_normalize in order to allow us to walk ↵b-naber-4/+12
valtrees in lockstep with the type
2022-04-26Auto merge of #96414 - Dylan-DPC:rollup-t4ofhoa, r=Dylan-DPCbors-3/+0
Rollup of 6 pull requests Successful merges: - #90312 (Fix some confusing wording and improve slice-search-related docs) - #96149 (Remove unused macro rules) - #96279 (rustdoc: Remove .woff font files) - #96355 (Better handle too many `#` recovery in raw str) - #96379 (delay bug when adjusting `NeverToAny` twice during diagnostic code) - #96384 (do not consider two extern types to be similar) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-26Rollup merge of #96149 - est31:remove_unused_macro_matchers, r=petrochenkovDylan DPC-3/+0
Remove unused macro rules Removes rules of internal macros that weren't triggered.
2022-04-25Auto merge of #96294 - Emilgardis:def_id-in-unsafetyviolationdetails, r=oli-obkbors-19/+49
Display function path in unsafety violations - E0133 adds `DefId` to `UnsafetyViolationDetails` this enables consumers to access the function definition that was reported to be unsafe and also changes the output for some E0133 diagnostics
2022-04-25Auto merge of #96116 - ouz-a:mir-opt, r=oli-obkbors-0/+20
Make derefer work everwhere Follow up work on previous PR's #95649 and #95857. r? rust-lang/mir-opt _Co-Authored-By: `@oli-obk_`
2022-04-25Correct documentation for `ShallowInitBox`Jakob Degen-2/+0
2022-04-25Auto merge of #95604 - nbdd0121:used2, r=petrochenkovbors-3/+20
Generate synthetic object file to ensure all exported and used symbols participate in the linking Fix #50007 and #47384 This is the synthetic object file approach that I described in https://github.com/rust-lang/rust/pull/95363#issuecomment-1079932354, allowing all exported and used symbols to be linked while still allowing them to be GCed. Related #93791, #95363 r? `@petrochenkov` cc `@carbotaniuman`
2022-04-24only show a simple description in E0133 span labelEmil Gardström-11/+32
2022-04-24add `DefId` to unsafety violations and display function path in E0133Emil Gardström-19/+28
this enables consumers to access the function definition that was reported to be unsafe
2022-04-23Auto merge of #93970 - cjgillot:novis, r=petrochenkovbors-25/+7
Remove visibility information from HIR The resolver exports all the necessary visibility information through the `tcx.visibility` query. This PR stops having a dedicated visibility field in HIR, in order to use this query. We keep a `vis_span` field for diagnostic purposes.
2022-04-23Hash visibilities in crate_hash.Camille GILLOT-0/+4