@@ -147,6 +147,7 @@ impl ItemAttributes {
147
147
errors. handle ( self . validate_action_combinations ( item_ident, item_type) ) ;
148
148
errors. handle ( self . validate_action_order ( item_ident, item_type) ) ;
149
149
errors. handle ( self . validate_item_name ( item_ident, item_type) ) ;
150
+ errors. handle ( self . validate_changed_item_name ( item_type) ) ;
150
151
errors. handle ( self . validate_item_attributes ( item_attrs) ) ;
151
152
152
153
// TODO (@Techassi): Add hint if a field or variant is added in the
@@ -294,6 +295,34 @@ impl ItemAttributes {
294
295
}
295
296
Ok ( ( ) )
296
297
}
298
+
299
+ /// This associated function is called by the top-level validation function
300
+ /// and validates that parameters provided to the `changed` actions are
301
+ /// valid.
302
+ fn validate_changed_item_name ( & self , item_type : & ItemType ) -> Result < ( ) , Error > {
303
+ let prefix = match item_type {
304
+ ItemType :: Field => DEPRECATED_FIELD_PREFIX ,
305
+ ItemType :: Variant => DEPRECATED_VARIANT_PREFIX ,
306
+ } ;
307
+
308
+ let mut errors = Error :: accumulator ( ) ;
309
+
310
+ // This ensures that `from_name` doesn't include the deprecation prefix.
311
+ for change in & self . changes {
312
+ if let Some ( from_name) = change. from_name . as_ref ( ) {
313
+ if from_name. starts_with ( prefix) {
314
+ errors. push (
315
+ Error :: custom ( format ! (
316
+ "the previous {item_type} name must not start with the deprecation prefix"
317
+ ) )
318
+ . with_span ( & from_name. span ( ) ) ,
319
+ ) ;
320
+ }
321
+ }
322
+ }
323
+
324
+ errors. finish ( )
325
+ }
297
326
}
298
327
299
328
// TODO (@Techassi): Add validation for when default_fn is "" (empty path).
0 commit comments