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

Make some newtype_index! derived impls opt-in instead of opt-out #118125

Merged
merged 3 commits into from
Nov 22, 2023

Conversation

nnethercote
Copy link
Contributor

Opt-in is the standard Rust way of doing things, and avoids some unnecessary dependencies on the rustc_serialize crate.

r? @lcnr

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Nov 21, 2023
@rustbot
Copy link
Collaborator

rustbot commented Nov 21, 2023

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@nnethercote
Copy link
Contributor Author

Best reviewed one commit at a time.

@fbstj

This comment was marked as resolved.

@nnethercote nnethercote changed the title Make some newtype_index! derived impls opt-out instead of opt-in Make some newtype_index! derived impls opt-in instead of opt-out Nov 21, 2023
@rustbot
Copy link
Collaborator

rustbot commented Nov 21, 2023

Could not assign reviewer from: lcnr.
User(s) lcnr are either the PR author, already assigned, or on vacation, and there are no other candidates.
Use r? to specify someone else to assign.

@nnethercote
Copy link
Contributor Author

r? @compiler-errors

@rustbot rustbot assigned compiler-errors and unassigned lcnr Nov 21, 2023
@bors
Copy link
Contributor

bors commented Nov 21, 2023

☔ The latest upstream changes (presumably #117580) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

r=me after rebased

@compiler-errors compiler-errors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 21, 2023
@nnethercote
Copy link
Contributor Author

I rebased.

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Nov 21, 2023

📌 Commit e55e28b has been approved by compiler-errors

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 21, 2023
@bors
Copy link
Contributor

bors commented Nov 22, 2023

☔ The latest upstream changes (presumably #117582) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 22, 2023
By default, `newtype_index!` types get a default `Encodable`/`Decodable`
impl. You can opt out of this with `custom_encodable`. Opting out is the
opposite to how Rust normally works with autogenerated (derived) impls.

This commit inverts the behaviour, replacing `custom_encodable` with
`encodable` which opts into the default `Encodable`/`Decodable` impl.
Only 23 of the 59 `newtype_index!` occurrences need `encodable`.

Even better, there were eight crates with a dependency on
`rustc_serialize` just from unused default `Encodable`/`Decodable`
impls. This commit removes that dependency from those eight crates.
Similar to the previous commit, this replaces `newtype_index`'s opt-out
`no_ord_impl` attribute with the opt-in `orderable` attribute.
@nnethercote
Copy link
Contributor Author

I rebased again.

@bors r=compiler-errors

@bors
Copy link
Contributor

bors commented Nov 22, 2023

📌 Commit 0991374 has been approved by compiler-errors

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 22, 2023
@bors
Copy link
Contributor

bors commented Nov 22, 2023

⌛ Testing commit 0991374 with merge 5a9e0e8...

@bors
Copy link
Contributor

bors commented Nov 22, 2023

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 5a9e0e8 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 22, 2023
@bors bors merged commit 5a9e0e8 into rust-lang:master Nov 22, 2023
12 checks passed
@rustbot rustbot added this to the 1.76.0 milestone Nov 22, 2023
@nnethercote nnethercote deleted the custom_encodable branch November 22, 2023 20:25
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (5a9e0e8): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

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

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)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-8.2% [-20.2%, -2.0%] 6
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 677.73s -> 676.065s (-0.25%)
Artifact size: 313.77 MiB -> 313.79 MiB (0.01%)

Comment on lines +28 to +33
/// - #[encodable]: derives `Encodable`/`Decodable`.
/// - #[orderable]: derives `PartialOrd`/`Ord`, plus step-related methods.
/// - #[debug_format = "Foo({})"]: derives `Debug` with particular output.
/// - #[max = 0xFFFF_FFFD]: specifies the max value, which allows niche
/// optimizations. The default max value is 0xFFFF_FF00.
/// - #[gate_rustc_only]: makes parts of the generated code nightly-only.
Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/rust-lang-ci/rust/actions/runs/6990882559/job/19020846394#step:26:27071

   warning: unresolved link to `encodable`
    --> compiler/rustc_index_macros/src/lib.rs:28:9
     |
  28 | /// - #[encodable]: derives `Encodable`/`Decodable`.
     |         ^^^^^^^^^ no item named `encodable` in scope
     |
     = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
     = note: `#[warn(rustdoc::broken_intra_doc_links)]` on by default
  
  warning: unresolved link to `orderable`
    --> compiler/rustc_index_macros/src/lib.rs:29:9
     |
  29 | /// - #[orderable]: derives `PartialOrd`/`Ord`, plus step-related methods.
     |         ^^^^^^^^^ no item named `orderable` in scope
     |
     = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
  
  warning: unresolved link to `gate_rustc_only`
    --> compiler/rustc_index_macros/src/lib.rs:33:9
     |
  33 | /// - #[gate_rustc_only]: makes parts of the generated code nightly-only.
     |         ^^^^^^^^^^^^^^^ no item named `gate_rustc_only` in scope
     |
     = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be fixed by #118338.

How did you notice this? I never notice warnings buried deep within CI runs like this...

Copy link
Contributor

Choose a reason for hiding this comment

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

Reading logs from time to time. It's nice to have github action to automate log diffing and grepping to notice interesting stuff.

@nnethercote nnethercote mentioned this pull request Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants