Skip to content
Open
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
13 changes: 9 additions & 4 deletions compiler/rustc_const_eval/src/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ use rustc_data_structures::fx::FxHashSet;
use rustc_hir as hir;
use rustc_middle::bug;
use rustc_middle::mir::interpret::{
InterpErrorKind, InvalidMetaKind, Misalignment, Provenance, alloc_range, interp_ok,
InterpErrorKind, InvalidMetaKind, Misalignment, PointerArithmetic, Provenance, alloc_range,
interp_ok,
};
use rustc_middle::ty::layout::{LayoutCx, TyAndLayout};
use rustc_middle::ty::{self, Ty};
Expand Down Expand Up @@ -653,9 +654,13 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValidityVisitor<'rt, 'tcx, M> {
let scalar = Scalar::from_maybe_pointer(place.ptr(), self.ecx);
// Skip this if we don't know the absolute address (during CTFE).
if let Ok(addr) = scalar.try_to_scalar_int() {
// Try to compute the end address.
let addr = Size::from_bytes(addr.to_target_usize(*self.ecx.tcx));
if addr.checked_add(size, self.ecx).is_none() {
// Try to compute the end address. Cannot use `Size` addition as that also applies
// the "max obj size" bound.
let addr = Size::from_bytes(addr.to_target_usize(*self.ecx.tcx)).bytes();
if addr
.checked_add(size.bytes())
.is_none_or(|result| result >= self.ecx.target_usize_max())
{
throw_validation_failure!(
self.path,
format!(
Expand Down
25 changes: 12 additions & 13 deletions compiler/rustc_resolve/src/effective_visibilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,32 +129,31 @@ impl<'a, 'ra, 'tcx> EffectiveVisibilitiesVisitor<'a, 'ra, 'tcx> {
let Some(decl) = name_resolution.borrow(self.r).best_decl() else {
continue;
};
self.update_decl_chain(decl, ParentId::Def(module_id));
self.update_decl_chain(decl, ParentId::Def(module_id), &mut FxHashSet::default());
}
}

/// Update effective visibilities for the whole reexport chain of a declaration.
/// Set the given effective visibility level to `Level::Direct` and
/// sets the rest of the `use` chain to `Level::Reexported` until
/// we hit the actual exported item.
fn update_decl_chain(&mut self, mut decl: Decl<'ra>, mut parent_id: ParentId<'ra>) {
fn update_decl_chain(
&mut self,
mut decl: Decl<'ra>,
mut parent_id: ParentId<'ra>,
seen_most_visible: &mut FxHashSet<Decl<'ra>>,
) {
let priv_vis = |this: &Self, parent_id, decl| match parent_id {
ParentId::Def(_) => this.current_private_vis,
ParentId::Import(_) => this.r.private_vis_decl(decl),
};
while let DeclKind::Import { source_decl, .. } = decl.kind {
self.update_import(decl, parent_id, priv_vis(self, parent_id, decl));
if let Some(max_vis_decl) = decl.ambiguity_vis_max.get() {
// The name is exported with the visibility of the most visible declaration
// in its ambiguous glob set (see `DeclData::vis`), so everything on that
// declaration's reexport chain, including the final item, must get its
// effective visibility from that declaration as well. Otherwise the item
// would be considered unreachable by dead code analysis and metadata
// encoding despite being exported (see the regression test
// `ambiguous-import-visibility-globglob-mir.rs`).
// This also avoids the most visible import in an ambiguous glob set
// being reported as unused.
self.update_decl_chain(max_vis_decl, parent_id);
// `ambiguity_vis_max` can cycle on mutual globs; follow each once.
if let Some(most_visible) = decl.ambiguity_vis_max.get()
&& seen_most_visible.insert(most_visible)
{
self.update_decl_chain(most_visible, parent_id, seen_most_visible);
}
parent_id = ParentId::Import(decl);
decl = source_decl;
Expand Down
16 changes: 8 additions & 8 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,14 @@ impl CommandLineStep for IntrinsicTest {
builder.info(&format!("Skipping intrinsic-test, as it is not available for {host}"));
return;
}
// intrinsic-test shells out to `cargo` and `rustfmt` make bootstrap's
// managed binaries findable by prepending their dirs to PATH.
let Some(rustfmt_path) = builder.ensure(InternalRustfmt) else {
eprintln!(
"WARNING: intrinsic-test skipped because rustfmt is required but not available on this channel"
);
return;
};

let (input_file, skip_file, cflags, sde_runner) = if host.contains("x86_64-unknown-linux") {
let Some(sde) = &builder.config.sde else {
Expand Down Expand Up @@ -1152,14 +1160,6 @@ impl CommandLineStep for IntrinsicTest {
cmd.arg("--cc-arg-style").arg("gcc");
cmd.env("CC", builder.cc(host));
cmd.env("CFLAGS", cflags);
// intrinsic-test shells out to `cargo` and `rustfmt` make bootstrap's
// managed binaries findable by prepending their dirs to PATH.
let Some(rustfmt_path) = builder.ensure(InternalRustfmt) else {
eprintln!(
"WARNING: intrinsic-test skipped because rustfmt is required but not available on this channel"
);
return;
};

let mut path_dirs: Vec<PathBuf> = Vec::new();
if let Some(cargo_dir) = builder.initial_cargo.parent() {
Expand Down
Loading
Loading