about summary refs log tree commit diff
path: root/compiler/rustc_mir_build/src
AgeCommit message (Collapse)AuthorLines
2023-08-15Rollup merge of #114819 - estebank:issue-78124, r=compiler-errorsMatthias Krüger-6/+9
Point at return type when it influences non-first `match` arm When encountering code like ```rust fn foo() -> i32 { match 0 { 1 => return 0, 2 => "", _ => 1, } } ``` Point at the return type and not at the prior arm, as that arm has type `!` which isn't influencing the arm corresponding to arm `2`. Fix #78124.
2023-08-15Deny FnDef in patternsMichael Goulet-1/+6
2023-08-14Move scrutinee `HirId` into `MatchSource::TryDesugar`Esteban Küber-6/+9
2023-08-14Remove unnecessary FIXMEouz-a-1/+0
2023-08-08Rollup merge of #114566 - fmease:type-alias-laziness-is-crate-specific, ↵Matthias Krüger-1/+1
r=oli-obk Store the laziness of type aliases in their `DefKind` Previously, we would treat paths referring to type aliases as *lazy* type aliases if the current crate had lazy type aliases enabled independently of whether the crate which the alias was defined in had the feature enabled or not. With this PR, the laziness of a type alias depends on the crate it is defined in. This generally makes more sense to me especially if / once lazy type aliases become the default in a new edition and we need to think about *edition interoperability*: Consider the hypothetical case where the dependency crate has an older edition (and thus eager type aliases), it exports a type alias with bounds & a where-clause (which are void but technically valid), the dependent crate has the latest edition (and thus lazy type aliases) and it uses that type alias. Arguably, the bounds should *not* be checked since at any time, the dependency crate should be allowed to change the bounds at will with a *non*-major version bump & without negatively affecting downstream crates. As for the reverse case (dependency: lazy type aliases, dependent: eager type aliases), I guess it rules out anything from slight confusion to mild annoyance from upstream crate authors that would be caused by the compiler ignoring the bounds of their type aliases in downstream crates with older editions. --- This fixes #114468 since before, my assumption that the type alias associated with a given weak projection was lazy (and therefore had its variances computed) did not necessarily hold in cross-crate scenarios (which [I kinda had a hunch about](https://github.com/rust-lang/rust/pull/114253#discussion_r1278608099)) as outlined above. Now it does hold. `@rustbot` label F-lazy_type_alias r? `@oli-obk`
2023-08-07Store the laziness of type aliases in the DefKindLeón Orell Valerian Liehr-1/+1
2023-08-07Auto merge of #113902 - Enselic:lint-recursive-drop, r=oli-obkbors-21/+96
Make `unconditional_recursion` warning detect recursive drops Closes #55388 Also closes #50049 unless we want to keep it for the second example which this PR does not solve, but I think it is better to track that work in #57965. r? `@oli-obk` since you are the mentor for #55388 Unresolved questions: - [x] There are two false positives that must be fixed before merging (see diff). I suspect the best way to solve them is to perform analysis after drop elaboration instead of before, as now, but I have not explored that any further yet. Could that be an option? **Answer:** Yes, that solved the problem. `@rustbot` label +T-compiler +C-enhancement +A-lint
2023-08-04Rollup merge of #114434 - Nilstrieb:indexing-spans, r=est31Matthias Krüger-2/+8
Improve spans for indexing expressions fixes #114388 Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR. r? compiler-errors
2023-08-04Improve spans for indexing expressionsNilstrieb-2/+8
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
2023-08-04Rollup merge of #114022 - oli-obk:tait_ice_alias_field_projection, r=cjgillotMatthias Krüger-0/+6
Perform OpaqueCast field projection on HIR, too. fixes #105819 This is necessary for closure captures in 2021 edition, as they capture individual fields, not the full mentioned variables. So it may try to capture a field of an opaque (because the hidden type is known to be something with a field). See https://github.com/rust-lang/rust/pull/99806 for when and why we added OpaqueCast to MIR.
2023-07-28Lower generic const items to HIRLeón Orell Valerian Liehr-1/+1
2023-07-25inline format!() args from rustc_codegen_llvm to the end (4)Matthias Krüger-54/+35
r? @WaffleLapkin
2023-07-24Perform OpaqueCast field projection on HIR, too.Oli Scherer-0/+6
This is necessary for closure captures in 2021 edition, as they capture individual fields, not the full mentioned variables. So it may try to capture a field of an opaque (because the hidden type is known to be something with a field).
2023-07-22Make `unconditional_recursion` warning detect recursive dropsMartin Nordholts-19/+91
2023-07-20Add is_recursive_terminator() helper for `unconditional_recursion` lintMartin Nordholts-10/+13
2023-07-20Avoid unneeded `terminator()` call in `fn ignore_edge()`Martin Nordholts-3/+3
2023-07-19Make it clearer that edition functions are >=, not ==Michael Goulet-1/+1
2023-07-15Implement "items do not inherit unsafety" for THIR unsafecksyvb-24/+146
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-152/+140
2023-07-14Auto merge of #113609 - nnethercote:maybe_lint_level_root_bounded-cache, ↵bors-12/+71
r=cjgillot Add a cache for `maybe_lint_level_root_bounded` `maybe_lint_level_root_bounded` is called many times and traces node sub-paths many times. This PR adds a cache that lets many of these tracings be skipped, avoiding lots of calls to functions like `Map::attrs` and `Map::parent_id`. r? `@cjgillot`
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-24/+20
2023-07-13Add a cache for `maybe_lint_level_root_bounded`.Nicholas Nethercote-10/+47
It's a nice speed win.
2023-07-12Move `maybe_lint_level_root_bounded`.Nicholas Nethercote-3/+24
From `TyCtxt` to the MIR `Builder`. This will allow us to add a cache to `Builder` and use it from `maybe_lint_level_root_bounded`.
2023-07-12Shorten some overlong comment lines.Nicholas Nethercote-6/+7
It's annoying that these wrap in a 100-char terminal window.
2023-07-10Do not set up wrong span for adjustmentsMichael Goulet-28/+1
2023-07-08Rollup merge of #113217 - ericmarkmartin:lower-type-relative-ctor-to-adt, ↵Matthias Krüger-15/+32
r=cjgillot resolve typerelative ctors to adt Associated issue: #110508 r? ``@spastorino``
2023-07-07Rename `adjustment::PointerCast` and variants using it to `PointerCoercion`Nilstrieb-16/+25
It makes it sound like the `ExprKind` and `Rvalue` are supposed to represent all pointer related casts, when in reality their just used to share a some enum variants. Make it clear there these are only coercion to make it clear why only some pointer related "casts" are in the enum.
2023-07-05Move `TyCtxt::mk_x` to `Ty::new_x` where applicableBoxy-23/+31
2023-07-04Replace `const_error` methods with `Const::new_error`Boxy-1/+1
2023-07-04Replace `mk_const` with `Const::new_x` methodsBoxy-8/+16
2023-07-02refactorEric Mark Martin-17/+19
2023-06-30resolve typerelative ctors to adtEric Mark Martin-12/+27
2023-06-28remove cruftEric Mark Martin-1/+0
2023-06-28use translatable subdiagnosticEric Mark Martin-1/+6
2023-06-28add note for non-exhaustive matches with guardsEric Mark Martin-0/+5
2023-06-27Rollup merge of #113093 - WaffleLapkin:become_unuwuable_in_thir, r=NilstriebMatthias Krüger-8/+24
`thir`: Add `Become` expression kind This PR is pretty small and just adds `thir::ExprKind::Become`. I didn't include the checks that will be done on thir, since they are much more complicated and can be done in parallel with with MIR (or, well, at least I believe they can). r? `@Nilstrieb`
2023-06-27`thir`: Add `Become` expression kindMaybe Waffle-8/+24
2023-06-27Rollup merge of #113039 - matthiaskrgr:custom_mir, r=compiler-errorsMatthias Krüger-1/+5
make custom mir ICE a bit nicer
2023-06-27Auto merge of #112693 - ericmarkmartin:use-more-placeref, r=spastorinobors-15/+4
Use PlaceRef abstractions more often Associated issue: https://github.com/rust-lang/rust/issues/80647 r? `@spastorino`
2023-06-26make custom mir ICE a bit nicerMatthias Krüger-1/+5
2023-06-26`hir`: Add `Become` expression kindMaybe Waffle-0/+5
2023-06-25use PlaceRef abstractions more consistentlyEric Mark Martin-15/+4
2023-06-21Rollup merge of #112759 - cjgillot:closure-names, r=oli-obkNilstrieb-0/+18
Make closure_saved_names_of_captured_variables a query. As we will start removing debuginfo during MIR optimizations, we need to keep them somewhere.
2023-06-20address most easy commentsZiru Niu-13/+7
2023-06-20merge `BorrowKind::Unique` into `BorrowKind::Mut`Ziru Niu-17/+27
2023-06-19Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naberMichael Goulet-5/+11
Better error for non const `PartialEq` call generated by `match` Resolves #90237
2023-06-19Remove duplicated comment.Camille GILLOT-7/+0
2023-06-19Make closure_saved_names_of_captured_variables a query.Camille GILLOT-0/+25
2023-06-18Better error for non const `PartialEq` call generated by `match`Deadbeef-5/+11
2023-06-16Re-use the deref-pattern recursion instead of duplicating the logicOli Scherer-59/+26