Rust-GCC / Rust-GCC/gccrs

Invalid `extended_key_value_attribute` error

Open
#4,690 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

expansion name resolution parser
Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
19h 55m
Merged PRs (30d)
67

Description

The error happens too early in the pipeline, and things like doc_comment! { concat!("...", "...") } trigger the error:

        doc_comment! {
            concat!("The smallest value that can be represented by this integer type.
Use [`", stringify!($T), "::MIN", "`](../../std/primitive.", stringify!($T), ".html#associatedconstant.MIN) instead.

# Examples

// unescape this for the testcase, this is just so github doesn't mess up the rendering
\```rust
// deprecated way
let min = std::", stringify!($T), "::MIN;

// intended way
let min = ", stringify!($T), "::MIN;
\```
"),
            #[$attr]
            pub const MIN: $T = $T::MIN;
        }

The error is triggered when parsing, but does not take into account built-in macros that could expand to a string literal (such as concat!()). We need to delay the error emission to after expansion/early nameres

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing parsing of extended_key_value_attribute through expansion and early name resolution, focusing on built-in macros such as concat!. Reproduce the doc_comment! example, then verify that macros expanding to string literals no longer trigger the error prematurely while invalid attributes still produce an error after expansion.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.