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

Replace discriminant_switch_effect with more general version #77242

Merged
merged 4 commits into from
Sep 28, 2020

Conversation

ecstatic-morse
Copy link
Contributor

@ecstatic-morse ecstatic-morse commented Sep 26, 2020

#68528 added a new edge-specific effect for SwitchInt terminators, discriminant_switch_effect, to the dataflow framework. While this accomplished the short-term goal of making drop elaboration more precise, it wasn't really useful in other contexts: It only supported SwitchInts on the discriminant of an enum and did not allow effects to be applied along the "otherwise" branch. In const-propagation, for example, arbitrary edge-specific effects for the targets of a SwitchInt can be used to remember the value a match scrutinee must have in each arm.

This PR replaces discriminant_switch_effect with a more general switch_int_edge_effects method. The new method has a slightly different interface from the other edge-specific effect methods (e.g. call_return_effect). This divergence is explained in the new method's documentation, and reading the changes to the various dataflow impls as well as direction.rs should further clarify things. This PR should not change behavior.

@rust-highfive
Copy link
Collaborator

r? @lcnr

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 26, 2020
...that allows arbitrary effects on each edge of a `SwitchInt`
terminator.
@ecstatic-morse
Copy link
Contributor Author

This shouldn't really affect perf, although it does do slightly less work than the old version. Just in case.

@bors try
@rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Sep 26, 2020

⌛ Trying commit 2364b58 with merge b61b01669af3db2429eae891e9c9da925db8d359...

@rust-log-analyzer
Copy link
Collaborator

The job dist-x86_64-linux of your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
warning: 4 warnings emitted

    Checking rustc_privacy v0.0.0 (/checkout/compiler/rustc_privacy)
 Documenting rustc_privacy v0.0.0 (/checkout/compiler/rustc_privacy)
error: public documentation for `apply_switch_int_edge_effects` links to private item `SwitchIntEdgeEffects::apply`
   --> compiler/rustc_mir/src/dataflow/framework/mod.rs:189:10
    |
189 |     /// [`SwitchIntEdgeEffects::apply`]. The callback will be run once for each outgoing edge and
    |
    |
    = note: `-D broken-intra-doc-links` implied by `-D warnings`
    = note: this link resolves only because you passed `--document-private-items`, but will break without

error: public documentation for `apply_switch_int_edge_effects` links to private item `SwitchIntEdgeEffects::apply`
   --> compiler/rustc_mir/src/dataflow/framework/mod.rs:189:10
    |
189 |     /// [`SwitchIntEdgeEffects::apply`]. The callback will be run once for each outgoing edge and
    |
    |
    = note: this link resolves only because you passed `--document-private-items`, but will break without
warning: could not parse code block as Rust code
    --> compiler/rustc_mir/src/borrow_check/region_infer/mod.rs:1219:13
     |
1219 |     ///     <T as Foo<'0>>::Item: '1
---
    |     ^^^^^^^

error: aborting due to 2 previous errors; 2 warnings emitted

error: Could not document `rustc_mir`.
Caused by:
Caused by:
  process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustdoc --edition=2018 --crate-type lib --crate-name rustc_mir compiler/rustc_mir/src/lib.rs --target x86_64-unknown-linux-gnu -o /checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/doc --error-format=json --json=diagnostic-rendered-ansi -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/release/deps --extern either=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/libeither-0886f79aa9644b59.rmeta --extern itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/libitertools-15ba3a79d5ec8f6f.rmeta --extern log_settings=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/liblog_settings-09a944a5749e95d8.rmeta --extern polonius_engine=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/libpolonius_engine-9a99b9287362070b.rmeta --extern regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/libregex-32ea2f287d81478c.rmeta --extern rustc_apfloat=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_apfloat-2bc88092b3516846.rmeta --extern rustc_ast=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_ast-27ad5e09ebab896d.rmeta --extern rustc_attr=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_attr-9bd7064b478506f7.rmeta --extern rustc_data_structures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_data_structures-5d3d1912340ee4c7.rmeta --extern rustc_errors=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_errors-94b39b40ea1509ed.rmeta --extern rustc_graphviz=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_graphviz-e79b54e3fcce812e.rmeta --extern rustc_hir=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_hir-98ac1e26a11e2929.rmeta --extern rustc_index=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_index-78f7d4c857d61346.rmeta --extern rustc_infer=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_infer-7cf4ec21cef32adb.rmeta --extern rustc_lexer=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_lexer-d9c58c19eb967beb.rmeta --extern rustc_macros=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/release/deps/librustc_macros-526b2b3435deae8e.so --extern rustc_middle=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_middle-af60eb12c80f2671.rmeta --extern rustc_serialize=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_serialize-ba853f2a3b898296.rmeta --extern rustc_session=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_session-49085084dc014133.rmeta --extern rustc_span=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_span-1ff4578e4d1f53ae.rmeta --extern rustc_target=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_target-54d995fca71a3ae5.rmeta --extern rustc_trait_selection=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_trait_selection-8ce1ed9cb916064a.rmeta --extern smallvec=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/libsmallvec-31c79deb030c1dbf.rmeta --extern tracing=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-rustc/x86_64-unknown-linux-gnu/release/deps/libtracing-62a9fe09301d4da9.rmeta -Dwarnings -Winvalid_codeblock_attributes --crate-version '1.48.0-nightly
  (b61b01669
  2020-09-26)' --document-private-items --enable-index-page -Zunstable-options` (exit code: 1)
error: build failed



command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "doc" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "16" "--release" "--locked" "--color" "always" "--features" "jemalloc llvm max_level_info" "--manifest-path" "/checkout/compiler/rustc/Cargo.toml" "--no-deps" "-p" "rustc_ast_pretty" "-p" "rustc_macros" "-p" "rustc_lexer" "-p" "rustc_span" "-p" "rustc_ast" "-p" "rustc_query_system" "-p" "rustc_apfloat" "-p" "rustc_infer" "-p" "rustc_serialize" "-p" "rustc_expand" "-p" "rustc_hir" "-p" "rustc_traits" "-p" "rustc_codegen_ssa" "-p" "rustc_fs_util" "-p" "rustc_mir_build" "-p" "rustc_hir_pretty" "-p" "rustc_data_structures" "-p" "rustc_llvm" "-p" "rustc_save_analysis" "-p" "rustc_typeck" "-p" "rustc_ast_passes" "-p" "rustc_attr" "-p" "rustc_index" "-p" "rustc_parse_format" "-p" "rustc_ast_lowering" "-p" "rustc_middle" "-p" "rustc_plugin_impl" "-p" "rustc_driver" "-p" "rustc_incremental" "-p" "rustc_parse" "-p" "rustc_symbol_mangling" "-p" "rustc_interface" "-p" "rustc_resolve" "-p" "rustc_passes" "-p" "rustc_target" "-p" "rustc_session" "-p" "rustc_ty" "-p" "rustc_metadata" "-p" "rustc_privacy" "-p" "rustc_arena" "-p" "rustc_codegen_llvm" "-p" "rustc_mir" "-p" "rustc_lint" "-p" "rustc_trait_selection" "-p" "rustc_feature" "-p" "rustc_error_codes" "-p" "rustc_builtin_macros" "-p" "rustc_graphviz" "-p" "rustc_errors"


failed to run: /checkout/obj/build/bootstrap/debug/bootstrap dist --host x86_64-unknown-linux-gnu --target x86_64-unknown-linux-gnu
Build completed unsuccessfully in 0:21:32
Build completed unsuccessfully in 0:21:32
== clock drift check ==
  local time: Sat Sep 26 23:14:14 UTC 2020
  network time: Sat, 26 Sep 2020 23:14:14 GMT
== end clock drift check ==
##[error]Process completed with exit code 1.
Terminate orphan process: pid (5376) (python)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @rust-lang/infra. (Feature Requests)

@bors
Copy link
Contributor

bors commented Sep 26, 2020

💔 Test failed - checks-actions

@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-review Status: Awaiting review from the assignee but also interested parties. labels Sep 26, 2020
@ecstatic-morse
Copy link
Contributor Author

ecstatic-morse commented Sep 27, 2020

@jyn514 AFAIK, we always pass --document-private-items for rustc. Can we relax broken_intra_doc_links here? I think you'd have to split this into a separate lint, since you would still want to error for actually broken links.

@ecstatic-morse
Copy link
Contributor Author

@bors try

@bors
Copy link
Contributor

bors commented Sep 27, 2020

⌛ Trying commit c0cd1b0 with merge 3191331f311bf46f945abd05d1e078654803bdc7...

@jyn514
Copy link
Member

jyn514 commented Sep 27, 2020

Splitting this into a separate lint sounds useful, I'll work on that. In the meantime you can add #[allow(broken_intra_doc_links)] on that exact item with a FIXME.

@bors
Copy link
Contributor

bors commented Sep 27, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: 3191331f311bf46f945abd05d1e078654803bdc7 (3191331f311bf46f945abd05d1e078654803bdc7)

@rust-timer
Copy link
Collaborator

Queued 3191331f311bf46f945abd05d1e078654803bdc7 with parent 623fb90, future comparison URL.

@lcnr
Copy link
Contributor

lcnr commented Sep 27, 2020

I don't know enough about this.

r? @jonas-schievink maybe

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (3191331f311bf46f945abd05d1e078654803bdc7): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never

@jonas-schievink
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Sep 27, 2020

📌 Commit c0cd1b0 has been approved by jonas-schievink

@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 Sep 27, 2020
@bors
Copy link
Contributor

bors commented Sep 27, 2020

⌛ Testing commit c0cd1b0 with merge c0b15cc...

@bors
Copy link
Contributor

bors commented Sep 28, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: jonas-schievink
Pushing c0b15cc to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 28, 2020
@bors bors merged commit c0b15cc into rust-lang:master Sep 28, 2020
@rustbot rustbot added this to the 1.48.0 milestone Sep 28, 2020
@ecstatic-morse ecstatic-morse deleted the dataflow-switch-int branch October 6, 2020 01:42
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. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants