Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
2849153
Implement RangeIntersect on core::range types
GrimlockOnline Nov 7, 2026
1ea503d
Prepare for merging from rust-lang/rust
workflows-miri[bot] Nov 10, 2026
be6f854
Merge ref 'ac8310ba643a' from rust-lang/rust
workflows-miri[bot] Nov 10, 2026
5aefb50
windows SetFileInformationByHandle: use stream_len to get current fil…
RalfJung Nov 10, 2026
e142b37
Merge pull request #5607 from rust-lang/rustup-2026-11-10
RalfJung Nov 10, 2026
ab74d54
Merge pull request #5608 from RalfJung/win-SetFileInformationByHandle
RalfJung Nov 10, 2026
0df5544
Rename `this` to `ecx` in shared socket code
WhySoBad Nov 9, 2026
9c41b09
Rename `this` to `ecx` in socket address shim
WhySoBad Nov 9, 2026
a8edb52
Rename `this` to `ecx` in TCP socket shim
WhySoBad Nov 9, 2026
f34c014
Rename `this` to `ecx` in virtual socket shim
WhySoBad Nov 9, 2026
8afbd0f
Merge pull request #5606 from WhySoBad/socket-this-to-ecx
RalfJung Nov 10, 2026
adaa069
rename this -> ecx in sse41, sse42 intrinsics and time shims
programskillforverification Nov 10, 2026
4d5dd2c
Merge pull request #5610 from programskillforverification/this-to-ecx-4
RalfJung Nov 10, 2026
a8eef01
update triagebot config
RalfJung Nov 10, 2026
41c2b0c
Merge pull request #5612 from RalfJung/triagebot
RalfJung Nov 10, 2026
14e5bd7
rename this -> ecx in poll, sync, thread unix shims and unwind shims
Enfey Nov 10, 2026
0160fd6
Prepare for merging from rust-lang/rust
workflows-miri[bot] Nov 11, 2026
915c8c1
Merge ref '9c5648833e5c' from rust-lang/rust
workflows-miri[bot] Nov 11, 2026
d1c1e29
Merge pull request #5613 from Enfey/rename-this-to-ecx-shims
RalfJung Nov 11, 2026
9eb356b
bless priroda tests
RalfJung Nov 11, 2026
3e91a2c
Merge pull request #5614 from rust-lang/rustup-2026-11-11
RalfJung Nov 11, 2026
e8e856e
Add libc direct tests for unlink and symlink
mehmettoplu-rs Nov 7, 2026
6a8c605
slightly extend test
RalfJung Nov 11, 2026
28b06a6
allow more slack in macos semaphore timeout test
RalfJung Nov 11, 2026
9406beb
Merge pull request #5584 from mehmettoplu-rs/test-unlink-symlink
RalfJung Nov 11, 2026
dc58d21
Add libc direct tests for pthread_atfork and sched_yield
mehmettoplu-rs Nov 11, 2026
2e73ebb
Prepare for merging from rust-lang/rust
workflows-miri[bot] Nov 13, 2026
aea078f
Merge ref '8eb778d04094' from rust-lang/rust
workflows-miri[bot] Nov 13, 2026
94ce7d2
fix lockfile workaround when min-publish-age is set
RalfJung Nov 13, 2026
0a4afdd
bless priroda
RalfJung Nov 13, 2026
417a15d
Merge pull request #5622 from rust-lang/rustup-2026-11-13
RalfJung Nov 13, 2026
ec3d5c5
Merge pull request #5616 from mehmettoplu-rs/test-sched-yield-pthread…
RalfJung Nov 15, 2026
dd95c16
some more this -> ecx
RalfJung Nov 15, 2026
fbb781c
Merge pull request #5627 from RalfJung/ecx
RalfJung Nov 15, 2026
f394280
NULL-terminate argv and add direct tests for _NSGetArgc and _NSGetArgv
mehmettoplu-rs Nov 13, 2026
b6255ac
Extend miri_start_with_std test to check argv[argc] is null
mehmettoplu-rs Nov 15, 2026
39e3586
tweak test
RalfJung Nov 15, 2026
49bc5f3
Merge pull request #5624 from mehmettoplu-rs/argv-null-terminator
RalfJung Nov 15, 2026
06154f0
feat: added more AdtDef queries
adpthegreat Nov 15, 2026
b0fdb91
fix: fixed wrong return type
adpthegreat Nov 15, 2026
6a4efb5
fix : fixed comments
adpthegreat Nov 15, 2026
7a0aab9
Use symbolic alignment checking in the allocator tests
saethlin Nov 13, 2026
0e902ad
Merge pull request #5625 from saethlin/windows-allocator-symbolic-ali…
saethlin Nov 15, 2026
52ba0a8
Add non-blocking `write` and `send` support for UDP sockets
WhySoBad Oct 19, 2026
3cdd90b
Add non-blocking `read` and `recv` support for UDP sockets, add I/O t…
WhySoBad Oct 19, 2026
5a852b5
Rename `make_listener` libc helper to `make_tcp_listener`
WhySoBad Nov 2, 2026
374819d
Fix x86 dot-product reduction order and signed zero
Kaileshwar16 Nov 10, 2026
14ef98d
Merge pull request #5609 from Kaileshwar16/issue-5599-dot-product
RalfJung Nov 16, 2026
a150369
implement unlinkat to support fs::remove_dir_all
programskillforverification Nov 11, 2026
1a1e3ce
Add libc direct test for abort
mehmettoplu-rs Nov 16, 2026
7078a59
Prepare for merging from rust-lang/rust
workflows-miri[bot] Nov 17, 2026
370e5c8
Merge ref '5df8c02afdf6' from rust-lang/rust
workflows-miri[bot] Nov 17, 2026
b39cd33
Merge pull request #5636 from rust-lang/rustup-2026-11-17
RalfJung Nov 17, 2026
0510b1f
Merge pull request #5414 from programskillforverification/unix-unlinkat
RalfJung Nov 17, 2026
37288a4
triagebot: enable merge command
RalfJung Nov 17, 2026
9607ce1
minor tweaks
RalfJung Nov 17, 2026
e3f9e04
Merge pull request #5637 from RalfJung/triagebot
RalfJung Nov 17, 2026
9fbdb74
Merge pull request #5634 from mehmettoplu-rs/test-abort
RalfJung Nov 17, 2026
67c45b2
Merge pull request #5507 from WhySoBad/udp-non-blocking-io
RalfJung Nov 17, 2026
94c2406
Test GetCurrentProcessId and _NSGetEnviron directly
Kaileshwar16 Nov 10, 2026
0bc008a
track pthread_attr_t stack size and fail pthread_create for huge stacks
programskillforverification Nov 9, 2026
119733c
tweak thread_stack_size_ok
RalfJung Nov 17, 2026
fe2968c
Merge pull request #5601 from programskillforverification/pthread-att…
rustbot Nov 17, 2026
27c1921
miri: use wrapping multiplication when computing element addresses fo…
eduardosm Nov 17, 2026
d6eb2b5
Merge pull request #5639 from eduardosm/gather-failure
RalfJung Nov 17, 2026
68906fb
windows tests: print_safe should not be needed
RalfJung Nov 17, 2026
ad25332
Merge pull request #5640 from RalfJung/win-print
RalfJung Nov 17, 2026
218e753
portable-sim tests: ensure that float ops are non-deterministic
RalfJung Nov 17, 2026
3bf85fe
[Priroda] Normalize MIR local IDs in UI test output
moabo3li Nov 17, 2026
692201e
[Priroda] Stop asserting unnamed dead MIR locals in the UI output
moabo3li Nov 17, 2026
da58a61
[Priroda] Document what the locals command lists
moabo3li Nov 17, 2026
7565191
move windows tests to their own folder
RalfJung Nov 17, 2026
43a20d3
Merge pull request #5643 from RalfJung/simd-float-nondet
RalfJung Nov 17, 2026
3a842be
Merge pull request #5626 from Kaileshwar16/test/3179-direct-win-macos…
RalfJung Nov 17, 2026
dee9bd8
Prepare for merging from rust-lang/rust
RalfJung Nov 17, 2026
7c09ebf
Merge ref '59cbdee2e7b3' from rust-lang/rust
RalfJung Nov 17, 2026
afc1997
add #[optimize] attribute tests
RalfJung Nov 17, 2026
6c3be76
Merge pull request #5644 from RalfJung/opt-attr
RalfJung Nov 17, 2026
a1ce554
[Priroda] Normalize standard-library paths in UI fixtures
moabo3li Nov 17, 2026
5ffc473
Prepare for merging from rust-lang/rust
workflows-miri[bot] Nov 18, 2026
0b09fbc
Merge ref 'ac7bce927202' from rust-lang/rust
workflows-miri[bot] Nov 18, 2026
828c560
fix genmc build
RalfJung Nov 18, 2026
5bc8443
do not mix backend and rust intrinsics
RalfJung Nov 18, 2026
239c8bf
Merge pull request #5647 from rust-lang/rustup-2026-11-18
RalfJung Nov 18, 2026
ee70d48
Lower to `hir::Param`s for extern functions
JonathanBrouwer Nov 18, 2026
db1eea4
Add regression test for `NON_SNAKE_CASE` in foreign fns
JonathanBrouwer Nov 18, 2026
939ac24
Add regression test `lint-check-params.rs`
JonathanBrouwer Nov 18, 2026
d6c7b46
make MetaObj opaque by default
RalfJung Nov 18, 2026
1fd2f0b
Merge pull request #5650 from RalfJung/meta-opaque
RalfJung Nov 18, 2026
e9dd805
Add `r? @ghost` for Josh push PRs
Kobzol Nov 18, 2026
8ca417b
Merge pull request #5653 from Kobzol/josh-push-msg
RalfJung Nov 18, 2026
6c11872
Support `NonNull` pointers as asm! input operands
hsanzg Oct 26, 2026
02725d0
Don't require `extern "llvm-intrinsic"` return structs to be `#[repr(…
beetrees Oct 24, 2026
e4611fa
remove `Box` from `Annotatable::Stmt`
cyrgani Oct 30, 2026
0471f67
remove useless wrap
cyrgani Oct 10, 2026
78f12f8
remove `AllocFnFactory`
cyrgani Oct 12, 2026
75f70ce
small debug tweaks
cyrgani Nov 11, 2026
66b2a86
avoid let statements in debug output
cyrgani Nov 11, 2026
05725ef
use `generic_param_to_arg` more
cyrgani Nov 11, 2026
ebeac38
store the corresponding `FieldDef` in the `FieldInfo`
cyrgani Oct 30, 2026
3a2322d
reorder and regroup special case checks
cyrgani Nov 11, 2026
7ed6bd3
add `MethodBody` to transition away from `Substructure`
cyrgani Nov 12, 2026
94ffc73
remove all usages of `StaticStruct` and `StaticEnum`
cyrgani Nov 12, 2026
eed5c03
remove all resulting dead code and outdated documentation
cyrgani Nov 12, 2026
dabbdeb
move `fieldless_variants_strategy` into `MethodBody::SubstructureFunc`
cyrgani Nov 12, 2026
835b140
inline `call_substructure_method`
cyrgani Nov 12, 2026
d48a5b7
move `has_other_selflike_arg` into `MethodBody::SubstructureFunc`
cyrgani Nov 12, 2026
8bd8604
merge `explicit_self` and `nonselflike_args`
cyrgani Nov 12, 2026
f96baed
fix asin value range
RalfJung Nov 19, 2026
cbfed63
fix atan2 NAN handling
RalfJung Nov 19, 2026
bab3e77
Merge pull request #5659 from RalfJung/asin
RalfJung Nov 19, 2026
d025ca0
Add avx512 shift intrinsics
TDecking Nov 19, 2026
354004b
Merge pull request #5651 from TDecking/avx512
rustbot Nov 19, 2026
e86400c
Test append mode with seek and reads
darkraider01 Nov 16, 2026
0a2a775
dont run broken seek-based emulation of pwrite for O_APPEND files
RalfJung Nov 19, 2026
72b2f56
Add support for blocking `send` to UDP socket shim
WhySoBad Nov 10, 2026
753d084
Add support for blocking `recv` to UDP socket shim, add blocking I/O …
WhySoBad Nov 12, 2026
5b0c763
Merge pull request #5635 from darkraider01/rename-shims-ecx
rustbot Nov 19, 2026
eef56f9
shims/fs tests: also test append mode
RalfJung Nov 19, 2026
748ab15
windows: test creating without writing, and dont falsely set append flag
RalfJung Nov 19, 2026
7c89832
migrate Windows API tests to windows-sys
programskillforverification Nov 20, 2026
bf85368
feat: write tests for new and existing adtdef queries
adpthegreat Nov 20, 2026
08fd6cc
Merge pull request #5655 from programskillforverification/migrate-win…
rustbot Nov 20, 2026
b286dd4
windows/fs: ensure bad read/write requests get rejected
RalfJung Nov 19, 2026
6c60271
libc/fs: test and fix O_CREAT on read-only open
RalfJung Nov 19, 2026
1b58c16
Merge pull request #5646 from moabo3li/priroda-local-id-normalization
oli-obk Nov 20, 2026
d7b3011
Merge pull request #5660 from RalfJung/test-append
RalfJung Nov 20, 2026
042d32c
Merge pull request #5638 from WhySoBad/udp-blocking-io
rustbot Nov 20, 2026
2f5945c
chore: ran ./x fmt
adpthegreat Nov 20, 2026
45426d2
chore: remove whitespace, fix typo
adpthegreat Nov 20, 2026
3e9646b
inline the parts of rustc_tools_util that we use
RalfJung Nov 20, 2026
d54e23b
rename env vars for more consistency
RalfJung Nov 20, 2026
4f2ad6c
Add red-green mark when dumping dep graph. Show DefIds if available
blyxyas Nov 13, 2026
3f47dc0
Merge pull request #5664 from RalfJung/rustc_tools_util
RalfJung Nov 20, 2026
ef7bfc6
update lockfile
RalfJung Nov 20, 2026
1995223
enable more std tests in Miri :)
RalfJung Nov 20, 2026
6515ff5
dont try mutating the original working directory
RalfJung Nov 20, 2026
e01e4a6
Revert some comment changes
GuillaumeGomez Nov 20, 2026
16c78c6
std: also mark doctests with skip_unsupported_miri_tests
RalfJung Nov 20, 2026
4599931
Use `core::ptr` in `implicit_provenance_casts` help for `no_std` crates
bardiharborow Nov 21, 2026
f9becad
use `cfg!(overflow_checks)` in `overflow_checks` intrinsic instead of…
BioTomateDE Nov 21, 2026
21d97db
Stop passing `-Ztrim-paths` to cargo now that it's stable in beta
Zalathar Nov 21, 2026
42804ba
fmt: Improve `Debug` for `FormattingOptions`
tgross35 Nov 20, 2026
46aa192
Rollup merge of #166266 - RalfJung:miri, r=RalfJung
JonathanBrouwer Nov 21, 2026
7dc300c
Rollup merge of #164878 - beetrees:llvm-intrinsic-dont-require-repr-p…
JonathanBrouwer Nov 21, 2026
79afbc1
Rollup merge of #165008 - hsanzg:rich-asm-ptr-inputs, r=Amanieu
JonathanBrouwer Nov 21, 2026
9bfeea9
Rollup merge of #165892 - cyrgani:builtin-macros-10, r=nnethercote
JonathanBrouwer Nov 21, 2026
2b825a5
Rollup merge of #165930 - blyxyas:better-dump-dep-graph, r=jackh726
JonathanBrouwer Nov 21, 2026
f4e7e01
Rollup merge of #166280 - RalfJung:miri-std-doctests, r=maxdexh
JonathanBrouwer Nov 21, 2026
b727f1e
Rollup merge of #166295 - BioTomateDE:intrinsics-stuff, r=thomcc
JonathanBrouwer Nov 21, 2026
57e79db
Rollup merge of #165618 - Kolgrim33:range-intersect-165428, r=Mark-Si…
JonathanBrouwer Nov 21, 2026
d235e3c
Rollup merge of #166012 - adpthegreat:add_more_adtdef_queries, r=maka…
JonathanBrouwer Nov 21, 2026
844a875
Rollup merge of #166142 - JonathanBrouwer:param4, r=Kivooeo
JonathanBrouwer Nov 21, 2026
1d116f4
Rollup merge of #166259 - tgross35:formatoptions-debug, r=hanna-kruppe
JonathanBrouwer Nov 21, 2026
e62a5aa
Rollup merge of #166269 - GuillaumeGomez:revert-comment-changes, r=Ra…
JonathanBrouwer Nov 21, 2026
274b5f8
Rollup merge of #166287 - bardiharborow:implicit-provenance-casts-no-…
JonathanBrouwer Nov 21, 2026
892bbb1
Rollup merge of #166306 - Zalathar:trim-paths, r=Urgau
JonathanBrouwer Nov 21, 2026
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
9 changes: 1 addition & 8 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ dependencies = [
"cargo_metadata 0.23.1",
"directories",
"rustc-build-sysroot",
"rustc_tools_util 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version",
"serde",
"serde_json",
Expand Down Expand Up @@ -667,7 +666,7 @@ dependencies = [
"itertools",
"pulldown-cmark",
"regex",
"rustc_tools_util 0.4.2",
"rustc_tools_util",
"serde",
"serde_json",
"tempfile",
Expand Down Expand Up @@ -4907,12 +4906,6 @@ dependencies = [
name = "rustc_tools_util"
version = "0.4.2"

[[package]]
name = "rustc_tools_util"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3b75158011a63889ba12084cf1224baad7bcad50f6ee7c842f772b74aa148ed"

[[package]]
name = "rustc_trait_selection"
version = "0.0.0"
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,16 +637,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
let (generics, (decl, fn_args)) = self.lower_generics(generics, itctx, |this| {
(
// Disallow `impl Trait` in foreign items.
// Parameters are discarded because foreign functions don't have a body
this.lower_fn_decl(
fdec,
i.id,
hir_id,
FnDeclKind::ExternFn,
None,
DiscardParams::Yes,
DiscardParams::No,
),
this.lower_fn_params_to_idents(fdec),
this.lower_fn_params(fdec),
)
});

Expand Down Expand Up @@ -1253,7 +1252,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
body_id
}

fn lower_param(&mut self, param: &Param) -> hir::Param<'hir> {
pub(super) fn lower_param(&mut self, param: &Param) -> hir::Param<'hir> {
let hir_id = self.lower_node_id(param.id);
self.lower_attrs(hir_id, &param.attrs, param.span, AstTarget::Param(param));
hir::Param {
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
))
}

fn lower_fn_params(&mut self, decl: &FnDecl) -> &'hir [hir::Param<'hir>] {
self.arena.alloc_from_iter(
decl.inputs
.iter()
.filter(|param| !param.is_const_param())
.map(|param| self.lower_param(param)),
)
}

/// Lowers a function declaration.
///
/// `decl`: the unlowered (AST) function declaration.
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_builtin_macros/src/alloc_error_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub(crate) fn expand(
return vec![orig_item];
};

// Generate a bunch of new items using the AllocFnFactory
let span = ecx.with_def_site_ctxt(item.span);

// Generate item statements for the allocator methods.
Expand All @@ -42,7 +41,7 @@ pub(crate) fn expand(
// Generate anonymous constant serving as container for the allocator methods.
let const_item = ecx.item_const_underscore(span, ecx.block(span, stmts));
let const_item = if is_stmt {
Annotatable::Stmt(Box::new(ecx.stmt_item(span, const_item)))
Annotatable::Stmt(ecx.stmt_item(span, const_item))
} else {
Annotatable::Item(const_item)
};
Expand Down
17 changes: 5 additions & 12 deletions compiler/rustc_builtin_macros/src/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ mod llvm_enzyme {
use rustc_ast::tokenstream::*;
use rustc_ast::visit::AssocCtxt::*;
use rustc_ast::{
self as ast, FnRetTy, FnSig, GenericArg, GenericParamKind, Generics, ItemKind,
MetaItemInner, PatKind, TyKind, Visibility,
self as ast, FnRetTy, FnSig, GenericParamKind, Generics, ItemKind, MetaItemInner, PatKind,
TyKind, Visibility,
};
use rustc_attr_ir::RustcAutodiff;
use rustc_expand::base::{Annotatable, ExtCtxt};
Expand All @@ -24,6 +24,7 @@ mod llvm_enzyme {
use tracing::{debug, trace};

use crate::diagnostics;
use crate::util::generic_param_to_arg;

pub(crate) fn outer_normal_attr(
kind: &Box<rustc_ast::NormalAttr>,
Expand Down Expand Up @@ -449,7 +450,7 @@ mod llvm_enzyme {
Annotatable::Stmt(_) => {
let mut d_fn = ecx.item(span, d_attrs, ItemKind::Fn(d_fn));
d_fn.vis = vis;
Annotatable::Stmt(Box::new(ecx.stmt_item(span, d_fn)))
Annotatable::Stmt(ecx.stmt_item(span, d_fn))
}
_ => {
unreachable!("item kind checked previously")
Expand Down Expand Up @@ -577,16 +578,8 @@ mod llvm_enzyme {
.params
.iter()
.filter_map(|p| match &p.kind {
GenericParamKind::Type { .. } => {
let path = ast::Path::from_ident(p.ident);
let ty = ecx.ty_path(path);
Some(GenericArg::Type(ty))
}
GenericParamKind::Const { .. } => {
let anon_const = ecx.const_ident(span, p.ident);
Some(GenericArg::Const(anon_const))
}
GenericParamKind::Lifetime => None,
_ => Some(generic_param_to_arg(ecx, p, span)),
})
.collect::<Vec<_>>();

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/cfg_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl CfgEval<'_> {
Annotatable::Stmt(_) => {
let stmt =
parser.parse_stmt_without_recovery(false, ForceCollect::Yes, false)?;
self.flat_map_stmt(stmt).pop().map(|stmt| Annotatable::Stmt(Box::new(stmt)))
self.flat_map_stmt(stmt).pop().map(Annotatable::Stmt)
}
Annotatable::Expr(_) => {
let mut expr = parser.parse_expr_force_collect()?;
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_builtin_macros/src/cfg_select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ fn tts_to_mac_result<'cx, 'sess>(
tts: TokenStream,
span: Span,
) -> Box<dyn MacResult + 'cx> {
match ExpandResult::from_tts(ecx, tts, site_span, span, Ident::with_dummy_span(sym::cfg_select))
{
ExpandResult::Ready(x) => x,
_ => unreachable!("from_tts always returns Ready"),
}
ExpandResult::from_tts(ecx, tts, site_span, span, Ident::with_dummy_span(sym::cfg_select))
}

macro_rules! forward_to_parser_any_macro {
Expand Down
35 changes: 19 additions & 16 deletions compiler/rustc_builtin_macros/src/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(crate) fn expand_derive_clone(
// enough. Whether Clone is implemented for fields is irrelevant so we
// don't assert it.)
let bounds;
let body: MethodBodyFunc<'_>;
let body;
let is_simple;
match &item.kind {
ItemKind::Struct(_, Generics { params, .. }, _)
Expand All @@ -42,16 +42,22 @@ pub(crate) fn expand_derive_clone(
.any(|param| matches!(param.kind, ast::GenericParamKind::Type { .. }))
{
is_simple = true;
body = Box::new(|c, s, sub| clone_simple_body(c, s, sub, false));
body = MethodBody::Directly(clone_simple_body(cx, span, item, false));
} else {
is_simple = false;
body = Box::new(|c, s, sub| clone_body(c, s, sub, item.kind.ident().unwrap()));
body = MethodBody::SubstructureFunc {
body_func: Box::new(|c, s, sub| {
clone_body(c, s, sub, item.kind.ident().unwrap())
}),
strategy: FieldlessVariantsStrategy::Default,
has_other_selflike_arg: false,
};
}
}
ItemKind::Union(..) => {
bounds = smallvec![path_std!(cx, span, marker::Copy)];
is_simple = true;
body = Box::new(|c, s, sub| clone_simple_body(c, s, sub, true));
body = MethodBody::Directly(clone_simple_body(cx, span, item, true));
}
_ => cx.dcx().span_bug(span, "`derive(Clone)` on wrong item kind"),
}
Expand Down Expand Up @@ -86,28 +92,25 @@ pub(crate) fn expand_derive_clone(
methods: smallvec![MethodDef {
name: sym::clone,
generics: cx.empty_generics(span),
explicit_self: true,
nonself_args: SmallVec::new(),
has_other_selflike_arg: false,
args: thin_vec![cx.param_self_ref(span)],
ret_ty: cx.ty_self(span),
attributes: thin_vec![
cx.generated_attr(span, ast::GeneratedAttr::Inline),
cx.generated_attr(span, ast::GeneratedAttr::RustcTrivialFieldReads)
],
fieldless_variants_strategy: FieldlessVariantsStrategy::Default,
body,
}],
is_const,
..
};

trait_def.expand_ext(cx, item, push, is_simple)
trait_def.expand(cx, item, push);
}

fn clone_simple_body(
cx: &ExtCtxt<'_>,
trait_span: Span,
substr: Substructure<'_>,
item: &ast::Item,
is_union: bool,
) -> BlockOrExpr {
let mut stmts = ThinVec::new();
Expand Down Expand Up @@ -148,16 +151,16 @@ fn clone_simple_body(
&[sym::clone, sym::AssertParamIsCopy],
);
} else {
match substr {
StaticStruct(vdata, ..) => {
match &item.kind {
ast::ItemKind::Struct(.., vdata) => {
process_variant(vdata);
}
StaticEnum(enum_def, ..) => {
ast::ItemKind::Enum(.., enum_def) => {
for variant in &enum_def.variants {
process_variant(&variant.data);
}
}
_ => cx.dcx().span_bug(trait_span, "unexpected substructure in simple `derive(Clone)`"),
_ => unreachable!(),
}
}
BlockOrExpr::new_mixed(stmts, Some(cx.expr_deref(trait_span, cx.expr_self(trait_span))))
Expand All @@ -169,7 +172,7 @@ fn clone_body(
substr: Substructure<'_>,
type_ident: Ident,
) -> BlockOrExpr {
let subcall = |field: FieldInfo| {
let subcall = |field: FieldInfo<'_>| {
let args = thin_vec![field.self_expr];
cx.expr_call_global(
field.span,
Expand Down Expand Up @@ -201,7 +204,7 @@ fn clone_body(
VariantData::Struct { .. } => {
let fields = all_fields
.into_iter()
.map(|field| cx.field_imm(field.span, field.name.unwrap(), subcall(field)))
.map(|field| cx.field_imm(field.span, field.def.ident.unwrap(), subcall(field)))
.collect::<ThinVec<_>>();

cx.expr_struct(trait_span, ctor_path, fields)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use thin_vec::{ThinVec, thin_vec};
use crate::deriving::generic::*;
use crate::deriving::path_std;
use crate::diagnostics;
use crate::util::generic_param_to_arg;

pub(crate) fn expand_derive_coerce_pointee(
cx: &ExtCtxt<'_>,
Expand Down
Loading
Loading