Rust-GCC / Rust-GCC/gccrs

`include_str` does not output an error when the file is missing

Open
#2,252 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug good-first-pr
Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
19h 55m
Merged PRs (30d)
67

Description

I tried this code:

#![feature(rustc_attrs)]

#[rustc_builtin_macro]
macro_rules! include_str {
    () => {{}};
}

macro_rules! file1 {
    () => {
        "missing_file.in"
    };
}

fn main() {
    include_str!(file1!(),); 
}

(note the trailing comma in the include_str macro invocation)

I expected to see this happen: Gccrs output an error message such like rustc.

error: couldn't read missing_file.in: No such file or directory (os error 2)

Instead, this happened: explanation

No error, simply expand the macro to an empty fragment.

Meta
  • fb1259001c2

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 running the supplied Rust reproduction with gccrs and compare its behavior with rustc. Trace the include_str builtin macro expansion, especially the trailing-comma case and missing-file handling; done means gccrs emits a diagnostic for missing_file.in rather than expanding to an empty fragment.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.