about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2022-09-04Make `const_eval_select` a real intrinsicDeadbeef-87/+93
2022-09-03Do not call object_lifetime_default on lifetime params.Camille GILLOT-5/+6
2022-09-03Include enum path in variant suggestionMichael Goulet-11/+27
2022-09-03Auto merge of #101361 - Dylan-DPC:rollup-xj1syld, r=Dylan-DPCbors-0/+3
Rollup of 7 pull requests Successful merges: - #99736 (Partially stabilize `bound_as_ref` by stabilizing `Bound::as_ref`) - #100928 (Migrate rustc_metadata to SessionDiagnostics) - #101217 ([drop tracking] Use parent expression for scope, not parent node ) - #101325 (Windows RNG: Use `BCRYPT_RNG_ALG_HANDLE` by default) - #101330 (Fix `std::collections::HashSet::drain` documentation) - #101338 (Fix unsupported syntax in .manifest file) - #101348 (Cleanup css theme) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-09-03Rollup merge of #101217 - eholk:drop-tracking-73137, r=jyn514Dylan DPC-0/+3
[drop tracking] Use parent expression for scope, not parent node Previously we were just using the parent node as the scope for a temporary value, but it turns out this is too narrow. For example, in an expression like Foo { b: &42, a: async { 0 }.await, } the scope for the &42 was set to the ExprField node for `b: &42`, when we actually want to use the Foo struct expression. We fix this by recursively searching through parent nodes until we find a Node::Expr. It may be that we don't find one, and if so that's okay, we will just fall back on the enclosing temporary scope which is always sufficient. Helps with #97331 r? ``@jyn514``
2022-09-03Auto merge of #101139 - nnethercote:shrink-thir-Pat, r=cjgillotbors-37/+37
Shrink `thir::Pat` r? `@cjgillot`
2022-09-02Refactor and re-use BindingAnnotationCameron Steffen-9/+5
2022-09-02Rollup merge of #100814 - gabrielBusta:port_trait_selection_diagnostics, ↵Matthias Krüger-0/+12
r=davidtwco Porting 'compiler/rustc_trait_selection' to translatable diagnostics - Part 1 ``@rustbot`` label +A-translation r? rust-lang/diagnostics cc #100717
2022-09-01Don't create two new closures for each queryJoshua Nelson-7/+7
- Parameterize DepKindStruct over `'tcx` This allows passing in an invariant function pointer in `query_callback`, rather than having to try and make it work for any lifetime. - Add a new `execute_query` function to `QueryDescription` so we can call `tcx.$name` without needing to be in a macro context
2022-09-02Use boxed slices in `PatKind`.Nicholas Nethercote-13/+13
To shrink it a little more.
2022-09-02Box `CanonicalUserTypeAnnotation::CanonicalUserType`.Nicholas Nethercote-3/+3
This shrinks `Ascription`, which shrinks `PatKind::AscribeUserType`, which shrinks `Pat`.
2022-09-02Box `PatKind::Range`.Nicholas Nethercote-5/+5
Because it's the biggest variant. Also, make `PatRange` non-`Copy`, because it's 104 bytes, which is pretty big.
2022-09-02Clean up THIR patterns.Nicholas Nethercote-26/+26
`thir::Pat::kind` is a `Box<PatKind>`, which doesn't follow the usual pattern in AST/HIR/THIR which is that the "kind" enum for a node is stored inline within the parent struct. This commit makes the `PatKind` directly inline within the `Pat`. This requires using `Box<Pat>` in all the types that hold a `Pat. Ideally, `Pat` would be stored in `Thir` like `Expr` and `Stmt` and referred to with a `PatId` rather than `Box<Pat>`. But this is hard to do because lots of `Pat`s get created after the destruction of the `Cx` that does normal THIR building. But this does get us a step closer to `PatId`, because all the `Box<Pat>` occurrences would be replaced with `PatId` if `PatId` ever happened. At 128 bytes, `Pat` is large. Subsequent commits will shrink it.
2022-09-01Auto merge of #98960 - cjgillot:entry-kind, r=estebankbors-0/+1
Remove EntryKind from metadata. This PR continues the refactor of metadata emission to be more systematic, iterating on definitions and filtering based on each definition's `DefKind`. This allows to remove the large `EntryKind` enum, replaced by linear tables in metadata.
2022-09-01Porting 'compiler/rustc_trait_selection' to translatable diagnostics - Part 1Gabriel Bustamante-0/+12
2022-09-01Migrate limit error111-6/+12
2022-09-01Migrate OpaqueHiddenType mismatch111-13/+37
2022-09-01Migrate DropCheckOverflow111-10/+18
2022-09-01tracing::instrument cleanupOli Scherer-28/+16
2022-09-01Auto merge of #100869 - nnethercote:replace-ThinVec, r=spastorinobors-16/+17
Replace `rustc_data_structures::thin_vec::ThinVec` with `thin_vec::ThinVec` `rustc_data_structures::thin_vec::ThinVec` looks like this: ``` pub struct ThinVec<T>(Option<Box<Vec<T>>>); ``` It's just a zero word if the vector is empty, but requires two allocations if it is non-empty. So it's only usable in cases where the vector is empty most of the time. This commit removes it in favour of `thin_vec::ThinVec`, which is also word-sized, but stores the length and capacity in the same allocation as the elements. It's good in a wider variety of situation, e.g. in enum variants where the vector is usually/always non-empty. The commit also: - Sorts some `Cargo.toml` dependency lists, to make additions easier. - Sorts some `use` item lists, to make additions easier. - Changes `clean_trait_ref_with_bindings` to take a `ThinVec<TypeBinding>` rather than a `&[TypeBinding]`, because this avoid some unnecessary allocations. r? `@spastorino`
2022-09-01Auto merge of #100707 - dzvon:fix-typo, r=davidtwcobors-13/+13
Fix a bunch of typo This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-31Use parent_iter instead of a find_parent_node loopEric Holk-0/+3
2022-08-31Rollup merge of #100730 - CleanCut:diagnostics-rustc_monomorphize, r=davidtwcoRalf Jung-3/+3
Migrate rustc_monomorphize to use SessionDiagnostic ### Description - Migrates diagnostics in `rustc_monomorphize` to use `SessionDiagnostic` - Adds an `impl IntoDiagnosticArg for PathBuf` ### TODO / Help! - [x] I'm having trouble figuring out how to apply an optional note. 😕 Help!? - Resolved. It was bad docs. Fixed in https://github.com/rust-lang/rustc-dev-guide/pull/1437/files - [x] `errors:RecursionLimit` should be `#[fatal ...]`, but that doesn't exist so it's `#[error ...]` at the moment. - Maybe I can switch after this is merged in? --> https://github.com/rust-lang/rust/pull/100694 - Or maybe I need to manually implement `SessionDiagnostic` instead of deriving it? - [x] How does one go about converting an error inside of [a call to struct_span_lint_hir](https://github.com/rust-lang/rust/blob/8064a495086c2e63c0ef77e8e82fe3b9b5dc535f/compiler/rustc_monomorphize/src/collector.rs#L917-L927)? - [x] ~What placeholder do you use in the fluent template to refer to the value in a vector? It seems like [this code](https://github.com/rust-lang/rust/blob/0b79f758c9aa6646606662a6d623a0752286cd17/compiler/rustc_macros/src/diagnostics/diagnostic_builder.rs#L83-L114) ought to have the answer (or something near it)...but I can't figure it out.~ You can't. Punted.
2022-08-31Fix a bunch of typoDezhi Wu-13/+13
This PR will fix some typos detected by [typos]. I only picked the ones I was sure were spelling errors to fix, mostly in the comments. [typos]: https://github.com/crate-ci/typos
2022-08-31Rollup merge of #101100 - compiler-errors:generalize-call-suggestions, ↵Matthias Krüger-0/+6
r=petrochenkov Make call suggestions more general and more accurate Cleans up some suggestions that have to do with adding `()` to make typeck happy. 1. Drive-by rename of `expr_t` to `base_ty` since it's the type of the `base_expr` 1. Autoderef until we get to a callable type in `suggest_fn_call`. 1. Don't erroneously suggest calling constructor when a method/field does not exist on it. 1. Suggest calling a method receiver if its function output has a method (e.g. `fn.method()` => `fn().method()`) 1. Extend call suggestions to type parameters, fn pointers, trait objects where possible 1. Suggest calling in operators too (fixes #101054) 1. Use `/* {ty} */` as argument placeholder instead of just `_`, which is confusing and makes suggestions look less like `if let` syntax.
2022-08-30Stabilize GATsJack Huey-1/+1
2022-08-30Auto merge of #99102 - JakobDegen:reorder-generators, r=oli-obkbors-55/+102
Rework definition of MIR phases to more closely reflect semantic concerns Implements most of rust-lang/compiler-team#522 . I tried my best to restrict this PR to the "core" parts of the MCP. In other words, this includes just enough changes to make the new definition of `MirPhase` make sense. That means there are a couple of FIXMEs lying around. Depending on what reviewers prefer, I can either fix them in this PR or send follow up PRs. There are also a couple other refactorings of the `rustc_mir_transform/src/lib.rs` file that I want to do in follow ups that I didn't leave explicit FIXMEs for.
2022-08-30Separate macro_rules and macro_definition.Camille GILLOT-1/+1
2022-08-30Use tables for macros.Camille GILLOT-1/+1
2022-08-30Move AssocContainer to a metadata table.Camille GILLOT-0/+1
2022-08-30Rollup merge of #99517 - Nilstrieb:display-raw-ptr, r=compiler-errorsDylan DPC-1/+14
Display raw pointer as *{mut,const} T instead of *-ptr in errors The `*-ptr` is rather confusing, and we have the full information for properly displaying the information.
2022-08-30Refactor MIR phasesJakob Degen-55/+102
2022-08-30Auto merge of #101183 - Dylan-DPC:rollup-6kewixv, r=Dylan-DPCbors-193/+223
Rollup of 9 pull requests Successful merges: - #95376 (Add `vec::Drain{,Filter}::keep_rest`) - #100092 (Fall back when relating two opaques by substs in MIR typeck) - #101019 (Suggest returning closure as `impl Fn`) - #101022 (Erase late bound regions before comparing types in `suggest_dereferences`) - #101101 (interpret: make read-pointer-as-bytes a CTFE-only error with extra information) - #101123 (Remove `register_attr` feature) - #101175 (Don't --bless in pre-push hook) - #101176 (rustdoc: remove unused CSS selectors for `.table-display`) - #101180 (Add another MaybeUninit array test with const) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-08-30Rollup merge of #101101 - RalfJung:read-pointer-as-bytes, r=oli-obkDylan DPC-193/+182
interpret: make read-pointer-as-bytes a CTFE-only error with extra information Next step in the reaction to https://github.com/rust-lang/rust/issues/99923. Also teaches Miri to implicitly strip provenance in more situations when transmuting pointers to integers, which fixes https://github.com/rust-lang/miri/issues/2456. Pointer-to-int transmutation during CTFE now produces a message like this: ``` = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported ``` r? ``@oli-obk``
2022-08-30Rollup merge of #101019 - compiler-errors:return-closure-suggestion, r=cjgillotDylan DPC-0/+41
Suggest returning closure as `impl Fn` Fixes #100936
2022-08-30Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrumbors-0/+1
Revert let_chains stabilization This is the revert against master, the beta revert was already done in #100538. Bumps the stage0 compiler which already has it reverted.
2022-08-29Display raw pointer as `*{mut,const} T` instead of `*-ptr` in errorsnils-1/+14
The `*-ptr` is rather confusing, and we have the full information for properly displaying the information.
2022-08-29Revert let_chains stabilizationNilstrieb-0/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. This is the revert against master, the beta revert was already done in #100538.
2022-08-29Rollup merge of #99821 - cjgillot:ast-lifetimes-2, r=compiler-errorsDylan DPC-8/+19
Remove separate indexing of early-bound regions ~Based on https://github.com/rust-lang/rust/pull/99728.~ This PR copies some modifications from https://github.com/rust-lang/rust/pull/97839 around object lifetime defaults. These modifications allow to stop counting generic parameters during lifetime resolution, and rely on the indexing given by `rustc_typeck::collect`.
2022-08-29Replace `rustc_data_structures::thin_vec::ThinVec` with `thin_vec::ThinVec`.Nicholas Nethercote-16/+17
`rustc_data_structures::thin_vec::ThinVec` looks like this: ``` pub struct ThinVec<T>(Option<Box<Vec<T>>>); ``` It's just a zero word if the vector is empty, but requires two allocations if it is non-empty. So it's only usable in cases where the vector is empty most of the time. This commit removes it in favour of `thin_vec::ThinVec`, which is also word-sized, but stores the length and capacity in the same allocation as the elements. It's good in a wider variety of situation, e.g. in enum variants where the vector is usually/always non-empty. The commit also: - Sorts some `Cargo.toml` dependency lists, to make additions easier. - Sorts some `use` item lists, to make additions easier. - Changes `clean_trait_ref_with_bindings` to take a `ThinVec<TypeBinding>` rather than a `&[TypeBinding]`, because this avoid some unnecessary allocations.
2022-08-29Rollup merge of #100437 - compiler-errors:better-const-mismatch-err, r=oli-obkMatthias Krüger-0/+7
Improve const mismatch `FulfillmentError` Fixes #100414
2022-08-29Rollup merge of #99027 - tmiasko:basic-blocks, r=oli-obkMatthias Krüger-19/+14
Replace `Body::basic_blocks()` with field access Since the refactoring in #98930, it is possible to borrow the basic blocks independently from other parts of MIR by accessing the `basic_blocks` field directly. Replace unnecessary `Body::basic_blocks()` method with a direct field access, which has an additional benefit of borrowing the basic blocks only.
2022-08-28improve OFFSET_IS_ADDR docsRalf Jung-2/+6
2022-08-28More descriptive argument placeholdersMichael Goulet-0/+6
2022-08-27interpret: make read-pointer-as-bytes *always* work in MiriRalf Jung-97/+85
and show some extra information when it happens in CTFE
2022-08-27rustc_middle: Remove `Visibility::Invisible`Vadim Petrochenkov-11/+1
2022-08-27interpret: rename relocation → provenanceRalf Jung-115/+112
2022-08-27Auto merge of #100999 - nnethercote:shrink-FnAbi, r=bjorn3bors-2/+2
Shrink `FnAbi` Because they can take up a lot of memory in debug and release builds. r? `@bjorn3`
2022-08-27Auto merge of #100946 - jyn514:query-system-3, r=cjgillotbors-2/+2
Simplify the arguments to macros generated by the `rustc_queries` proc macro Very small cleanup. Based on https://github.com/rust-lang/rust/pull/100436 which modifies some of the same code. r? `@cjgillot`
2022-08-27Auto merge of #101074 - JohnTitor:rollup-zwznihq, r=JohnTitorbors-24/+2
Rollup of 11 pull requests Successful merges: - #96240 (Stabilize `const_ptr_offset_from`.) - #99784 (Make forward compatibility lint deprecated_cfg_attr_crate_type_name deny by default) - #100811 (Fix wrong compiletest filters on Windows) - #100924 (Smaller improvements of tidy and the unicode generator) - #100953 (Update documentation for `write!` and `writeln!`) - #101018 (rustdoc: omit start/end tags for empty item description blocks) - #101044 (rustdoc: remove unused CSS for `hidden-by-*-hider`) - #101046 (rustdoc: remove incorrect CSS selector `.impl-items table td`) - #101057 (Merge implementations of HIR fn_decl and fn_sig.) - #101062 (rustdoc: remove empty extern_crates and type="text/javascript" on script) - #101063 (Merge duplicated CSS rules) Failed merges: - #101055 (Use smaller span for suggestions) r? `@ghost` `@rustbot` modify labels: rollup