Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtin_macros: Migrate diagnostic #101935

Closed

Conversation

wonchulee
Copy link
Contributor

  • Migrate the rustc_biltin_macros crate's diagnostic to translatable diagnostic structs.

@rust-highfive
Copy link
Collaborator

r? @compiler-errors

(rust-highfive has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 17, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 17, 2022
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking rustc_middle v0.0.0 (/checkout/compiler/rustc_middle)
    Checking rustc_ast_passes v0.0.0 (/checkout/compiler/rustc_ast_passes)
    Checking rustc_expand v0.0.0 (/checkout/compiler/rustc_expand)
    Checking rustc_builtin_macros v0.0.0 (/checkout/compiler/rustc_builtin_macros)
error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
486 |                         let mut err = self.ecx.struct_span_err(
    |                                                ^^^^^^^^^^^^^^^
    |
    |
note: the lint level is defined here
   --> compiler/rustc_builtin_macros/src/lib.rs:17:9
    |
17  | #![deny(rustc::diagnostic_outside_of_impl)]


error: diagnostics should be created using translatable messages
    |
486 |                         let mut err = self.ecx.struct_span_err(
    |                                                ^^^^^^^^^^^^^^^
    |
    |
note: the lint level is defined here
   --> compiler/rustc_builtin_macros/src/lib.rs:16:9
    |
16  | #![deny(rustc::untranslatable_diagnostic)]


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
593 |             e = self.ecx.struct_span_err(


error: diagnostics should be created using translatable messages
    |
    |
593 |             e = self.ecx.struct_span_err(


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
625 |             e = self.ecx.struct_span_err(


error: diagnostics should be created using translatable messages
    |
    |
625 |             e = self.ecx.struct_span_err(


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
782 | ...                   let mut err = self.ecx.struct_span_err(sp, &msg);


error: diagnostics should be created using translatable messages
    |
    |
782 | ...                   let mut err = self.ecx.struct_span_err(sp, &msg);


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
     |
     |
1282 |         let mut e = ecx.struct_span_err(sp, &format!("invalid format string: {}", err.description));


error: diagnostics should be created using translatable messages
     |
     |
1282 |         let mut e = ecx.struct_span_err(sp, &format!("invalid format string: {}", err.description));


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
     |
     |
1408 |                 let mut diag = cx.ecx.struct_span_err(*sp, *msg);


error: diagnostics should be created using translatable messages
     |
     |
1408 |                 let mut diag = cx.ecx.struct_span_err(*sp, *msg);


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
     |
     |
1412 |                 let mut diag = cx.ecx.struct_span_err(


error: diagnostics should be created using translatable messages
     |
     |
1412 |                 let mut diag = cx.ecx.struct_span_err(


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
   |
   |
24 |         ecx.sess.parse_sess.span_diagnostic.span_err(item.span(), "allocators must be statics");


error: diagnostics should be created using translatable messages
   |
   |
24 |         ecx.sess.parse_sess.span_diagnostic.span_err(item.span(), "allocators must be statics");


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
   --> compiler/rustc_builtin_macros/src/source_util.rs:153:36
    |
153 | ...                   self.p.struct_span_err(self.p.token.span, &msg).emit();


error: diagnostics should be created using translatable messages
   --> compiler/rustc_builtin_macros/src/source_util.rs:153:36
    |
153 | ...                   self.p.struct_span_err(self.p.token.span, &msg).emit();


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
   --> compiler/rustc_builtin_macros/src/source_util.rs:191:20
    |
191 |                 cx.span_err(sp, &format!("{} wasn't a utf-8 file", file.display()));


error: diagnostics should be created using translatable messages
   --> compiler/rustc_builtin_macros/src/source_util.rs:191:20
    |
191 |                 cx.span_err(sp, &format!("{} wasn't a utf-8 file", file.display()));


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
   --> compiler/rustc_builtin_macros/src/source_util.rs:196:16
    |
196 |             cx.span_err(sp, &format!("couldn't read {}: {}", file.display(), e));


error: diagnostics should be created using translatable messages
   --> compiler/rustc_builtin_macros/src/source_util.rs:196:16
    |
196 |             cx.span_err(sp, &format!("couldn't read {}: {}", file.display(), e));


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
   --> compiler/rustc_builtin_macros/src/source_util.rs:221:16
    |
221 |             cx.span_err(sp, &format!("couldn't read {}: {}", file.display(), e));


error: diagnostics should be created using translatable messages
   --> compiler/rustc_builtin_macros/src/source_util.rs:221:16
    |
221 |             cx.span_err(sp, &format!("couldn't read {}: {}", file.display(), e));


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
   |
96 |             cx.struct_span_err(
   |                ^^^^^^^^^^^^^^^


error: diagnostics should be created using translatable messages
   |
96 |             cx.struct_span_err(
   |                ^^^^^^^^^^^^^^^


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
112 |             ast::ItemKind::MacCall(_) => diag.struct_span_warn(attr_sp, msg),


error: diagnostics should be created using translatable messages
    |
    |
112 |             ast::ItemKind::MacCall(_) => diag.struct_span_warn(attr_sp, msg),


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
116 |             _ => diag.struct_span_err(attr_sp, msg).forget_guarantee(),


error: diagnostics should be created using translatable messages
    |
    |
116 |             _ => diag.struct_span_err(attr_sp, msg).forget_guarantee(),


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
407 |                         sd.struct_span_warn(
    |                            ^^^^^^^^^^^^^^^^


error: diagnostics should be created using translatable messages
    |
407 |                         sd.struct_span_warn(
    |                            ^^^^^^^^^^^^^^^^


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
464 |             sd.struct_span_err(i.span, "unsafe functions cannot be used for tests")


error: diagnostics should be created using translatable messages
    |
    |
464 |             sd.struct_span_err(i.span, "unsafe functions cannot be used for tests")


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
470 |             sd.struct_span_err(i.span, "async functions cannot be used for tests")


error: diagnostics should be created using translatable messages
    |
    |
470 |             sd.struct_span_err(i.span, "async functions cannot be used for tests")


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
485 |             sd.span_err(i.span, "functions used as tests can not have any arguments");


error: diagnostics should be created using translatable messages
    |
    |
485 |             sd.span_err(i.span, "functions used as tests can not have any arguments");


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
491 |                 sd.span_err(i.span, "functions using `#[should_panic]` must return `()`");


error: diagnostics should be created using translatable messages
    |
    |
491 |                 sd.span_err(i.span, "functions using `#[should_panic]` must return `()`");


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
496 |                     sd.span_err(i.span, "functions used as tests must have signature fn() -> ()");


error: diagnostics should be created using translatable messages
    |
    |
496 |                     sd.span_err(i.span, "functions used as tests must have signature fn() -> ()");


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
520 |         cx.sess.parse_sess.span_diagnostic.span_err(


error: diagnostics should be created using translatable messages
    |
    |
520 |         cx.sess.parse_sess.span_diagnostic.span_err(


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
   |
   |
23 |         cx.span_err(sp, "trace_macros! accepts only `true` or `false`")


error: diagnostics should be created using translatable messages
   |
   |
23 |         cx.span_err(sp, "trace_macros! accepts only `true` or `false`")


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
592 |             let mut e = ecx.struct_span_err(err_sp, msg);


error: diagnostics should be created using translatable messages
    |
    |
592 |             let mut e = ecx.struct_span_err(err_sp, msg);


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
626 | ...                   let mut err = ecx.struct_span_err(span, &msg);


error: diagnostics should be created using translatable messages
    |
    |
626 | ...                   let mut err = ecx.struct_span_err(span, &msg);


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
738 |             let mut err = ecx.struct_span_err(sp, msg);


error: diagnostics should be created using translatable messages
    |
    |
738 |             let mut err = ecx.struct_span_err(sp, msg);


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
748 |             let mut err = ecx.struct_span_err(
    |                               ^^^^^^^^^^^^^^^


error: diagnostics should be created using translatable messages
    |
748 |             let mut err = ecx.struct_span_err(
    |                               ^^^^^^^^^^^^^^^


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
  --> compiler/rustc_builtin_macros/src/cmdline_attrs.rs:27:40
   |
27 |             parse_sess.span_diagnostic.span_err(start_span.to(end_span), "invalid crate attribute");


error: diagnostics should be created using translatable messages
  --> compiler/rustc_builtin_macros/src/cmdline_attrs.rs:27:40
   |
27 |             parse_sess.span_diagnostic.span_err(start_span.to(end_span), "invalid crate attribute");


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
   |
   |
91 |             self.handler.span_err(


error: diagnostics should be created using translatable messages
   |
   |
91 |             self.handler.span_err(


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
120 |             self.handler.span_err(self.source_map.guess_head_span(item.span), msg);


error: diagnostics should be created using translatable messages
    |
    |
120 |             self.handler.span_err(self.source_map.guess_head_span(item.span), msg);


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
138 |             self.handler.span_err(self.source_map.guess_head_span(item.span), msg);


error: diagnostics should be created using translatable messages
    |
    |
138 |             self.handler.span_err(self.source_map.guess_head_span(item.span), msg);


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
156 |             self.handler.span_err(self.source_map.guess_head_span(item.span), msg);


error: diagnostics should be created using translatable messages
    |
    |
156 |             self.handler.span_err(self.source_map.guess_head_span(item.span), msg);


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
167 |                 self.handler.span_err(self.source_map.guess_head_span(item.span), msg);


error: diagnostics should be created using translatable messages
    |
    |
167 |                 self.handler.span_err(self.source_map.guess_head_span(item.span), msg);


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
202 |                         .struct_span_err(attr.span, &msg)


error: diagnostics should be created using translatable messages
    |
    |
202 |                         .struct_span_err(attr.span, &msg)


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
227 |             self.handler.span_err(attr.span, &msg);


error: diagnostics should be created using translatable messages
    |
    |
227 |             self.handler.span_err(attr.span, &msg);


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
241 |             self.handler.span_err(attr.span, &msg);


error: diagnostics should be created using translatable messages
    |
    |
241 |             self.handler.span_err(attr.span, &msg);


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
387 |                 sd.struct_span_err(span, "`test_runner` argument must be a path").emit();


error: diagnostics should be created using translatable messages
    |
    |
387 |                 sd.struct_span_err(span, "`test_runner` argument must be a path").emit();


error: diagnostics should only be created in `SessionDiagnostic`/`AddSubdiagnostic` impls
    |
    |
391 |             sd.struct_span_err(span, "`#![test_runner(..)]` accepts exactly 1 argument").emit();


error: diagnostics should be created using translatable messages
    |
    |
391 |             sd.struct_span_err(span, "`#![test_runner(..)]` accepts exactly 1 argument").emit();

error: could not compile `rustc_builtin_macros` due to 76 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `rustc_builtin_macros` due to 76 previous errors

@bors
Copy link
Contributor

bors commented Sep 28, 2022

☔ The latest upstream changes (presumably #100996) made this pull request unmergeable. Please resolve the merge conflicts.

@compiler-errors
Copy link
Member

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 5, 2022
@Nilstrieb
Copy link
Member

Hi, I've seen you changed some diagnostic structs in your PR. After #103345, the way we refer to fluent messages changed. They are now in a flat namespace with the same identifier as in the fluent file. For example, parser::cool_thing is now parser_cool_thing and parser::suggestion just suggestion.
You should rebase to the latest master and change your fluent message references as described above. Thanks!

Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay in reviewing this, this is a great start - I assume from the CI failures that there are some diagnostics still to migrate.

#[primary_span]
#[label]
pub(crate) span: Span,
// FIXME: This should be a `tool_only_span_suggestion`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we've got support for this now after #103575.

WrappingNumberInArray { span: Span, snippet: String },
}

impl AddSubdiagnostic for Snippet {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that you can use the derive for this.

@Dylan-DPC
Copy link
Member

@wonchulee any updates on this?

@wonchulee
Copy link
Contributor Author

@wonchulee any updates on this?

Hello, This is still a work in progress, and as I mentioned in #100717, I don't have enough time to finish it these days. If someone would like to take it on, that would be great. I'll try to keep going as long as I can until then.

@jyn514
Copy link
Member

jyn514 commented Apr 27, 2023

Hi @wonchulee, I'm going to close this since you're not sure when you'll have time to work on it. Thank you for the effort you've put in already, and feel free to pick up the work later if you have more time :) (although do be aware that #110092 migrated a lot of the diagnostics in the meantime, so it might make sense to pick a crate other than rustc_builtin_macros).

@jyn514 jyn514 closed this Apr 27, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 4, 2024
…, r=davidtwco

Migrate some rustc_builtin_macros to SessionDiagnostic

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->

Part of rust-lang#100717.
pick up abandoned pr: rust-lang#101935
`@rustbot` label +A-translation
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jul 4, 2024
Rollup merge of rust-lang#126405 - He1pa:translate_builtin_macro_diag, r=davidtwco

Migrate some rustc_builtin_macros to SessionDiagnostic

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->

Part of rust-lang#100717.
pick up abandoned pr: rust-lang#101935
`@rustbot` label +A-translation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-translation Area: Translation infrastructure, and migrating existing diagnostics to SessionDiagnostic S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet