Skip to content

Commit d659758

Browse files
authored
Merge pull request #4730 from RalfJung/rustup
Rustup
2 parents 9a26fb2 + ff0910a commit d659758

File tree

1,359 files changed

+18690
-12115
lines changed

Some content is hidden

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

1,359 files changed

+18690
-12115
lines changed

bootstrap.example.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,11 @@
220220
# which is also used in places like debuginfo `DW_AT_producer`. This may be useful for
221221
# supplementary build information, like distro-specific package versions.
222222
#
223+
# IMPORTANT: Changing this value changes crate IDs and symbol name mangling, making
224+
# compiled artifacts incompatible. PGO profiles cannot be reused across different
225+
# descriptions, and incremental compilation caches are invalidated. Keep this value
226+
# consistent when reusing build artifacts.
227+
#
223228
# The Rust compiler will differentiate between versions of itself, including
224229
# based on this string, which means that if you wish to be compatible with
225230
# upstream Rust you need to set this to "". However, note that if you set this to "" but

compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -857,15 +857,15 @@ impl BindingMode {
857857
}
858858
}
859859

860-
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
860+
#[derive(Clone, Copy, Encodable, Decodable, Debug, Walkable)]
861861
pub enum RangeEnd {
862862
/// `..=` or `...`
863863
Included(RangeSyntax),
864864
/// `..`
865865
Excluded,
866866
}
867867

868-
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
868+
#[derive(Clone, Copy, Encodable, Decodable, Debug, Walkable)]
869869
pub enum RangeSyntax {
870870
/// `...`
871871
DotDotDot,
@@ -1915,7 +1915,7 @@ pub enum ForLoopKind {
19151915
}
19161916

19171917
/// Used to differentiate between `async {}` blocks and `gen {}` blocks.
1918-
#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq, Walkable)]
1918+
#[derive(Clone, Copy, Encodable, Decodable, Debug, PartialEq, Eq, Walkable)]
19191919
pub enum GenBlockKind {
19201920
Async,
19211921
Gen,
@@ -2513,8 +2513,6 @@ pub enum TyKind {
25132513
ImplTrait(NodeId, #[visitable(extra = BoundKind::Impl)] GenericBounds),
25142514
/// No-op; kept solely so that we can pretty-print faithfully.
25152515
Paren(Box<Ty>),
2516-
/// Unused for now.
2517-
Typeof(AnonConst),
25182516
/// This means the type should be inferred instead of it having been
25192517
/// specified. This can appear anywhere in a type.
25202518
Infer,

compiler/rustc_ast/src/util/classify.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ fn type_trailing_braced_mac_call(mut ty: &ast::Ty) -> Option<&ast::MacCall> {
294294
| ast::TyKind::Never
295295
| ast::TyKind::Tup(..)
296296
| ast::TyKind::Paren(..)
297-
| ast::TyKind::Typeof(..)
298297
| ast::TyKind::Infer
299298
| ast::TyKind::ImplicitSelf
300299
| ast::TyKind::CVarArgs

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13671367
self.lower_ty(ty, itctx),
13681368
self.lower_array_length_to_const_arg(length),
13691369
),
1370-
TyKind::Typeof(expr) => hir::TyKind::Typeof(self.lower_anon_const_to_anon_const(expr)),
13711370
TyKind::TraitObject(bounds, kind) => {
13721371
let mut lifetime_bound = None;
13731372
let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {

compiler/rustc_ast_passes/messages.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ ast_passes_const_and_coroutine = functions cannot be both `const` and `{$corouti
8989
.coroutine = `{$coroutine_kind}` because of this
9090
.label = {""}
9191
92+
ast_passes_const_auto_trait = auto traits cannot be const
93+
.help = remove the `const` keyword
94+
9295
ast_passes_const_bound_trait_object = const trait bounds are not allowed in trait object types
9396
9497
ast_passes_const_without_body =

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,12 @@ impl<'a> AstValidator<'a> {
820820
self.dcx().emit_err(errors::ModuleNonAscii { span: ident.span, name: ident.name });
821821
}
822822

823+
fn deny_const_auto_traits(&self, constness: Const) {
824+
if let Const::Yes(span) = constness {
825+
self.dcx().emit_err(errors::ConstAutoTrait { span });
826+
}
827+
}
828+
823829
fn deny_generic_params(&self, generics: &Generics, ident_span: Span) {
824830
if !generics.params.is_empty() {
825831
self.dcx()
@@ -1257,6 +1263,8 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
12571263
}) => {
12581264
self.visit_attrs_vis_ident(&item.attrs, &item.vis, ident);
12591265
if *is_auto == IsAuto::Yes {
1266+
// For why we reject `const auto trait`, see rust-lang/rust#149285.
1267+
self.deny_const_auto_traits(*constness);
12601268
// Auto traits cannot have generics, super traits nor contain items.
12611269
self.deny_generic_params(generics, ident.span);
12621270
self.deny_super_traits(bounds, ident.span);

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,14 @@ pub(crate) struct AutoTraitItems {
429429
pub ident: Span,
430430
}
431431

432+
#[derive(Diagnostic)]
433+
#[diag(ast_passes_const_auto_trait)]
434+
#[help]
435+
pub(crate) struct ConstAutoTrait {
436+
#[primary_span]
437+
pub span: Span,
438+
}
439+
432440
#[derive(Diagnostic)]
433441
#[diag(ast_passes_generic_before_constraints)]
434442
pub(crate) struct ArgsBeforeConstraint {

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,11 +1325,6 @@ impl<'a> State<'a> {
13251325
self.print_expr(&length.value, FixupContext::default());
13261326
self.word("]");
13271327
}
1328-
ast::TyKind::Typeof(e) => {
1329-
self.word("typeof(");
1330-
self.print_expr(&e.value, FixupContext::default());
1331-
self.word(")");
1332-
}
13331328
ast::TyKind::Infer => {
13341329
self.word("_");
13351330
}

compiler/rustc_attr_parsing/src/attributes/crate_level.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use rustc_hir::attrs::WindowsSubsystemKind;
2+
13
use super::prelude::*;
24

35
pub(crate) struct CrateNameParser;
@@ -142,3 +144,34 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcCoherenceIsCoreParser {
142144
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::CrateLevel;
143145
const CREATE: fn(Span) -> AttributeKind = AttributeKind::RustcCoherenceIsCore;
144146
}
147+
148+
pub(crate) struct WindowsSubsystemParser;
149+
150+
impl<S: Stage> SingleAttributeParser<S> for WindowsSubsystemParser {
151+
const PATH: &[Symbol] = &[sym::windows_subsystem];
152+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
153+
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepOutermost;
154+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::CrateLevel;
155+
const TEMPLATE: AttributeTemplate = template!(NameValueStr: ["windows", "console"], "https://doc.rust-lang.org/reference/runtime.html#the-windows_subsystem-attribute");
156+
157+
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
158+
let Some(nv) = args.name_value() else {
159+
cx.expected_name_value(
160+
args.span().unwrap_or(cx.inner_span),
161+
Some(sym::windows_subsystem),
162+
);
163+
return None;
164+
};
165+
166+
let kind = match nv.value_as_str() {
167+
Some(sym::console) => WindowsSubsystemKind::Console,
168+
Some(sym::windows) => WindowsSubsystemKind::Windows,
169+
Some(_) | None => {
170+
cx.expected_specific_argument_strings(nv.value_span, &[sym::console, sym::windows]);
171+
return None;
172+
}
173+
};
174+
175+
Some(AttributeKind::WindowsSubsystem(kind, cx.attr_span))
176+
}
177+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use crate::attributes::confusables::ConfusablesParser;
2828
use crate::attributes::crate_level::{
2929
CrateNameParser, MoveSizeLimitParser, NoCoreParser, NoStdParser, PatternComplexityLimitParser,
3030
RecursionLimitParser, RustcCoherenceIsCoreParser, TypeLengthLimitParser,
31+
WindowsSubsystemParser,
3132
};
3233
use crate::attributes::debugger::DebuggerViualizerParser;
3334
use crate::attributes::deprecation::DeprecationParser;
@@ -211,6 +212,7 @@ attribute_parsers!(
211212
Single<SkipDuringMethodDispatchParser>,
212213
Single<TransparencyParser>,
213214
Single<TypeLengthLimitParser>,
215+
Single<WindowsSubsystemParser>,
214216
Single<WithoutArgs<AllowIncoherentImplParser>>,
215217
Single<WithoutArgs<AllowInternalUnsafeParser>>,
216218
Single<WithoutArgs<AsPtrParser>>,

0 commit comments

Comments
 (0)