@@ -336,30 +336,30 @@ diagnostic struct.
336336
337337### Argument sharing and isolation
338338
339- Subdiagnostics will add their own arguments,
340- i.e. some fields in their struct, into the subdiagnostic when rendering the message,
341- so that the parameters in the main diagnostic can be used.
339+ Subdiagnostics add their own arguments (i.e., certain fields in their structure) to the ` Diag ` structure before rendering the information.
340+ ` Diag ` structure also stores the arguments from the main diagnostic, so the subdiagnostic can also use the arguments from the main diagnostic.
341+
342342However, when a subdiagnostic is added to a main diagnostic by implementing ` #[derive(Subdiagnostic)] ` ,
343343the following rules, introduced in [ rust-lang/rust #142724 ] ( https://github.com/rust-lang/rust/pull/142724 )
344344apply to the handling of arguments (i.e., variables used in Fluent messages):
345345
346346** Argument isolation between sub diagnostics** :
347347Arguments set by a subdiagnostic are only available during the rendering of that subdiagnostic.
348- After the subdiagnostic is rendered, all arguments it introduced are restore from the main diagnostic.
348+ After the subdiagnostic is rendered, all arguments it introduced are restored from the main diagnostic.
349349This ensures that multiple subdiagnostics do not pollute each other's argument scope.
350- For example, when using a ` Vec<Subdiag> ` , it iteratively add the same arg over and over again.
350+ For example, when using a ` Vec<Subdiag> ` , it iteratively adds the same argument over and over again.
351351
352352** Same argument override between sub and main diagnostics** :
353- If a subdiagnostic sets a argument with the same name as a arg already in the master diagnostic,
353+ If a subdiagnostic sets a argument with the same name as a arguments already in the main diagnostic,
354354it will report an error at runtime unless both have exactly the same value.
355- This
356- - preserves the flexibility that can that * arguments is allowed to appear in the attributes of the subdiagnostic.
357- For example, There is a attribute ` #[suggestion(code = "{new_vis}")] ` in sub-diagnostic , but ` new_vis ` is the field in main diagnostic struct.
358- - prevents accidental overwriting or deletion of parameters required by the main diagnostic or other sub-diagnostics .
355+ It has two benefits:
356+ - preserves the flexibility that arguments in the main diagnostic are allowed to appear in the attributes of the subdiagnostic.
357+ For example, There is an attribute ` #[suggestion(code = "{new_vis}")] ` in the subdiagnostic , but ` new_vis ` is the field in the main diagnostic struct.
358+ - prevents accidental overwriting or deletion of arguments required by the main diagnostic or other subdiagnostics .
359359
360360These rules guarantee that arguments injected by subdiagnostics are strictly scoped to their own rendering.
361361The main diagnostic's arguments remain unaffected by subdiagnostic logic, even in the presence of name collisions.
362- Additionally, subdiagnostics can access parameters from the main diagnostic with the same name when needed.
362+ Additionally, subdiagnostics can access arguments from the main diagnostic with the same name when needed.
363363
364364### Reference for ` #[derive(Subdiagnostic)] `
365365` #[derive(Subdiagnostic)] ` supports the following attributes:
0 commit comments