Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not add leading asterisk in the PartialEq #124157

Merged
merged 2 commits into from
May 9, 2024

Conversation

wutchzone
Copy link
Contributor

I think we should address this issue, however I am not exactly sure, if this is the right way to do it. It is related to the #123056.

Imagine the simplified code:

trait MyTrait {}

impl PartialEq for dyn MyTrait {
    fn eq(&self, _other: &Self) -> bool {
        true
    }
}

#[derive(PartialEq)]
enum Bar {
    Foo(Box<dyn MyTrait>),
}

On the nightly compiler, the derive produces invalid code with the weird error message:

error[E0507]: cannot move out of `*__arg1_0` which is behind a shared reference
  --> src/main.rs:11:9
   |
9  | #[derive(PartialEq)]
   |          --------- in this derive macro expansion
10 | enum Things {
11 |     Foo(Box<dyn MyTrait>),
   |         ^^^^^^^^^^^^^^^^ move occurs because `*__arg1_0` has type `Box<dyn MyTrait>`, which does not implement the `Copy` trait
   |
   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)

It may be related to the perfect derive problem, although requiring the type to be Copy seems unfortunate because it is not necessary. Besides, we are adding the extra dereference only for the diagnostics?

@rustbot
Copy link
Collaborator

rustbot commented Apr 19, 2024

r? @estebank

rustbot has assigned @estebank.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 19, 2024
@rustbot
Copy link
Collaborator

rustbot commented Apr 19, 2024

Changes to the code generated for builtin derived traits.

cc @nnethercote

@rust-log-analyzer

This comment has been minimized.

@@ -0,0 +1,18 @@
//@ check-pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to add this case to the existing tests/ui/deriving/deriving-all-codegen.rs file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved, thank you for pointing it out.

@rust-log-analyzer

This comment has been minimized.

Adding leading asterisk can cause compilation failure for
the _types_ that don't implement the `Copy`.
@estebank
Copy link
Contributor

@nnethercote the original change for this was here

Do you remember why we were dereferencing these values? Looking at the expanded code, it doesn't seem like it was ever needed, right? It also claimed that it improved errors, but there was no new test to show the new output, so I'm not sure if it refers to the "&T can't be ==" vs "T can't be ==" difference that we see now on this PR ^_^'

@estebank
Copy link
Contributor

The changes look good to me, but out of an over abundance of caution I'll do a crater run.

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 23, 2024
Do not add leading asterisk in the `PartialEq`

I think we should address this issue, however I am not exactly sure, if this is the right way to do it. It is related to the rust-lang#123056.

Imagine the simplified code:

```rust
trait MyTrait {}

impl PartialEq for dyn MyTrait {
    fn eq(&self, _other: &Self) -> bool {
        true
    }
}

#[derive(PartialEq)]
enum Bar {
    Foo(Box<dyn MyTrait>),
}
```

On the nightly compiler, the `derive` produces invalid code with the weird error message:
```
error[E0507]: cannot move out of `*__arg1_0` which is behind a shared reference
  --> src/main.rs:11:9
   |
9  | #[derive(PartialEq)]
   |          --------- in this derive macro expansion
10 | enum Things {
11 |     Foo(Box<dyn MyTrait>),
   |         ^^^^^^^^^^^^^^^^ move occurs because `*__arg1_0` has type `Box<dyn MyTrait>`, which does not implement the `Copy` trait
   |
   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
```

It may be related to the perfect derive problem, although requiring the _type_ to be `Copy` seems unfortunate because it is not necessary. Besides, we are adding the extra dereference only for the diagnostics?
@bors
Copy link
Contributor

bors commented Apr 23, 2024

⌛ Trying commit c2a0ef6 with merge 9c7b5f5...

@compiler-errors
Copy link
Member

@rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Apr 23, 2024
@bors
Copy link
Contributor

bors commented Apr 23, 2024

☀️ Try build successful - checks-actions
Build commit: 9c7b5f5 (9c7b5f5b6b8ec32bbbcf9f07fc0e5208da6c5f88)

@rust-timer

This comment has been minimized.

@nnethercote
Copy link
Contributor

This was the commit. The message said:

The exception is PartialEq, which needs T expressions for lots of
special case error messaging to work. So we now convert the &T back to
a T for PartialEq.

I have a memory of some error messages getting worse when using &T, but this PR doesn't seem to have any problem with that, so maybe it was in a case not affected here.

Also, I think "binary operation == cannot be applied to type Error" is a better message than "binary operation == cannot be applied to type &Error" for an invalid derive... but generating correct code is more important, so I think that slightly worse error message is worth accepting.

@nnethercote
Copy link
Contributor

It would be good to squash the two commits before merging. But wait for the crater run to finish first.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9c7b5f5): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.1% [0.4%, 1.8%] 2
Regressions ❌
(secondary)
0.4% [0.3%, 0.5%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.4% [-2.4%, -2.4%] 1
All ❌✅ (primary) 1.1% [0.4%, 1.8%] 2

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.4% [0.1%, 10.8%] 4
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.6% [-2.9%, -2.4%] 2
Improvements ✅
(secondary)
-4.9% [-4.9%, -4.9%] 1
All ❌✅ (primary) 1.4% [-2.9%, 10.8%] 6

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.6% [1.6%, 1.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.2% [-2.4%, -2.1%] 3
All ❌✅ (primary) 1.6% [1.6%, 1.6%] 1

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.4%] 25
Regressions ❌
(secondary)
0.1% [0.0%, 0.2%] 7
Improvements ✅
(primary)
-0.1% [-0.2%, -0.0%] 7
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 3
All ❌✅ (primary) 0.1% [-0.2%, 0.4%] 32

Bootstrap: 675.427s -> 673.89s (-0.23%)
Artifact size: 315.55 MiB -> 316.20 MiB (0.21%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Apr 23, 2024
@estebank
Copy link
Contributor

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-124157 created and queued.
🤖 Automatically detected try build 9c7b5f5
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 26, 2024
@craterbot craterbot added the S-waiting-on-crater Status: Waiting on a crater run to be completed. label Apr 26, 2024
@craterbot
Copy link
Collaborator

🚧 Experiment pr-124157 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-124157 is completed!
📊 6 regressed and 1 fixed (443002 total)
📰 Open the full report.

⚠️ If you notice any spurious failure please add them to the blacklist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-crater Status: Waiting on a crater run to be completed. labels May 4, 2024
@estebank
Copy link
Contributor

estebank commented May 9, 2024

lcdr.lu_packets

[INFO] [stdout] error[E0275]: overflow evaluating the requirement `BitWriter<endio_bit::endian::BigEndian, _>: std::io::Write`
[INFO] [stdout]   |
[INFO] [stdout]   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`lu_packets`)
[INFO] [stdout]   = note: required for `BitWriter<endio_bit::endian::BigEndian, _>` to implement `EWrite<LittleEndian>`
[INFO] [stdout]   = note: required for `&'a Vec<_>` to implement `for<'a> Serialize<LittleEndian, BitWriter<endio_bit::endian::BigEndian, _>>`
[INFO] [stdout]   = note: 125 redundant requirements hidden
[INFO] [stdout]   = note: required for `&Option<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<Vec<...>>>>>>>>>>>>>>>>>>>>` to implement `Serialize<LittleEndian, BitWriter<endio_bit::endian::BigEndian, _>>`
[INFO] [stdout]   = note: the full name for the type has been written to '/opt/rustwide/target/debug/deps/lu_packets-b9a10b97ce492327.long-type-1692593626393380450.txt'
[INFO] [stdout]   = note: consider using `--verbose` to print the full type name to the console
[INFO] [stdout] 

and schnauzer_ui-0.1.1

[INFO] [stdout] error: expected expression, found `<eof>`
[INFO] [stdout]  --> /opt/rustwide/target/debug/build/sailfish-compiler-efa85aa12d4f46d1/out/templates/test_report-e8e7cbd90db8dbdc:0:1
[INFO] [stdout]   |
[INFO] [stdout] 
[INFO] [stdout] 
[INFO] [stdout] error: non-statement macro in statement position: include
[INFO] [stdout]    --> src/test_report.rs:124:17
[INFO] [stdout]     |
[INFO] [stdout] 124 | #[derive(Debug, TemplateOnce)]
[INFO] [stdout]     |                 ^^^^^^^^^^^^
[INFO] [stdout]     |
[INFO] [stdout]     = note: this error originates in the derive macro `TemplateOnce` (in Nightly builds, run with -Z macro-backtrace for more info)

I'd like to dig deeper into those two, but it seems like this change is ok to land as-is.

@bors r+

cc @rust-lang/compiler for visibility

@bors
Copy link
Contributor

bors commented May 9, 2024

📌 Commit c2a0ef6 has been approved by estebank

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 9, 2024
@estebank estebank added relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 9, 2024
@wutchzone
Copy link
Contributor Author

@estebank Could I help you in any way by further analyzing these two occurrences you mentioned?

@bors
Copy link
Contributor

bors commented May 9, 2024

⌛ Testing commit c2a0ef6 with merge cb93c24...

@bors
Copy link
Contributor

bors commented May 9, 2024

☀️ Test successful - checks-actions
Approved by: estebank
Pushing cb93c24 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 9, 2024
@bors bors merged commit cb93c24 into rust-lang:master May 9, 2024
13 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 9, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (cb93c24): comparison URL.

Overall result: ❌ regressions - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.3% [0.2%, 0.5%] 9
Regressions ❌
(secondary)
0.4% [0.3%, 0.8%] 9
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.2%, 0.5%] 9

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.5% [0.7%, 4.9%] 8
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.1% [-3.1%, -3.1%] 1
Improvements ✅
(secondary)
-3.2% [-3.2%, -3.2%] 1
All ❌✅ (primary) 1.8% [-3.1%, 4.9%] 9

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.8%] 27
Regressions ❌
(secondary)
0.1% [0.0%, 0.2%] 7
Improvements ✅
(primary)
-0.1% [-0.1%, -0.0%] 2
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 3
All ❌✅ (primary) 0.1% [-0.1%, 0.8%] 29

Bootstrap: 676.422s -> 673.974s (-0.36%)
Artifact size: 315.81 MiB -> 315.95 MiB (0.05%)

@Kobzol
Copy link
Contributor

Kobzol commented May 14, 2024

Looks like a bit more work has to be done to perhaps auto deref the types when we don't manually insert the asterisk?

--------------------------------------------------------------------------------
-- File:function summary
--------------------------------------------------------------------------------
  Ir_______  file:function

< 6,919,799  ???:
  6,448,647    <rustc_trait_selection::traits::select::SelectionContext>::candidate_from_obligation_no_cache
    524,410    <rustc_middle::traits::specialization_graph::Children as rustc_trait_selection::traits::specialize::specialization_graph::ChildrenExt>::insert
   -431,727    <rustc_parse::parser::Parser>::parse_path_inner
   -312,880    <hashbrown::raw::RawTable<(rustc_query_system::dep_graph::dep_node::DepNode, rustc_type_ir::canonical::Canonical<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::Normalize<rustc_middle::ty::Ty>>>)>>::reserve_rehash::<hashbrown::map::make_hasher<rustc_query_system::dep_graph::dep_node::DepNode, rustc_type_ir::canonical::Canonical<rustc_middle::ty::context::TyCtxt, rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::Normalize<rustc_middle::ty::Ty>>>, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>::{closure#0}>
    312,880    <hashbrown::raw::RawTable<(rustc_query_system::dep_graph::dep_node::DepNode, (rustc_middle::ty::instance::Instance, rustc_span::def_id::LocalDefId))>>::reserve_rehash::<hashbrown::map::make_hasher<rustc_query_system::dep_graph::dep_node::DepNode, (rustc_middle::ty::instance::Instance, rustc_span::def_id::LocalDefId), core::hash::BuildHasherDefault<rustc_hash::FxHasher>>::{closure#0}>
    288,633    <rustc_parse::parser::Parser>::parse_path_segments
   -269,679    <hashbrown::raw::RawTable<(rustc_ast::node_id::NodeId, rustc_ast::node_id::NodeId)>>::reserve_rehash::<hashbrown::map::make_hasher<rustc_ast::node_id::NodeId, rustc_ast::node_id::NodeId, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>::{closure#0}>
    262,517    <hashbrown::raw::RawTable<(rustc_span::def_id::LocalDefId, rustc_span::def_id::CrateNum)>>::reserve_rehash::<hashbrown::map::make_hasher<rustc_span::def_id::LocalDefId, rustc_span::def_id::CrateNum, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>::{closure#0}>
    181,297    <hashbrown::raw::RawTable<(rustc_span::def_id::LocalDefId, rustc_resolve::late::LifetimeUseSet)>>::reserve_rehash::<hashbrown::map::make_hasher<rustc_span::def_id::LocalDefId, rustc_resolve::late::LifetimeUseSet, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>::{closure#0}>
   -155,132    <rustc_middle::ty::generic_args::GenericArg as rustc_type_ir::interner::CollectAndApply<rustc_middle::ty::generic_args::GenericArg, &rustc_middle::ty::list::RawList<(), rustc_middle::ty::generic_args::GenericArg>>>::collect_and_apply::<core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::generic_args::GenericArg>>, <rustc_middle::ty::generic_args::GenericArg as core::convert::Into<rustc_middle::ty::generic_args::GenericArg>>::into>, <rustc_middle::ty::context::TyCtxt>::mk_args_from_iter<core::iter::adapters::map::Map<core::iter::adapters::copied::Copied<core::slice::iter::Iter<rustc_middle::ty::generic_args::GenericArg>>, <rustc_middle::ty::generic_args::GenericArg as core::convert::Into<rustc_middle::ty::generic_args::GenericArg>>::into>, rustc_middle::ty::generic_args::GenericArg>::{closure#0}>
    153,028    <rustc_middle::ty::context::TyCtxt>::mk_args
    151,480    <rustc_parse::parser::Parser>::break_and_eat
   -144,673    <hashbrown::raw::RawTable<(rustc_ast::node_id::NodeId, rustc_resolve::Module)>>::reserve_rehash::<hashbrown::map::make_hasher<rustc_ast::node_id::NodeId, rustc_resolve::Module, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>::{closure#0}>
   -134,320    rustc_hir_analysis::collect::impl_trait_header
   -133,203    <rustc_middle::ty::context::CtxtInterners>::intern_predicate
    132,488    <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_impl_trait_ref
    -99,465    <rustc_lint::early::EarlyContextAndPass<rustc_lint::BuiltinCombinedPreExpansionLintPass> as rustc_ast::visit::Visitor>::visit_path
     95,277    <rustc_lint::early::EarlyContextAndPass<rustc_lint::BuiltinCombinedPreExpansionLintPass> as rustc_ast::visit::Visitor>::visit_mac_call
    -79,834    <rustc_infer::infer::relate::generalize::Generalizer as rustc_middle::ty::relate::TypeRelation>::consts::{closure#0}
     76,921    <hashbrown::raw::RawTable<(rustc_span::def_id::LocalDefId, ())>>::reserve_rehash::<hashbrown::map::make_hasher<rustc_span::def_id::LocalDefId, (), core::hash::BuildHasherDefault<rustc_hash::FxHasher>>::{closure#0}>
    -76,921    <hashbrown::raw::RawTable<(rustc_ast::node_id::NodeId, ())>>::reserve_rehash::<hashbrown::map::make_hasher<rustc_ast::node_id::NodeId, (), core::hash::BuildHasherDefault<rustc_hash::FxHasher>>::{closure#0}>
     76,478    <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::complain_about_internal_fn_trait
    -70,866    <rustc_resolve::Resolver>::resolve_path_with_ribs
     67,961    <rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::Normalize<rustc_middle::ty::Ty>> as rustc_trait_selection::traits::query::type_op::TypeOp>::fully_perform
    -57,612    <rustc_middle::ty::fast_reject::DeepRejectCtxt>::types_may_unify
     50,164    rustc_trait_selection::traits::normalize_param_env_or_error
     49,668    <rustc_trait_selection::traits::select::SelectionContext>::evaluate_trait_predicate_recursively
     45,995    <rustc_trait_selection::traits::select::SelectionContext>::match_impl::{closure#0}
     43,568    <rustc_parse::parser::Parser>::parse_expr_paren_seq
    -43,142    <rustc_parse::parser::Parser>::parse_delim_comma_seq::<rustc_ast::ptr::P<rustc_ast::ast::Expr>, <rustc_parse::parser::Parser>::parse_expr_paren_seq::{closure#0}>
     40,280    <rustc_parse::parser::Parser>::handle_unambiguous_unbraced_const_arg
     39,106    rustc_hir_analysis::check::compare_impl_item::check_type_bounds
    -36,624    <hashbrown::raw::RawTable<(rustc_ast::node_id::NodeId, rustc_hir::def::LifetimeRes)>>::reserve_rehash::<hashbrown::map::make_hasher<rustc_ast::node_id::NodeId, rustc_hir::def::LifetimeRes, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>::{closure#0}>
     36,370    <rustc_borrowck::type_check::TypeChecker>::typeck_mir
    -36,252    <rustc_parse::parser::Parser>::parse_path_segment
    -35,049    <rustc_middle::ty::list::RawList<(), rustc_middle::ty::generic_args::GenericArg>>::fill_item::<<rustc_infer::infer::InferCtxt>::fresh_args_for_item::{closure#0}>
     34,995    <rustc_infer::infer::canonical::canonicalizer::Canonicalizer as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
    -29,955    <rustc_middle::ty::context::CtxtInterners>::intern_ty
    -29,906    <rustc_hir::hir::Ty as rustc_data_structures::stable_hasher::HashStable<rustc_query_system::ich::hcx::StableHashingContext>>::hash_stable
     29,650    <hashbrown::raw::RawTable<(rustc_span::def_id::LocalDefId, alloc::vec::Vec<rustc_span::def_id::DefId>)>>::reserve_rehash::<hashbrown::map::make_hasher<rustc_span::def_id::LocalDefId, alloc::vec::Vec<rustc_span::def_id::DefId>, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>::{closure#0}>
    -29,650    <hashbrown::raw::RawTable<(rustc_ast::node_id::NodeId, alloc::vec::Vec<rustc_hir::hir::TraitCandidate>)>>::reserve_rehash::<hashbrown::map::make_hasher<rustc_ast::node_id::NodeId, alloc::vec::Vec<rustc_hir::hir::TraitCandidate>, core::hash::BuildHasherDefault<rustc_hash::FxHasher>>::{closure#0}>
     27,923    <rustc_borrowck::type_check::TypeChecker>::fully_perform_op::<rustc_middle::ty::Ty, rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::Normalize<rustc_middle::ty::Ty>>>
     27,271    <rustc_parse::parser::Parser>::parse_expr_dot_or_call
     22,418    <rustc_mir_build::thir::cx::Cx>::mirror_expr
    -19,893    <rustc_lint::BuiltinCombinedPreExpansionLintPass as rustc_lint::passes::EarlyLintPass>::check_ident
    -17,181    <rustc_infer::infer::InferCtxt>::fresh_args_for_item
    -16,268    alloc::raw_vec::finish_grow::<alloc::alloc::Global>
    -15,043    core::slice::sort::recurse::<rustc_span::def_id::DefId, <[rustc_span::def_id::DefId]>::sort_unstable_by_key<(i64, usize), rustc_trait_selection::traits::specialize::specialization_graph_provider::{closure#0}>::{closure#0}>
     13,706    <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::try_super_fold_with::<rustc_middle::ty::fold::RegionFolder>
     13,373    <rustc_resolve::late::LateResolutionVisitor as rustc_ast::visit::Visitor>::visit_item
     12,562    <rustc_trait_selection::traits::fulfill::FulfillProcessor as rustc_data_structures::obligation_forest::ObligationProcessor>::process_obligation
    -12,352    <rustc_mir_transform::elaborate_drops::ElaborateDrops as rustc_middle::mir::MirPass>::run_pass
    -11,644    <rustc_parse::parser::Parser>::parse_angle_args
     11,400    <rustc_resolve::Resolver>::try_define
    -11,031    <rustc_metadata::rmeta::encoder::EncodeContext>::encode_attrs
    -10,821    rustc_middle::ty::relate::structurally_relate_tys::<rustc_infer::infer::relate::type_relating::TypeRelating>::{closure#0}
     10,264    <rustc_middle::ty::Ty as rustc_type_ir::fold::TypeSuperFoldable<rustc_middle::ty::context::TyCtxt>>::try_super_fold_with::<rustc_infer::infer::freshen::TypeFreshener>
    -10,260    <alloc::raw_vec::RawVec<rustc_middle::mir::syntax::ProjectionElem<rustc_middle::mir::Local, rustc_middle::ty::Ty>>>::grow_one
     10,238    rustc_middle::ty::codec::encode_with_shorthand::<rustc_metadata::rmeta::encoder::EncodeContext, rustc_middle::ty::Ty, <rustc_metadata::rmeta::encoder::EncodeContext as rustc_type_ir::codec::TyEncoder>::type_shorthands>
     -9,975    <alloc::raw_vec::RawVec<rustc_infer::infer::region_constraints::RegionVariableInfo>>::grow_one
     -9,817    <rustc_middle::ty::generic_args::ArgFolder as rustc_type_ir::fold::TypeFolder<rustc_middle::ty::context::TyCtxt>>::fold_ty
      9,750    rustc_trait_selection::traits::project::opt_normalize_projection_type
      8,976    rustc_query_system::query::plumbing::try_execute_query::<rustc_query_impl::DynamicConfig<rustc_query_system::query::caches::DefIdCache<rustc_middle::query::erase::Erased<[u8; 1]>>, false, false, false>, rustc_query_impl::plumbing::QueryCtxt, false>
     -8,635    <dyn rustc_hir_analysis::hir_ty_lowering::HirTyLowerer>::lower_path
     -8,184    <rustc_borrowck::type_check::TypeChecker>::fully_perform_op::<(), rustc_middle::ty::ParamEnvAnd<rustc_middle::traits::query::type_op::ProvePredicate>>
      7,960    rustc_query_impl::plumbing::__rust_begin_short_backtrace::<rustc_query_impl::query_impl::impl_trait_header::dynamic_query::{closure#2}::{closure#0}, rustc_middle::query::erase::Erased<[u8; 24]>>
      7,839    <alloc::raw_vec::RawVec<rustc_middle::mir::BasicBlock>>::grow_one
     -7,530    rustc_hir_analysis::check::wfcheck::check_well_formed
     -7,487    <rustc_parse::parser::Parser>::is_import_coupler
      7,432    <rustc_trait_selection::traits::select::SelectionContext>::poly_select::{closure#0}
     -7,098    <rustc_arena::DroplessArena>::alloc_from_iter::<rustc_hir::hir::Pat, alloc::vec::Vec<rustc_hir::hir::Pat>>
      7,092    <indexmap::map::core::IndexMapCore<rustc_middle::mir::Local, ()>>::reserve_entries
     -7,092    <indexmap::map::core::IndexMapCore<rustc_borrowck::constraints::ConstraintSccIndex, rustc_borrowck::member_constraints::NllMemberConstraintIndex>>::reserve_entries

<    95,280  ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:__memcpy_avx_unaligned_erms

<   -28,090  ./string/../sysdeps/x86_64/strcmp.S:strcmp

<   -19,071  ./elf/./elf/dl-lookup.c:
    -18,044    _dl_lookup_symbol_x

In any case, the regressions are relatively small, and this seems to be a fix that allows more code to compile. We probably can't do much about this, since we just change the derive codegen, and for known reasons we can't do this e.g. selectively based on the type of the field.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label May 14, 2024
@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 27, 2024

@estebank why does this have the relnotes label, it's unclear to me what exactly the user facing change was here

@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 27, 2024

In general I am a bit confused by this PR:

  • It had no FCP so should not have had any user facing impact (so why is it relnotes?)
  • The PR also does not fix the linked issue so the reason for relnotes can't be that
  • If it did fix a bug there was no test added for it and it was not mentioned anywhere in the PR or the files changed(?)
  • The PR description gives no information as to what is happening here, there's a lot of text and all it really says is "we dont fix this linked issue idk how we should do that"

@nnethercote
Copy link
Contributor

I don't think this needs relnotes. The failure to fix the original issue is unfortunate, I didn't realize that.

@estebank
Copy link
Contributor

estebank commented Jul 1, 2024

I think I added relnotes because of change of desugaring might be useful to learn about for people doing lower level shenanigans, but you're right that it isn't needed.

The PR also does not fix the linked issue so the reason for relnotes can't be that

My read of #123056 is that the ticket was for the cryptic output:

error[E0507]: cannot move out of `*__arg1_0` which is behind a shared reference
  --> src/main.rs:21:12
   |
19 | #[derive(PartialEq)] // To fix error, comment out this line and uncomment 25-34
   |          --------- in this derive macro expansion
20 | enum Things {
21 |     Animal(Box<dyn Animal>),
   |            ^^^^^^^^^^^^^^^ move occurs because `*__arg1_0` has type `Box<dyn Animal>`, which does not implement the `Copy` trait

which with this PR it no longer happens, but there's the more general case of the move error itself which could do with better output.

Edit: closed the ticket and opened #127215 for more granular tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.