Skip to content

gccrs: Improve rust_debug formatting - #4783

Draft
powerboat9 wants to merge 2 commits into
Rust-GCC:masterfrom
powerboat9:simple-diag
Draft

gccrs: Improve rust_debug formatting#4783
powerboat9 wants to merge 2 commits into
Rust-GCC:masterfrom
powerboat9:simple-diag

Conversation

@powerboat9

Copy link
Copy Markdown
Collaborator

This allows rust_debug to use (an ad-hoc implementation of) gcc diagnostic formatting. To keep this patch as small as possible, proper fixes for -Wformat-diag are mostly left for future patches.

ChangeLog:

	* .github/glibcxx_ubuntu64b_log_expected_warnings: Add warnings.
	* .github/log_expected_warnings: Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
@powerboat9

Copy link
Copy Markdown
Collaborator Author

@philberty is this good to merge?

#include "rust-system.h"

// TODO: remove
#pragma GCC diagnostic ignored "-Wformat-diag"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

whats going on with all the #pragma GCC diagnostic ignored "-Wformat-diag"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

With the change from printf to GCC diagnostic formatting, GCC starts warning about diagnostic quality (excess punctuation, unquoted identifiers, etc).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i'm not sure what to review here whats the improvement maybe i cant see it with all the diff

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It switches from printf style formatting (no %qs, %<, %>, %m, %r, %R, etc) to our implementation of GCC diagnostic style formatting (backwards compatible and with support for %qs, %<, %>, and %m, but not everything supported by GCC's main diagnostics system) for debug printing. #4784 is a follow up that switches us over to using GCC diagnostic formatting proper.

This allows rust_debug to use (an ad-hoc implementation of) gcc
diagnostic formatting. To keep this patch as small as possible, proper
fixes for -Wformat-diag are mostly left for future patches.

gcc/rust/ChangeLog:

	* ast/rust-ast.cc: Ignore -Wformat-diag.
	* backend/rust-compile-base.cc: Likewise.
	* backend/rust-compile-expr.cc: Likewise.
	* backend/rust-compile-stmt.cc: Likewise.
	* backend/rust-mangle-v0.cc: Likewise.
	* checks/errors/borrowck/rust-bir-builder.h: Likewise.
	* checks/errors/borrowck/rust-bir-fact-collector.h: Likewise.
	* checks/errors/rust-hir-pattern-analysis.cc: Likewise.
	* expand/rust-cfg-strip.cc: Likewise.
	* expand/rust-macro-builtins-asm.cc: Likewise.
	* expand/rust-macro-builtins-log-debug.cc: Likewise.
	* hir/tree/rust-hir.cc: Likewise.
	* lex/rust-lex.cc: Likewise.
	* parse/rust-parse-impl-lexer.cc: Likewise.
	* parse/rust-parse-impl-macro.cc: Likewise.
	* resolve/rust-forever-stack.hxx: Likewise.
	* rust-diagnostics.cc (rust_debug_loc): Use expand_message.
	* rust-diagnostics.h (rust_debug_loc): Change formatting
	attribute.
	* rust-lang.cc (grs_langhook_parse_file): Change debug message.
	* rust-session-manager.cc: Ignore -Wformat-diag.
	* typecheck/rust-autoderef.cc: Likewise.
	* typecheck/rust-casts.cc: Likewise.
	* typecheck/rust-coercion.cc: Likewise.
	* typecheck/rust-hir-dot-operator.cc: Likewise.
	* typecheck/rust-hir-type-check-expr.cc: Likewise.
	* typecheck/rust-hir-type-check-path.cc: Likewise.
	* typecheck/rust-hir-type-check-type.cc: Likewise.
	* typecheck/rust-type-util.cc: Likewise.
	* typecheck/rust-tyty-bounds.cc: Likewise.
	* typecheck/rust-tyty-subst.cc: Likewise.
	* typecheck/rust-tyty-variance-analysis.cc: Likewise.
	* typecheck/rust-tyty.cc: Likewise.
	* typecheck/rust-unify.cc: Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
@powerboat9
powerboat9 marked this pull request as draft August 16, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants