Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #84804

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.39"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3748f82c7d366a0b4950257d19db685d4958d2fa27c6d164a3f069fec42b748b"
checksum = "68448b4c6cee41f17bef42cbdad2fde55d05b91a6116c3a517e5389fb742758d"
dependencies = [
"cc",
"rustc-std-workspace-core",
Expand Down
64 changes: 34 additions & 30 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ impl RecursiveTypeDescription<'ll, 'tcx> {
unfinished_type,
member_holding_stub,
member_descriptions,
None,
);
MetadataCreationResult::new(metadata_stub, true)
}
Expand Down Expand Up @@ -1459,6 +1460,7 @@ struct EnumMemberDescriptionFactory<'ll, 'tcx> {
layout: TyAndLayout<'tcx>,
tag_type_metadata: Option<&'ll DIType>,
containing_scope: &'ll DIScope,
common_members: Vec<Option<&'ll DIType>>,
span: Span,
}

Expand Down Expand Up @@ -1493,10 +1495,6 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
} else {
type_metadata(cx, self.enum_type, self.span)
};
let flags = match self.enum_type.kind() {
ty::Generator(..) => DIFlags::FlagArtificial,
_ => DIFlags::FlagZero,
};

match self.layout.variants {
Variants::Single { index } => {
Expand All @@ -1523,14 +1521,15 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
self.enum_type,
variant_type_metadata,
member_descriptions,
Some(&self.common_members),
);
vec![MemberDescription {
name: if fallback { String::new() } else { variant_info.variant_name() },
type_metadata: variant_type_metadata,
offset: Size::ZERO,
size: self.layout.size,
align: self.layout.align.abi,
flags,
flags: DIFlags::FlagZero,
discriminant: None,
source_info: variant_info.source_info(cx),
}]
Expand Down Expand Up @@ -1572,6 +1571,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
self.enum_type,
variant_type_metadata,
member_descriptions,
Some(&self.common_members),
);

MemberDescription {
Expand All @@ -1584,7 +1584,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
offset: Size::ZERO,
size: self.layout.size,
align: self.layout.align.abi,
flags,
flags: DIFlags::FlagZero,
discriminant: Some(
self.layout.ty.discriminant_for_variant(cx.tcx, i).unwrap().val
as u64,
Expand Down Expand Up @@ -1621,6 +1621,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
self.enum_type,
variant_type_metadata,
variant_member_descriptions,
Some(&self.common_members),
);

// Encode the information about the null variant in the union
Expand Down Expand Up @@ -1667,7 +1668,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
offset: Size::ZERO,
size: variant.size,
align: variant.align.abi,
flags,
flags: DIFlags::FlagZero,
discriminant: None,
source_info: variant_info.source_info(cx),
}]
Expand Down Expand Up @@ -1695,6 +1696,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
self.enum_type,
variant_type_metadata,
member_descriptions,
Some(&self.common_members),
);

let niche_value = if i == dataful_variant {
Expand All @@ -1717,7 +1719,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> {
offset: Size::ZERO,
size: self.layout.size,
align: self.layout.align.abi,
flags,
flags: DIFlags::FlagZero,
discriminant: niche_value,
source_info: variant_info.source_info(cx),
}
Expand Down Expand Up @@ -1849,13 +1851,6 @@ impl<'tcx> VariantInfo<'_, 'tcx> {
}
None
}

fn is_artificial(&self) -> bool {
match self {
VariantInfo::Generator { .. } => true,
VariantInfo::Adt(..) => false,
}
}
}

/// Returns a tuple of (1) `type_metadata_stub` of the variant, (2) a
Expand All @@ -1881,8 +1876,7 @@ fn describe_enum_variant(
&variant_name,
unique_type_id,
Some(containing_scope),
// FIXME(tmandry): This doesn't seem to have any effect.
if variant.is_artificial() { DIFlags::FlagArtificial } else { DIFlags::FlagZero },
DIFlags::FlagZero,
)
});

Expand Down Expand Up @@ -1945,11 +1939,6 @@ fn prepare_enum_metadata(
) -> RecursiveTypeDescription<'ll, 'tcx> {
let tcx = cx.tcx;
let enum_name = compute_debuginfo_type_name(tcx, enum_type, false);
// FIXME(tmandry): This doesn't seem to have any effect.
let enum_flags = match enum_type.kind() {
ty::Generator(..) => DIFlags::FlagArtificial,
_ => DIFlags::FlagZero,
};

let containing_scope = get_namespace_for_item(cx, enum_def_id);
// FIXME: This should emit actual file metadata for the enum, but we
Expand Down Expand Up @@ -2082,7 +2071,7 @@ fn prepare_enum_metadata(
UNKNOWN_LINE_NUMBER,
layout.size.bits(),
layout.align.abi.bits() as u32,
enum_flags,
DIFlags::FlagZero,
None,
0, // RuntimeLang
unique_type_id_str.as_ptr().cast(),
Expand All @@ -2102,6 +2091,7 @@ fn prepare_enum_metadata(
layout,
tag_type_metadata: discriminant_type_metadata,
containing_scope,
common_members: vec![],
span,
}),
);
Expand Down Expand Up @@ -2171,7 +2161,7 @@ fn prepare_enum_metadata(
}
};

let mut outer_fields = match layout.variants {
let outer_fields = match layout.variants {
Variants::Single { .. } => vec![],
Variants::Multiple { .. } => {
let tuple_mdf = TupleMemberDescriptionFactory {
Expand Down Expand Up @@ -2203,18 +2193,21 @@ fn prepare_enum_metadata(
UNKNOWN_LINE_NUMBER,
layout.size.bits(),
layout.align.abi.bits() as u32,
enum_flags,
DIFlags::FlagZero,
discriminator_metadata,
empty_array,
variant_part_unique_type_id_str.as_ptr().cast(),
variant_part_unique_type_id_str.len(),
)
};
outer_fields.push(Some(variant_part));

let struct_wrapper = {
// The variant part must be wrapped in a struct according to DWARF.
let type_array = create_DIArray(DIB(cx), &outer_fields);
// All fields except the discriminant (including `outer_fields`)
// should be put into structures inside the variant part, which gives
// an equivalent layout but offers us much better integration with
// debuggers.
let type_array = create_DIArray(DIB(cx), &[Some(variant_part)]);

let type_map = debug_context(cx).type_map.borrow();
let unique_type_id_str = type_map.get_unique_type_id_as_string(unique_type_id);
Expand All @@ -2229,7 +2222,7 @@ fn prepare_enum_metadata(
UNKNOWN_LINE_NUMBER,
layout.size.bits(),
layout.align.abi.bits() as u32,
enum_flags,
DIFlags::FlagZero,
None,
type_array,
0,
Expand All @@ -2251,6 +2244,7 @@ fn prepare_enum_metadata(
layout,
tag_type_metadata: None,
containing_scope,
common_members: outer_fields,
span,
}),
)
Expand Down Expand Up @@ -2283,7 +2277,13 @@ fn composite_type_metadata(
DIFlags::FlagZero,
);
// ... and immediately create and add the member descriptions.
set_members_of_composite_type(cx, composite_type, composite_type_metadata, member_descriptions);
set_members_of_composite_type(
cx,
composite_type,
composite_type_metadata,
member_descriptions,
None,
);

composite_type_metadata
}
Expand All @@ -2293,6 +2293,7 @@ fn set_members_of_composite_type(
composite_type: Ty<'tcx>,
composite_type_metadata: &'ll DICompositeType,
member_descriptions: Vec<MemberDescription<'ll>>,
common_members: Option<&Vec<Option<&'ll DIType>>>,
) {
// In some rare cases LLVM metadata uniquing would lead to an existing type
// description being used instead of a new one created in
Expand All @@ -2311,10 +2312,13 @@ fn set_members_of_composite_type(
}
}

let member_metadata: Vec<_> = member_descriptions
let mut member_metadata: Vec<_> = member_descriptions
.into_iter()
.map(|desc| Some(desc.into_metadata(cx, composite_type_metadata)))
.collect();
if let Some(other_members) = common_members {
member_metadata.extend(other_members.iter());
}

let type_params = compute_type_parameters(cx, composite_type);
unsafe {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,7 @@ impl<O> AssertKind<O> {
}

/// Format the message arguments for the `assert(cond, msg..)` terminator in MIR printing.
fn fmt_assert_args<W: Write>(&self, f: &mut W) -> fmt::Result
pub fn fmt_assert_args<W: Write>(&self, f: &mut W) -> fmt::Result
where
O: Debug,
{
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub fn spin_loop() {
#[cfg(target_arch = "aarch64")]
{
// SAFETY: the `cfg` attr ensures that we only execute this on aarch64 targets.
unsafe { crate::arch::aarch64::__yield() };
unsafe { crate::arch::aarch64::__isb(crate::arch::aarch64::SY) };
}
#[cfg(target_arch = "arm")]
{
Expand Down
5 changes: 3 additions & 2 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ impl Clean<Item> for doctree::Module<'_> {
// determine if we should display the inner contents or
// the outer `mod` item for the source code.
let span = Span::from_rustc_span({
let where_outer = self.where_outer(cx.tcx);
let sm = cx.sess().source_map();
let outer = sm.lookup_char_pos(self.where_outer.lo());
let outer = sm.lookup_char_pos(where_outer.lo());
let inner = sm.lookup_char_pos(self.where_inner.lo());
if outer.file.start_pos == inner.file.start_pos {
// mod foo { ... }
self.where_outer
where_outer
} else {
// mod foo; (and a separate SourceFile for the contents)
self.where_inner
Expand Down
13 changes: 8 additions & 5 deletions src/librustdoc/doctree.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! This module is used to store stuff from Rust's AST in a more convenient
//! manner (and with prettier names) before cleaning.
use rustc_middle::ty::TyCtxt;
use rustc_span::{self, Span, Symbol};

use rustc_hir as hir;

crate struct Module<'hir> {
crate name: Symbol,
crate where_outer: Span,
crate where_inner: Span,
crate mods: Vec<Module<'hir>>,
crate id: hir::HirId,
Expand All @@ -17,16 +17,19 @@ crate struct Module<'hir> {
}

impl Module<'hir> {
crate fn new(name: Symbol) -> Module<'hir> {
crate fn new(name: Symbol, id: hir::HirId, where_inner: Span) -> Module<'hir> {
Module {
name,
id: hir::CRATE_HIR_ID,
where_outer: rustc_span::DUMMY_SP,
where_inner: rustc_span::DUMMY_SP,
id,
where_inner,
mods: Vec::new(),
items: Vec::new(),
foreigns: Vec::new(),
macros: Vec::new(),
}
}

crate fn where_outer(&self, tcx: TyCtxt<'_>) -> Span {
tcx.hir().span(self.id)
}
}
11 changes: 3 additions & 8 deletions src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use rustc_hir::def_id::DefId;
use rustc_hir::Node;
use rustc_middle::middle::privacy::AccessLevel;
use rustc_middle::ty::TyCtxt;
use rustc_span;
use rustc_span::source_map::Spanned;
use rustc_span::symbol::{kw, sym, Symbol};
use rustc_span::{self, Span};

use std::mem;

Expand Down Expand Up @@ -73,7 +73,6 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
crate fn visit(mut self, krate: &'tcx hir::Crate<'_>) -> Module<'tcx> {
let span = krate.item.inner;
let mut top_level_module = self.visit_mod_contents(
span,
&Spanned { span, node: hir::VisibilityKind::Public },
hir::CRATE_HIR_ID,
&krate.item,
Expand Down Expand Up @@ -129,16 +128,12 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {

fn visit_mod_contents(
&mut self,
span: Span,
vis: &hir::Visibility<'_>,
id: hir::HirId,
m: &'tcx hir::Mod<'tcx>,
name: Symbol,
) -> Module<'tcx> {
let mut om = Module::new(name);
om.where_outer = span;
om.where_inner = m.inner;
om.id = id;
let mut om = Module::new(name, id, m.inner);
// Keep track of if there were any private modules in the path.
let orig_inside_public_path = self.inside_public_path;
self.inside_public_path &= vis.node.is_pub();
Expand Down Expand Up @@ -312,7 +307,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
om.items.push((item, renamed))
}
hir::ItemKind::Mod(ref m) => {
om.mods.push(self.visit_mod_contents(item.span, &item.vis, item.hir_id(), m, name));
om.mods.push(self.visit_mod_contents(&item.vis, item.hir_id(), m, name));
}
hir::ItemKind::Fn(..)
| hir::ItemKind::ExternCrate(..)
Expand Down
Loading