Skip to content

Commit 8c0b4f6

Browse files
committed
Auto merge of #120660 - matthiaskrgr:rollup-zuqljul, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #119481 (Clarify ambiguity in select_nth_unstable docs) - #119600 (Remove outdated references to librustc_middle) - #120458 (Document `&CStr` to `CString` conversion) - #120569 (coverage: Improve handling of function/closure spans) - #120572 (Update libc to 0.2.153) - #120587 (miri: normalize struct tail in ABI compat check) - #120607 (fix #120603 by adding a check in default_read_buf) - #120636 (Subtree update of `rust-analyzer`) - #120641 (rustdoc: trait.impl, type.impl: sort impls to make it not depend on serialization order) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0984bec + a2d3eed commit 8c0b4f6

File tree

228 files changed

+3480
-2121
lines changed

Some content is hidden

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

228 files changed

+3480
-2121
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,9 +2169,9 @@ checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760"
21692169

21702170
[[package]]
21712171
name = "libc"
2172-
version = "0.2.150"
2172+
version = "0.2.153"
21732173
source = "registry+https://github.com/rust-lang/crates.io-index"
2174-
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
2174+
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
21752175
dependencies = [
21762176
"rustc-std-workspace-core",
21772177
]

compiler/rustc_const_eval/src/const_eval/error.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ impl MachineStopType for ConstEvalErrKind {
4949
}
5050
}
5151

52-
// The errors become `MachineStop` with plain strings when being raised.
53-
// `ConstEvalErr` (in `librustc_middle/mir/interpret/error.rs`) knows to
54-
// handle these.
52+
/// The errors become [`InterpError::MachineStop`] when being raised.
5553
impl<'tcx> Into<InterpErrorInfo<'tcx>> for ConstEvalErrKind {
5654
fn into(self) -> InterpErrorInfo<'tcx> {
5755
err_machine_stop!(self).into()

compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
373373
if let (Some(caller), Some(callee)) = (pointee_ty(caller.ty)?, pointee_ty(callee.ty)?) {
374374
// This is okay if they have the same metadata type.
375375
let meta_ty = |ty: Ty<'tcx>| {
376-
let (meta, only_if_sized) = ty.ptr_metadata_ty(*self.tcx, |ty| ty);
376+
// Even if `ty` is normalized, the search for the unsized tail will project
377+
// to fields, which can yield non-normalized types. So we need to provide a
378+
// normalization function.
379+
let normalize = |ty| self.tcx.normalize_erasing_regions(self.param_env, ty);
380+
let (meta, only_if_sized) = ty.ptr_metadata_ty(*self.tcx, normalize);
377381
assert!(
378382
!only_if_sized,
379383
"there should be no more 'maybe has that metadata' types during interpretation"

compiler/rustc_data_structures/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub fn make_display(f: impl Fn(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl
148148
Printer { f }
149149
}
150150

151-
// See comments in src/librustc_middle/lib.rs
151+
// See comments in compiler/rustc_middle/src/tests.rs
152152
#[doc(hidden)]
153153
pub fn __noop_fix_for_27438() {}
154154

compiler/rustc_error_codes/src/error_codes/E0264.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ extern "C" {
1313
```
1414

1515
A list of available external lang items is available in
16-
`src/librustc_middle/middle/weak_lang_items.rs`. Example:
16+
`compiler/rustc_hir/src/weak_lang_items.rs`. Example:
1717

1818
```
1919
#![feature(lang_items)]

compiler/rustc_errors/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,8 @@ impl DiagCtxt {
645645
}
646646

647647
// This is here to not allow mutation of flags;
648-
// as of this writing it's only used in tests in librustc_middle.
648+
// as of this writing it's used in Session::consider_optimizing and
649+
// in tests in rustc_interface.
649650
pub fn can_emit_warnings(&self) -> bool {
650651
self.inner.borrow_mut().flags.can_emit_warnings
651652
}

compiler/rustc_lint/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ use crate::nonstandard_style::{method_context, MethodLateContext};
7272

7373
use std::fmt::Write;
7474

75-
// hardwired lints from librustc_middle
75+
// hardwired lints from rustc_lint_defs
7676
pub use rustc_session::lint::builtin::*;
7777

7878
declare_lint! {

compiler/rustc_middle/src/arena.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ macro_rules! arena_types {
9494

9595
// Note that this deliberately duplicates items in the `rustc_hir::arena`,
9696
// since we need to allocate this type on both the `rustc_hir` arena
97-
// (during lowering) and the `librustc_middle` arena (for decoding MIR)
97+
// (during lowering) and the `rustc_middle` arena (for decoding MIR)
9898
[decode] asm_template: rustc_ast::InlineAsmTemplatePiece,
9999
[decode] used_trait_imports: rustc_data_structures::unord::UnordSet<rustc_hir::def_id::LocalDefId>,
100100
[decode] is_late_bound_map: rustc_data_structures::fx::FxIndexSet<rustc_hir::ItemLocalId>,

compiler/rustc_middle/src/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::*;
22

3-
// FIXME(#27438): right now the unit tests of librustc_middle don't refer to any actual
4-
// functions generated in librustc_data_structures (all
3+
// FIXME(#27438): right now the unit tests of rustc_middle don't refer to any actual
4+
// functions generated in rustc_data_structures (all
55
// references are through generic functions), but statics are
66
// referenced from time to time. Due to this bug we won't
77
// actually correctly link in the statics unless we also

compiler/rustc_mir_transform/src/coverage/mod.rs

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ fn is_eligible_for_coverage(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
394394
struct ExtractedHirInfo {
395395
function_source_hash: u64,
396396
is_async_fn: bool,
397-
fn_sig_span: Span,
397+
/// The span of the function's signature, extended to the start of `body_span`.
398+
/// Must have the same context and filename as the body span.
399+
fn_sig_span_extended: Option<Span>,
398400
body_span: Span,
399401
}
400402

@@ -407,13 +409,25 @@ fn extract_hir_info<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> ExtractedHir
407409
hir::map::associated_body(hir_node).expect("HIR node is a function with body");
408410
let hir_body = tcx.hir().body(fn_body_id);
409411

410-
let is_async_fn = hir_node.fn_sig().is_some_and(|fn_sig| fn_sig.header.is_async());
411-
let body_span = get_body_span(tcx, hir_body, def_id);
412+
let maybe_fn_sig = hir_node.fn_sig();
413+
let is_async_fn = maybe_fn_sig.is_some_and(|fn_sig| fn_sig.header.is_async());
414+
415+
let mut body_span = hir_body.value.span;
416+
417+
use rustc_hir::{Closure, Expr, ExprKind, Node};
418+
// Unexpand a closure's body span back to the context of its declaration.
419+
// This helps with closure bodies that consist of just a single bang-macro,
420+
// and also with closure bodies produced by async desugaring.
421+
if let Node::Expr(&Expr { kind: ExprKind::Closure(&Closure { fn_decl_span, .. }), .. }) =
422+
hir_node
423+
{
424+
body_span = body_span.find_ancestor_in_same_ctxt(fn_decl_span).unwrap_or(body_span);
425+
}
412426

413427
// The actual signature span is only used if it has the same context and
414428
// filename as the body, and precedes the body.
415-
let maybe_fn_sig_span = hir_node.fn_sig().map(|fn_sig| fn_sig.span);
416-
let fn_sig_span = maybe_fn_sig_span
429+
let fn_sig_span_extended = maybe_fn_sig
430+
.map(|fn_sig| fn_sig.span)
417431
.filter(|&fn_sig_span| {
418432
let source_map = tcx.sess.source_map();
419433
let file_idx = |span: Span| source_map.lookup_source_file_idx(span.lo());
@@ -423,30 +437,11 @@ fn extract_hir_info<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> ExtractedHir
423437
&& file_idx(fn_sig_span) == file_idx(body_span)
424438
})
425439
// If so, extend it to the start of the body span.
426-
.map(|fn_sig_span| fn_sig_span.with_hi(body_span.lo()))
427-
// Otherwise, create a dummy signature span at the start of the body.
428-
.unwrap_or_else(|| body_span.shrink_to_lo());
440+
.map(|fn_sig_span| fn_sig_span.with_hi(body_span.lo()));
429441

430442
let function_source_hash = hash_mir_source(tcx, hir_body);
431443

432-
ExtractedHirInfo { function_source_hash, is_async_fn, fn_sig_span, body_span }
433-
}
434-
435-
fn get_body_span<'tcx>(
436-
tcx: TyCtxt<'tcx>,
437-
hir_body: &rustc_hir::Body<'tcx>,
438-
def_id: LocalDefId,
439-
) -> Span {
440-
let mut body_span = hir_body.value.span;
441-
442-
if tcx.is_closure_or_coroutine(def_id.to_def_id()) {
443-
// If the current function is a closure, and its "body" span was created
444-
// by macro expansion or compiler desugaring, try to walk backwards to
445-
// the pre-expansion call site or body.
446-
body_span = body_span.source_callsite();
447-
}
448-
449-
body_span
444+
ExtractedHirInfo { function_source_hash, is_async_fn, fn_sig_span_extended, body_span }
450445
}
451446

452447
fn hash_mir_source<'tcx>(tcx: TyCtxt<'tcx>, hir_body: &'tcx rustc_hir::Body<'tcx>) -> u64 {

0 commit comments

Comments
 (0)