Skip to content

Commit 8a961ad

Browse files
authored
Merge branch 'rust-lang:main' into main
2 parents 1e1de80 + 61cc47e commit 8a961ad

File tree

995 files changed

+19034
-11244
lines changed

Some content is hidden

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

995 files changed

+19034
-11244
lines changed

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ Lzu Tao <taolzu@gmail.com>
431431
Maik Klein <maikklein@googlemail.com>
432432
Maja Kądziołka <maya@compilercrim.es> <github@compilercrim.es>
433433
Maja Kądziołka <maya@compilercrim.es> <kuba@kadziolka.net>
434+
Makai <m4kai410@gmail.com>
434435
Malo Jaffré <jaffre.malo@gmail.com>
435436
Manish Goregaokar <manishsmail@gmail.com>
436437
Mara Bos <m-ou.se@m-ou.se>

Cargo.lock

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
621621

622622
[[package]]
623623
name = "clippy"
624-
version = "0.1.93"
624+
version = "0.1.94"
625625
dependencies = [
626626
"anstream",
627627
"askama",
@@ -648,7 +648,7 @@ dependencies = [
648648

649649
[[package]]
650650
name = "clippy_config"
651-
version = "0.1.93"
651+
version = "0.1.94"
652652
dependencies = [
653653
"clippy_utils",
654654
"itertools",
@@ -671,7 +671,7 @@ dependencies = [
671671

672672
[[package]]
673673
name = "clippy_lints"
674-
version = "0.1.93"
674+
version = "0.1.94"
675675
dependencies = [
676676
"arrayvec",
677677
"cargo_metadata 0.18.1",
@@ -703,7 +703,7 @@ dependencies = [
703703

704704
[[package]]
705705
name = "clippy_utils"
706-
version = "0.1.93"
706+
version = "0.1.94"
707707
dependencies = [
708708
"arrayvec",
709709
"itertools",
@@ -1107,7 +1107,7 @@ dependencies = [
11071107

11081108
[[package]]
11091109
name = "declare_clippy_lint"
1110-
version = "0.1.93"
1110+
version = "0.1.94"
11111111

11121112
[[package]]
11131113
name = "derive-where"
@@ -3613,6 +3613,7 @@ dependencies = [
36133613
"gimli 0.31.1",
36143614
"itertools",
36153615
"libc",
3616+
"libloading 0.9.0",
36163617
"measureme",
36173618
"object 0.37.3",
36183619
"rustc-demangle",
@@ -4630,7 +4631,6 @@ dependencies = [
46304631
name = "rustc_session"
46314632
version = "0.0.0"
46324633
dependencies = [
4633-
"bitflags",
46344634
"getopts",
46354635
"libc",
46364636
"rand 0.9.2",
@@ -4657,6 +4657,7 @@ dependencies = [
46574657
name = "rustc_span"
46584658
version = "0.0.0"
46594659
dependencies = [
4660+
"bitflags",
46604661
"blake3",
46614662
"derive-where",
46624663
"indexmap",

bootstrap.example.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,31 @@
191191
# Currently, this is only supported for the `x86_64-unknown-linux-gnu` target.
192192
#gcc.download-ci-gcc = false
193193

194+
# Provide a directory of prebuilt libgccjit.so dylibs for given (host, target) compilation pairs.
195+
# This is useful when you want to cross-compile `rustc` to another target since GCC is not a
196+
# multi-target compiler.
197+
# You have to use a directory structure that looks like this:
198+
# `<libgccjit-libs-dir>/<host>/<target>/libgccjit.so`.
199+
# For example:
200+
#
201+
# ```
202+
# <libgccjit-libs-dir>
203+
# ├── m68k-unknown-linux-gnu
204+
# │ └── m68k-unknown-linux-gnu
205+
# │ └── libgccjit.so
206+
# └── x86_64-unknown-linux-gnu
207+
# ├── m68k-unknown-linux-gnu
208+
# │ └── libgccjit.so
209+
# └── x86_64-unknown-linux-gnu
210+
# └── libgccjit.so
211+
# ```
212+
# The directory above would allow you to cross-compile rustc from x64 to m68k
213+
#
214+
# Note that this option has priority over `gcc.download-ci-gcc`.
215+
# If you set both, bootstrap will first try to load libgccjit.so from this directory.
216+
# Only if it isn't found, it will try to download it from CI or build it locally.
217+
#gcc.libgccjit-libs-dir = "/path/to/libgccjit-libs-dir"
218+
194219
# =============================================================================
195220
# General build configuration options
196221
# =============================================================================

compiler/rustc_ast/src/ast.rs

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,11 @@ impl Path {
141141
/// Check if this path is potentially a trivial const arg, i.e., one that can _potentially_
142142
/// be represented without an anon const in the HIR.
143143
///
144-
/// If `allow_mgca_arg` is true (as should be the case in most situations when
145-
/// `#![feature(min_generic_const_args)]` is enabled), then this always returns true
146-
/// because all paths are valid.
147-
///
148-
/// Otherwise, it returns true iff the path has exactly one segment, and it has no generic args
144+
/// Returns true iff the path has exactly one segment, and it has no generic args
149145
/// (i.e., it is _potentially_ a const parameter).
150146
#[tracing::instrument(level = "debug", ret)]
151-
pub fn is_potential_trivial_const_arg(&self, allow_mgca_arg: bool) -> bool {
152-
allow_mgca_arg
153-
|| self.segments.len() == 1 && self.segments.iter().all(|seg| seg.args.is_none())
147+
pub fn is_potential_trivial_const_arg(&self) -> bool {
148+
self.segments.len() == 1 && self.segments.iter().all(|seg| seg.args.is_none())
154149
}
155150
}
156151

@@ -1385,6 +1380,15 @@ pub enum UnsafeSource {
13851380
UserProvided,
13861381
}
13871382

1383+
/// Track whether under `feature(min_generic_const_args)` this anon const
1384+
/// was explicitly disambiguated as an anon const or not through the use of
1385+
/// `const { ... }` syntax.
1386+
#[derive(Clone, PartialEq, Encodable, Decodable, Debug, Copy, Walkable)]
1387+
pub enum MgcaDisambiguation {
1388+
AnonConst,
1389+
Direct,
1390+
}
1391+
13881392
/// A constant (expression) that's not an item or associated item,
13891393
/// but needs its own `DefId` for type-checking, const-eval, etc.
13901394
/// These are usually found nested inside types (e.g., array lengths)
@@ -1394,6 +1398,7 @@ pub enum UnsafeSource {
13941398
pub struct AnonConst {
13951399
pub id: NodeId,
13961400
pub value: Box<Expr>,
1401+
pub mgca_disambiguation: MgcaDisambiguation,
13971402
}
13981403

13991404
/// An expression.
@@ -1412,26 +1417,20 @@ impl Expr {
14121417
///
14131418
/// This will unwrap at most one block level (curly braces). After that, if the expression
14141419
/// is a path, it mostly dispatches to [`Path::is_potential_trivial_const_arg`].
1415-
/// See there for more info about `allow_mgca_arg`.
14161420
///
1417-
/// The only additional thing to note is that when `allow_mgca_arg` is false, this function
1418-
/// will only allow paths with no qself, before dispatching to the `Path` function of
1419-
/// the same name.
1421+
/// This function will only allow paths with no qself, before dispatching to the `Path`
1422+
/// function of the same name.
14201423
///
14211424
/// Does not ensure that the path resolves to a const param/item, the caller should check this.
14221425
/// This also does not consider macros, so it's only correct after macro-expansion.
1423-
pub fn is_potential_trivial_const_arg(&self, allow_mgca_arg: bool) -> bool {
1426+
pub fn is_potential_trivial_const_arg(&self) -> bool {
14241427
let this = self.maybe_unwrap_block();
1425-
if allow_mgca_arg {
1426-
matches!(this.kind, ExprKind::Path(..))
1428+
if let ExprKind::Path(None, path) = &this.kind
1429+
&& path.is_potential_trivial_const_arg()
1430+
{
1431+
true
14271432
} else {
1428-
if let ExprKind::Path(None, path) = &this.kind
1429-
&& path.is_potential_trivial_const_arg(allow_mgca_arg)
1430-
{
1431-
true
1432-
} else {
1433-
false
1434-
}
1433+
false
14351434
}
14361435
}
14371436

@@ -1534,11 +1533,10 @@ impl Expr {
15341533
// then type of result is trait object.
15351534
// Otherwise we don't assume the result type.
15361535
ExprKind::Binary(binop, lhs, rhs) if binop.node == BinOpKind::Add => {
1537-
if let (Some(lhs), Some(rhs)) = (lhs.to_bound(), rhs.to_bound()) {
1538-
TyKind::TraitObject(vec![lhs, rhs], TraitObjectSyntax::None)
1539-
} else {
1536+
let (Some(lhs), Some(rhs)) = (lhs.to_bound(), rhs.to_bound()) else {
15401537
return None;
1541-
}
1538+
};
1539+
TyKind::TraitObject(vec![lhs, rhs], TraitObjectSyntax::None)
15421540
}
15431541

15441542
ExprKind::Underscore => TyKind::Infer,
@@ -2109,6 +2107,19 @@ pub struct MacroDef {
21092107
pub body: Box<DelimArgs>,
21102108
/// `true` if macro was defined with `macro_rules`.
21112109
pub macro_rules: bool,
2110+
2111+
/// If this is a macro used for externally implementable items,
2112+
/// it refers to an extern item which is its "target". This requires
2113+
/// name resolution so can't just be an attribute, so we store it in this field.
2114+
pub eii_extern_target: Option<EiiExternTarget>,
2115+
}
2116+
2117+
#[derive(Clone, Encodable, Decodable, Debug, HashStable_Generic, Walkable)]
2118+
pub struct EiiExternTarget {
2119+
/// path to the extern item we're targetting
2120+
pub extern_item_path: Path,
2121+
pub impl_unsafe: bool,
2122+
pub span: Span,
21122123
}
21132124

21142125
#[derive(Clone, Encodable, Decodable, Debug, Copy, Hash, Eq, PartialEq)]
@@ -3748,6 +3759,21 @@ pub struct Fn {
37483759
pub contract: Option<Box<FnContract>>,
37493760
pub define_opaque: Option<ThinVec<(NodeId, Path)>>,
37503761
pub body: Option<Box<Block>>,
3762+
3763+
/// This function is an implementation of an externally implementable item (EII).
3764+
/// This means, there was an EII declared somewhere and this function is the
3765+
/// implementation that should be run when the declaration is called.
3766+
pub eii_impls: ThinVec<EiiImpl>,
3767+
}
3768+
3769+
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
3770+
pub struct EiiImpl {
3771+
pub node_id: NodeId,
3772+
pub eii_macro_path: Path,
3773+
pub impl_safety: Safety,
3774+
pub span: Span,
3775+
pub inner_span: Span,
3776+
pub is_default: bool,
37513777
}
37523778

37533779
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
@@ -4114,7 +4140,7 @@ mod size_asserts {
41144140
static_assert_size!(Block, 32);
41154141
static_assert_size!(Expr, 72);
41164142
static_assert_size!(ExprKind, 40);
4117-
static_assert_size!(Fn, 184);
4143+
static_assert_size!(Fn, 192);
41184144
static_assert_size!(ForeignItem, 80);
41194145
static_assert_size!(ForeignItemKind, 16);
41204146
static_assert_size!(GenericArg, 24);

compiler/rustc_ast/src/attr/mod.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -447,20 +447,17 @@ impl MetaItem {
447447
thin_vec![PathSegment::path_root(span)]
448448
};
449449
loop {
450-
if let Some(&TokenTree::Token(Token { kind: token::Ident(name, _), span }, _)) =
450+
let Some(&TokenTree::Token(Token { kind: token::Ident(name, _), span }, _)) =
451451
iter.next().map(|tt| TokenTree::uninterpolate(tt)).as_deref()
452-
{
453-
segments.push(PathSegment::from_ident(Ident::new(name, span)));
454-
} else {
452+
else {
455453
return None;
456-
}
457-
if let Some(TokenTree::Token(Token { kind: token::PathSep, .. }, _)) =
458-
iter.peek()
459-
{
460-
iter.next();
461-
} else {
454+
};
455+
segments.push(PathSegment::from_ident(Ident::new(name, span)));
456+
let Some(TokenTree::Token(Token { kind: token::PathSep, .. }, _)) = iter.peek()
457+
else {
462458
break;
463-
}
459+
};
460+
iter.next();
464461
}
465462
let span = span.with_hi(segments.last().unwrap().ident.span.hi());
466463
Path { span, segments, tokens: None }

compiler/rustc_ast/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
// tidy-alphabetical-start
88
#![cfg_attr(bootstrap, feature(array_windows))]
9+
#![deny(clippy::manual_let_else)]
910
#![doc(test(attr(deny(warnings), allow(internal_features))))]
1011
#![feature(associated_type_defaults)]
1112
#![feature(box_patterns)]

compiler/rustc_ast/src/visit.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ macro_rules! common_visitor_and_walkers {
393393
ThinVec<Pat>,
394394
ThinVec<Box<Ty>>,
395395
ThinVec<TyPat>,
396+
ThinVec<EiiImpl>,
396397
);
397398

398399
// This macro generates `impl Visitable` and `impl MutVisitable` that forward to `Walkable`
@@ -415,6 +416,7 @@ macro_rules! common_visitor_and_walkers {
415416
UnsafeBinderCastKind,
416417
BinOpKind,
417418
BlockCheckMode,
419+
MgcaDisambiguation,
418420
BorrowKind,
419421
BoundAsyncness,
420422
BoundConstness,
@@ -485,6 +487,8 @@ macro_rules! common_visitor_and_walkers {
485487
WhereEqPredicate,
486488
WhereRegionPredicate,
487489
YieldKind,
490+
EiiExternTarget,
491+
EiiImpl,
488492
);
489493

490494
/// Each method of this trait is a hook to be potentially
@@ -919,13 +923,13 @@ macro_rules! common_visitor_and_walkers {
919923
_ctxt,
920924
// Visibility is visited as a part of the item.
921925
_vis,
922-
Fn { defaultness, ident, sig, generics, contract, body, define_opaque },
926+
Fn { defaultness, ident, sig, generics, contract, body, define_opaque, eii_impls },
923927
) => {
924928
let FnSig { header, decl, span } = sig;
925929
visit_visitable!($($mut)? vis,
926930
defaultness, ident, header, generics, decl,
927-
contract, body, span, define_opaque
928-
)
931+
contract, body, span, define_opaque, eii_impls
932+
);
929933
}
930934
FnKind::Closure(binder, coroutine_kind, decl, body) =>
931935
visit_visitable!($($mut)? vis, binder, coroutine_kind, decl, body),

0 commit comments

Comments
 (0)