Skip to content

Commit 4f83a42

Browse files
authored
Merge pull request #652 from rust-lang/sync_from_rust_2025_04_25_2
Sync from rust 2025/04/25
2 parents db1a31c + 9059f8c commit 4f83a42

File tree

12 files changed

+68
-64
lines changed

12 files changed

+68
-64
lines changed

example/example.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![feature(no_core, unboxed_closures)]
22
#![no_core]
3-
#![allow(dead_code)]
3+
#![allow(dead_code, unnecessary_transmutes)]
44

55
extern crate mini_core;
66

@@ -11,11 +11,7 @@ fn abc(a: u8) -> u8 {
1111
}
1212

1313
fn bcd(b: bool, a: u8) -> u8 {
14-
if b {
15-
a * 2
16-
} else {
17-
a * 3
18-
}
14+
if b { a * 2 } else { a * 3 }
1915
}
2016

2117
fn call() {

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2025-04-17"
2+
channel = "nightly-2025-04-25"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

src/asm.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
165165
let mut input_registers = vec![];
166166

167167
for op in rust_operands {
168-
if let InlineAsmOperandRef::In { reg, .. } = *op {
169-
if let ConstraintOrRegister::Register(reg_name) = reg_to_gcc(reg) {
170-
input_registers.push(reg_name);
171-
}
168+
if let InlineAsmOperandRef::In { reg, .. } = *op
169+
&& let ConstraintOrRegister::Register(reg_name) = reg_to_gcc(reg)
170+
{
171+
input_registers.push(reg_name);
172172
}
173173
}
174174

src/common.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
3333
}
3434

3535
pub fn const_bitcast(&self, value: RValue<'gcc>, typ: Type<'gcc>) -> RValue<'gcc> {
36-
if value.get_type() == self.bool_type.make_pointer() {
37-
if let Some(pointee) = typ.get_pointee() {
38-
if pointee.dyncast_vector().is_some() {
39-
panic!()
40-
}
41-
}
36+
if value.get_type() == self.bool_type.make_pointer()
37+
&& let Some(pointee) = typ.get_pointee()
38+
&& pointee.dyncast_vector().is_some()
39+
{
40+
panic!()
4241
}
4342
// NOTE: since bitcast makes a value non-constant, don't bitcast if not necessary as some
4443
// SIMD builtins require a constant value.

src/consts.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,10 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
242242
let fn_attrs = self.tcx.codegen_fn_attrs(def_id);
243243

244244
let global = if def_id.is_local() && !self.tcx.is_foreign_item(def_id) {
245-
if let Some(global) = self.get_declared_value(sym) {
246-
if self.val_ty(global) != self.type_ptr_to(gcc_type) {
247-
span_bug!(self.tcx.def_span(def_id), "Conflicting types for static");
248-
}
245+
if let Some(global) = self.get_declared_value(sym)
246+
&& self.val_ty(global) != self.type_ptr_to(gcc_type)
247+
{
248+
span_bug!(self.tcx.def_span(def_id), "Conflicting types for static");
249249
}
250250

251251
let is_tls = fn_attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL);

src/debuginfo.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,15 @@ fn make_mir_scope<'gcc, 'tcx>(
126126
return;
127127
};
128128

129-
if let Some(ref vars) = *variables {
130-
if !vars.contains(scope) && scope_data.inlined.is_none() {
131-
// Do not create a DIScope if there are no variables defined in this
132-
// MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat.
133-
debug_context.scopes[scope] = parent_scope;
134-
instantiated.insert(scope);
135-
return;
136-
}
129+
if let Some(ref vars) = *variables
130+
&& !vars.contains(scope)
131+
&& scope_data.inlined.is_none()
132+
{
133+
// Do not create a DIScope if there are no variables defined in this
134+
// MIR `SourceScope`, and it's not `inlined`, to avoid debuginfo bloat.
135+
debug_context.scopes[scope] = parent_scope;
136+
instantiated.insert(scope);
137+
return;
137138
}
138139

139140
let loc = cx.lookup_debug_loc(scope_data.span.lo());

src/gcc_util.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,12 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
136136
});
137137
features.extend(feats);
138138

139-
if diagnostics {
140-
if let Some(f) = check_tied_features(sess, &featsmap) {
141-
sess.dcx().emit_err(TargetFeatureDisableOrEnable {
142-
features: f,
143-
span: None,
144-
missing_features: None,
145-
});
146-
}
139+
if diagnostics && let Some(f) = check_tied_features(sess, &featsmap) {
140+
sess.dcx().emit_err(TargetFeatureDisableOrEnable {
141+
features: f,
142+
span: None,
143+
missing_features: None,
144+
});
147145
}
148146

149147
features

src/intrinsic/simd.rs

+11-14
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,14 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
447447
m_len == v_len,
448448
InvalidMonomorphization::MismatchedLengths { span, name, m_len, v_len }
449449
);
450+
// TODO: also support unsigned integers.
450451
match *m_elem_ty.kind() {
451452
ty::Int(_) => {}
452-
_ => return_error!(InvalidMonomorphization::MaskType { span, name, ty: m_elem_ty }),
453+
_ => return_error!(InvalidMonomorphization::MaskWrongElementType {
454+
span,
455+
name,
456+
ty: m_elem_ty
457+
}),
453458
}
454459
return Ok(bx.vector_select(args[0].immediate(), args[1].immediate(), args[2].immediate()));
455460
}
@@ -991,19 +996,15 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
991996
assert_eq!(pointer_count - 1, ptr_count(element_ty0));
992997
assert_eq!(underlying_ty, non_ptr(element_ty0));
993998

994-
// The element type of the third argument must be a signed integer type of any width:
999+
// The element type of the third argument must be an integer type of any width:
1000+
// TODO: also support unsigned integers.
9951001
let (_, element_ty2) = arg_tys[2].simd_size_and_type(bx.tcx());
9961002
match *element_ty2.kind() {
9971003
ty::Int(_) => (),
9981004
_ => {
9991005
require!(
10001006
false,
1001-
InvalidMonomorphization::ThirdArgElementType {
1002-
span,
1003-
name,
1004-
expected_element: element_ty2,
1005-
third_arg: arg_tys[2]
1006-
}
1007+
InvalidMonomorphization::MaskWrongElementType { span, name, ty: element_ty2 }
10071008
);
10081009
}
10091010
}
@@ -1109,17 +1110,13 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
11091110
assert_eq!(underlying_ty, non_ptr(element_ty0));
11101111

11111112
// The element type of the third argument must be a signed integer type of any width:
1113+
// TODO: also support unsigned integers.
11121114
match *element_ty2.kind() {
11131115
ty::Int(_) => (),
11141116
_ => {
11151117
require!(
11161118
false,
1117-
InvalidMonomorphization::ThirdArgElementType {
1118-
span,
1119-
name,
1120-
expected_element: element_ty2,
1121-
third_arg: arg_tys[2]
1122-
}
1119+
InvalidMonomorphization::MaskWrongElementType { span, name, ty: element_ty2 }
11231120
);
11241121
}
11251122
}

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#![warn(rust_2018_idioms)]
2323
#![warn(unused_lifetimes)]
2424
#![deny(clippy::pattern_type_mismatch)]
25-
#![allow(clippy::needless_lifetimes)]
25+
#![allow(clippy::needless_lifetimes, clippy::uninlined_format_args)]
2626

2727
// Some "regular" crates we want to share with rustc
2828
extern crate object;

src/type_of.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ fn uncached_gcc_type<'gcc, 'tcx>(
102102
let mut name = with_no_trimmed_paths!(layout.ty.to_string());
103103
if let (&ty::Adt(def, _), &Variants::Single { index }) =
104104
(layout.ty.kind(), &layout.variants)
105+
&& def.is_enum()
106+
&& !def.variants().is_empty()
105107
{
106-
if def.is_enum() && !def.variants().is_empty() {
107-
write!(&mut name, "::{}", def.variant(index).name).unwrap();
108-
}
108+
write!(&mut name, "::{}", def.variant(index).name).unwrap();
109109
}
110110
if let (&ty::Coroutine(_, _), &Variants::Single { index }) =
111111
(layout.ty.kind(), &layout.variants)
@@ -264,10 +264,10 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
264264
}
265265

266266
fn immediate_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> {
267-
if let BackendRepr::Scalar(ref scalar) = self.backend_repr {
268-
if scalar.is_bool() {
269-
return cx.type_i1();
270-
}
267+
if let BackendRepr::Scalar(ref scalar) = self.backend_repr
268+
&& scalar.is_bool()
269+
{
270+
return cx.type_i1();
271271
}
272272
self.gcc_type(cx)
273273
}

tests/lang_tests_common.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! The common code for `tests/lang_tests_*.rs`
22
3+
#![allow(clippy::uninlined_format_args)]
4+
35
use std::env::{self, current_dir};
46
use std::path::{Path, PathBuf};
57
use std::process::Command;

tests/run/ptr_cast.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
//
33
// Run-time:
44
// status: 0
5-
// stdout: 1
5+
// stdout: 10
6+
// 10
7+
// 42
8+
// 1
69

710
#![feature(no_core)]
811
#![no_std]
@@ -12,15 +15,23 @@
1215
extern crate mini_core;
1316
use mini_core::*;
1417

15-
static mut ONE: usize = 1;
16-
17-
fn make_array() -> [u8; 3] {
18-
[42, 10, 5]
18+
fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) {
19+
(
20+
a as u8, a as u16, a as u32, a as usize, a as i8, a as i16, a as i32, a as isize, b as u8,
21+
b as u32,
22+
)
1923
}
2024

25+
static mut ONE: usize = 1;
26+
2127
#[no_mangle]
2228
extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 {
29+
let (a, b, c, d, e, f, g, h, i, j) = int_cast(10, 42);
2330
unsafe {
31+
libc::printf(b"%d\n\0" as *const u8 as *const i8, c);
32+
libc::printf(b"%ld\n\0" as *const u8 as *const i8, d);
33+
libc::printf(b"%ld\n\0" as *const u8 as *const i8, j);
34+
2435
let ptr = ONE as *mut usize;
2536
let value = ptr as usize;
2637
libc::printf(b"%ld\n\0" as *const u8 as *const i8, value);

0 commit comments

Comments
 (0)