Skip to content

Commit 36e2b8a

Browse files
committed
Auto merge of #151860 - JonathanBrouwer:rollup-FqYVDlY, r=JonathanBrouwer
Rollup of 4 pull requests Successful merges: - #151376 (Fix performance issue in liveness checking) - #151851 (Remove redundant `IntoQueryParam` calls from query plumbing) - #151854 (Show break type expectation cause for let-else) - #151859 (Disable append-elements.rs test with debug assertions)
2 parents e823167 + a93e9eb commit 36e2b8a

File tree

6 files changed

+58
-9
lines changed

6 files changed

+58
-9
lines changed

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
605605
parent_id = self.tcx.parent_hir_id(*hir_id);
606606
parent
607607
}
608+
hir::Node::Stmt(hir::Stmt { hir_id, kind: hir::StmtKind::Let(_), .. }) => {
609+
parent_id = self.tcx.parent_hir_id(*hir_id);
610+
parent
611+
}
612+
hir::Node::LetStmt(hir::LetStmt { hir_id, .. }) => {
613+
parent_id = self.tcx.parent_hir_id(*hir_id);
614+
parent
615+
}
608616
hir::Node::Block(_) => {
609617
parent_id = self.tcx.parent_hir_id(parent_id);
610618
parent

compiler/rustc_middle/src/query/inner.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rustc_query_system::query::{QueryCache, QueryMode, try_get_cached};
1010
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
1111

1212
use crate::dep_graph;
13-
use crate::query::IntoQueryParam;
1413
use crate::query::erase::{self, Erasable, Erased};
1514
use crate::ty::TyCtxt;
1615

@@ -27,7 +26,6 @@ pub(crate) fn query_get_at<'tcx, Cache>(
2726
where
2827
Cache: QueryCache,
2928
{
30-
let key = key.into_query_param();
3129
match try_get_cached(tcx, query_cache, &key) {
3230
Some(value) => value,
3331
None => execute_query(tcx, span, key, QueryMode::Get).unwrap(),
@@ -46,7 +44,6 @@ pub(crate) fn query_ensure<'tcx, Cache>(
4644
) where
4745
Cache: QueryCache,
4846
{
49-
let key = key.into_query_param();
5047
if try_get_cached(tcx, query_cache, &key).is_none() {
5148
execute_query(tcx, DUMMY_SP, key, QueryMode::Ensure { check_cache });
5249
}
@@ -66,7 +63,6 @@ where
6663
Cache: QueryCache<Value = Erased<Result<T, ErrorGuaranteed>>>,
6764
Result<T, ErrorGuaranteed>: Erasable,
6865
{
69-
let key = key.into_query_param();
7066
if let Some(res) = try_get_cached(tcx, query_cache, &key) {
7167
erase::restore_val(res).map(drop)
7268
} else {

compiler/rustc_mir_transform/src/liveness.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,11 +1086,6 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {
10861086

10871087
let Some((name, decl_span)) = self.checked_places.names[index] else { continue };
10881088

1089-
// By convention, underscore-prefixed bindings are explicitly allowed to be unused.
1090-
if name.as_str().starts_with('_') {
1091-
continue;
1092-
}
1093-
10941089
let is_maybe_drop_guard = maybe_drop_guard(
10951090
tcx,
10961091
self.typing_env,
@@ -1118,6 +1113,11 @@ impl<'a, 'tcx> AssignmentResult<'a, 'tcx> {
11181113
continue;
11191114
};
11201115

1116+
// By convention, underscore-prefixed bindings are allowed to be unused explicitly
1117+
if name.as_str().starts_with('_') {
1118+
break;
1119+
}
1120+
11211121
match kind {
11221122
AccessKind::Assign => {
11231123
let suggestion = annotate_mut_binding_to_immutable_binding(

tests/codegen-llvm/lib-optimizations/append-elements.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ compile-flags: -O -Zmerge-functions=disabled
22
//@ needs-deterministic-layouts
33
//@ min-llvm-version: 21
4+
//@ ignore-std-debug-assertions (causes different value naming)
45
#![crate_type = "lib"]
56

67
//! Check that a temporary intermediate allocations can eliminated and replaced
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// testcase from https://github.com/rust-lang/rust/issues/142602
2+
3+
pub fn main() {
4+
// Case 1: break before let-else
5+
let _a = loop {
6+
if true {
7+
break;
8+
}
9+
let Some(_) = Some(5) else {
10+
break 3; //~ ERROR mismatched types
11+
};
12+
};
13+
14+
// Case 2: two let-else statements
15+
let _b = loop {
16+
let Some(_) = Some(5) else {
17+
break;
18+
};
19+
let Some(_) = Some(4) else {
20+
break 3; //~ ERROR mismatched types
21+
};
22+
};
23+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/let-else-break-help-issue-142602.rs:10:19
3+
|
4+
LL | break;
5+
| ----- expected because of this `break`
6+
...
7+
LL | break 3;
8+
| ^ expected `()`, found integer
9+
10+
error[E0308]: mismatched types
11+
--> $DIR/let-else-break-help-issue-142602.rs:20:19
12+
|
13+
LL | break;
14+
| ----- expected because of this `break`
15+
...
16+
LL | break 3;
17+
| ^ expected `()`, found integer
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)