Skip to content

Commit 7a41eac

Browse files
committed
Auto merge of rust-lang#2885 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 7fb4332 + 68c7d20 commit 7a41eac

File tree

610 files changed

+16522
-6465
lines changed

Some content is hidden

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

610 files changed

+16522
-6465
lines changed

Cargo.lock

+38-6
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,13 @@ dependencies = [
14431443
"serde_json",
14441444
]
14451445

1446+
[[package]]
1447+
name = "generate-windows-sys"
1448+
version = "0.1.0"
1449+
dependencies = [
1450+
"windows-bindgen",
1451+
]
1452+
14461453
[[package]]
14471454
name = "generic-array"
14481455
version = "0.14.4"
@@ -1546,9 +1553,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
15461553
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
15471554
dependencies = [
15481555
"ahash 0.7.4",
1549-
"compiler_builtins",
1550-
"rustc-std-workspace-alloc",
1551-
"rustc-std-workspace-core",
15521556
]
15531557

15541558
[[package]]
@@ -1558,6 +1562,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
15581562
checksum = "33ff8ae62cd3a9102e5637afc8452c55acf3844001bd5374e0b0bd7b6616c038"
15591563
dependencies = [
15601564
"ahash 0.8.2",
1565+
"compiler_builtins",
1566+
"rustc-std-workspace-alloc",
1567+
"rustc-std-workspace-core",
15611568
]
15621569

15631570
[[package]]
@@ -1938,9 +1945,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
19381945

19391946
[[package]]
19401947
name = "libc"
1941-
version = "0.2.142"
1948+
version = "0.2.143"
19421949
source = "registry+https://github.com/rust-lang/crates.io-index"
1943-
checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317"
1950+
checksum = "edc207893e85c5d6be840e969b496b53d94cec8be2d501b214f50daa97fa8024"
19441951
dependencies = [
19451952
"rustc-std-workspace-core",
19461953
]
@@ -3353,6 +3360,7 @@ dependencies = [
33533360
"rustc_middle",
33543361
"rustc_mir_build",
33553362
"rustc_mir_dataflow",
3363+
"rustc_mir_transform",
33563364
"rustc_monomorphize",
33573365
"rustc_parse",
33583366
"rustc_passes",
@@ -3861,8 +3869,10 @@ dependencies = [
38613869
"rustc_const_eval",
38623870
"rustc_data_structures",
38633871
"rustc_errors",
3872+
"rustc_fluent_macro",
38643873
"rustc_hir",
38653874
"rustc_index",
3875+
"rustc_macros",
38663876
"rustc_middle",
38673877
"rustc_mir_dataflow",
38683878
"rustc_serialize",
@@ -4607,7 +4617,7 @@ dependencies = [
46074617
"core",
46084618
"dlmalloc",
46094619
"fortanix-sgx-abi",
4610-
"hashbrown 0.12.3",
4620+
"hashbrown 0.13.1",
46114621
"hermit-abi 0.3.0",
46124622
"libc",
46134623
"miniz_oxide",
@@ -5506,6 +5516,22 @@ dependencies = [
55065516
"windows-targets 0.48.0",
55075517
]
55085518

5519+
[[package]]
5520+
name = "windows-bindgen"
5521+
version = "0.49.0"
5522+
source = "registry+https://github.com/rust-lang/crates.io-index"
5523+
checksum = "b6935fb09b84ee57929ae92518b475f5dfdfbeb87c5334756acc28ee8e202b60"
5524+
dependencies = [
5525+
"windows-metadata",
5526+
"windows-tokens",
5527+
]
5528+
5529+
[[package]]
5530+
name = "windows-metadata"
5531+
version = "0.49.0"
5532+
source = "registry+https://github.com/rust-lang/crates.io-index"
5533+
checksum = "2f5bca94a32bf1e6a376522b6601275a3b611ee885ec0f1b6a05f17e8cfd3385"
5534+
55095535
[[package]]
55105536
name = "windows-sys"
55115537
version = "0.42.0"
@@ -5569,6 +5595,12 @@ dependencies = [
55695595
"windows_x86_64_msvc 0.48.0",
55705596
]
55715597

5598+
[[package]]
5599+
name = "windows-tokens"
5600+
version = "0.48.0"
5601+
source = "registry+https://github.com/rust-lang/crates.io-index"
5602+
checksum = "b34c9a3b28cb41db7385546f7f9a8179348dffc89923dde66857b1ba5312f6b4"
5603+
55725604
[[package]]
55735605
name = "windows_aarch64_gnullvm"
55745606
version = "0.42.2"

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ members = [
3939
"src/tools/collect-license-metadata",
4040
"src/tools/generate-copyright",
4141
"src/tools/suggest-tests",
42+
"src/tools/generate-windows-sys",
4243
]
4344

4445
exclude = [

compiler/rustc_ast/src/ast.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ impl Path {
120120
pub fn is_global(&self) -> bool {
121121
!self.segments.is_empty() && self.segments[0].ident.name == kw::PathRoot
122122
}
123+
124+
/// If this path is a single identifier with no arguments, does not ensure
125+
/// that the path resolves to a const param, the caller should check this.
126+
pub fn is_potential_trivial_const_arg(&self) -> bool {
127+
self.segments.len() == 1 && self.segments[0].args.is_none()
128+
}
123129
}
124130

125131
/// A segment of a path: an identifier, an optional lifetime, and a set of types.
@@ -1154,7 +1160,9 @@ impl Expr {
11541160
///
11551161
/// If this is not the case, name resolution does not resolve `N` when using
11561162
/// `min_const_generics` as more complex expressions are not supported.
1157-
pub fn is_potential_trivial_const_param(&self) -> bool {
1163+
///
1164+
/// Does not ensure that the path resolves to a const param, the caller should check this.
1165+
pub fn is_potential_trivial_const_arg(&self) -> bool {
11581166
let this = if let ExprKind::Block(block, None) = &self.kind
11591167
&& block.stmts.len() == 1
11601168
&& let StmtKind::Expr(expr) = &block.stmts[0].kind
@@ -1165,8 +1173,7 @@ impl Expr {
11651173
};
11661174

11671175
if let ExprKind::Path(None, path) = &this.kind
1168-
&& path.segments.len() == 1
1169-
&& path.segments[0].args.is_none()
1176+
&& path.is_potential_trivial_const_arg()
11701177
{
11711178
true
11721179
} else {

compiler/rustc_ast/src/visit.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ pub trait Visitor<'ast>: Sized {
188188
fn visit_variant(&mut self, v: &'ast Variant) {
189189
walk_variant(self, v)
190190
}
191+
fn visit_variant_discr(&mut self, discr: &'ast AnonConst) {
192+
self.visit_anon_const(discr);
193+
}
191194
fn visit_label(&mut self, label: &'ast Label) {
192195
walk_label(self, label)
193196
}
@@ -380,7 +383,7 @@ where
380383
visitor.visit_ident(variant.ident);
381384
visitor.visit_vis(&variant.vis);
382385
visitor.visit_variant_data(&variant.data);
383-
walk_list!(visitor, visit_anon_const, &variant.disr_expr);
386+
walk_list!(visitor, visit_variant_discr, &variant.disr_expr);
384387
walk_list!(visitor, visit_attribute, &variant.attrs);
385388
}
386389

compiler/rustc_ast_lowering/src/format.rs

+24-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,30 @@ fn expand_format_args<'hir>(
446446
&& argmap.iter().enumerate().all(|(i, (&(j, _), _))| i == j)
447447
&& arguments.iter().skip(1).all(|arg| !may_contain_yield_point(&arg.expr));
448448

449-
let args = if use_simple_array {
449+
let args = if arguments.is_empty() {
450+
// Generate:
451+
// &<core::fmt::Argument>::none()
452+
//
453+
// Note:
454+
// `none()` just returns `[]`. We use `none()` rather than `[]` to limit the lifetime.
455+
//
456+
// This makes sure that this still fails to compile, even when the argument is inlined:
457+
//
458+
// ```
459+
// let f = format_args!("{}", "a");
460+
// println!("{f}"); // error E0716
461+
// ```
462+
//
463+
// Cases where keeping the object around is allowed, such as `format_args!("a")`,
464+
// are handled above by the `allow_const` case.
465+
let none_fn = ctx.arena.alloc(ctx.expr_lang_item_type_relative(
466+
macsp,
467+
hir::LangItem::FormatArgument,
468+
sym::none,
469+
));
470+
let none = ctx.expr_call(macsp, none_fn, &[]);
471+
ctx.expr(macsp, hir::ExprKind::AddrOf(hir::BorrowKind::Ref, hir::Mutability::Not, none))
472+
} else if use_simple_array {
450473
// Generate:
451474
// &[
452475
// <core::fmt::Argument>::new_display(&arg0),

compiler/rustc_ast_lowering/src/lib.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1190,13 +1190,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
11901190
// parsing. We try to resolve that ambiguity by attempting resolution in both the
11911191
// type and value namespaces. If we resolved the path in the value namespace, we
11921192
// transform it into a generic const argument.
1193-
TyKind::Path(qself, path) => {
1193+
TyKind::Path(None, path) => {
11941194
if let Some(res) = self
11951195
.resolver
11961196
.get_partial_res(ty.id)
11971197
.and_then(|partial_res| partial_res.full_res())
11981198
{
1199-
if !res.matches_ns(Namespace::TypeNS) {
1199+
if !res.matches_ns(Namespace::TypeNS)
1200+
&& path.is_potential_trivial_const_arg()
1201+
{
12001202
debug!(
12011203
"lower_generic_arg: Lowering type argument as const argument: {:?}",
12021204
ty,
@@ -1218,7 +1220,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12181220

12191221
let path_expr = Expr {
12201222
id: ty.id,
1221-
kind: ExprKind::Path(qself.clone(), path.clone()),
1223+
kind: ExprKind::Path(None, path.clone()),
12221224
span,
12231225
attrs: AttrVec::new(),
12241226
tokens: None,
@@ -1477,20 +1479,22 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14771479
/// Given a function definition like:
14781480
///
14791481
/// ```rust
1482+
/// use std::fmt::Debug;
1483+
///
14801484
/// fn test<'a, T: Debug>(x: &'a T) -> impl Debug + 'a {
14811485
/// x
14821486
/// }
14831487
/// ```
14841488
///
14851489
/// we will create a TAIT definition in the HIR like
14861490
///
1487-
/// ```
1491+
/// ```rust,ignore (pseudo-Rust)
14881492
/// type TestReturn<'a, T, 'x> = impl Debug + 'x
14891493
/// ```
14901494
///
14911495
/// and return a type like `TestReturn<'static, T, 'a>`, so that the function looks like:
14921496
///
1493-
/// ```rust
1497+
/// ```rust,ignore (pseudo-Rust)
14941498
/// fn test<'a, T: Debug>(x: &'a T) -> TestReturn<'static, T, 'a>
14951499
/// ```
14961500
///

compiler/rustc_ast_passes/src/feature_gate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
603603
gate_all!(yeet_expr, "`do yeet` expression is experimental");
604604
gate_all!(dyn_star, "`dyn*` trait objects are experimental");
605605
gate_all!(const_closures, "const closures are experimental");
606+
gate_all!(builtin_syntax, "`builtin #` syntax is unstable");
606607

607608
if !visitor.features.negative_bounds {
608609
for &span in spans.get(&sym::negative_bounds).iter().copied().flatten() {

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,7 @@ impl<'a> State<'a> {
556556
self.pclose();
557557
}
558558
ast::ExprKind::OffsetOf(container, fields) => {
559-
// FIXME: This should have its own syntax, distinct from a macro invocation.
560-
self.word("offset_of!");
559+
self.word("builtin # offset_of");
561560
self.popen();
562561
self.rbox(0, Inconsistent);
563562
self.print_type(container);

0 commit comments

Comments
 (0)