Skip to content

E0267 is used twice in different struct_span_err calls #63712

Closed
@estebank

Description

@estebank

The following code

Closure => {
struct_span_err!(self.sess, span, E0267, "`{}` inside of a closure", name)
.span_label(span, "cannot break inside of a closure")
.emit();
}
AsyncClosure => {
struct_span_err!(self.sess, span, E0267, "`{}` inside of an async block", name)
.span_label(span, "cannot break inside of an async block")
.emit();
}

Should either assign a new error code to the AsyncClosure case, or move the common code to a closure and call it from those two branches to avoid using the same error code twice:

warning: diagnostic code E0267 already used
   --> <::syntax::diagnostics::macros::struct_span_err macros>:3:6
    |
1   | / ($ session : expr , $ span : expr , $ code : ident , $ ($ message : tt) *) =>
2   | | ({
3   | |      __diagnostic_used ! ($ code) ; $ session . struct_span_err_with_code
    | |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4   | |      ($ span , & format ! ($ ($ message) *) , $ crate :: errors ::
5   | |       DiagnosticId :: Error (stringify ! ($ code) . to_owned ()) ,)
6   | |  })
    | |___- in this expansion of `struct_span_err!`
    |
   ::: src/librustc_passes/loops.rs:181:17
    |
181 |                   struct_span_err!(self.sess, span, E0267, "`{}` inside of an async block", name)
    |                   ------------------------------------------------------------------------------- in this macro invocation
    |
note: previous invocation
   --> <::syntax::diagnostics::macros::struct_span_err macros>:3:6
    |
1   | / ($ session : expr , $ span : expr , $ code : ident , $ ($ message : tt) *) =>
2   | | ({
3   | |      __diagnostic_used ! ($ code) ; $ session . struct_span_err_with_code
    | |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4   | |      ($ span , & format ! ($ ($ message) *) , $ crate :: errors ::
5   | |       DiagnosticId :: Error (stringify ! ($ code) . to_owned ()) ,)
6   | |  })
    | |___- in this expansion of `struct_span_err!`
    |
   ::: src/librustc_passes/loops.rs:176:17
    |
176 |                   struct_span_err!(self.sess, span, E0267, "`{}` inside of a closure", name)
    |                   -------------------------------------------------------------------------- in this macro invocation

This issue has been assigned to @u32i64 via this comment.

Metadata

Metadata

Assignees

Labels

C-cleanupCategory: PRs that clean code up or issues documenting cleanup.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions