Skip to content

add test to reproduce #137687 and add a hotfix #140584

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_ast_pretty::pprust;
use rustc_errors::DiagCtxtHandle;
use rustc_hir::{self as hir, AttrPath};
use rustc_span::symbol::{Ident, kw, sym};
use rustc_span::{ErrorGuaranteed, Span, Symbol};
use rustc_span::{Span, Symbol};

pub struct SegmentIterator<'a> {
offset: usize,
Expand Down Expand Up @@ -176,7 +176,7 @@ impl<'a> ArgParser<'a> {
pub enum MetaItemOrLitParser<'a> {
MetaItemParser(MetaItemParser<'a>),
Lit(MetaItemLit),
Err(Span, ErrorGuaranteed),
Err(Span),
Copy link
Member

Choose a reason for hiding this comment

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

Is MetaItemOrLitParser::Err no longer constructed on master?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this may be true, actually! lets see

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think @nnethercote 's recent work did that

Copy link
Member

@fmease fmease May 2, 2025

Choose a reason for hiding this comment

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

Uh, right. It was 'unintentionally' fixed in #124141 which is part of 1.88 and since we need a hotfix for 1.87 (current beta) and certainly don't want to backport #124141, we'd need a PR targeting the beta branch. Lemme think.

Copy link
Member

Choose a reason for hiding this comment

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

we'd need a PR targeting the beta branch

Opened #140601.

}

impl<'a> MetaItemOrLitParser<'a> {
Expand All @@ -186,7 +186,7 @@ impl<'a> MetaItemOrLitParser<'a> {
generic_meta_item_parser.span()
}
MetaItemOrLitParser::Lit(meta_item_lit) => meta_item_lit.span,
MetaItemOrLitParser::Err(span, _) => *span,
MetaItemOrLitParser::Err(span) => *span,
}
}

Expand Down
8 changes: 8 additions & 0 deletions tests/ui/attributes/auxiliary/bar_derive.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extern crate proc_macro;

use proc_macro::TokenStream;

#[proc_macro_derive(Bar, attributes(arg))]
pub fn derive_bar(_: proc_macro::TokenStream) -> proc_macro::TokenStream {
TokenStream::new()
}
12 changes: 12 additions & 0 deletions tests/ui/attributes/crate_name_on_other_items.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@compile-flags: --crate-type=lib
// reproduces #137687
// FIXME(jdonszelmann): should ERROR malformed `crate_name` attribute input but now still ignored.
// This is for the beta backport of 1.87
#[crate_name = concat!("Cloneb")]

macro_rules! inline {
() => {};
}

#[crate_name] //~ ERROR malformed `crate_name` attribute input
Copy link
Member

@fmease fmease May 2, 2025

Choose a reason for hiding this comment

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

Oh yeah, this test case should definitely not reside in the same file as the one above as it masks the delayed_span_bug! If you remove the one below, the one above still ICEs on master: In compiler/rustc_attr_parsing/src/context.rs:337:43

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ugh, alright ty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will fix

Copy link
Member

@fmease fmease May 2, 2025

Choose a reason for hiding this comment

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

Just to be clear because it's getting slightly complicated ^^', you can either hotfix this issue (#137687) in this PR as you said you might and then we can beta-nominate it or we just ignore the ICE hitting stable (because it's fuzzer-generated and might not affect real users but who knows) and wait for "that lint buffering PR" to get merged which would unblock your real fix in #137729. 🤷

mod foo {}
8 changes: 8 additions & 0 deletions tests/ui/attributes/crate_name_on_other_items.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: malformed `crate_name` attribute input
--> $DIR/crate_name_on_other_items.rs:11:1
|
LL | #[crate_name]
| ^^^^^^^^^^^^^ help: must be of the form: `#[crate_name = "name"]`

error: aborting due to 1 previous error

17 changes: 17 additions & 0 deletions tests/ui/attributes/proc_macro_in_macro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//@ proc-macro: bar_derive.rs
//@ check-pass

extern crate bar_derive;
use bar_derive as bar;

macro_rules! call_macro {
($text:expr) => {
#[derive(bar::Bar)]
#[arg($text)]
pub struct Foo;
};
}

call_macro!(1 + 1);

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@check-pass
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
//@check-pass
// FIXME: This should fail.
//@ known-bug: rust-lang/rust#NNN
//@ check-pass

with NNN being the relavant issue or //@ known-bug: unknown otherwise.

//@ compile-flags: --print=file-names

#[crate_name = concat!("wrapped")]

macro_rules! inline {
() => {};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print-file-names-request-malformed-crate-name-3
Loading