summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2022-05-14Auto merge of #96883 - jackh726:early-binder-2, r=oli-obkbors-38/+174
Add EarlyBinder Chalk has no concept of `Param` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L579) or `ReEarlyBound` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L1308). Everything is just "bound" - the equivalent of rustc's late-bound. It's not completely clear yet whether to move everything to the same time of binder in rustc or add `Param` and `ReEarlyBound` in Chalk. Either way, tracking when we have or haven't already substituted out these in rustc can be helpful. As a first step, I'm just adding a `EarlyBinder` newtype that is required to call `subst`. I also add a couple "transparent" `bound_*` wrappers around a couple query that are often immediately substituted. r? `@nikomatsakis`
2022-05-14Add rustc_on_unimplemented to SubstJack Huey-0/+1
2022-05-14Add bound_explicit_item_bounds and bound_item_boundsJack Huey-6/+42
2022-05-14Auto merge of #95826 - carbotaniuman:miri-permissive-provenance, r=RalfJungbors-5/+8
Initial work on Miri permissive-exposed-provenance Rustc portion of the changes for portions of a permissive ptr-to-int model for Miri. The main changes here are changing `ptr_get_alloc` and `get_alloc_id` to return an Option, and also making ptr-to-int casts have an expose side effect.
2022-05-13Add bound_impl_trait_refJack Huey-4/+8
2022-05-13Add bound_fn_sigJack Huey-6/+30
2022-05-13Add bound_type_ofJack Huey-26/+32
2022-05-13Rustc changes for permissive provenancecarbotaniuman-5/+8
2022-05-13Rollup merge of #96989 - cjgillot:defpath-use, r=davidtwcoMatthias Krüger-6/+2
Be more precise than DefPathData::Misc. This variant was used for two unrelated things. Let's make this cleaner.
2022-05-12Correct comment.Camille GILLOT-6/+2
2022-05-12Auto merge of #95562 - lcnr:attr-no-encode, r=davidtwcobors-27/+43
don't encode only locally used attrs Part of https://github.com/rust-lang/compiler-team/issues/505. We now filter builtin attributes before encoding them in the crate metadata in case they should only be used in the local crate. To prevent accidental misuse `get_attrs` now requires the caller to state which attribute they are interested in. For places where that isn't trivially possible, I've added a method `fn get_attrs_unchecked` which I intend to remove in a followup PR. After this pull request landed, we can then slowly move all attributes to only be used in the local crate while being certain that we don't accidentally try to access them from extern crates. cc https://github.com/rust-lang/rust/pull/94963#issuecomment-1082924289
2022-05-12Auto merge of #96889 - Aaron1011:place-ref-remove, r=compiler-errorsbors-1/+8
Remove `PartialOrd`/`Ord` impl for `PlaceRef` This is a new attempt at #93315. It removes one usage of the `Ord` impl for `DefId`, which should make it easier to eventually remove that impl.
2022-05-12Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkovbors-0/+3
Implement a lint to warn about unused macro rules This implements a new lint to warn about unused macro rules (arms/matchers), similar to the `unused_macros` lint added by #41907 that warns about entire macros. ```rust macro_rules! unused_empty { (hello) => { println!("Hello, world!") }; () => { println!("empty") }; //~ ERROR: 1st rule of macro `unused_empty` is never used } fn main() { unused_empty!(hello); } ``` Builds upon #96149 and #96156. Fixes #73576
2022-05-11Auto merge of #96806 - cjgillot:codegen-fulfill-nice, r=oli-obkbors-1/+19
Gracefully fail to resolve associated items instead of `delay_span_bug`. `codegen_fulfill_obligation` is used during instance resolution for trait items. In case of insufficient normalization issues during MIR inlining, it caused ICEs. It's better to gracefully refuse to resolve the associated item, and let the caller decide what to do with this. Split from https://github.com/rust-lang/rust/pull/91743 Closes #69121 Closes #73021 Closes #88599 Closes #93008 Closes #93248 Closes #94680 Closes #96170 r? `@oli-obk`
2022-05-11Remove `PartialOrd`/`Ord` impl for `PlaceRef`Aaron Hill-1/+8
This is a new attempt at #93315. It removes one usage of the `Ord` impl for `DefId`, which should make it easier to eventually remove that impl.
2022-05-11Gracefully fail to resolve associated items instead of `delay_span_bug`.Camille GILLOT-1/+19
2022-05-10Introduce EarlyBinderJack Huey-44/+109
2022-05-10Use lifetimes on type-alias-impl-trait used in function signatures to infer ↵Oli Scherer-1/+1
output type lifetimes
2022-05-10Auto merge of #94799 - lcnr:list-ty-perf, r=petrochenkovbors-7/+5
update `hash_stable` for `List<Ty<'tcx>>` cc https://github.com/rust-lang/rust/pull/93505#issuecomment-1047538798 this is the hottest part changed since the pre-merge perf run
2022-05-10update clippylcnr-1/+1
2022-05-10only_local: always check for misuselcnr-31/+37
2022-05-10Rollup merge of #96872 - RalfJung:layout-sanity, r=eddybDylan DPC-9/+127
make sure ScalarPair enums have ScalarPair variants; add some layout sanity checks `@eddyb` suggested that it might be reasonable for `ScalarPair` enums to simply adjust the ABI of their variants accordingly, such that the layout invariant Miri expects actually holds. This PR implements that. I should note though that I don't know much about this layout computation code and what non-Miri consumers expect from it, so tread with caution! I also added a function to sanity-check that computed layouts are internally consistent. This helped a lot in figuring out the final shape of this PR, though I am also not 100% sure that these sanity checks are the right ones. Cc `@oli-obk` Fixes https://github.com/rust-lang/rust/issues/96221
2022-05-10add check and don't encode `#[inline]`lcnr-0/+3
2022-05-10fix commentlcnr-3/+3
2022-05-10don't encode only locally used attrslcnr-0/+7
2022-05-09Auto merge of #96838 - tmiasko:lazy-switch-sources, r=oli-obkbors-7/+7
Optimize switch sources representation and usage * Avoid constructing switch sources unless necessary - switch sources are used by backward analysis with a custom switch int edge effects, but are otherwise unnecessarily computed. * Use sparse representation of switch sources to avoid quadratic space overhead.
2022-05-09Auto merge of #96473 - lcnr:querify-codegen-fn-attrs, r=cjgillotbors-23/+50
store `codegen_fn_attrs` in crate metadata extracted from #95562 because the change isn't trivial.
2022-05-09also sanity-check Abi::Vector, and slight refactoringRalf Jung-26/+43
2022-05-09Rollup merge of #96854 - jackh726:subst-cleanup, r=compiler-errorsMatthias Krüger-38/+10
Some subst cleanup Two separate things here. Both changes are useful for some refactoring I'm doing to add an "EarlyBinder" newtype. (Part of chalkification). 1) Remove `subst_spanned` and just use `subst`. It wasn't used much anyways. In practice, I think we can probably get most of the info just from the actual error message. If not, outputting logs should do the trick. (The specific line probably wouldn't help much anyways). 2) Call `.subst()` before `replace_bound_vars_with_fresh_vars` and `erase_late_bound_regions` in three places that do the opposite. I think there might have been some time in the past that the order here matter for something, but this shouldn't be the case anymore. Conceptually, it makes more sense to the of the *early bound* vars on `fn`s as "outside" the late bound vars.
2022-05-09reviewlcnr-38/+24
2022-05-09only compute `codegen_fn_attrs` where neededlcnr-2/+41
2022-05-09make sure ScalarPair enums have ScalarPair variants; add some layout sanity ↵Ralf Jung-11/+112
checks
2022-05-09only cache `codegen_fn_attrs` on disk if its locallcnr-1/+1
2022-05-09move `panic-in-drop=abort` check for `drop_in_place`lcnr-20/+21
Whether `drop_in_place` can abort does depend on the `panic-in-drop` option while compiling the current crate, not `core`
2022-05-09store `codegen_fn_attrs` in crate metadatalcnr-0/+1
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