Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit c86e7fb

Browse files
committed
Auto merge of rust-lang#111342 - Dylan-DPC:rollup-b5p6wzy, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - rust-lang#110297 (Make `(try_)subst_and_normalize_erasing_regions` take `EarlyBinder`) - rust-lang#110827 (Fix lifetime suggestion for type aliases with objects in them) - rust-lang#111022 (Use smaller ints for bitflags) - rust-lang#111056 (Fix some suggestions where a `Box<T>` is expected.) - rust-lang#111262 (Further normalize msvc-non-utf8-ouput) - rust-lang#111265 (Make generics_of has_self on RPITITs delegate to the opaque) - rust-lang#111323 (Give a more helpful error when running the rustc shim directly) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents ea0c22e + 172ddcc commit c86e7fb

File tree

37 files changed

+312
-85
lines changed

37 files changed

+312
-85
lines changed

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
845845
return;
846846
}
847847

848-
let Some((alias_tys, alias_span)) = self
848+
let Some((alias_tys, alias_span, lt_addition_span)) = self
849849
.infcx
850850
.tcx
851851
.return_type_impl_or_dyn_traits_with_type_alias(suitable_region.def_id) else { return; };
@@ -858,10 +858,20 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
858858
()
859859
}
860860
if let TyKind::TraitObject(_, lt, _) = alias_ty.kind {
861-
spans_suggs.push((lt.ident.span.shrink_to_hi(), " + 'a".to_string()));
861+
if lt.ident.name == kw::Empty {
862+
spans_suggs.push((lt.ident.span.shrink_to_hi(), " + 'a".to_string()));
863+
} else {
864+
spans_suggs.push((lt.ident.span, "'a".to_string()));
865+
}
862866
}
863867
}
864-
spans_suggs.push((alias_span.shrink_to_hi(), "<'a>".to_string()));
868+
869+
if let Some(lt_addition_span) = lt_addition_span {
870+
spans_suggs.push((lt_addition_span, "'a, ".to_string()));
871+
} else {
872+
spans_suggs.push((alias_span.shrink_to_hi(), "<'a>".to_string()));
873+
}
874+
865875
diag.multipart_suggestion_verbose(
866876
format!(
867877
"to declare that the trait object {captures}, you can add a lifetime parameter `'a` in the type alias"

compiler/rustc_codegen_cranelift/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
361361
self.instance.subst_mir_and_normalize_erasing_regions(
362362
self.tcx,
363363
ty::ParamEnv::reveal_all(),
364-
value,
364+
ty::EarlyBinder(value),
365365
)
366366
}
367367

compiler/rustc_codegen_llvm/src/debuginfo/create_scope_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn make_mir_scope<'ll, 'tcx>(
9393
let callee = cx.tcx.subst_and_normalize_erasing_regions(
9494
instance.substs,
9595
ty::ParamEnv::reveal_all(),
96-
callee,
96+
ty::EarlyBinder(callee),
9797
);
9898
let callee_fn_abi = cx.fn_abi_of_instance(callee, ty::List::empty());
9999
cx.dbg_scope_fn(callee, callee_fn_abi, None)

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
529529
let impl_self_ty = cx.tcx.subst_and_normalize_erasing_regions(
530530
instance.substs,
531531
ty::ParamEnv::reveal_all(),
532-
cx.tcx.type_of(impl_def_id).skip_binder(),
532+
cx.tcx.type_of(impl_def_id),
533533
);
534534

535535
// Only "class" methods are generally understood by LLVM,

compiler/rustc_codegen_ssa/src/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
111111
self.instance.subst_mir_and_normalize_erasing_regions(
112112
self.cx.tcx(),
113113
ty::ParamEnv::reveal_all(),
114-
value,
114+
ty::EarlyBinder(value),
115115
)
116116
}
117117
}

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
495495
) -> Result<T, InterpError<'tcx>> {
496496
frame
497497
.instance
498-
.try_subst_mir_and_normalize_erasing_regions(*self.tcx, self.param_env, value)
498+
.try_subst_mir_and_normalize_erasing_regions(
499+
*self.tcx,
500+
self.param_env,
501+
ty::EarlyBinder(value),
502+
)
499503
.map_err(|_| err_inval!(TooGeneric))
500504
}
501505

compiler/rustc_data_structures/src/profiling.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ use parking_lot::RwLock;
101101
use smallvec::SmallVec;
102102

103103
bitflags::bitflags! {
104-
struct EventFilter: u32 {
104+
struct EventFilter: u16 {
105105
const GENERIC_ACTIVITIES = 1 << 0;
106106
const QUERY_PROVIDERS = 1 << 1;
107107
const QUERY_CACHE_HITS = 1 << 2;

compiler/rustc_hir_typeck/messages.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,7 @@ hir_typeck_union_pat_dotdot = `..` cannot be used in union patterns
7575
7676
hir_typeck_arg_mismatch_indeterminate = argument type mismatch was detected, but rustc had trouble determining where
7777
.note = we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new
78+
79+
hir_typeck_suggest_boxing_note = for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html
80+
81+
hir_typeck_suggest_boxing_when_appropriate = store this in the heap by calling `Box::new`

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5151
|| self.suggest_non_zero_new_unwrap(err, expr, expected, expr_ty)
5252
|| self.suggest_calling_boxed_future_when_appropriate(err, expr, expected, expr_ty)
5353
|| self.suggest_no_capture_closure(err, expected, expr_ty)
54-
|| self.suggest_boxing_when_appropriate(err, expr, expected, expr_ty)
54+
|| self.suggest_boxing_when_appropriate(err, expr.span, expr.hir_id, expected, expr_ty)
5555
|| self.suggest_block_to_brackets_peeling_refs(err, expr, expr_ty, expected)
5656
|| self.suggest_copied_or_cloned(err, expr, expr_ty, expected)
5757
|| self.suggest_clone_for_ref(err, expr, expr_ty, expected)

compiler/rustc_hir_typeck/src/errors.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,31 @@ pub struct ArgMismatchIndeterminate {
267267
#[primary_span]
268268
pub span: Span,
269269
}
270+
271+
#[derive(Subdiagnostic)]
272+
pub enum SuggestBoxing {
273+
#[note(hir_typeck_suggest_boxing_note)]
274+
#[multipart_suggestion(
275+
hir_typeck_suggest_boxing_when_appropriate,
276+
applicability = "machine-applicable"
277+
)]
278+
Unit {
279+
#[suggestion_part(code = "Box::new(())")]
280+
start: Span,
281+
#[suggestion_part(code = "")]
282+
end: Span,
283+
},
284+
#[note(hir_typeck_suggest_boxing_note)]
285+
AsyncBody,
286+
#[note(hir_typeck_suggest_boxing_note)]
287+
#[multipart_suggestion(
288+
hir_typeck_suggest_boxing_when_appropriate,
289+
applicability = "machine-applicable"
290+
)]
291+
Other {
292+
#[suggestion_part(code = "Box::new(")]
293+
start: Span,
294+
#[suggestion_part(code = ")")]
295+
end: Span,
296+
},
297+
}

0 commit comments

Comments
 (0)