-
Notifications
You must be signed in to change notification settings - Fork 14k
Implement pin!() using super let
#139114
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
Implement pin!() using super let
#139114
Conversation
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #138740) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment was marked as outdated.
This comment was marked as outdated.
|
r? compiler |
This comment was marked as outdated.
This comment was marked as outdated.
|
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 2ef7858 (parent) -> a7c39b6 (this PR) Test differencesShow 49 test diffsStage 0
Stage 1
Stage 2
Additionally, 44 doctest diffs were found. These are ignored, as they are noisy. Job group index
Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (a7c39b6): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary -0.5%, secondary -2.7%)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.
CyclesResults (primary -0.6%, secondary -2.9%)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.
Binary sizeResults (primary 0.0%, secondary 0.1%)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.
Bootstrap: 774.105s -> 772.535s (-0.20%) |
…Urgau Remove (now unused) #[rustc_macro_edition_2021] attribute Now that rust-lang#139114 has been merged, we no longer need the temporary hack (`#[rustc_macro_edition_2021]`) that we introduced in rust-lang#138717. Time to remove it.
…Urgau Remove (now unused) #[rustc_macro_edition_2021] attribute Now that rust-lang#139114 has been merged, we no longer need the temporary hack (`#[rustc_macro_edition_2021]`) that we introduced in rust-lang#138717. Time to remove it.
Rollup merge of rust-lang#140067 - m-ou-se:remove-macro-2021-hack, r=Urgau Remove (now unused) #[rustc_macro_edition_2021] attribute Now that rust-lang#139114 has been merged, we no longer need the temporary hack (`#[rustc_macro_edition_2021]`) that we introduced in rust-lang#138717. Time to remove it.
Implement `pin!()` using `super let` Tracking issue for super let: rust-lang#139076 This uses `super let` to implement `pin!()`. This means we can remove [the hack](rust-lang#138717) we had to put in to fix rust-lang#138596. It also means we can remove the original hack to make `pin!()` work, which used a questionable public-but-unstable field rather than a proper private field. While `super let` is still unstable and subject to change, it seems safe to assume that future Rust will always have a way to express `pin!()` in a compatible way, considering `pin!()` is already stable. It'd help [the experiment](rust-lang#139076) to have `pin!()` use `super let`, so we can get some more experience with it.
Allow storing format_args!() in variable Fixes rust-lang#92698 Tracking issue for super let: rust-lang#139076 This change allows: ```rust let name = "world"; let f = format_args!("hello {name}!"); println!("{f}"); ``` This will need an FCP. This implementation makes use of `super let`, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have _a_ way of expressing temporary lifetimes like this, since the (stable) `pin!()` macro needs this. (This was also the motivation for merging rust-lang#139114.) > [!NOTE] > This PR causes many subtle changes in diagnostics output. Most of those are good. Some of those are bad. I've collected all the bad ones in the last commit. Those still need fixing. Marking this PR as draft. (This is a second version of rust-lang#139135)
Allow storing `format_args!()` in variable Fixes #92698 Tracking issue for super let: #139076 Tracking issue for format_args: #99012 This change allows: ```rust let name = "world"; let f = format_args!("hello {name}!"); // New: Store format_args!() for later! println!("{f}"); ``` This will need an FCP. This implementation makes use of `super let`, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have _a_ way of expressing temporary lifetimes like this, since the (stable) `pin!()` macro needs this too. (This was also the motivation for merging #139114.) (This is a second version of #139135)
Allow storing `format_args!()` in variable Fixes rust-lang/rust#92698 Tracking issue for super let: rust-lang/rust#139076 Tracking issue for format_args: rust-lang/rust#99012 This change allows: ```rust let name = "world"; let f = format_args!("hello {name}!"); // New: Store format_args!() for later! println!("{f}"); ``` This will need an FCP. This implementation makes use of `super let`, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have _a_ way of expressing temporary lifetimes like this, since the (stable) `pin!()` macro needs this too. (This was also the motivation for merging rust-lang/rust#139114.) (This is a second version of rust-lang/rust#139135)
Allow storing `format_args!()` in variable Fixes rust-lang/rust#92698 Tracking issue for super let: rust-lang/rust#139076 Tracking issue for format_args: rust-lang/rust#99012 This change allows: ```rust let name = "world"; let f = format_args!("hello {name}!"); // New: Store format_args!() for later! println!("{f}"); ``` This will need an FCP. This implementation makes use of `super let`, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have _a_ way of expressing temporary lifetimes like this, since the (stable) `pin!()` macro needs this too. (This was also the motivation for merging rust-lang/rust#139114.) (This is a second version of rust-lang/rust#139135)
Allow storing `format_args!()` in variable Fixes rust-lang/rust#92698 Tracking issue for super let: rust-lang/rust#139076 Tracking issue for format_args: rust-lang/rust#99012 This change allows: ```rust let name = "world"; let f = format_args!("hello {name}!"); // New: Store format_args!() for later! println!("{f}"); ``` This will need an FCP. This implementation makes use of `super let`, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have _a_ way of expressing temporary lifetimes like this, since the (stable) `pin!()` macro needs this too. (This was also the motivation for merging rust-lang/rust#139114.) (This is a second version of rust-lang/rust#139135)
…elmann Allow storing `format_args!()` in variable Fixes rust-lang#92698 Tracking issue for super let: rust-lang#139076 Tracking issue for format_args: rust-lang#99012 This change allows: ```rust let name = "world"; let f = format_args!("hello {name}!"); // New: Store format_args!() for later! println!("{f}"); ``` This will need an FCP. This implementation makes use of `super let`, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have _a_ way of expressing temporary lifetimes like this, since the (stable) `pin!()` macro needs this too. (This was also the motivation for merging rust-lang#139114.) (This is a second version of rust-lang#139135)
Trying to run `cargo shear --expand` on the majority of Rust 1.88+ projects will fail due to the use of `super let` by the `pin!` macro on nightly, which `syn` can't parse: rust-lang/rust#139114 `syn` won't add support for parsing `super let` until it's closer to stabilization: dtolnay/syn#1947 So I opted to switch to rust-analyzer's syntax parser instead. The API is pretty similar overall. Main benefit is it supports more experimental syntax. Though I'm not sure how stable it is, which might be a concern. It's a more resilient parser, so it handles syntax errors gracefully. That might backfire in certain scenarios. With these changes, I was able to run `--expand` against the Zed monorepo, which found 100+ issues. <details> ```bash Analyzing /home/cmullan/workspace/zed acp_thread -- crates/acp_thread/Cargo.toml: unused dependencies: zlog tempfile acp_tools -- crates/acp_tools/Cargo.toml: unused dependencies: serde action_log -- crates/action_log/Cargo.toml: unused dependencies: indoc agent -- crates/agent/Cargo.toml: unused dependencies: editor terminal worktree agent_servers -- crates/agent_servers/Cargo.toml: unused dependencies: nix libc language agent_settings -- crates/agent_settings/Cargo.toml: unused dependencies: serde_json_lenient serde_json paths ai_onboarding -- crates/ai_onboarding/Cargo.toml: unused dependencies: serde assistant_text_thread -- crates/assistant_text_thread/Cargo.toml: unused dependencies: indoc audio -- crates/audio/Cargo.toml: unused dependencies: serde buffer_diff -- crates/buffer_diff/Cargo.toml: unused dependencies: serde_json call -- crates/call/Cargo.toml: unused dependencies: http_client serde client -- crates/client/Cargo.toml: unused dependencies: fs collab -- crates/collab/Cargo.toml: unused dependencies: context_server dap-types sea-orm-macros agent_settings hyper audio multi_buffer collab_ui -- crates/collab_ui/Cargo.toml: unused dependencies: pretty_assertions tree-sitter-md command_palette -- crates/command_palette/Cargo.toml: unused dependencies: env_logger serde_json ctor copilot -- crates/copilot/Cargo.toml: unused dependencies: async-std clock client task credentials_provider -- crates/credentials_provider/Cargo.toml: unused dependencies: serde dap -- crates/dap/Cargo.toml: unused dependencies: tree-sitter tree-sitter-go dap_adapters -- crates/dap_adapters/Cargo.toml: unused dependencies: serde diagnostics -- crates/diagnostics/Cargo.toml: unused dependencies: serde client component edit_prediction_button -- crates/edit_prediction_button/Cargo.toml: unused dependencies: theme lsp serde_json futures edit_prediction_context -- crates/edit_prediction_context/Cargo.toml: unused dependencies: clap editor -- crates/editor/Cargo.toml: unused dependencies: http_client tempfile extension_cli -- crates/extension_cli/Cargo.toml: unused dependencies: serde extensions_ui -- crates/extensions_ui/Cargo.toml: unused dependencies: serde feedback -- crates/feedback/Cargo.toml: unused dependencies: editor file_finder -- crates/file_finder/Cargo.toml: unused dependencies: language file_icons -- crates/file_icons/Cargo.toml: unused dependencies: serde git -- crates/git/Cargo.toml: unused dependencies: unindent git_ui -- crates/git_ui/Cargo.toml: unused dependencies: windows go_to_line -- crates/go_to_line/Cargo.toml: unused dependencies: tree-sitter-typescript serde tree-sitter-rust gpui -- crates/gpui/Cargo.toml: unused dependencies: cocoa-foundation x11-clipboard pretty_assertions image_viewer -- crates/image_viewer/Cargo.toml: unused dependencies: serde journal -- crates/journal/Cargo.toml: unused dependencies: serde json_schema_store -- crates/json_schema_store/Cargo.toml: unused dependencies: serde keymap_editor -- crates/keymap_editor/Cargo.toml: unused dependencies: serde component language_models -- crates/language_models/Cargo.toml: unused dependencies: project editor languages -- crates/languages/Cargo.toml: unused dependencies: text rope workspace livekit_client -- crates/livekit_client/Cargo.toml: unused dependencies: sha2 serde_json objc media -- crates/media/Cargo.toml: unused dependencies: ctor multi_buffer -- crates/multi_buffer/Cargo.toml: unused dependencies: project net -- crates/net/Cargo.toml: unused dependencies: anyhow node_runtime -- crates/node_runtime/Cargo.toml: unused dependencies: async-std notifications -- crates/notifications/Cargo.toml: unused dependencies: settings outline -- crates/outline/Cargo.toml: unused dependencies: tree-sitter-typescript picker -- crates/picker/Cargo.toml: unused dependencies: env_logger ctor proto -- crates/proto/Cargo.toml: unused dependencies: typed-path recent_projects -- crates/recent_projects/Cargo.toml: unused dependencies: serde dap task remote_server -- crates/remote_server/Cargo.toml: unused dependencies: crash-handler git2 minidumper serde dap workspace repl -- crates/repl/Cargo.toml: unused dependencies: env_logger serde reqwest_client -- crates/reqwest_client/Cargo.toml: unused dependencies: serde gpui rules_library -- crates/rules_library/Cargo.toml: unused dependencies: serde schema_generator -- crates/schema_generator/Cargo.toml: unused dependencies: serde settings_profile_selector -- crates/settings_profile_selector/Cargo.toml: unused dependencies: client language settings_ui -- crates/settings_ui/Cargo.toml: unused dependencies: futures zlog session node_runtime client assets language supermaven -- crates/supermaven/Cargo.toml: unused dependencies: project theme http_client env_logger editor tab_switcher -- crates/tab_switcher/Cargo.toml: unused dependencies: language anyhow tasks_ui -- crates/tasks_ui/Cargo.toml: unused dependencies: serde telemetry -- crates/telemetry/Cargo.toml: unused dependencies: serde terminal_view -- crates/terminal_view/Cargo.toml: unused dependencies: rand client text -- crates/text/Cargo.toml: unused dependencies: http_client theme_selector -- crates/theme_selector/Cargo.toml: unused dependencies: serde title_bar -- crates/title_bar/Cargo.toml: unused dependencies: pretty_assertions tree-sitter-md ui -- crates/ui/Cargo.toml: unused dependencies: windows util -- crates/util/Cargo.toml: unused dependencies: indoc vim -- crates/vim/Cargo.toml: unused dependencies: assets watch -- crates/watch/Cargo.toml: unused dependencies: rand web_search -- crates/web_search/Cargo.toml: unused dependencies: serde web_search_providers -- crates/web_search_providers/Cargo.toml: unused dependencies: serde workspace -- crates/workspace/Cargo.toml: unused dependencies: windows dap worktree -- crates/worktree/Cargo.toml: unused dependencies: serde git2 zed -- crates/zed/Cargo.toml: unused dependencies: profiling dap task zeta -- crates/zeta/Cargo.toml: unused dependencies: reqwest_client call rpc serde tree-sitter-go zeta2 -- crates/zeta2/Cargo.toml: unused dependencies: lsp zeta2_tools -- crates/zeta2_tools/Cargo.toml: unused dependencies: zlog indoc clap serde settings pretty_assertions root -- Cargo.toml: unused dependencies: pet-pixi collab wit-component num-traits storybook futures-batch plugin_macros cocoa-foundation ai hyper scheduler auto_update_helper plugin theme_importer rich_text cargo-shear may have detected unused dependencies incorrectly due to its limitations. They can be ignored by adding the crate name to the package's Cargo.toml: [package.metadata.cargo-shear] ignored = ["crate-name"] or in the workspace Cargo.toml: [workspace.metadata.cargo-shear] ignored = ["crate-name"] To automatically fix issues, run with --fix ``` </details>
Tracking issue for super let: #139076
This uses
super letto implementpin!().This means we can remove the hack we had to put in to fix #138596.
It also means we can remove the original hack to make
pin!()work, which used a questionable public-but-unstable field rather than a proper private field.While
super letis still unstable and subject to change, it seems safe to assume that future Rust will always have a way to expresspin!()in a compatible way, consideringpin!()is already stable.It'd help the experiment to have
pin!()usesuper let, so we can get some more experience with it.