Skip to content

Commit d03017b

Browse files
authored
Merge pull request #447 from rustcoreutils/updates
Updates
2 parents bf717fb + 95588a6 commit d03017b

Some content is hidden

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

56 files changed

+629
-503
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

awk/interpreter/io.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,13 @@ impl RecordReader for FileStream {
142142
}
143143
}
144144

145+
#[cfg(test)]
145146
pub struct StringRecordReader {
146147
string: String,
147148
index: usize,
148149
}
149150

151+
#[cfg(test)]
150152
impl<S: Into<String>> From<S> for StringRecordReader {
151153
fn from(value: S) -> Self {
152154
Self {
@@ -156,6 +158,7 @@ impl<S: Into<String>> From<S> for StringRecordReader {
156158
}
157159
}
158160

161+
#[cfg(test)]
159162
impl Iterator for StringRecordReader {
160163
type Item = ReadResult;
161164

@@ -170,6 +173,7 @@ impl Iterator for StringRecordReader {
170173
}
171174
}
172175

176+
#[cfg(test)]
173177
impl RecordReader for StringRecordReader {
174178
fn is_done(&self) -> bool {
175179
self.index == self.string.len()

awk/interpreter/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,9 +1022,9 @@ struct CallFrame<'i> {
10221022

10231023
/// # Invariants
10241024
/// - `sp` and `bp` are pointers into the same
1025-
/// contiguously allocated chunk of memory
1025+
/// contiguously allocated chunk of memory
10261026
/// - `stack_end` is one past the last valid pointer
1027-
/// of the allocated memory starting at `bp`
1027+
/// of the allocated memory starting at `bp`
10281028
/// - values in the range [`bp`, `sp`) can be accessed safely
10291029
struct Stack<'i, 's> {
10301030
current_function_name: Rc<str>,
@@ -1761,7 +1761,7 @@ impl Interpreter {
17611761
.pop()
17621762
// there are no active references to stack values at this point, so this is safe
17631763
.map(|sv| unsafe { sv.into_owned() })
1764-
.unwrap_or(AwkValue::uninitialized()),
1764+
.unwrap_or_default(),
17651765
))
17661766
}
17671767

awk/regex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl Regex {
8282

8383
/// Returns an iterator over all match locations in the string.
8484
/// Takes ownership of the CString.
85-
pub fn match_locations(&self, string: CString) -> MatchIter {
85+
pub fn match_locations(&self, string: CString) -> MatchIter<'_> {
8686
let s = string.into_string().unwrap_or_default();
8787
MatchIter {
8888
next_start: 0,

cc/arch/aarch64/codegen.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,9 @@ impl Aarch64CodeGen {
361361
// Need space for: fp/lr (16 bytes) + GP callee-saved + FP callee-saved + local vars + reg save area
362362
// Round up callee-saved counts to even for 16-byte alignment
363363
// Note: AAPCS64 only requires the lower 64 bits of V8-V15 to be preserved (d8-d15)
364-
let callee_saved_gp_pairs = (callee_saved.len() + 1) / 2;
364+
let callee_saved_gp_pairs = callee_saved.len().div_ceil(2);
365365
let callee_saved_gp_size = callee_saved_gp_pairs as i32 * 16;
366-
let callee_saved_fp_pairs = (callee_saved_fp.len() + 1) / 2;
366+
let callee_saved_fp_pairs = callee_saved_fp.len().div_ceil(2);
367367
let callee_saved_fp_size = callee_saved_fp_pairs as i32 * 16; // 8 bytes per d-reg, 16 per pair
368368
let callee_saved_size = callee_saved_gp_size + callee_saved_fp_size;
369369
let total_frame = 16 + callee_saved_size + stack_size + reg_save_area_size;
@@ -2264,7 +2264,7 @@ impl Aarch64CodeGen {
22642264
frame_size: i32,
22652265
) {
22662266
let struct_size = insn.size; // Size in bits
2267-
let num_qwords = (struct_size + 63) / 64;
2267+
let num_qwords = struct_size.div_ceil(64);
22682268

22692269
// Get source address (where the struct data is)
22702270
let value_loc = self.get_location(value);

cc/arch/x86_64/codegen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2696,7 +2696,7 @@ impl X86_64CodeGen {
26962696
/// The value is a symbol containing the source struct data
26972697
fn emit_struct_store(&mut self, insn: &Instruction, addr: PseudoId, value: PseudoId) {
26982698
let struct_size = insn.size; // Size in bits
2699-
let num_qwords = (struct_size + 63) / 64;
2699+
let num_qwords = struct_size.div_ceil(64);
27002700

27012701
// Get source address (where the struct data is)
27022702
let value_loc = self.get_location(value);

cc/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ fn process_file(
291291
let _ = std::fs::remove_file(&temp_asm);
292292

293293
if !status.success() {
294-
return Err(io::Error::new(io::ErrorKind::Other, "assembler failed"));
294+
return Err(io::Error::other("assembler failed"));
295295
}
296296

297297
if args.verbose {
@@ -314,7 +314,7 @@ fn process_file(
314314
let _ = std::fs::remove_file(&temp_asm);
315315

316316
if !status.success() {
317-
return Err(io::Error::new(io::ErrorKind::Other, "assembler failed"));
317+
return Err(io::Error::other("assembler failed"));
318318
}
319319

320320
// Link
@@ -325,7 +325,7 @@ fn process_file(
325325
let _ = std::fs::remove_file(&temp_obj);
326326

327327
if !status.success() {
328-
return Err(io::Error::new(io::ErrorKind::Other, "linker failed"));
328+
return Err(io::Error::other("linker failed"));
329329
}
330330

331331
if args.verbose {

cc/parse/ast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ pub struct FunctionDef {
711711

712712
/// An external declaration (top-level item)
713713
#[derive(Debug, Clone)]
714+
#[allow(clippy::large_enum_variant)]
714715
pub enum ExternalDecl {
715716
/// Function definition
716717
FunctionDef(FunctionDef),

cc/parse/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3564,7 +3564,7 @@ impl Parser<'_> {
35643564
// Build the type from the base type
35653565
let mut result_type_id = base_type_id;
35663566

3567-
if inner_type_id.is_some() {
3567+
if let Some(inner_tid) = inner_type_id {
35683568
// Grouped declarator: int (*p)[3] or void (*fp)(int)
35693569
// Arrays/functions in suffix apply to the base type first
35703570
// Then we substitute into the inner declarator
@@ -3612,7 +3612,7 @@ impl Parser<'_> {
36123612
// -> Pointer(Array(3, int))
36133613
// For void (*fp)(int): inner_decl is Pointer(Void), result_type is Function(void, [int])
36143614
// -> Pointer(Function(void, [int]))
3615-
result_type_id = self.substitute_base_type(inner_type_id.unwrap(), result_type_id);
3615+
result_type_id = self.substitute_base_type(inner_tid, result_type_id);
36163616
} else {
36173617
// Simple declarator: char *arr[3]
36183618
// Pointers bind tighter than arrays: *arr[3] = array of pointers

cc/symbol.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,6 @@ pub enum SymbolKind {
5656
Typedef,
5757
}
5858

59-
// ============================================================================
60-
// Storage Class
61-
// ============================================================================
62-
63-
/// Storage class for variables/functions
64-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
65-
pub enum StorageClass {
66-
#[default]
67-
None,
68-
}
69-
7059
// ============================================================================
7160
// Symbol
7261
// ============================================================================

0 commit comments

Comments
 (0)