Skip to content

Add AcceptContext::expect_key_value#155831

Draft
scrabsha wants to merge 1 commit intorust-lang:mainfrom
scrabsha:push-pqrumlqtlsyk
Draft

Add AcceptContext::expect_key_value#155831
scrabsha wants to merge 1 commit intorust-lang:mainfrom
scrabsha:push-pqrumlqtlsyk

Conversation

@scrabsha
Copy link
Copy Markdown
Contributor

@scrabsha scrabsha commented Apr 26, 2026

(I would like to do one more self-review, I'm not sure reading right now this is the best use of your time)

This PR adds AcceptContext::expect_name_value that takes any name-value-ish node and returns what's in it (it depends on the node). It follows the same style as AcceptContext::expect_list and AcceptContext::single.

As expect_name_value takes care of all the error emission, this allowed to remove any call to AttributeDiagnosticContext::expected_name_value from outside rustc_attr_parsing::context. The method now private. as_name_value is still used in places in which we want to emit our own error messages.

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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. labels Apr 26, 2026
Comment thread compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs Outdated
@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs Outdated
Comment thread compiler/rustc_attr_parsing/src/attributes/doc.rs Outdated
Comment thread compiler/rustc_attr_parsing/src/attributes/rustc_allocator.rs Outdated
Comment thread compiler/rustc_attr_parsing/src/context.rs
Comment thread compiler/rustc_attr_parsing/src/parser.rs
Comment thread compiler/rustc_attr_parsing/src/parser.rs Outdated
@scrabsha scrabsha force-pushed the push-pqrumlqtlsyk branch from 5c6f7cf to 27cefb8 Compare April 26, 2026 16:20
@rust-log-analyzer

This comment has been minimized.

@scrabsha scrabsha force-pushed the push-pqrumlqtlsyk branch from 27cefb8 to 1e7d852 Compare April 26, 2026 16:40
@rust-log-analyzer

This comment has been minimized.

@scrabsha scrabsha force-pushed the push-pqrumlqtlsyk branch from 1e7d852 to 601b48d Compare April 26, 2026 19:28
@rust-log-analyzer

This comment has been minimized.

@scrabsha scrabsha force-pushed the push-pqrumlqtlsyk branch from 601b48d to 8cc254b Compare April 27, 2026 11:04
@rust-log-analyzer

This comment has been minimized.

@scrabsha scrabsha force-pushed the push-pqrumlqtlsyk branch from 8cc254b to cf8ee27 Compare April 27, 2026 19:15
@scrabsha scrabsha force-pushed the push-pqrumlqtlsyk branch from cf8ee27 to c92e28d Compare April 27, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) 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.

3 participants