about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
AgeCommit message (Collapse)AuthorLines
2022-07-09don't allow ZST in ScalarIntRalf Jung-1/+17
There are several indications that we should not ZST as a ScalarInt: - We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it. `ValTree::zst()` used the former, but the latter could possibly arise as well. - Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`. - LLVM codegen already had to special-case ZST ScalarInt. So instead add new ZST variants to those types that did not have other variants which could be used for this purpose.
2022-07-07Make MIR basic blocks field publicTomasz Miąsko-3/+5
This makes it possible to mutably borrow different fields of the MIR body without resorting to methods like `basic_blocks_local_decls_mut_and_var_debug_info`. To preserve validity of control flow graph caches in the presence of modifications, a new struct `BasicBlocks` wraps together basic blocks and control flow graph caches. The `BasicBlocks` dereferences to `IndexVec<BasicBlock, BasicBlockData>`. On the other hand a mutable access requires explicit `as_mut()` call.
2022-07-06Update TypeVisitor pathsAlan Egerton-1/+1
2022-07-05Auto merge of #98925 - Dylan-DPC:rollup-9185c9y, r=Dylan-DPCbors-1/+1
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-05Rollup merge of #98624 - davidtwco:translation-on-lints, r=compiler-errorsDylan DPC-1/+1
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-6/+28
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-05Prefer trace level instrumentation for the new noisy instrument attributesOli Scherer-2/+2
2022-07-02Rollup merge of #98639 - camsteffen:no-node-binding, r=compiler-errorsDylan DPC-2/+2
Factor out `hir::Node::Binding`
2022-07-01Factor out hir::Node::BindingCameron Steffen-2/+2
2022-07-01Auto merge of #98402 - cjgillot:undead, r=michaelwoeristerbors-22/+1
Rewrite dead-code pass to avoid fetching HIR. This allows to get a more uniform handling of spans, and to simplify the grouping of diagnostics for variants and fields.
2022-06-30middle: translation in `LintDiagnosticBuilder`David Wood-1/+1
Accept `DiagnosticMessage` in `LintDiagnosticBuilder::build` so that lints can be built with translatable diagnostic messages. Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30Change enum->int casts to not go through MIR casts.Oli Scherer-4/+25
Instead we generate a discriminant rvalue and cast the result of that.
2022-06-29Rollup merge of #98668 - TaKO8Ki:avoid-many-&str-to-string-conversions, ↵Matthias Krüger-1/+1
r=Dylan-DPC Avoid some `&str` to `String` conversions with `MultiSpan::push_span_label` This patch removes some`&str` to `String` conversions with `MultiSpan::push_span_label`.
2022-06-29avoid many `&str` to `String` conversions with `MultiSpan::push_span_label`Takayuki Maeda-1/+1
2022-06-29Some tracing cleanupsOli Scherer-2/+3
2022-06-28Do not use a suggestion to change a binding's name to a typeMichael Goulet-1/+5
2022-06-25Rollup merge of #98429 - b-naber:use-correct-substs-discriminant-cast, r=lcnrMatthias Krüger-92/+94
Use correct substs in enum discriminant cast Fixes https://github.com/rust-lang/rust/issues/97634 r? ```@lcnr```
2022-06-24fmtb-naber-8/+6
2022-06-24address reviewb-naber-14/+14
2022-06-24small refactorb-naber-95/+96
2022-06-24use true recursionouz-a-14/+19
2022-06-24use correct substs in enum discriminant hackb-naber-1/+4
2022-06-23Remove dead code.Camille GILLOT-22/+1
2022-06-20Rollup merge of #98267 - compiler-errors:suggest-wildcard-arm, r=oli-obkMatthias Krüger-11/+23
Don't omit comma when suggesting wildcard arm after macro expr * Also adds `Span::eq_ctxt` to consolidate the various usages of `span.ctxt() == other.ctxt()` * Also fixes an unhygenic usage of spans which caused the suggestion to render weirdly when we had one arm match in a macro * Also always suggests a comma (i.e. even after a block) if we're rendering a wildcard arm in a single-line match (looks prettier :rose:) Fixes #94866
2022-06-20Auto merge of #97931 - xldenis:fix-if-let-source-scopes, r=nagisabors-12/+51
Fix `SourceScope` for `if let` bindings. Fixes #97799. I'm not sure how to test this properly, is there any way to observe the difference in behavior apart from `ui` tests? I'm worried that they would be overlooked in the case of a regression.
2022-06-19Be more hygenic with spansMichael Goulet-6/+7
2022-06-19Use `Span::eq_ctxt` method instead of `.ctxt() == .ctxt()`Michael Goulet-4/+4
2022-06-19Only omit trailing comma if block doesn't come from macro expansionMichael Goulet-3/+14
2022-06-17expand inner `or` patternouz-a-1/+11
2022-06-16compare_const_vals: add a special case for certain ranges.Nicholas Nethercote-4/+19
This commit removes the `a == b` early return, which isn't useful in practice, and replaces it with one that helps matches with many ranges, including char ranges.
2022-06-16compare_const_vals: Use infallible evaluation.Nicholas Nethercote-27/+23
Because these evaluations can never fail.
2022-06-16Remove `ty` arg from `compare_const_vals`.Nicholas Nethercote-21/+8
It's now only used in no-longer-interesting assertion.
2022-06-16Remove `from_bool` closure.Nicholas Nethercote-4/+2
The code is clearer and simpler without it. Note that the `a == b` early return at the top of the function means the `a == b` test at the end of the function could never succeed.
2022-06-16Inline and remove `fallback` closure.Nicholas Nethercote-3/+1
2022-06-16Remove one use of `compare_const_vals`.Nicholas Nethercote-15/+2
A direct comparison has the same effect. This also avoids the need for a type test within `compare_const_vals`.
2022-06-16Assert type equality of `a` and `b` in `compare_const_vals`.Nicholas Nethercote-1/+3
Because they're always equal.
2022-06-16Remove dead code from `compare_const_vals`.Nicholas Nethercote-11/+0
It's never executed when running the entire test suite. I think it's because of the early return at the top of the function if `a.ty() != ty` succeeds.
2022-06-16simplify_match_pair: avoid the second comparison if possible.Nicholas Nethercote-9/+12
Also, the `try_to_bits` always succeeds, so use `unwrap`.
2022-06-16sort_candidates: avoid the second comparison if possible.Nicholas Nethercote-25/+19
This is a performance win for `unicode-normalization`. The commit also removes the closure, which isn't necessary. And reformulates the comparison into a form I find easier to read.
2022-06-16const_range_contains: avoid the second comparison if possible.Nicholas Nethercote-8/+11
This is a performance win for `unicode-normalization`. Also, I find the new formulation easier to read.
2022-06-15Rollup merge of #98110 - cjgillot:closure-brace, r=Aaron1011Yuki Okushi-3/+3
Make `ExprKind::Closure` a struct variant. Simple refactor since we both need it to introduce additional fields in `ExprKind::Closure`. r? ``@Aaron1011``
2022-06-14Only create scopes for if letXavier Denis-4/+20
2022-06-14rebaseb-naber-1/+2
2022-06-14address reviewb-naber-72/+59
2022-06-14address reviewb-naber-57/+3
2022-06-14fix clippy test failuresb-naber-1/+1
2022-06-14implement valtrees as the type-system representation for constant valuesb-naber-93/+169
2022-06-14Rename the `ConstS::val` field as `kind`.Nicholas Nethercote-4/+4
And likewise for the `Const::val` method. Because its type is called `ConstKind`. Also `val` is a confusing name because `ConstKind` is an enum with seven variants, one of which is called `Value`. Also, this gives consistency with `TyS` and `PredicateS` which have `kind` fields. The commit also renames a few `Const` variables from `val` to `c`, to avoid confusion with the `ConstKind::Value` variant.
2022-06-12Make `ExprKind::Closure` a struct variant.Camille GILLOT-3/+3
2022-06-10Actually fixXavier Denis-19/+23