about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src/thir
AgeCommit message (Collapse)AuthorLines
2022-02-12change to a struct variantEllen-1/+1
2022-01-21Remove a span from hir::ExprKind::MethodCallCameron Steffen-2/+2
2022-01-18Formally implement let chainsCaio-9/+35
2022-01-17Auto merge of #90986 - camsteffen:nested-filter, r=cjgillotbors-7/+1
Replace `NestedVisitorMap` with generic `NestedFilter` This is an attempt to make the `intravisit::Visitor` API simpler and "more const" with regard to nested visiting. With this change, `intravisit::Visitor` does not visit nested things by default, unless you specify `type NestedFilter = nested_filter::OnlyBodies` (or `All`). `nested_visit_map` returns `Self::Map` instead of `NestedVisitorMap<Self::Map>`. It panics by default (unreachable if `type NestedFilter` is omitted). One somewhat trixty thing here is that `nested_filter::{OnlyBodies, All}` live in `rustc_middle` so that they may have `type Map = map::Map` and so that `impl Visitor`s never need to specify `type Map` - it has a default of `Self::NestedFilter::Map`.
2022-01-17Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieubors-6/+0
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2022-01-16Replace NestedVisitorMap with NestedFilterCameron Steffen-7/+1
2022-01-16Auto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnrbors-1/+1
partially revertish `lazily "compute" anon const default substs` reverts #87280 except for some of the changes around `ty::Unevaluated` having a visitor and a generic for promoted why revert: <https://github.com/rust-lang/rust/pull/92805#issuecomment-1010736049> r? `@lcnr`
2022-01-15Reduce use of local_def_id_to_hir_id.Camille GILLOT-28/+26
2022-01-15attempt to re-add `ty::Unevaluated` visitor and friendsEllen-8/+6
2022-01-15initial revertEllen-7/+9
2022-01-13Auto merge of #89861 - nbdd0121:closure, r=wesleywiserbors-2/+2
Closure capture cleanup & refactor Follow up of #89648 Each commit is self-contained and the rationale/changes are documented in the commit message, so it's advisable to review commit by commit. The code is significantly cleaner (at least IMO), but that could have some perf implication, so I'd suggest a perf run. r? `@wesleywiser` cc `@arora-aman`
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-6/+0
2022-01-11Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`Aaron Hill-3/+3
The field is also renamed from `ident` to `name. In most cases, we don't actually need the `Span`. A new `ident` method is added to `VariantDef` and `FieldDef`, which constructs the full `Ident` using `tcx.def_ident_span()`. This method is used in the cases where we actually need an `Ident`. This makes incremental compilation properly track changes to the `Span`, without all of the invalidations caused by storing a `Span` directly via an `Ident`.
2022-01-07Remove region from UpvarCapture and move it to CapturedPlaceGary Guo-1/+1
Region info is completely unnecessary for upvar capture kind computation and is only needed to create the final upvar tuple ty. Doing so makes creation of UpvarCapture very cheap and expose further cleanup opportunity.
2022-01-07Remove span from UpvarCapture::ByValueGary Guo-1/+1
This span is unused and is superseded by capture_kind_expr_id in CaptureInfo
2021-12-23implement `generic_arg_infer` for array lengthslcnr-3/+6
2021-12-19Rollup merge of #91791 - terrarier2111:fix-float-ice, r=nagisaMatthias Krüger-9/+13
Fix an ICE when lowering a float with missing exponent magnitude This fixes: https://github.com/rust-lang/rust/issues/91434
2021-12-19Fix an ICE when lowering a float with missing exponent magnitudethreadexception-9/+13
Co-authored-by: Simonas Kazlauskas <github@kazlauskas.me>
2021-12-13let-else: add hir::Let and type check it like a hir::LocalCormac Relf-6/+9
unify typeck of hir::Local and hir::Let remove extraneous pub(crate/super)
2021-12-05Evaluate inline const pat early and report error if too genericGary Guo-31/+52
2021-11-23Fix stack overflow in `usefulness.rs`Badel2-4/+7
2021-11-21Simplify for loop desugarCameron Steffen-7/+14
2021-11-12Auto merge of #90813 - notriddle:notriddle/vec-extend, r=GuillaumeGomezbors-3/+1
Use Vec extend and collect instead of repeatedly calling push
2021-11-11Use `Vec::extend`, instead of calling `Vec::push` in a loopMichael Howell-3/+1
2021-11-11Auto merge of #90746 - nnethercote:opt-pattern-matching, r=Nadrierilbors-1/+1
Optimize pattern matching These commits speed up the `match-stress-enum` benchmark, which is very artificial, but the changes are simple enough that it's probably worth doing. r? `@Nadrieril`
2021-11-09Change the `assert` in `is_useful` to a `debug_assert`.Nicholas Nethercote-1/+1
It's hot in the `match-stress-enum` benchmark.
2021-11-07Implement type inference for inline constsGary Guo-2/+2
In most cases it is handled in the same way as closures.
2021-10-19Reject closures in patternsTomasz Miąsko-0/+3
2021-10-12Filter unstable and doc hidden variants in usefulness checkingDevin Ragotzy-35/+82
Add test cases for unstable variants Add test cases for doc hidden variants Move is_doc_hidden to method on TyCtxt Add unstable variants test to reachable-patterns ui test Rename reachable-patterns -> omitted-patterns
2021-10-08clippy::complexity fixesMatthias Krüger-3/+1
2021-10-01Rollup merge of #89441 - Nadrieril:fix-89393, r=tmandryManish Goregaokar-3/+4
Normalize after substituting via `field.ty()` Back in https://github.com/rust-lang/rust/issues/72476 I hadn't understood where the problem was coming from, and only worked around the issue. What happens is that calling `field.ty()` on a field of a generic struct substitutes the appropriate generics but doesn't normalize the resulting type. As a consumer of types I'm surprised that one would substitute without normalizing, feels like a footgun, so I added a comment. Fixes https://github.com/rust-lang/rust/issues/89393.
2021-10-01Normalize after substituting via `field.ty()`Nadrieril-3/+4
2021-09-30Rollup merge of #89314 - notriddle:notriddle/lint-fix-enum-variant-match, ↵Manish Goregaokar-19/+36
r=davidtwco fix(lint): don't suggest refutable patterns to "fix" irrefutable bind In function arguments and let bindings, do not suggest changing `C` to `Foo::C` unless `C` is the only variant of `Foo`, because it won't work. The general warning is still kept, because code like this is confusing. Fixes #88730 p.s. `src/test/ui/lint/lint-uppercase-variables.rs` already tests the one-variant case.
2021-09-30Auto merge of #89110 - Aaron1011:adjustment-span, r=estebankbors-2/+27
Use larger span for adjustment THIR expressions Currently, we use a relatively 'small' span for THIR expressions generated by an 'adjustment' (e.g. an autoderef, autoborrow, unsizing). As a result, if a borrow generated by an adustment ends up causing a borrowcheck error, for example: ```rust let mut my_var = String::new(); let my_ref = &my_var my_var.push('a'); my_ref; ``` then the span for the mutable borrow may end up referring to only the base expression (e.g. `my_var`), rather than the method call which triggered the mutable borrow (e.g. `my_var.push('a')`) Due to a quirk of the MIR borrowck implementation, this doesn't always get exposed in migration mode, but it does in many cases. This commit makes THIR building consistently use 'larger' spans for adjustment expressions. These spans are recoded when we first create the adjustment during typecheck. For example, an autoref adjustment triggered by a method call will record the span of the entire method call. The intent of this change it make it clearer to users when it's the specific way in which a variable is used (for example, in a method call) that produdes a borrowcheck error. For example, an error message claiming that a 'mutable borrow occurs here' might be confusing if it just points at a usage of a variable (e.g. `my_var`), when no `&mut` is in sight. Pointing at the entire expression should help to emphasize that the method call itself is responsible for the mutable borrow. In several cases, this makes the `#![feature(nll)]` diagnostic output match up exactly with the default (migration mode) output. As a result, several `.nll.stderr` files end up getting removed entirely.
2021-09-29fix(lint): don't suggest refutable patterns to "fix" irrefutable bindMichael Howell-19/+36
In function arguments and let bindings, do not suggest changing `C` to `Foo::C` unless `C` is the only variant of `Foo`, because it won't work. The general warning is still kept, because code like this is confusing. Fixes #88730
2021-09-29Auto merge of #88950 - Nadrieril:deconstruct-pat, r=oli-obkbors-977/+794
Add an intermediate representation to exhaustiveness checking The exhaustiveness checking algorithm keeps deconstructing patterns into a `Constructor` and some `Fields`, but does so a bit all over the place. This PR introduces a new representation for patterns that already has that information, so we only compute it once at the start. I find this makes code easier to follow. In particular `DeconstructedPat::specialize` is a lot simpler than what happened before, and more closely matches the description of the algorithm. I'm also hoping this could help for the project of librarifying exhaustiveness for rust_analyzer since it decouples the algorithm from `rustc_middle::Pat`.
2021-09-26Trivialize tracking of unreachable subpatternsNadrieril-297/+95
Phew it had been very had to make it work without a good way to identify patterns. Now it's dead easy.
2021-09-26Avoid double-deref in `Fields`Nadrieril-35/+31
2021-09-26Replace `Pat` with a new intermediate representationNadrieril-489/+615
2021-09-26Remove dependency of `SubPatSet` on `Pat`Nadrieril-27/+23
2021-09-26Move special `&str` handling to `Constructor` and `Fields`Nadrieril-21/+21
2021-09-26Use usize for slice arityNadrieril-15/+15
2021-09-26Rework `Fields` internals.Nadrieril-240/+195
Now `Fields` is just a `Vec` of patterns, with some extra info on the side to reconstruct patterns when needed. This emphasizes that this extra info is not central to the algorithm.
2021-09-26A for loop is a lot faster apparentlyNadrieril-29/+9
2021-09-26Cleanup the reporting of unreachable patternsNadrieril-20/+14
2021-09-26Always report reachability for user-supplied patternsNadrieril-8/+3
2021-09-26Remove some unreachable codeNadrieril-20/+11
2021-09-26Remove premature shortcuttingNadrieril-26/+12
2021-09-25Use larger span for adjustments on method callsAaron Hill-2/+27
Currently, we use a relatively 'small' span for THIR expressions generated by an 'adjustment' (e.g. an autoderef, autoborrow, unsizing). As a result, if a borrow generated by an adustment ends up causing a borrowcheck error, for example: ```rust let mut my_var = String::new(); let my_ref = &my_var my_var.push('a'); my_ref; ``` then the span for the mutable borrow may end up referring to only the base expression (e.g. `my_var`), rather than the method call which triggered the mutable borrow (e.g. `my_var.push('a')`) Due to a quirk of the MIR borrowck implementation, this doesn't always get exposed in migration mode, but it does in many cases. This commit makes THIR building consistently use 'larger' spans for adjustment expressions The intent of this change it make it clearer to users when it's the specific way in which a variable is used (for example, in a method call) that produdes a borrowcheck error. For example, an error message claiming that a 'mutable borrow occurs here' might be confusing if it just points at a usage of a variable (e.g. `my_var`), when no `&mut` is in sight. Pointing at the entire expression should help to emphasize that the method call itself is responsible for the mutable borrow. In several cases, this makes the `#![feature(nll)]` diagnostic output match up exactly with the default (migration mode) output. As a result, several `.nll.stderr` files end up getting removed entirely.
2021-09-20Fix ICE when `indirect_structural_match` is allowedFabian Wolff-6/+8