Skip to content

Manual rollup of 19 pull requests #145545

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 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
aab1563
`impl PartialEq<{str,String}> for {Path,PathBuf}`
Kixunil Dec 18, 2022
964eb82
Stabilize `ip_from`
GrigorenkoPV May 29, 2025
a067c6a
refactor `unreachable/expr_cast.rs` test
WaffleLapkin Jun 1, 2025
d2e133d
don't warn on explicit casts of never to any
WaffleLapkin Jun 1, 2025
970ac40
updated doc comment
Kivooeo Aug 2, 2025
c64c6d8
Use `LLVMSetTailCallKind`
Zalathar Aug 14, 2025
51bccdd
Port `#[custom_mir(..)]` to the new attribute system
scrabsha Aug 10, 2025
4d62bf1
All weak lang items have an explicit link name and vice versa
bjorn3 Aug 15, 2025
f3ef465
Combining no_mangle and rustc_std_internal_symbol is not allowed
bjorn3 Aug 15, 2025
e193b53
Use `LLVMGetTypeKind`
Zalathar Aug 14, 2025
460519a
Merge link_name and export_name
bjorn3 Aug 15, 2025
f94a0d0
Remove unused feature gate
bjorn3 Aug 15, 2025
1d00627
add static glibc to the nix dev shell
WaffleLapkin Aug 15, 2025
9fab380
Fix typo in doc for library/std/src/fs.rs#set_permissions
alurm Aug 15, 2025
5107ac9
Do not call `fs::remove_file` in `cp_link_filtered_recurse`
Kobzol Aug 15, 2025
cdea62d
Optimize `copy_src_dirs`
Kobzol Aug 15, 2025
e8f90b1
Don't show foreign types as an allowed target if the feature is not e…
JonathanBrouwer Aug 16, 2025
a69ba29
Fix deprecation attribute on foreign statics & types
JonathanBrouwer Aug 16, 2025
70e26c1
take attr style into account in attr diagnostics
jdonszelmann Aug 11, 2025
e906a59
Fix `unicode_data.rs` mention message
Urgau Aug 16, 2025
3450975
remove `should_render` in `PrintAttribute` derive
fee1-dead Aug 16, 2025
e31fed0
run spellcheck as a tidy extra check in ci
lolbinarycat Aug 6, 2025
6c15339
Simplify decode_span.
cjgillot Aug 16, 2025
a843730
Simplify span_data_to_lines_and_cols.
cjgillot Aug 16, 2025
1cb4fd7
tidy now installs typos-cli as-needed via cargo
lolbinarycat Aug 8, 2025
6a51eef
tidy: run typos check in src root, not current dir
lolbinarycat Aug 9, 2025
d73e6b4
tidy: add better error reporting for if typos can't be run
lolbinarycat Aug 8, 2025
0d797d2
typos: allow moreso
lolbinarycat Aug 16, 2025
2050a3b
std: fix more typos
lolbinarycat Aug 16, 2025
80d3234
Fix bug where `rustdoc-js` tester would not pick the right `search.js…
GuillaumeGomez Aug 13, 2025
826ebde
Strenghten rustdoc js tester file macthing regex
GuillaumeGomez Aug 16, 2025
8792010
Rust build fails on OpenBSD after using file_lock feature
semarie Aug 16, 2025
cbfa17a
Reorder `lto` options from most to least optimizing
smoelius Aug 17, 2025
70cd6d7
Merge remote-tracking branch 'Kixunil/impl-partialeq-str-for-path' in…
jhpratt Aug 17, 2025
df00682
Merge remote-tracking branch 'GrigorenkoPV/ip_from' into manual-rollup
jhpratt Aug 17, 2025
79bd407
Merge remote-tracking branch 'WaffleLapkin/reach-for-the-casts' into …
jhpratt Aug 17, 2025
7a7b2c9
Merge remote-tracking branch 'Kivooeo/doc-subtype' into manual-rollup
jhpratt Aug 17, 2025
3f64bf5
Merge remote-tracking branch 'jdonszelmann/inner-attr-errors' into ma…
jhpratt Aug 17, 2025
e9b213d
Merge remote-tracking branch 'GuillaumeGomez/correctly-pick-search.js…
jhpratt Aug 17, 2025
ef0a03f
Merge remote-tracking branch 'Zalathar/llvm-c' into manual-rollup
jhpratt Aug 17, 2025
8b0524f
Merge remote-tracking branch 'WaffleLapkin/norailoveyou' into manual-…
jhpratt Aug 17, 2025
ca524fb
Merge remote-tracking branch 'lolbinarycat/ci-tidy-spellcheck' into m…
jhpratt Aug 17, 2025
f4534a1
Merge remote-tracking branch 'scrabsha/push-uxovoqzrxnlx' into manual…
jhpratt Aug 17, 2025
504ef31
Merge remote-tracking branch 'bjorn3/codegen_fn_attrs_improvements' i…
jhpratt Aug 17, 2025
b313906
Merge remote-tracking branch 'Kobzol/bootstrap-speedup-copy-src-dirs'…
jhpratt Aug 17, 2025
bda3b9a
Merge remote-tracking branch 'alurm/patch-1' into manual-rollup
jhpratt Aug 17, 2025
df421ec
Merge remote-tracking branch 'JonathanBrouwer/fix-deprecation-targets…
jhpratt Aug 17, 2025
c478d71
Merge remote-tracking branch 'Urgau/unicode-mention' into manual-rollup
jhpratt Aug 17, 2025
b2ba435
Merge remote-tracking branch 'fee1-dead-contrib/push-rsqlqymxyyqp' in…
jhpratt Aug 17, 2025
248bf23
Merge remote-tracking branch 'cjgillot/tweak-span-cache' into manual-…
jhpratt Aug 17, 2025
0953957
Merge remote-tracking branch 'semarie/push-rnytptsoxrxn' into manual-…
jhpratt Aug 17, 2025
cbc4330
Merge remote-tracking branch 'smoelius/patch-2' into manual-rollup
jhpratt Aug 17, 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
2 changes: 2 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/deprecation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ impl<S: Stage> SingleAttributeParser<S> for DeprecationParser {
Allow(Target::TyAlias),
Allow(Target::Use),
Allow(Target::ForeignFn),
Allow(Target::ForeignStatic),
Allow(Target::ForeignTy),
Allow(Target::Field),
Allow(Target::Trait),
Allow(Target::AssocTy),
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_attr_parsing/src/attributes/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ impl<S: Stage> SingleAttributeParser<S> for InlineParser {
}
}
ArgParser::NameValue(_) => {
let suggestions =
<Self as SingleAttributeParser<S>>::TEMPLATE.suggestions(false, "inline");
let suggestions = <Self as SingleAttributeParser<S>>::TEMPLATE
.suggestions(cx.attr_style, "inline");
let span = cx.attr_span;
cx.emit_lint(AttributeLintKind::IllFormedAttributeInput { suggestions }, span);
return None;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl<S: Stage> AttributeParser<S> for MacroUseParser {
}
}
ArgParser::NameValue(_) => {
let suggestions = MACRO_USE_TEMPLATE.suggestions(false, sym::macro_use);
let suggestions = MACRO_USE_TEMPLATE.suggestions(cx.attr_style, sym::macro_use);
cx.emit_err(session_diagnostics::IllFormedAttributeInputLint {
num_suggestions: suggestions.len(),
suggestions: DiagArgValue::StrListSepByAnd(
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
4 changes: 2 additions & 2 deletions compiler/rustc_attr_parsing/src/attributes/must_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ impl<S: Stage> SingleAttributeParser<S> for MustUseParser {
Some(value_str)
}
ArgParser::List(_) => {
let suggestions =
<Self as SingleAttributeParser<S>>::TEMPLATE.suggestions(false, "must_use");
let suggestions = <Self as SingleAttributeParser<S>>::TEMPLATE
.suggestions(cx.attr_style, "must_use");
cx.emit_err(session_diagnostics::IllFormedAttributeInputLint {
num_suggestions: suggestions.len(),
suggestions: DiagArgValue::StrListSepByAnd(
Expand Down
140 changes: 140 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/prototype.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
//! Attributes that are only used on function prototypes.

use rustc_feature::{AttributeTemplate, template};
use rustc_hir::Target;
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, AllowedTargets, MaybeWarn, 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 ALLOWED_TARGETS: AllowedTargets =
AllowedTargets::AllowList(&[MaybeWarn::Allow(Target::Fn)]);

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))
}
6 changes: 3 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/test_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl<S: Stage> SingleAttributeParser<S> for IgnoreParser {
ArgParser::NameValue(name_value) => {
let Some(str_value) = name_value.value_as_str() else {
let suggestions = <Self as SingleAttributeParser<S>>::TEMPLATE
.suggestions(false, "ignore");
.suggestions(cx.attr_style, "ignore");
let span = cx.attr_span;
cx.emit_lint(
AttributeLintKind::IllFormedAttributeInput { suggestions },
Expand All @@ -40,8 +40,8 @@ impl<S: Stage> SingleAttributeParser<S> for IgnoreParser {
Some(str_value)
}
ArgParser::List(_) => {
let suggestions =
<Self as SingleAttributeParser<S>>::TEMPLATE.suggestions(false, "ignore");
let suggestions = <Self as SingleAttributeParser<S>>::TEMPLATE
.suggestions(cx.attr_style, "ignore");
let span = cx.attr_span;
cx.emit_lint(AttributeLintKind::IllFormedAttributeInput { suggestions }, span);
return None;
Expand Down
23 changes: 22 additions & 1 deletion compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::LazyLock;

use itertools::Itertools;
use private::Sealed;
use rustc_ast::{self as ast, LitKind, MetaItemLit, NodeId};
use rustc_ast::{self as ast, AttrStyle, LitKind, MetaItemLit, NodeId};
use rustc_errors::{DiagCtxtHandle, Diagnostic};
use rustc_feature::{AttributeTemplate, Features};
use rustc_hir::attrs::AttributeKind;
Expand Down Expand Up @@ -46,6 +46,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 @@ -167,6 +168,7 @@ attribute_parsers!(

// tidy-alphabetical-start
Single<CoverageParser>,
Single<CustomMirParser>,
Single<DeprecationParser>,
Single<DummyParser>,
Single<ExportNameParser>,
Expand Down Expand Up @@ -313,6 +315,7 @@ pub struct AcceptContext<'f, 'sess, S: Stage> {
/// The span of the attribute currently being parsed
pub(crate) attr_span: Span,

pub(crate) attr_style: AttrStyle,
/// The expected structure of the attribute.
///
/// Used in reporting errors to give a hint to users what the attribute *should* look like.
Expand Down Expand Up @@ -394,6 +397,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
i.kind.is_bytestr().then(|| self.sess().source_map().start_point(i.span))
}),
},
attr_style: self.attr_style,
})
}

Expand All @@ -404,6 +408,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
template: self.template.clone(),
attribute: self.attr_path.clone(),
reason: AttributeParseErrorReason::ExpectedIntegerLiteral,
attr_style: self.attr_style,
})
}

Expand All @@ -414,6 +419,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
template: self.template.clone(),
attribute: self.attr_path.clone(),
reason: AttributeParseErrorReason::ExpectedList,
attr_style: self.attr_style,
})
}

Expand All @@ -424,6 +430,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
template: self.template.clone(),
attribute: self.attr_path.clone(),
reason: AttributeParseErrorReason::ExpectedNoArgs,
attr_style: self.attr_style,
})
}

Expand All @@ -435,6 +442,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
template: self.template.clone(),
attribute: self.attr_path.clone(),
reason: AttributeParseErrorReason::ExpectedIdentifier,
attr_style: self.attr_style,
})
}

Expand All @@ -447,6 +455,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
template: self.template.clone(),
attribute: self.attr_path.clone(),
reason: AttributeParseErrorReason::ExpectedNameValue(name),
attr_style: self.attr_style,
})
}

Expand All @@ -458,6 +467,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
template: self.template.clone(),
attribute: self.attr_path.clone(),
reason: AttributeParseErrorReason::DuplicateKey(key),
attr_style: self.attr_style,
})
}

Expand All @@ -470,6 +480,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
template: self.template.clone(),
attribute: self.attr_path.clone(),
reason: AttributeParseErrorReason::UnexpectedLiteral,
attr_style: self.attr_style,
})
}

Expand All @@ -480,6 +491,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
template: self.template.clone(),
attribute: self.attr_path.clone(),
reason: AttributeParseErrorReason::ExpectedSingleArgument,
attr_style: self.attr_style,
})
}

Expand All @@ -490,6 +502,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
template: self.template.clone(),
attribute: self.attr_path.clone(),
reason: AttributeParseErrorReason::ExpectedAtLeastOneArgument,
attr_style: self.attr_style,
})
}

Expand All @@ -508,6 +521,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
strings: false,
list: false,
},
attr_style: self.attr_style,
})
}

Expand All @@ -526,6 +540,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
strings: false,
list: true,
},
attr_style: self.attr_style,
})
}

Expand All @@ -544,6 +559,7 @@ impl<'f, 'sess: 'f, S: Stage> AcceptContext<'f, 'sess, S> {
strings: true,
list: false,
},
attr_style: self.attr_style,
})
}

Expand Down Expand Up @@ -802,6 +818,7 @@ impl<'sess> AttributeParser<'sess, Early> {
},
},
attr_span: attr.span,
attr_style: attr.style,
template,
attr_path: path.get_attribute_path(),
};
Expand Down Expand Up @@ -912,6 +929,7 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> {
emit_lint: &mut emit_lint,
},
attr_span: lower_span(attr.span),
attr_style: attr.style,
template: &accept.template,
attr_path: path.get_attribute_path(),
};
Expand Down Expand Up @@ -1060,6 +1078,9 @@ pub(crate) fn allowed_targets_applied(
if !features.stmt_expr_attributes() {
allowed_targets.retain(|t| !matches!(t, Target::Expression | Target::Statement));
}
if !features.extern_types() {
allowed_targets.retain(|t| !matches!(t, Target::ForeignTy));
}
}

// We define groups of "similar" targets.
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_attr_parsing/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::num::IntErrorKind;

use rustc_ast as ast;
use rustc_ast::{self as ast, AttrStyle};
use rustc_errors::codes::*;
use rustc_errors::{
Applicability, Diag, DiagArgValue, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level,
Expand Down Expand Up @@ -579,6 +579,7 @@ pub(crate) enum AttributeParseErrorReason {
pub(crate) struct AttributeParseError {
pub(crate) span: Span,
pub(crate) attr_span: Span,
pub(crate) attr_style: AttrStyle,
pub(crate) template: AttributeTemplate,
pub(crate) attribute: AttrPath,
pub(crate) reason: AttributeParseErrorReason,
Expand Down Expand Up @@ -717,7 +718,8 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for AttributeParseError {
if let Some(link) = self.template.docs {
diag.note(format!("for more information, visit <{link}>"));
}
let suggestions = self.template.suggestions(false, &name);
let suggestions = self.template.suggestions(self.attr_style, &name);

diag.span_suggestions(
self.attr_span,
if suggestions.len() == 1 {
Expand Down
Loading
Loading