Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fa98c79

Browse files
committedFeb 26, 2025
Auto merge of #137649 - fmease:rollup-59lpxdh, r=fmease
Rollup of 13 pull requests Successful merges: - #136576 (pass optimization level to llvm-bitcode-linker) - #137320 (fix(rustdoc): Fixed stability version in rustdoc) - #137502 (Don't include global asm in `mir_keys`, fix error body synthesis) - #137529 (remove few unused args) - #137544 (tests: Add regression test for derive token invalidation (#81099)) - #137559 (run some tests on emscripten again) - #137601 (ssa/mono: deduplicate `type_has_metadata`) - #137603 (codegen_llvm: avoid `Deref` impls w/ extern type) - #137604 (trait_sel: resolve vars in host effects) - #137609 (Complete the list of resources used in rustdoc output) - #137613 (hir_analysis: skip self type of host effect preds in variances_of) - #137614 (fix doc in library/core/src/pin.rs) - #137622 (fix attribute-related ICE when parsing macro on the rhs of a name-value attribute) r? `@ghost` `@rustbot` modify labels: rollup
2 parents cb06d12 + 1b26ed6 commit fa98c79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+506
-116
lines changed
 

‎compiler/rustc_attr_parsing/src/context.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,10 @@ impl<'sess> AttributeParser<'sess> {
333333
{
334334
lit
335335
} else {
336-
let guar = self.dcx().has_errors().unwrap();
336+
let guar = self.dcx().span_delayed_bug(
337+
args.span().unwrap_or(DUMMY_SP),
338+
"expr in place where literal is expected (builtin attr parsing)",
339+
);
337340
ast::MetaItemLit {
338341
symbol: kw::Empty,
339342
suffix: None,

‎compiler/rustc_attr_parsing/src/parser.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_ast_pretty::pprust;
1313
use rustc_errors::DiagCtxtHandle;
1414
use rustc_hir::{self as hir, AttrPath};
1515
use rustc_span::symbol::{Ident, kw};
16-
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol};
16+
use rustc_span::{ErrorGuaranteed, Span, Symbol};
1717

1818
pub struct SegmentIterator<'a> {
1919
offset: usize,
@@ -127,7 +127,7 @@ impl<'a> ArgParser<'a> {
127127
}
128128
AttrArgs::Eq { eq_span, expr } => Self::NameValue(NameValueParser {
129129
eq_span: *eq_span,
130-
value: expr_to_lit(dcx, &expr),
130+
value: expr_to_lit(dcx, &expr, *eq_span),
131131
value_span: expr.span,
132132
}),
133133
}
@@ -348,16 +348,19 @@ impl NameValueParser {
348348
}
349349
}
350350

351-
fn expr_to_lit(dcx: DiagCtxtHandle<'_>, expr: &Expr) -> MetaItemLit {
351+
fn expr_to_lit(dcx: DiagCtxtHandle<'_>, expr: &Expr, span: Span) -> MetaItemLit {
352352
// In valid code the value always ends up as a single literal. Otherwise, a dummy
353353
// literal suffices because the error is handled elsewhere.
354354
if let ExprKind::Lit(token_lit) = expr.kind
355355
&& let Ok(lit) = MetaItemLit::from_token_lit(token_lit, expr.span)
356356
{
357357
lit
358358
} else {
359-
let guar = dcx.has_errors().unwrap();
360-
MetaItemLit { symbol: kw::Empty, suffix: None, kind: LitKind::Err(guar), span: DUMMY_SP }
359+
let guar = dcx.span_delayed_bug(
360+
span,
361+
"expr in place where literal is expected (builtin attr parsing)",
362+
);
363+
MetaItemLit { symbol: kw::Empty, suffix: None, kind: LitKind::Err(guar), span }
361364
}
362365
}
363366

0 commit comments

Comments
 (0)
Please sign in to comment.