Skip to content

c2rust-refactor moves derive attributes #1426

@fw-immunant

Description

@fw-immunant

Given this input file, "derive.rs":

#![allow(
    dead_code,
    non_camel_case_types,
    non_snake_case,
    non_upper_case_globals,
    unused_assignments,
    unused_mut
)]

#[derive(Copy, Clone)]
#[repr(C)]
pub struct S {}

running c2rust-refactor --rewrite-mode diff remove_unused_labels -- derive.rs produces:


--- old/derive.rs
+++ new/derive.rs
@@ -7,7 +7,7 @@
     unused_mut
 )]

-#[derive(Copy, Clone)]
-#[repr(C)]
+
+#[repr(C)]#[derive(Copy, Clone)]
 pub struct S {}

This appears to be an issue with roundtripping attributes, as it also occurs with various other transforms that aren't supposed to modify attributes, such as test_one_plus_one. This adds lots of noise to the diffs generated and makes it harder to identify what transforms are actually intending to change.

This change appears to only occur if the derive attribute precedes the repr one.

Metadata

Metadata

Assignees

Labels

refactorerThis issue relates to the refactoring tool

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions