Auto merge of #151471 - JonathanBrouwer:rollup-EgxENYU, r=JonathanBrouwer

Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#151010 (std: use `ByteStr`'s `Display` for `OsStr`)
 - rust-lang/rust#151156 (Add GCC and the GCC codegen backend to build-manifest and rustup)
 - rust-lang/rust#151219 (Fixed ICE when using function pointer as const generic parameter)
 - rust-lang/rust#151343 (Port some crate level attrs to the attribute parser)
 - rust-lang/rust#151463 (add x86_64-unknown-linux-gnuasan to CI)

r? @ghost
This commit is contained in:
bors 2026-01-21 22:38:46 +00:00
commit 004d710faf
25 changed files with 353 additions and 158 deletions

View file

@ -184,3 +184,39 @@ impl<S: Stage> SingleAttributeParser<S> for WindowsSubsystemParser {
Some(AttributeKind::WindowsSubsystem(kind, cx.attr_span))
}
}
pub(crate) struct PanicRuntimeParser;
impl<S: Stage> NoArgsAttributeParser<S> for PanicRuntimeParser {
const PATH: &[Symbol] = &[sym::panic_runtime];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::PanicRuntime;
}
pub(crate) struct NeedsPanicRuntimeParser;
impl<S: Stage> NoArgsAttributeParser<S> for NeedsPanicRuntimeParser {
const PATH: &[Symbol] = &[sym::needs_panic_runtime];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NeedsPanicRuntime;
}
pub(crate) struct ProfilerRuntimeParser;
impl<S: Stage> NoArgsAttributeParser<S> for ProfilerRuntimeParser {
const PATH: &[Symbol] = &[sym::profiler_runtime];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::ProfilerRuntime;
}
pub(crate) struct NoBuiltinsParser;
impl<S: Stage> NoArgsAttributeParser<S> for NoBuiltinsParser {
const PATH: &[Symbol] = &[sym::no_builtins];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NoBuiltins;
}

View file

@ -665,3 +665,12 @@ impl<S: Stage> NoArgsAttributeParser<S> for NeedsAllocatorParser {
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::NeedsAllocator;
}
pub(crate) struct CompilerBuiltinsParser;
impl<S: Stage> NoArgsAttributeParser<S> for CompilerBuiltinsParser {
const PATH: &[Symbol] = &[sym::compiler_builtins];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Crate)]);
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::CompilerBuiltins;
}

View file

@ -28,9 +28,10 @@ use crate::attributes::codegen_attrs::{
};
use crate::attributes::confusables::ConfusablesParser;
use crate::attributes::crate_level::{
CrateNameParser, MoveSizeLimitParser, NoCoreParser, NoMainParser, NoStdParser,
PatternComplexityLimitParser, RecursionLimitParser, RustcCoherenceIsCoreParser,
TypeLengthLimitParser, WindowsSubsystemParser,
CrateNameParser, MoveSizeLimitParser, NeedsPanicRuntimeParser, NoBuiltinsParser, NoCoreParser,
NoMainParser, NoStdParser, PanicRuntimeParser, PatternComplexityLimitParser,
ProfilerRuntimeParser, RecursionLimitParser, RustcCoherenceIsCoreParser, TypeLengthLimitParser,
WindowsSubsystemParser,
};
use crate::attributes::debugger::DebuggerViualizerParser;
use crate::attributes::deprecation::DeprecationParser;
@ -40,8 +41,9 @@ use crate::attributes::dummy::DummyParser;
use crate::attributes::inline::{InlineParser, RustcForceInlineParser};
use crate::attributes::instruction_set::InstructionSetParser;
use crate::attributes::link_attrs::{
ExportStableParser, FfiConstParser, FfiPureParser, LinkNameParser, LinkOrdinalParser,
LinkParser, LinkSectionParser, LinkageParser, NeedsAllocatorParser, StdInternalSymbolParser,
CompilerBuiltinsParser, ExportStableParser, FfiConstParser, FfiPureParser, LinkNameParser,
LinkOrdinalParser, LinkParser, LinkSectionParser, LinkageParser, NeedsAllocatorParser,
StdInternalSymbolParser,
};
use crate::attributes::lint_helpers::{
AsPtrParser, AutomaticallyDerivedParser, PassByValueParser, PubTransparentParser,
@ -251,6 +253,7 @@ attribute_parsers!(
Single<WithoutArgs<AutomaticallyDerivedParser>>,
Single<WithoutArgs<CoinductiveParser>>,
Single<WithoutArgs<ColdParser>>,
Single<WithoutArgs<CompilerBuiltinsParser>>,
Single<WithoutArgs<ConstContinueParser>>,
Single<WithoutArgs<ConstStabilityIndirectParser>>,
Single<WithoutArgs<CoroutineParser>>,
@ -266,6 +269,8 @@ attribute_parsers!(
Single<WithoutArgs<MarkerParser>>,
Single<WithoutArgs<MayDangleParser>>,
Single<WithoutArgs<NeedsAllocatorParser>>,
Single<WithoutArgs<NeedsPanicRuntimeParser>>,
Single<WithoutArgs<NoBuiltinsParser>>,
Single<WithoutArgs<NoCoreParser>>,
Single<WithoutArgs<NoImplicitPreludeParser>>,
Single<WithoutArgs<NoLinkParser>>,
@ -273,12 +278,14 @@ attribute_parsers!(
Single<WithoutArgs<NoMangleParser>>,
Single<WithoutArgs<NoStdParser>>,
Single<WithoutArgs<NonExhaustiveParser>>,
Single<WithoutArgs<PanicRuntimeParser>>,
Single<WithoutArgs<ParenSugarParser>>,
Single<WithoutArgs<PassByValueParser>>,
Single<WithoutArgs<PinV2Parser>>,
Single<WithoutArgs<PointeeParser>>,
Single<WithoutArgs<ProcMacroAttributeParser>>,
Single<WithoutArgs<ProcMacroParser>>,
Single<WithoutArgs<ProfilerRuntimeParser>>,
Single<WithoutArgs<PubTransparentParser>>,
Single<WithoutArgs<RustcAllocatorParser>>,
Single<WithoutArgs<RustcAllocatorZeroedParser>>,

View file

@ -6,7 +6,6 @@ use std::sync::mpsc::{Receiver, Sender, channel};
use std::{fs, io, mem, str, thread};
use rustc_abi::Size;
use rustc_ast::attr;
use rustc_data_structures::assert_matches;
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::jobserver::{self, Acquired};
@ -19,6 +18,8 @@ use rustc_errors::{
Level, MultiSpan, Style, Suggestions, catch_fatal_errors,
};
use rustc_fs_util::link_or_copy;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::find_attr;
use rustc_incremental::{
copy_cgu_workproduct_to_incr_comp_cache_dir, in_incr_comp_dir, in_incr_comp_dir_sess,
};
@ -31,7 +32,7 @@ use rustc_session::config::{
self, CrateType, Lto, OutFileName, OutputFilenames, OutputType, Passes, SwitchWithOptPath,
};
use rustc_span::source_map::SourceMap;
use rustc_span::{FileName, InnerSpan, Span, SpanData, sym};
use rustc_span::{FileName, InnerSpan, Span, SpanData};
use rustc_target::spec::{MergeFunctions, SanitizerSet};
use tracing::debug;
@ -453,7 +454,7 @@ pub(crate) fn start_async_codegen<B: ExtraBackendMethods>(
let (coordinator_send, coordinator_receive) = channel();
let crate_attrs = tcx.hir_attrs(rustc_hir::CRATE_HIR_ID);
let no_builtins = attr::contains_name(crate_attrs, sym::no_builtins);
let no_builtins = find_attr!(crate_attrs, AttributeKind::NoBuiltins);
let crate_info = CrateInfo::new(tcx, target_cpu);

View file

@ -2,7 +2,7 @@ use std::str::FromStr;
use rustc_abi::{Align, ExternAbi};
use rustc_ast::expand::autodiff_attrs::{AutoDiffAttrs, DiffActivity, DiffMode};
use rustc_ast::{LitKind, MetaItem, MetaItemInner, attr};
use rustc_ast::{LitKind, MetaItem, MetaItemInner};
use rustc_hir::attrs::{
AttributeKind, EiiImplResolution, InlineAttr, Linkage, RtsanSetting, UsedBy,
};
@ -353,7 +353,7 @@ fn apply_overrides(tcx: TyCtxt<'_>, did: LocalDefId, codegen_fn_attrs: &mut Code
// When `no_builtins` is applied at the crate level, we should add the
// `no-builtins` attribute to each function to ensure it takes effect in LTO.
let crate_attrs = tcx.hir_attrs(rustc_hir::CRATE_HIR_ID);
let no_builtins = attr::contains_name(crate_attrs, sym::no_builtins);
let no_builtins = find_attr!(crate_attrs, AttributeKind::NoBuiltins);
if no_builtins {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_BUILTINS;
}

View file

@ -687,6 +687,9 @@ pub enum AttributeKind {
/// Represents `#[collapse_debuginfo]`.
CollapseDebugInfo(CollapseMacroDebuginfo),
/// Represents `#[compiler_builtins]`.
CompilerBuiltins,
/// Represents `#[rustc_confusables]`.
Confusables {
symbols: ThinVec<Symbol>,
@ -843,6 +846,12 @@ pub enum AttributeKind {
/// Represents `#[needs_allocator]`
NeedsAllocator,
/// Represents `#[needs_panic_runtime]`
NeedsPanicRuntime,
/// Represents `#[no_builtins]`
NoBuiltins,
/// Represents `#[no_core]`
NoCore(Span),
@ -873,6 +882,9 @@ pub enum AttributeKind {
/// Represents `#[optimize(size|speed)]`
Optimize(OptimizeAttr, Span),
/// Represents `#[panic_runtime]`
PanicRuntime,
/// Represents `#[rustc_paren_sugar]`.
ParenSugar(Span),
@ -903,6 +915,9 @@ pub enum AttributeKind {
/// Represents `#[proc_macro_derive]`
ProcMacroDerive { trait_name: Symbol, helper_attrs: ThinVec<Symbol>, span: Span },
/// Represents `#[profiler_runtime]`
ProfilerRuntime,
/// Represents `#[rustc_pub_transparent]` (used by the `repr_transparent_external_private_fields` lint).
PubTransparent(Span),

View file

@ -32,6 +32,7 @@ impl AttributeKind {
Coinductive(..) => No,
Cold(..) => No,
CollapseDebugInfo(..) => Yes,
CompilerBuiltins => No,
Confusables { .. } => Yes,
ConstContinue(..) => No,
ConstStability { .. } => Yes,
@ -76,6 +77,8 @@ impl AttributeKind {
MustUse { .. } => Yes,
Naked(..) => No,
NeedsAllocator => No,
NeedsPanicRuntime => No,
NoBuiltins => Yes,
NoCore(..) => No,
NoImplicitPrelude(..) => No,
NoLink => No,
@ -86,6 +89,7 @@ impl AttributeKind {
ObjcClass { .. } => No,
ObjcSelector { .. } => No,
Optimize(..) => No,
PanicRuntime => No,
ParenSugar(..) => No,
PassByValue(..) => Yes,
PatchableFunctionEntry { .. } => Yes,
@ -96,6 +100,7 @@ impl AttributeKind {
ProcMacro(..) => No,
ProcMacroAttribute(..) => No,
ProcMacroDerive { .. } => No,
ProfilerRuntime => No,
PubTransparent(..) => Yes,
RecursionLimit { .. } => No,
Repr { .. } => No,

View file

@ -627,13 +627,10 @@ pub(crate) fn prohibit_explicit_late_bound_lifetimes(
position: GenericArgPosition,
) -> ExplicitLateBound {
let param_counts = def.own_counts();
let infer_lifetimes = position != GenericArgPosition::Type && !args.has_lifetime_params();
if infer_lifetimes {
return ExplicitLateBound::No;
}
if let Some(span_late) = def.has_late_bound_regions {
if let Some(span_late) = def.has_late_bound_regions
&& args.has_lifetime_params()
{
let msg = "cannot specify lifetime arguments explicitly \
if late bound lifetime parameters are present";
let note = "the late bound lifetime parameter is introduced here";

View file

@ -741,12 +741,12 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
externally_implementable_items,
proc_macro_data,
debugger_visualizers,
compiler_builtins: ast::attr::contains_name(attrs, sym::compiler_builtins),
compiler_builtins: find_attr!(attrs, AttributeKind::CompilerBuiltins),
needs_allocator: find_attr!(attrs, AttributeKind::NeedsAllocator),
needs_panic_runtime: ast::attr::contains_name(attrs, sym::needs_panic_runtime),
no_builtins: ast::attr::contains_name(attrs, sym::no_builtins),
panic_runtime: ast::attr::contains_name(attrs, sym::panic_runtime),
profiler_runtime: ast::attr::contains_name(attrs, sym::profiler_runtime),
needs_panic_runtime: find_attr!(attrs, AttributeKind::NeedsPanicRuntime),
no_builtins: find_attr!(attrs, AttributeKind::NoBuiltins),
panic_runtime: find_attr!(attrs, AttributeKind::PanicRuntime),
profiler_runtime: find_attr!(attrs, AttributeKind::ProfilerRuntime),
symbol_mangling_version: tcx.sess.opts.get_symbol_mangling_version(),
crate_deps,

View file

@ -38,7 +38,7 @@ use rustc_hir::definitions::{DefPathData, Definitions, DisambiguatorState};
use rustc_hir::intravisit::VisitorExt;
use rustc_hir::lang_items::LangItem;
use rustc_hir::limit::Limit;
use rustc_hir::{self as hir, Attribute, HirId, Node, TraitCandidate, find_attr};
use rustc_hir::{self as hir, HirId, Node, TraitCandidate, find_attr};
use rustc_index::IndexVec;
use rustc_query_system::cache::WithDepNode;
use rustc_query_system::dep_graph::DepNodeIndex;
@ -49,7 +49,7 @@ use rustc_session::config::CrateType;
use rustc_session::cstore::{CrateStoreDyn, Untracked};
use rustc_session::lint::Lint;
use rustc_span::def_id::{CRATE_DEF_ID, DefPathHash, StableCrateId};
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw};
use rustc_type_ir::TyKind::*;
use rustc_type_ir::lang_items::{SolverAdtLangItem, SolverLangItem, SolverTraitLangItem};
pub use rustc_type_ir::lift::Lift;
@ -3560,16 +3560,12 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn provide(providers: &mut Providers) {
providers.is_panic_runtime =
|tcx, LocalCrate| contains_name(tcx.hir_krate_attrs(), sym::panic_runtime);
|tcx, LocalCrate| find_attr!(tcx.hir_krate_attrs(), AttributeKind::PanicRuntime);
providers.is_compiler_builtins =
|tcx, LocalCrate| contains_name(tcx.hir_krate_attrs(), sym::compiler_builtins);
|tcx, LocalCrate| find_attr!(tcx.hir_krate_attrs(), AttributeKind::CompilerBuiltins);
providers.has_panic_handler = |tcx, LocalCrate| {
// We want to check if the panic handler was defined in this crate
tcx.lang_items().panic_impl().is_some_and(|did| did.is_local())
};
providers.source_span = |tcx, def_id| tcx.untracked.source_span.get(def_id).unwrap_or(DUMMY_SP);
}
pub fn contains_name(attrs: &[Attribute], name: Symbol) -> bool {
attrs.iter().any(|x| x.has_name(name))
}

View file

@ -299,6 +299,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| AttributeKind::NoCore { .. }
| AttributeKind::NoStd { .. }
| AttributeKind::NoMain
| AttributeKind::CompilerBuiltins
| AttributeKind::PanicRuntime
| AttributeKind::NeedsPanicRuntime
| AttributeKind::ProfilerRuntime
| AttributeKind::NoBuiltins
| AttributeKind::ObjcClass { .. }
| AttributeKind::ObjcSelector { .. }
| AttributeKind::RustcCoherenceIsCore(..)
@ -397,13 +402,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| sym::rustc_no_implicit_bounds
| sym::test_runner
| sym::reexport_test_harness_main
| sym::no_main
| sym::no_builtins
| sym::crate_type
| sym::compiler_builtins
| sym::profiler_runtime
| sym::needs_panic_runtime
| sym::panic_runtime
| sym::rustc_preserve_ub_checks,
..
] => {}

View file

@ -4,8 +4,8 @@
use core::clone::CloneToUninit;
use crate::borrow::Cow;
use crate::bstr::ByteStr;
use crate::collections::TryReserveError;
use crate::fmt::Write;
use crate::rc::Rc;
use crate::sync::Arc;
use crate::sys::{AsInner, FromInner, IntoInner};
@ -64,25 +64,7 @@ impl fmt::Debug for Slice {
impl fmt::Display for Slice {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// If we're the empty string then our iterator won't actually yield
// anything, so perform the formatting manually
if self.inner.is_empty() {
return "".fmt(f);
}
for chunk in self.inner.utf8_chunks() {
let valid = chunk.valid();
// If we successfully decoded the whole chunk as a valid string then
// we can return a direct formatting of the string which will also
// respect various formatting flags if possible.
if chunk.invalid().is_empty() {
return valid.fmt(f);
}
f.write_str(valid)?;
f.write_char(char::REPLACEMENT_CHARACTER)?;
}
Ok(())
fmt::Display::fmt(ByteStr::new(&self.inner), f)
}
}

View file

@ -30,7 +30,7 @@ use crate::core::build_steps::tool::{
use crate::core::build_steps::vendor::{VENDOR_DIR, Vendor};
use crate::core::build_steps::{compile, llvm};
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step, StepMetadata};
use crate::core::config::TargetSelection;
use crate::core::config::{GccCiMode, TargetSelection};
use crate::utils::build_stamp::{self, BuildStamp};
use crate::utils::channel::{self, Info};
use crate::utils::exec::{BootstrapCommand, command};
@ -3084,6 +3084,14 @@ impl Step for Gcc {
return None;
}
if builder.config.is_running_on_ci {
assert_eq!(
builder.config.gcc_ci_mode,
GccCiMode::BuildLocally,
"Cannot use gcc.download-ci-gcc when distributing GCC on CI"
);
}
// We need the GCC sources to build GCC and also to add its license and README
// files to the tarball
builder.require_submodule(

View file

@ -425,7 +425,7 @@ impl std::str::FromStr for RustcLto {
}
/// Determines how will GCC be provided.
#[derive(Default, Clone)]
#[derive(Default, Debug, Clone, PartialEq)]
pub enum GccCiMode {
/// Build GCC from the local `src/gcc` submodule.
BuildLocally,

View file

@ -113,6 +113,7 @@ ENV TARGETS=$TARGETS,wasm32-wasip1
ENV TARGETS=$TARGETS,wasm32-wasip1-threads
ENV TARGETS=$TARGETS,wasm32-wasip2
ENV TARGETS=$TARGETS,wasm32v1-none
ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnuasan
ENV TARGETS=$TARGETS,x86_64-unknown-linux-gnux32
ENV TARGETS=$TARGETS,x86_64-fortanix-unknown-sgx
ENV TARGETS=$TARGETS,nvptx64-nvidia-cuda

View file

@ -31,8 +31,16 @@ static DOCS_FALLBACK: &[(&str, &str)] = &[
static PKG_INSTALLERS: &[&str] = &["x86_64-apple-darwin", "aarch64-apple-darwin"];
static NIGHTLY_ONLY_COMPONENTS: &[PkgType] =
&[PkgType::Miri, PkgType::JsonDocs, PkgType::RustcCodegenCranelift];
fn is_nightly_only(pkg: &PkgType) -> bool {
match pkg {
PkgType::Miri
| PkgType::JsonDocs
| PkgType::RustcCodegenCranelift
| PkgType::RustcCodegenGcc
| PkgType::Gcc { .. } => true,
_ => false,
}
}
macro_rules! t {
($e:expr) => {
@ -158,7 +166,7 @@ impl Builder {
}
fn add_packages_to(&mut self, manifest: &mut Manifest) {
for pkg in PkgType::all() {
for pkg in &PkgType::all() {
self.package(pkg, &mut manifest.pkg);
}
}
@ -227,7 +235,7 @@ impl Builder {
};
for pkg in PkgType::all() {
if pkg.is_preview() {
rename(pkg.tarball_component_name(), &pkg.manifest_component_name());
rename(&pkg.tarball_component_name(), &pkg.manifest_component_name());
}
}
}
@ -263,7 +271,7 @@ impl Builder {
let host_component = |pkg: &_| Component::from_pkg(pkg, host);
for pkg in PkgType::all() {
for pkg in &PkgType::all() {
match pkg {
// rustc/rust-std/cargo/docs are all required
PkgType::Rustc | PkgType::Cargo | PkgType::HtmlDocs => {
@ -303,6 +311,8 @@ impl Builder {
| PkgType::JsonDocs
| PkgType::RustcDocs
| PkgType::RustcCodegenCranelift
| PkgType::RustcCodegenGcc
| PkgType::Gcc { .. }
| PkgType::LlvmBitcodeLinker => {
extensions.push(host_component(pkg));
}
@ -374,7 +384,7 @@ impl Builder {
let mut is_present = version_info.present;
// Never ship nightly-only components for other trains.
if self.versions.channel() != "nightly" && NIGHTLY_ONLY_COMPONENTS.contains(&pkg) {
if self.versions.channel() != "nightly" && is_nightly_only(&pkg) {
is_present = false; // Pretend the component is entirely missing.
}

View file

@ -11,29 +11,54 @@ use xz2::read::XzDecoder;
const DEFAULT_TARGET: &str = "x86_64-unknown-linux-gnu";
macro_rules! pkg_type {
( $($variant:ident = $component:literal $(; preview = true $(@$is_preview:tt)? )? ),+ $(,)? ) => {
( $($variant:ident = $component:literal $(; preview = true $(@$is_preview:tt)? )? $(; suffixes = [$($suffixes:literal),+] $(@$is_suffixed:tt)? )? ),+ $(,)? ) => {
#[derive(Debug, Hash, Eq, PartialEq, Clone)]
pub(crate) enum PkgType {
$($variant,)+
$($variant $( $($is_suffixed)? { suffix: &'static str })?,)+
}
impl PkgType {
pub(crate) fn is_preview(&self) -> bool {
match self {
$( $( $($is_preview)? PkgType::$variant => true, )? )+
_ => false,
$( PkgType::$variant $($($is_suffixed)? { .. })? => false $( $($is_preview)? || true)?, )+
}
}
/// First part of the tarball name.
pub(crate) fn tarball_component_name(&self) -> &str {
/// First part of the tarball name. May include a suffix, if the package has one.
pub(crate) fn tarball_component_name(&self) -> String {
match self {
$( PkgType::$variant => $component,)+
$( PkgType::$variant $($($is_suffixed)? { suffix })? => {
#[allow(unused_mut)]
let mut name = $component.to_owned();
$($($is_suffixed)?
name.push('-');
name.push_str(suffix);
)?
name
},)+
}
}
pub(crate) fn all() -> &'static [PkgType] {
&[ $(PkgType::$variant),+ ]
pub(crate) fn all() -> Vec<PkgType> {
let mut packages = vec![];
$(
// Push the single variant
packages.push(PkgType::$variant $($($is_suffixed)? { suffix: "" })?);
// Macro hell, we have to remove the fake empty suffix if we actually have
// suffixes
$(
$($is_suffixed)?
packages.pop();
)?
// And now add the suffixes, if any
$(
$($is_suffixed)?
$(
packages.push(PkgType::$variant { suffix: $suffixes });
)+
)?
)+
packages
}
}
}
@ -59,6 +84,10 @@ pkg_type! {
JsonDocs = "rust-docs-json"; preview = true,
RustcCodegenCranelift = "rustc-codegen-cranelift"; preview = true,
LlvmBitcodeLinker = "llvm-bitcode-linker"; preview = true,
RustcCodegenGcc = "rustc-codegen-gcc"; preview = true,
Gcc = "gcc"; preview = true; suffixes = [
"x86_64-unknown-linux-gnu"
],
}
impl PkgType {
@ -67,7 +96,7 @@ impl PkgType {
if self.is_preview() {
format!("{}-preview", self.tarball_component_name())
} else {
self.tarball_component_name().to_string()
self.tarball_component_name()
}
}
@ -82,6 +111,8 @@ impl PkgType {
PkgType::LlvmTools => false,
PkgType::Miri => false,
PkgType::RustcCodegenCranelift => false,
PkgType::RustcCodegenGcc => false,
PkgType::Gcc { suffix: _ } => false,
PkgType::Rust => true,
PkgType::RustStd => true,
@ -111,6 +142,14 @@ impl PkgType {
RustcDocs => HOSTS,
Cargo => HOSTS,
RustcCodegenCranelift => HOSTS,
RustcCodegenGcc => HOSTS,
// Gcc is "special", because we need a separate libgccjit.so for each
// (host, target) compilation pair. So it's even more special than stdlib, which has a
// separate component per target. This component thus hardcodes its compilation
// target in its name, and we thus ship it for HOSTS only. So we essentially have
// gcc-T1, gcc-T2, a separate *component/package* per each compilation target.
// So on host T1, if you want to compile for T2, you would install gcc-T2.
Gcc { suffix: _ } => HOSTS,
RustMingw => MINGW,
RustStd => TARGETS,
HtmlDocs => HOSTS,

View file

@ -1,6 +0,0 @@
//@ known-bug: #137084
#![feature(min_generic_const_args)]
fn a<const b: i32>() {}
fn d(e: &String) {
a::<d>
}

View file

@ -0,0 +1,14 @@
// Regression test for https://github.com/rust-lang/rust/issues/137084
// Previously caused ICE when using function item as const generic argument
#![feature(min_generic_const_args)]
#![allow(incomplete_features)]
fn a<const b: i32>() {}
fn d(e: &String) {
a::<d>
//~^ ERROR mismatched types
//~| ERROR the constant `d` is not of type `i32`
}
fn main() {}

View file

@ -0,0 +1,35 @@
error[E0308]: mismatched types
--> $DIR/fn-item-as-const-arg-137084.rs:9:5
|
LL | fn a<const b: i32>() {}
| -------------------- function `a` defined here
LL | fn d(e: &String) {
LL | a::<d>
| ^^^^^^ expected `()`, found fn item
|
= note: expected unit type `()`
found fn item `fn() {a::<d>}`
help: try adding a return type
|
LL | fn d(e: &String) -> fn() {
| +++++++
help: use parentheses to call this function
|
LL | a::<d>()
| ++
error: the constant `d` is not of type `i32`
--> $DIR/fn-item-as-const-arg-137084.rs:9:9
|
LL | a::<d>
| ^ expected `i32`, found fn item
|
note: required by a const generic parameter in `a`
--> $DIR/fn-item-as-const-arg-137084.rs:7:6
|
LL | fn a<const b: i32>() {}
| ^^^^^^^^^^^^ required by this const generic parameter in `a`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.

View file

@ -0,0 +1,16 @@
// Regression test for https://github.com/rust-lang/rust/issues/151186
#![feature(min_generic_const_args)]
#![allow(incomplete_features)]
trait Maybe<T> {}
trait MyTrait<const F: fn() -> ()> {}
//~^ ERROR using function pointers as const generic parameters is forbidden
fn foo<'a>(x: &'a ()) -> &'a () { x }
impl<T> Maybe<T> for T where T: MyTrait<{ foo }> {}
//~^ ERROR the constant `foo` is not of type `fn()`
fn main() {}

View file

@ -0,0 +1,22 @@
error: using function pointers as const generic parameters is forbidden
--> $DIR/ice-151186-fn-ptr-in-where-clause.rs:8:24
|
LL | trait MyTrait<const F: fn() -> ()> {}
| ^^^^^^^^^^
|
= note: the only supported types are integers, `bool`, and `char`
error: the constant `foo` is not of type `fn()`
--> $DIR/ice-151186-fn-ptr-in-where-clause.rs:13:33
|
LL | impl<T> Maybe<T> for T where T: MyTrait<{ foo }> {}
| ^^^^^^^^^^^^^^^^ expected fn pointer, found fn item
|
note: required by a const generic parameter in `MyTrait`
--> $DIR/ice-151186-fn-ptr-in-where-clause.rs:8:15
|
LL | trait MyTrait<const F: fn() -> ()> {}
| ^^^^^^^^^^^^^^^^^^^ required by this const generic parameter in `MyTrait`
error: aborting due to 2 previous errors

View file

@ -908,26 +908,26 @@ mod no_main_1 {
#[no_builtins]
//~^ WARN crate-level attribute should be an inner attribute
//~| HELP add a `!`
mod no_builtins {
//~^ NOTE: this attribute does not have an `!`, which means it is applied to this module
mod inner { #![no_builtins] }
//~^ WARN crate-level attribute should be in the root module
//~^ WARN the `#![no_builtins]` attribute can only be used at the crate root
#[no_builtins] fn f() { }
//~^ WARN crate-level attribute should be an inner attribute
//~| HELP add a `!`
//~| NOTE this attribute does not have an `!`, which means it is applied to this function
#[no_builtins] struct S;
//~^ WARN crate-level attribute should be an inner attribute
//~| HELP add a `!`
//~| NOTE this attribute does not have an `!`, which means it is applied to this struct
#[no_builtins] type T = S;
//~^ WARN crate-level attribute should be an inner attribute
//~| HELP add a `!`
//~| NOTE this attribute does not have an `!`, which means it is applied to this type alias
#[no_builtins] impl S { }
//~^ WARN crate-level attribute should be an inner attribute
//~| HELP add a `!`
//~| NOTE this attribute does not have an `!`, which means it is applied to this implementation
}
#[recursion_limit="0200"]

View file

@ -240,17 +240,6 @@ help: add a `!`
LL | #![feature(x0600)]
| +
warning: crate-level attribute should be an inner attribute
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:909:1
|
LL | #[no_builtins]
| ^^^^^^^^^^^^^^
|
help: add a `!`
|
LL | #![no_builtins]
| +
warning: attribute should be applied to an `extern` block with non-Rust ABI
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:71:1
|
@ -465,56 +454,6 @@ help: add a `!`
LL | #![feature(x0600)] impl S { }
| +
warning: crate-level attribute should be in the root module
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:913:17
|
LL | mod inner { #![no_builtins] }
| ^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:916:5
|
LL | #[no_builtins] fn f() { }
| ^^^^^^^^^^^^^^
|
help: add a `!`
|
LL | #![no_builtins] fn f() { }
| +
warning: crate-level attribute should be an inner attribute
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:920:5
|
LL | #[no_builtins] struct S;
| ^^^^^^^^^^^^^^
|
help: add a `!`
|
LL | #![no_builtins] struct S;
| +
warning: crate-level attribute should be an inner attribute
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:924:5
|
LL | #[no_builtins] type T = S;
| ^^^^^^^^^^^^^^
|
help: add a `!`
|
LL | #![no_builtins] type T = S;
| +
warning: crate-level attribute should be an inner attribute
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:928:5
|
LL | #[no_builtins] impl S { }
| ^^^^^^^^^^^^^^
|
help: add a `!`
|
LL | #![no_builtins] impl S { }
| +
warning: `#[macro_use]` attribute cannot be used on functions
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:190:5
|
@ -1416,6 +1355,76 @@ note: this attribute does not have an `!`, which means it is applied to this imp
LL | #[no_main] impl S { }
| ^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_builtins]`
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:909:1
|
LL | #[no_builtins]
| ^^^^^^^^^^^^^^
|
note: this attribute does not have an `!`, which means it is applied to this module
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:911:1
|
LL | / mod no_builtins {
LL | |
LL | | mod inner { #![no_builtins] }
... |
LL | | }
| |_^
warning: the `#![no_builtins]` attribute can only be used at the crate root
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:913:17
|
LL | mod inner { #![no_builtins] }
| ^^^^^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_builtins]`
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:916:5
|
LL | #[no_builtins] fn f() { }
| ^^^^^^^^^^^^^^
|
note: this attribute does not have an `!`, which means it is applied to this function
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:916:20
|
LL | #[no_builtins] fn f() { }
| ^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_builtins]`
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:920:5
|
LL | #[no_builtins] struct S;
| ^^^^^^^^^^^^^^
|
note: this attribute does not have an `!`, which means it is applied to this struct
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:920:20
|
LL | #[no_builtins] struct S;
| ^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_builtins]`
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:924:5
|
LL | #[no_builtins] type T = S;
| ^^^^^^^^^^^^^^
|
note: this attribute does not have an `!`, which means it is applied to this type alias
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:924:20
|
LL | #[no_builtins] type T = S;
| ^^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![no_builtins]`
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:928:5
|
LL | #[no_builtins] impl S { }
| ^^^^^^^^^^^^^^
|
note: this attribute does not have an `!`, which means it is applied to this implementation block
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:928:20
|
LL | #[no_builtins] impl S { }
| ^^^^^^^^^^
warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![recursion_limit]`
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:933:1
|

View file

@ -16,18 +16,6 @@ note: the lint level is defined here
LL | #![deny(unused_attributes)]
| ^^^^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr-duplicate.rs:34:1
|
LL | #![no_builtins]
| ^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/unused-attr-duplicate.rs:33:1
|
LL | #![no_builtins]
| ^^^^^^^^^^^^^^^
error: unused attribute
--> $DIR/unused-attr-duplicate.rs:37:1
|
@ -316,5 +304,17 @@ LL | #![windows_subsystem = "console"]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
error: unused attribute
--> $DIR/unused-attr-duplicate.rs:34:1
|
LL | #![no_builtins]
| ^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/unused-attr-duplicate.rs:33:1
|
LL | #![no_builtins]
| ^^^^^^^^^^^^^^^
error: aborting due to 25 previous errors