Skip to content

Commit d7dd01f

Browse files
committed
Auto merge of #103228 - Dylan-DPC:rollup-31yiauw, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #102863 (Standardize "use parentheses to call" suggestions between typeck and trait selection) - #103034 (Let expressions on RHS shouldn't be terminating scopes) - #103127 (Make transpose const and inline) - #103153 (Allow `Vec::leak` when using `no_global_oom_handling`) - #103182 (Clean up query descriptions) - #103216 (Consider patterns in fn params in an `Elided(Infer)` lifetime rib.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5605ed8 + 32159e3 commit d7dd01f

35 files changed

+417
-224
lines changed

Diff for: compiler/rustc_hir_analysis/src/check/callee.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::method::probe::{IsSuggestion, Mode, ProbeScope};
22
use super::method::MethodCallee;
3-
use super::{DefIdOrName, Expectation, FnCtxt, TupleArgumentsFlag};
3+
use super::{Expectation, FnCtxt, TupleArgumentsFlag};
44
use crate::type_error_struct;
55

66
use rustc_ast::util::parser::PREC_POSTFIX;
@@ -27,6 +27,7 @@ use rustc_span::Span;
2727
use rustc_target::spec::abi;
2828
use rustc_trait_selection::autoderef::Autoderef;
2929
use rustc_trait_selection::infer::InferCtxtExt as _;
30+
use rustc_trait_selection::traits::error_reporting::DefIdOrName;
3031
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
3132

3233
use std::iter;

Diff for: compiler/rustc_hir_analysis/src/check/fn_ctxt/suggestions.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use super::FnCtxt;
22
use crate::astconv::AstConv;
33
use crate::errors::{AddReturnTypeSuggestion, ExpectedReturnTypeLabel};
44

5-
use hir::def_id::DefId;
65
use rustc_ast::util::parser::{ExprPrecedence, PREC_POSTFIX};
76
use rustc_errors::{Applicability, Diagnostic, MultiSpan};
87
use rustc_hir as hir;
@@ -19,6 +18,7 @@ use rustc_session::errors::ExprParenthesesNeeded;
1918
use rustc_span::symbol::sym;
2019
use rustc_span::Span;
2120
use rustc_trait_selection::infer::InferCtxtExt;
21+
use rustc_trait_selection::traits::error_reporting::DefIdOrName;
2222
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
2323

2424
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
@@ -90,7 +90,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
9090
if ty.is_suggestable(self.tcx, false) {
9191
format!("/* {ty} */")
9292
} else {
93-
"".to_string()
93+
"/* value */".to_string()
9494
}
9595
})
9696
.collect::<Vec<_>>()
@@ -102,10 +102,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
102102

103103
let msg = match def_id_or_name {
104104
DefIdOrName::DefId(def_id) => match self.tcx.def_kind(def_id) {
105-
DefKind::Ctor(CtorOf::Struct, _) => "instantiate this tuple struct".to_string(),
106-
DefKind::Ctor(CtorOf::Variant, _) => {
107-
"instantiate this tuple variant".to_string()
108-
}
105+
DefKind::Ctor(CtorOf::Struct, _) => "construct this tuple struct".to_string(),
106+
DefKind::Ctor(CtorOf::Variant, _) => "construct this tuple variant".to_string(),
109107
kind => format!("call this {}", kind.descr(def_id)),
110108
},
111109
DefIdOrName::Name(name) => format!("call this {name}"),
@@ -1209,8 +1207,3 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12091207
}
12101208
}
12111209
}
1212-
1213-
pub enum DefIdOrName {
1214-
DefId(DefId),
1215-
Name(&'static str),
1216-
}

Diff for: compiler/rustc_hir_analysis/src/check/region.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,13 @@ fn resolve_expr<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, expr: &'tcx h
252252
) => {
253253
// For shortcircuiting operators, mark the RHS as a terminating
254254
// scope since it only executes conditionally.
255-
terminating(r.hir_id.local_id);
256-
}
257255

256+
// `Let` expressions (in a let-chain) shouldn't be terminating, as their temporaries
257+
// should live beyond the immediate expression
258+
if !matches!(r.kind, hir::ExprKind::Let(_)) {
259+
terminating(r.hir_id.local_id);
260+
}
261+
}
258262
hir::ExprKind::If(_, ref then, Some(ref otherwise)) => {
259263
terminating(then.hir_id.local_id);
260264
terminating(otherwise.hir_id.local_id);

0 commit comments

Comments
 (0)