Skip to content

Rollup of 8 pull requests #141753

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

Merged
merged 25 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f83ecd8
Refactor the two-phase check for impls and impl items
mu001999 May 22, 2025
65bdb31
Report text_direction_codepoint_in_literal when parsing
matthewjasper May 14, 2025
e5bfd02
Avoid including text direction codepoints in lint messages
matthewjasper May 14, 2025
f652067
Warn on non-crate level text direction lints
matthewjasper May 27, 2025
419897c
Add cfg for FormatShortCmd
mu001999 May 28, 2025
4794ea1
atomic_load intrinsic: use const generic parameter for ordering
RalfJung May 24, 2025
a387c86
get rid of rustc_codegen_ssa::common::AtomicOrdering
RalfJung May 28, 2025
5e71855
remove `visit_clobber` and move `DummyAstNode` to `rustc_expand`
fee1-dead May 23, 2025
b2e9c72
`emit_xtensa_va_arg`: use `inbounds_ptradd` instead of `inbounds_gep`
folkertdev May 27, 2025
f80e3ac
Use `cfg_attr` AST placeholder AST `cfg_attr_trace` for diagnostics
estebank Dec 3, 2024
6eb6010
Add test for issue 127911 and 128839
mu001999 May 29, 2025
94cc726
implement `va_arg` for x86_64 systemv and macOS
folkertdev May 24, 2025
c6eb1d9
rustdoc: display doc(cfg(false)) properly
lolbinarycat May 29, 2025
6a79b27
float: Use a shared `assert_biteq!` macro for tests
tgross35 May 28, 2025
9907c5a
float: Replace some approximate assertions with exact
tgross35 May 28, 2025
5446ba3
float: Enable some f16 and f128 rounding tests on miri
tgross35 May 29, 2025
70cce1c
float: Use `assert_biteq!` where possible
tgross35 May 29, 2025
7aba37d
Rollup merge of #133823 - estebank:issue-56328, r=petrochenkov
matthiaskrgr May 30, 2025
5fc3f26
Rollup merge of #141004 - matthewjasper:unicode-before-expansion, r=d…
matthiaskrgr May 30, 2025
896be66
Rollup merge of #141407 - mu001999-contrib:dead-code/refactor, r=petr…
matthiaskrgr May 30, 2025
a87bc9d
Rollup merge of #141430 - fee1-dead-contrib:push-nmzoprvtsvww, r=petr…
matthiaskrgr May 30, 2025
ad2d91c
Rollup merge of #141507 - RalfJung:atomic-intrinsics, r=bjorn3
matthiaskrgr May 30, 2025
5023691
Rollup merge of #141538 - folkertdev:systemv-x86_64-va_arg, r=working…
matthiaskrgr May 30, 2025
3ebdd59
Rollup merge of #141669 - tgross35:float-test-cleanup, r=RalfJung
matthiaskrgr May 30, 2025
71529f5
Rollup merge of #141747 - lolbinarycat:rustdoc-cfg-138112, r=Guillaum…
matthiaskrgr May 30, 2025
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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2171,6 +2171,7 @@ dependencies = [
name = "lint-docs"
version = "0.1.0"
dependencies = [
"rustc-literal-escaper",
"serde_json",
"tempfile",
"walkdir",
Expand Down
15 changes: 14 additions & 1 deletion compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use rustc_data_structures::tagged_ptr::Tag;
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
pub use rustc_span::AttrId;
use rustc_span::source_map::{Spanned, respan};
use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Ident, Span, Symbol, kw, sym};
use thin_vec::{ThinVec, thin_vec};

pub use crate::format::*;
Expand Down Expand Up @@ -1526,6 +1526,19 @@ impl Expr {
| ExprKind::Struct(_)
)
}

/// Creates a dummy `P<Expr>`.
///
/// Should only be used when it will be replaced afterwards or as a return value when an error was encountered.
pub fn dummy() -> P<Expr> {
P(Expr {
id: DUMMY_NODE_ID,
kind: ExprKind::Dummy,
span: DUMMY_SP,
attrs: ThinVec::new(),
tokens: None,
})
}
}

#[derive(Clone, Encodable, Decodable, Debug)]
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_ast/src/ast_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ impl HasAttrs for Stmt {
}

/// A newtype around an AST node that implements the traits above if the node implements them.
#[repr(transparent)]
pub struct AstNodeWrapper<Wrapped, Tag> {
pub wrapped: Wrapped,
pub tag: PhantomData<Tag>,
Expand All @@ -313,6 +314,11 @@ impl<Wrapped, Tag> AstNodeWrapper<Wrapped, Tag> {
pub fn new(wrapped: Wrapped, _tag: Tag) -> AstNodeWrapper<Wrapped, Tag> {
AstNodeWrapper { wrapped, tag: Default::default() }
}

pub fn from_mut(wrapped: &mut Wrapped, _tag: Tag) -> &mut AstNodeWrapper<Wrapped, Tag> {
// SAFETY: `AstNodeWrapper` is `repr(transparent)` w.r.t `Wrapped`
unsafe { &mut *<*mut Wrapped>::cast(wrapped) }
}
}

impl<Wrapped: HasNodeId, Tag> HasNodeId for AstNodeWrapper<Wrapped, Tag> {
Expand Down
103 changes: 0 additions & 103 deletions compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,14 +368,6 @@ pub trait MutVisitor: Sized {

super::common_visitor_and_walkers!((mut) MutVisitor);

/// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
/// when using a `flat_map_*` or `filter_map_*` method within a `visit_`
/// method.
pub fn visit_clobber<T: DummyAstNode>(t: &mut T, f: impl FnOnce(T) -> T) {
let old_t = std::mem::replace(t, T::dummy());
*t = f(old_t);
}

#[inline]
fn visit_vec<T, F>(elems: &mut Vec<T>, mut visit_elem: F)
where
Expand Down Expand Up @@ -1417,101 +1409,6 @@ fn walk_capture_by<T: MutVisitor>(vis: &mut T, capture_by: &mut CaptureBy) {
}
}

/// Some value for the AST node that is valid but possibly meaningless. Similar
/// to `Default` but not intended for wide use. The value will never be used
/// meaningfully, it exists just to support unwinding in `visit_clobber` in the
/// case where its closure panics.
pub trait DummyAstNode {
fn dummy() -> Self;
}

impl<T> DummyAstNode for Option<T> {
fn dummy() -> Self {
Default::default()
}
}

impl<T: DummyAstNode + 'static> DummyAstNode for P<T> {
fn dummy() -> Self {
P(DummyAstNode::dummy())
}
}

impl DummyAstNode for Item {
fn dummy() -> Self {
Item {
attrs: Default::default(),
id: DUMMY_NODE_ID,
span: Default::default(),
vis: Visibility {
kind: VisibilityKind::Public,
span: Default::default(),
tokens: Default::default(),
},
kind: ItemKind::ExternCrate(None, Ident::dummy()),
tokens: Default::default(),
}
}
}

impl DummyAstNode for Expr {
fn dummy() -> Self {
Expr {
id: DUMMY_NODE_ID,
kind: ExprKind::Dummy,
span: Default::default(),
attrs: Default::default(),
tokens: Default::default(),
}
}
}

impl DummyAstNode for Ty {
fn dummy() -> Self {
Ty {
id: DUMMY_NODE_ID,
kind: TyKind::Dummy,
span: Default::default(),
tokens: Default::default(),
}
}
}

impl DummyAstNode for Pat {
fn dummy() -> Self {
Pat {
id: DUMMY_NODE_ID,
kind: PatKind::Wild,
span: Default::default(),
tokens: Default::default(),
}
}
}

impl DummyAstNode for Stmt {
fn dummy() -> Self {
Stmt { id: DUMMY_NODE_ID, kind: StmtKind::Empty, span: Default::default() }
}
}

impl DummyAstNode for Crate {
fn dummy() -> Self {
Crate {
attrs: Default::default(),
items: Default::default(),
spans: Default::default(),
id: DUMMY_NODE_ID,
is_placeholder: Default::default(),
}
}
}

impl<N: DummyAstNode, T: DummyAstNode> DummyAstNode for crate::ast_traits::AstNodeWrapper<N, T> {
fn dummy() -> Self {
crate::ast_traits::AstNodeWrapper::new(N::dummy(), T::dummy())
}
}

#[derive(Debug)]
pub enum FnKind<'a> {
/// E.g., `fn foo()`, `fn foo(&self)`, or `extern "Abi" fn foo()`.
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,11 +870,12 @@ fn codegen_regular_intrinsic_call<'tcx>(
// FIXME use a compiler fence once Cranelift supports it
fx.bcx.ins().fence();
}
_ if intrinsic.as_str().starts_with("atomic_load") => {
sym::atomic_load => {
intrinsic_args!(fx, args => (ptr); intrinsic);
let ptr = ptr.load_scalar(fx);

let ty = generic_args.type_at(0);
let _ord = generic_args.const_at(1).to_value(); // FIXME: forward this to cranelift once they support that
match ty.kind() {
ty::Uint(UintTy::U128) | ty::Int(IntTy::I128) => {
// FIXME implement 128bit atomics
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_codegen_gcc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_abi::{Align, HasDataLayout, Size, TargetDataLayout, WrappingRange};
use rustc_apfloat::{Float, Round, Status, ieee};
use rustc_codegen_ssa::MemFlags;
use rustc_codegen_ssa::common::{
AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
};
use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue};
use rustc_codegen_ssa::mir::place::PlaceRef;
Expand All @@ -26,7 +26,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
use rustc_middle::ty::layout::{
FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasTyCtxt, HasTypingEnv, LayoutError, LayoutOfHelpers,
};
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
use rustc_middle::ty::{self, AtomicOrdering, Instance, Ty, TyCtxt};
use rustc_span::Span;
use rustc_span::def_id::DefId;
use rustc_target::callconv::FnAbi;
Expand Down Expand Up @@ -75,7 +75,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {

let load_ordering = match order {
// TODO(antoyo): does this make sense?
AtomicOrdering::AcquireRelease | AtomicOrdering::Release => AtomicOrdering::Acquire,
AtomicOrdering::AcqRel | AtomicOrdering::Release => AtomicOrdering::Acquire,
_ => order,
};
let previous_value =
Expand Down Expand Up @@ -2474,8 +2474,8 @@ impl ToGccOrdering for AtomicOrdering {
AtomicOrdering::Relaxed => __ATOMIC_RELAXED, // TODO(antoyo): check if that's the same.
AtomicOrdering::Acquire => __ATOMIC_ACQUIRE,
AtomicOrdering::Release => __ATOMIC_RELEASE,
AtomicOrdering::AcquireRelease => __ATOMIC_ACQ_REL,
AtomicOrdering::SequentiallyConsistent => __ATOMIC_SEQ_CST,
AtomicOrdering::AcqRel => __ATOMIC_ACQ_REL,
AtomicOrdering::SeqCst => __ATOMIC_SEQ_CST,
};
ordering as i32
}
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_codegen_llvm/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
&mut self,
ty: &'ll Type,
ptr: &'ll Value,
order: rustc_codegen_ssa::common::AtomicOrdering,
order: rustc_middle::ty::AtomicOrdering,
size: Size,
) -> &'ll Value {
unsafe {
Expand Down Expand Up @@ -851,7 +851,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
&mut self,
val: &'ll Value,
ptr: &'ll Value,
order: rustc_codegen_ssa::common::AtomicOrdering,
order: rustc_middle::ty::AtomicOrdering,
size: Size,
) {
debug!("Store {:?} -> {:?}", val, ptr);
Expand Down Expand Up @@ -1307,8 +1307,8 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
dst: &'ll Value,
cmp: &'ll Value,
src: &'ll Value,
order: rustc_codegen_ssa::common::AtomicOrdering,
failure_order: rustc_codegen_ssa::common::AtomicOrdering,
order: rustc_middle::ty::AtomicOrdering,
failure_order: rustc_middle::ty::AtomicOrdering,
weak: bool,
) -> (&'ll Value, &'ll Value) {
let weak = if weak { llvm::True } else { llvm::False };
Expand All @@ -1334,7 +1334,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
op: rustc_codegen_ssa::common::AtomicRmwBinOp,
dst: &'ll Value,
mut src: &'ll Value,
order: rustc_codegen_ssa::common::AtomicOrdering,
order: rustc_middle::ty::AtomicOrdering,
) -> &'ll Value {
// The only RMW operation that LLVM supports on pointers is compare-exchange.
let requires_cast_to_int = self.val_ty(src) == self.type_ptr()
Expand All @@ -1360,7 +1360,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {

fn atomic_fence(
&mut self,
order: rustc_codegen_ssa::common::AtomicOrdering,
order: rustc_middle::ty::AtomicOrdering,
scope: SynchronizationScope,
) {
let single_threaded = match scope {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,14 +426,14 @@ pub(crate) enum AtomicOrdering {
}

impl AtomicOrdering {
pub(crate) fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
use rustc_codegen_ssa::common::AtomicOrdering as Common;
pub(crate) fn from_generic(ao: rustc_middle::ty::AtomicOrdering) -> Self {
use rustc_middle::ty::AtomicOrdering as Common;
match ao {
Common::Relaxed => Self::Monotonic,
Common::Acquire => Self::Acquire,
Common::Release => Self::Release,
Common::AcquireRelease => Self::AcquireRelease,
Common::SequentiallyConsistent => Self::SequentiallyConsistent,
Common::AcqRel => Self::AcquireRelease,
Common::SeqCst => Self::SequentiallyConsistent,
}
}
}
Expand Down
Loading
Loading