Skip to content

Rollup of 8 pull requests #145317

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

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7af87d1
editorconfig: don't trim trailing whitespace in tests
lolbinarycat Jul 29, 2025
378dd7c
Add regression test for former ICE involving malformed meta items con…
fmease Aug 11, 2025
c1a31d8
Deprecate RUST_TEST_* env variables
epage Aug 11, 2025
e854013
Port `#[custom_mir(..)]` to the new attribute system
scrabsha Aug 10, 2025
db1a64c
simplify stack handling, be completely lazy
lcnr Aug 5, 2025
bd44d85
Link to payload_as_str() from payload().
m-ou-se Aug 12, 2025
0d72323
chore(ci): upgrade checkout to v5
rejected-l Aug 12, 2025
0b855bc
Switch to a bitflags `MacroKinds` to support macros with more than on…
joshtriplett Aug 8, 2025
d7b30be
Expand documentation of `GlobDelegation`
joshtriplett Aug 9, 2025
c81fcac
Only suggest changing `#[derive(mymacro)]` to `#[mymacro]` for attrib…
joshtriplett Aug 9, 2025
ba231db
Detect and report macro kind mismatches early, and more precisely
joshtriplett Aug 9, 2025
b74e1cb
mbe: Rename macro parsing state names to use `Bang` instead of `Not`
joshtriplett Aug 9, 2025
33ba4a2
clippy: Update for switch to `MacroKinds`
joshtriplett Aug 9, 2025
e1fc89a
rustdoc: Minimal fixes to compile with `MacroKinds`
joshtriplett Aug 9, 2025
0338842
Rollup merge of #144642 - lolbinarycat:editorconfig-no-run-make, r=lcnr
jhpratt Aug 12, 2025
7b66001
Rollup merge of #144955 - lcnr:lazily-update-non-parent-goals, r=BoxyUwU
jhpratt Aug 12, 2025
25a3df8
Rollup merge of #145153 - joshtriplett:macro-kinds-plural, r=petroche…
jhpratt Aug 12, 2025
044cdf2
Rollup merge of #145206 - scrabsha:push-uxovoqzrxnlx, r=jdonszelmann
jhpratt Aug 12, 2025
d7bf066
Rollup merge of #145250 - fmease:regr-test-for-attr-meta-ice, r=jdons…
jhpratt Aug 12, 2025
3cb4a98
Rollup merge of #145269 - epage:test-env, r=jhpratt
jhpratt Aug 12, 2025
581a7ce
Rollup merge of #145289 - rejected-l:master, r=Kobzol
jhpratt Aug 12, 2025
77fe3d6
Rollup merge of #145303 - m-ou-se:payload-as-str-doc, r=jhpratt
jhpratt Aug 12, 2025
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
11 changes: 10 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

# some tests need trailing whitespace in output snapshots
[!tests/]
trim_trailing_whitespace = true
# for actual source code files of test, we still don't want trailing whitespace
[tests/**.{rs,js}]
trim_trailing_whitespace = true
# these specific source files need to have trailing whitespace.
[tests/ui/{frontmatter/frontmatter-whitespace-3.rs,parser/shebang/shebang-space.rs}]
trim_trailing_whitespace = false

[!src/llvm-project]
indent_style = space
indent_size = 4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
run_type: ${{ steps.jobs.outputs.run_type }}
steps:
- name: Checkout the source code
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Test citool
# Only test citool on the auto branch, to reduce latency of the calculate matrix job
# on PR/try builds.
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:
run: git config --global core.autocrlf false

- name: checkout the source code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 2

Expand Down Expand Up @@ -313,7 +313,7 @@ jobs:
if: ${{ !cancelled() && contains(fromJSON('["auto", "try"]'), needs.calculate_matrix.outputs.run_type) }}
steps:
- name: checkout the source code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 2
# Calculate the exit status of the whole CI workflow.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
runs-on: ubuntu-24.04
steps:
- name: checkout the source code
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
submodules: recursive
- name: install the bootstrap toolchain
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:
pull-requests: write
steps:
- name: checkout the source code
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: download Cargo.lock from update job
uses: actions/download-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
# Needed to write to the ghcr.io registry
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
persist-credentials: false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/post-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
# Make sure that we have enough commits to find the parent merge commit.
# Since all merges should be through merge commits, fetching two commits
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3889,6 +3889,7 @@ dependencies = [
name = "rustc_hir"
version = "0.0.0"
dependencies = [
"bitflags",
"odht",
"rustc_abi",
"rustc_arena",
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,14 +436,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
let body = Box::new(self.lower_delim_args(body));
let def_id = self.local_def_id(id);
let def_kind = self.tcx.def_kind(def_id);
let DefKind::Macro(macro_kind) = def_kind else {
let DefKind::Macro(macro_kinds) = def_kind else {
unreachable!(
"expected DefKind::Macro for macro item, found {}",
def_kind.descr(def_id.to_def_id())
);
};
let macro_def = self.arena.alloc(ast::MacroDef { body, macro_rules: *macro_rules });
hir::ItemKind::Macro(ident, macro_def, macro_kind)
hir::ItemKind::Macro(ident, macro_def, macro_kinds)
}
ItemKind::Delegation(box delegation) => {
let delegation_results = self.lower_delegation(delegation, id, false);
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_attr_parsing/src/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub(crate) mod no_implicit_prelude;
pub(crate) mod non_exhaustive;
pub(crate) mod path;
pub(crate) mod proc_macro_attrs;
pub(crate) mod prototype;
pub(crate) mod repr;
pub(crate) mod rustc_internal;
pub(crate) mod semantics;
Expand Down
136 changes: 136 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/prototype.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
//! Attributes that are only used on function prototypes.

use rustc_feature::{AttributeTemplate, template};
use rustc_hir::attrs::{AttributeKind, MirDialect, MirPhase};
use rustc_span::{Span, Symbol, sym};

use super::{AttributeOrder, OnDuplicate};
use crate::attributes::SingleAttributeParser;
use crate::context::{AcceptContext, Stage};
use crate::parser::ArgParser;

pub(crate) struct CustomMirParser;

impl<S: Stage> SingleAttributeParser<S> for CustomMirParser {
const PATH: &[rustc_span::Symbol] = &[sym::custom_mir];

const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;

const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;

const TEMPLATE: AttributeTemplate = template!(List: r#"dialect = "...", phase = "...""#);

fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
let Some(list) = args.list() else {
cx.expected_list(cx.attr_span);
return None;
};

let mut dialect = None;
let mut phase = None;
let mut failed = false;

for item in list.mixed() {
let Some(meta_item) = item.meta_item() else {
cx.expected_name_value(item.span(), None);
failed = true;
break;
};

if let Some(arg) = meta_item.word_is(sym::dialect) {
extract_value(cx, sym::dialect, arg, meta_item.span(), &mut dialect, &mut failed);
} else if let Some(arg) = meta_item.word_is(sym::phase) {
extract_value(cx, sym::phase, arg, meta_item.span(), &mut phase, &mut failed);
} else if let Some(word) = meta_item.path().word() {
let word = word.to_string();
cx.unknown_key(meta_item.span(), word, &["dialect", "phase"]);
failed = true;
} else {
cx.expected_name_value(meta_item.span(), None);
failed = true;
};
}

let dialect = parse_dialect(cx, dialect, &mut failed);
let phase = parse_phase(cx, phase, &mut failed);

if failed {
return None;
}

Some(AttributeKind::CustomMir(dialect, phase, cx.attr_span))
}
}

fn extract_value<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
key: Symbol,
arg: &ArgParser<'_>,
span: Span,
out_val: &mut Option<(Symbol, Span)>,
failed: &mut bool,
) {
if out_val.is_some() {
cx.duplicate_key(span, key);
*failed = true;
return;
}

let Some(val) = arg.name_value() else {
cx.expected_single_argument(arg.span().unwrap_or(span));
*failed = true;
return;
};

let Some(value_sym) = val.value_as_str() else {
cx.expected_string_literal(val.value_span, Some(val.value_as_lit()));
*failed = true;
return;
};

*out_val = Some((value_sym, val.value_span));
}

fn parse_dialect<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
dialect: Option<(Symbol, Span)>,
failed: &mut bool,
) -> Option<(MirDialect, Span)> {
let (dialect, span) = dialect?;

let dialect = match dialect {
sym::analysis => MirDialect::Analysis,
sym::built => MirDialect::Built,
sym::runtime => MirDialect::Runtime,

_ => {
cx.expected_specific_argument(span, vec!["analysis", "built", "runtime"]);
*failed = true;
return None;
}
};

Some((dialect, span))
}

fn parse_phase<S: Stage>(
cx: &mut AcceptContext<'_, '_, S>,
phase: Option<(Symbol, Span)>,
failed: &mut bool,
) -> Option<(MirPhase, Span)> {
let (phase, span) = phase?;

let phase = match phase {
sym::initial => MirPhase::Initial,
sym::post_cleanup => MirPhase::PostCleanup,
sym::optimized => MirPhase::Optimized,

_ => {
cx.expected_specific_argument(span, vec!["initial", "post-cleanup", "optimized"]);
*failed = true;
return None;
}
};

Some((phase, span))
}
2 changes: 2 additions & 0 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use crate::attributes::path::PathParser as PathAttributeParser;
use crate::attributes::proc_macro_attrs::{
ProcMacroAttributeParser, ProcMacroDeriveParser, ProcMacroParser, RustcBuiltinMacroParser,
};
use crate::attributes::prototype::CustomMirParser;
use crate::attributes::repr::{AlignParser, ReprParser};
use crate::attributes::rustc_internal::{
RustcLayoutScalarValidRangeEnd, RustcLayoutScalarValidRangeStart,
Expand Down Expand Up @@ -159,6 +160,7 @@ attribute_parsers!(

// tidy-alphabetical-start
Single<CoverageParser>,
Single<CustomMirParser>,
Single<DeprecationParser>,
Single<DummyParser>,
Single<ExportNameParser>,
Expand Down
23 changes: 23 additions & 0 deletions compiler/rustc_errors/src/diagnostic_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use rustc_abi::TargetDataLayoutErrors;
use rustc_ast::util::parser::ExprPrecedence;
use rustc_ast_pretty::pprust;
use rustc_hir::RustcVersion;
use rustc_hir::attrs::{MirDialect, MirPhase};
use rustc_macros::Subdiagnostic;
use rustc_span::edition::Edition;
use rustc_span::{Ident, MacroRulesNormalizedIdent, Span, Symbol};
Expand Down Expand Up @@ -312,6 +313,28 @@ impl IntoDiagArg for ExprPrecedence {
}
}

impl IntoDiagArg for MirDialect {
fn into_diag_arg(self, _path: &mut Option<PathBuf>) -> DiagArgValue {
let arg = match self {
MirDialect::Analysis => "analysis",
MirDialect::Built => "built",
MirDialect::Runtime => "runtime",
};
DiagArgValue::Str(Cow::Borrowed(arg))
}
}

impl IntoDiagArg for MirPhase {
fn into_diag_arg(self, _path: &mut Option<PathBuf>) -> DiagArgValue {
let arg = match self {
MirPhase::Initial => "initial",
MirPhase::PostCleanup => "post-cleanup",
MirPhase::Optimized => "optimized",
};
DiagArgValue::Str(Cow::Borrowed(arg))
}
}

#[derive(Clone)]
pub struct DiagSymbolList<S = Symbol>(Vec<S>);

Expand Down
Loading
Loading