Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a931943

Browse files
committedFeb 14, 2025
Auto merge of #137040 - jhpratt:rollup-lr17zya, r=jhpratt
Rollup of 11 pull requests Successful merges: - #133312 (triagebot: automatically add more rustdoc related labels) - #134016 (Stabilize `const_is_char_boundary` and `const_str_split_at`.) - #135813 (CI: split i686-mingw job to three free runners) - #136879 (Add safe new() to NotAllOnes) - #136971 (Add a new check-pass UI test for returning `impl Fn(T) -> impl Trait`) - #136983 (Prepare standard library for Rust 2024 migration) - #137002 (Fix early lint check desc in query) - #137006 (borrowck diagnostics cleanup: remove an unused and a barely-used field) - #137026 (Stabilize (and const-stabilize) `integer_sign_cast`) - #137028 (mir_build: Clarify some code for lowering `hir::PatExpr` to THIR) - #137032 (Decode metadata buffer in one go) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d8810e3 + 8491b54 commit a931943

File tree

64 files changed

+457
-281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+457
-281
lines changed
 

‎compiler/rustc_borrowck/src/diagnostics/region_errors.rs

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ pub(crate) enum RegionErrorKind<'tcx> {
147147
pub(crate) struct ErrorConstraintInfo<'tcx> {
148148
// fr: outlived_fr
149149
pub(super) fr: RegionVid,
150-
pub(super) fr_is_local: bool,
151150
pub(super) outlived_fr: RegionVid,
152-
pub(super) outlived_fr_is_local: bool,
153151

154152
// Category and span for best blame constraint
155153
pub(super) category: ConstraintCategory<'tcx>,
@@ -471,14 +469,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
471469
fr_is_local, outlived_fr_is_local, category
472470
);
473471

474-
let errci = ErrorConstraintInfo {
475-
fr,
476-
outlived_fr,
477-
fr_is_local,
478-
outlived_fr_is_local,
479-
category,
480-
span: cause.span,
481-
};
472+
let errci = ErrorConstraintInfo { fr, outlived_fr, category, span: cause.span };
482473

483474
let mut diag = match (category, fr_is_local, outlived_fr_is_local) {
484475
(ConstraintCategory::Return(kind), true, false) if self.is_closure_fn_mut(fr) => {
@@ -680,11 +671,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
680671
&& self.regioncx.universal_regions().defining_ty.is_fn_def())
681672
|| self.regioncx.universal_regions().defining_ty.is_const()
682673
{
683-
return self.report_general_error(&ErrorConstraintInfo {
684-
fr_is_local: true,
685-
outlived_fr_is_local: false,
686-
..*errci
687-
});
674+
return self.report_general_error(errci);
688675
}
689676

690677
let mut diag =
@@ -762,15 +749,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
762749
/// ```
763750
#[allow(rustc::diagnostic_outside_of_impl)] // FIXME
764751
fn report_general_error(&self, errci: &ErrorConstraintInfo<'tcx>) -> Diag<'infcx> {
765-
let ErrorConstraintInfo {
766-
fr,
767-
fr_is_local,
768-
outlived_fr,
769-
outlived_fr_is_local,
770-
span,
771-
category,
772-
..
773-
} = errci;
752+
let ErrorConstraintInfo { fr, outlived_fr, span, category, .. } = errci;
774753

775754
let mir_def_name = self.infcx.tcx.def_descr(self.mir_def_id().to_def_id());
776755

@@ -789,19 +768,22 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
789768
let outlived_fr_name = self.give_region_a_name(*outlived_fr).unwrap();
790769
outlived_fr_name.highlight_region_name(&mut diag);
791770

792-
let err_category = match (category, outlived_fr_is_local, fr_is_local) {
793-
(ConstraintCategory::Return(_), true, _) => LifetimeReturnCategoryErr::WrongReturn {
771+
let err_category = if matches!(category, ConstraintCategory::Return(_))
772+
&& self.regioncx.universal_regions().is_local_free_region(*outlived_fr)
773+
{
774+
LifetimeReturnCategoryErr::WrongReturn {
794775
span: *span,
795776
mir_def_name,
796777
outlived_fr_name,
797778
fr_name: &fr_name,
798-
},
799-
_ => LifetimeReturnCategoryErr::ShortReturn {
779+
}
780+
} else {
781+
LifetimeReturnCategoryErr::ShortReturn {
800782
span: *span,
801783
category_desc: category.description(),
802784
free_region_name: &fr_name,
803785
outlived_fr_name,
804-
},
786+
}
805787
};
806788

807789
diag.subdiagnostic(err_category);

‎compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,10 +2272,7 @@ impl<D: Decoder> Decodable<D> for EncodedMetadata {
22722272
let len = d.read_usize();
22732273
let mmap = if len > 0 {
22742274
let mut mmap = MmapMut::map_anon(len).unwrap();
2275-
for _ in 0..len {
2276-
(&mut mmap[..]).write_all(&[d.read_u8()]).unwrap();
2277-
}
2278-
mmap.flush().unwrap();
2275+
mmap.copy_from_slice(d.read_raw_bytes(len));
22792276
Some(mmap.make_read_only().unwrap())
22802277
} else {
22812278
None

0 commit comments

Comments
 (0)
Please sign in to comment.