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

Remove most specialization use in serialization #73851

Merged
merged 8 commits into from
Aug 15, 2020

Conversation

matthewjasper
Copy link
Contributor

Switching from specialization to min_specialization in the compiler made the unsoundness of how we used these traits pretty clear. This changes how the Encodable and Decodable traits work to be more friendly for types need a TyCtxt to deserialize.

The alternative design of having both Encodable and TyEncodable traits was considered, but doesn't really work because the following impls would conflict:

impl<E: Ecodable> TyEncodable for Encodable
impl<E: TyEcodable> TyEncodable for [E]

How-to guide

  • Rustc(De|En)codable is now spelled Ty(De|En)coable in rustc_middle, Metadata(En|De)codable in rustc_metadata where needed, and (De|En)codable everywhere else.
  • Manual implementations of (De|En)codable shouldn't be much different.
  • If you're adding a new interned type that needs to be en/decodable then the simplest thing way to handle this is:
    • Have the type be a wrapper around a reference to the interned data (i.e. do what ty::Predicate does, and not what all of the other interned types do)
    • Derive Ty(En|De)codable on the inner type
    • Implement Encodable<impl TyEncoder> by forwarding to the inner type.
    • Implement Decodable<impl TyDecoder> by decoding the inner type and then creating the wrapper around that (using the tcx from the decoder as needed).

cc @rust-lang/compiler for opinions on this change
r? @oli-obk

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 28, 2020
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-8 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.
##[section]Starting: Linux x86_64-gnu-llvm-8
##[section]Starting: Initialize job
Agent name: 'Azure Pipelines 63'
Agent machine name: 'fv-az659'
Current agent version: '2.171.1'
##[group]Operating System
16.04.6
LTS
LTS
##[endgroup]
##[group]Virtual Environment
Environment: ubuntu-16.04
Version: 20200621.1
Included Software: https://github.com/actions/virtual-environments/blob/ubuntu16/20200621.1/images/linux/Ubuntu1604-README.md
##[endgroup]
Agent running as: 'vsts'
Prepare build directory.
Set build variables.
Download all required tasks.
Download all required tasks.
Downloading task: Bash (3.171.1)
Checking job knob settings.
   Knob: AgentToolsDirectory = /opt/hostedtoolcache Source: ${AGENT_TOOLSDIRECTORY} 
   Knob: AgentPerflog = /home/vsts/perflog Source: ${VSTS_AGENT_PERFLOG} 
Start tracking orphan processes.
##[section]Finishing: Initialize job
##[section]Starting: Configure Job Name
==============================================================================
---
========================== Starting Command Output ===========================
[command]/bin/bash --noprofile --norc /home/vsts/work/_temp/23ef5675-6305-4292-b8bc-30cd05ec8421.sh

##[section]Finishing: Disable git automatic line ending conversion
##[section]Starting: Checkout rust-lang/rust@refs/pull/73851/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
---
##[command]git remote add origin https://github.com/rust-lang/rust
##[command]git config gc.auto 0
##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
##[command]git config --get-all http.proxy
##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/73851/merge:refs/remotes/pull/73851/merge
---
 ---> 31fea614d2f3
Step 5/8 : ENV RUST_CONFIGURE_ARGS       --build=x86_64-unknown-linux-gnu       --llvm-root=/usr/lib/llvm-8       --enable-llvm-link-shared       --set rust.thin-lto-import-instr-limit=10
 ---> Using cache
 ---> 4195cadf126d
Step 6/8 : ENV SCRIPT python2.7 ../x.py test --exclude src/tools/tidy &&            python2.7 ../x.py test src/test/mir-opt --pass=build                                   --target=armv5te-unknown-linux-gnueabi &&            python2.7 ../x.py test src/tools/tidy
 ---> 4e90f6b48f05
Step 7/8 : ENV NO_DEBUG_ASSERTIONS=1
 ---> Using cache
 ---> dfa0a356d899
---
Set({"src/librustc_parse_format"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_passes"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_plugin_impl"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_privacy"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_query_system"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_save_analysis"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_serialize"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_session"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_span"}) not skipped for "bootstrap::test::CrateLibrustc" -- not in ["src/tools/tidy"]
---
Set({"src/librustc_parse_format"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_passes"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_plugin_impl"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_privacy"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_query_system"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_save_analysis"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_serialize"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_session"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
Set({"src/librustc_span"}) not skipped for "bootstrap::doc::Rustc" -- not in ["src/tools/tidy"]
---
   Compiling rustc_parse_format v0.0.0 (/checkout/src/librustc_parse_format)
   Compiling chalk-solve v0.14.0
   Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
   Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
   Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
   Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
   Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
   Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
   Compiling rustc_ast_passes v0.0.0 (/checkout/src/librustc_ast_passes)
---
   Compiling rustc_parse_format v0.0.0 (/checkout/src/librustc_parse_format)
   Compiling tracing v0.1.15
   Compiling rustc_ast_pretty v0.0.0 (/checkout/src/librustc_ast_pretty)
   Compiling rustc_hir v0.0.0 (/checkout/src/librustc_hir)
   Compiling rustc_query_system v0.0.0 (/checkout/src/librustc_query_system)
   Compiling chalk-engine v0.14.0
   Compiling rustc_hir_pretty v0.0.0 (/checkout/src/librustc_hir_pretty)
   Compiling rustc_parse v0.0.0 (/checkout/src/librustc_parse)
   Compiling rustc_ast_lowering v0.0.0 (/checkout/src/librustc_ast_lowering)
---
...............................i.................................................................... 1900/10417
.................................................................................................... 2000/10417
..........................................................i..i...................................... 2100/10417
.................................................................................................... 2200/10417
................................................iiiii............................................... 2300/10417
.................................................................................................... 2500/10417
.................................................................................................... 2600/10417
.................................................................................................... 2700/10417
.................................................................................................... 2800/10417
---
.......i............................................................................................ 5300/10417
.................................................................................................... 5400/10417
........................................i........................................................... 5500/10417
..................................i................................................................. 5600/10417
......................................................ii.ii........i...i............................ 5700/10417
...................................................................................................i 5800/10417
....................i............................................................................... 6000/10417
..............................................................................ii.................... 6100/10417
.................i.................................................................................. 6200/10417
.................................................................................................... 6300/10417
.................................................................................................... 6300/10417
.................................................................................................... 6400/10417
..........................................ii...i..ii...........i.................................... 6500/10417
.................................................................................................... 6700/10417
.................................................................................................... 6800/10417
.................................................................................................... 6800/10417
..............................................................................i..ii................. 6900/10417
.................................................................................................... 7100/10417
.................................................................................................... 7200/10417
..................................i................................................................. 7300/10417
.................................................................................................... 7400/10417
---
.................................................................................................... 8300/10417
.................................................................................................... 8400/10417
.....................................................................................i.............. 8500/10417
.................................................................................................... 8600/10417
.......................................iiiiii..iiiiii.i............................................. 8700/10417
.................................................................................................... 8900/10417
.................................................................................................... 9000/10417
.................................................................................................... 9100/10417
.................................................................................................... 9200/10417
---

---- [ui] ui/ast-json/ast-json-noexpand-output.rs stdout ----
diff of stdout:

- {"module":{"inner":{"lo":0,"hi":0},"items":[{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"_field0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"NonJoint"]]}]}}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0}}],"span":{"lo":0,"hi":0},"proc_macros":[]}
+ {"module":{"inner":{"lo":0,"hi":0},"items":[{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"NonJoint"]]}]}}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0}}],"span":{"lo":0,"hi":0},"proc_macros":[]}


The actual stdout differed from the expected stdout.
The actual stdout differed from the expected stdout.
Actual stdout saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/ast-json/ast-json-noexpand-output/ast-json-noexpand-output.stdout
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args ast-json/ast-json-noexpand-output.rs`
error: 1 errors occurred comparing output.
error: 1 errors occurred comparing output.
failed to decode compiler output as json: line: {"module":{"inner":{"lo":39,"hi":259},"items":[{"attrs":[],"id":4294967040,"span":{"lo":241,"hi":259},"vis":{"node":"Inherited","span":{"lo":241,"hi":241}},"ident":{"name":"core","span":{"lo":254,"hi":258}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":42,"hi":52},"segments":[{"ident":{"name":"crate_type","span":{"lo":42,"hi":52}},"id":4294967040,"args":null}]},"args":{"variant":"Eq","fields":[{"lo":53,"hi":54},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":55,"hi":60}}]},"NonJoint"]]}]}}]},"id":null,"style":"Inner","span":{"lo":39,"hi":61}}],"span":{"lo":39,"hi":259},"proc_macros":[]}
output: {"module":{"inner":{"lo":39,"hi":259},"items":[{"attrs":[],"id":4294967040,"span":{"lo":241,"hi":259},"vis":{"node":"Inherited","span":{"lo":241,"hi":241}},"ident":{"name":"core","span":{"lo":254,"hi":258}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":42,"hi":52},"segments":[{"ident":{"name":"crate_type","span":{"lo":42,"hi":52}},"id":4294967040,"args":null}]},"args":{"variant":"Eq","fields":[{"lo":53,"hi":54},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":55,"hi":60}}]},"NonJoint"]]}]}}]},"id":null,"style":"Inner","span":{"lo":39,"hi":61}}],"span":{"lo":39,"hi":259},"proc_macros":[]}
thread '[ui] ui/ast-json/ast-json-noexpand-output.rs' panicked at 'explicit panic', src/tools/compiletest/src/json.rs:86:21

---- [ui] ui/ast-json/ast-json-output.rs stdout ----
diff of stdout:


- {"module":{"inner":{"lo":0,"hi":0},"items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"args":"Empty"}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"args":"Empty"}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"_field0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"NonJoint"]]}]}}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0}}],"span":{"lo":0,"hi":0},"proc_macros":[]}
+ {"module":{"inner":{"lo":0,"hi":0},"items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"args":"Empty"}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"args":"Empty"}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"NonJoint"]]}]}}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0}}],"span":{"lo":0,"hi":0},"proc_macros":[]}


The actual stdout differed from the expected stdout.
Actual stdout saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/ast-json/ast-json-output/ast-json-output.stdout
Actual stdout saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/ast-json/ast-json-output/ast-json-output.stdout
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args ast-json/ast-json-output.rs`
error: 1 errors occurred comparing output.
error: 1 errors occurred comparing output.
failed to decode compiler output as json: line: {"module":{"inner":{"lo":39,"hi":250},"items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":4,"args":null}]},"args":"Empty"}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":5,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":6,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":7,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":8,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":9,"args":null}]},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":10,"args":null}]},"args":"Empty"}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":11,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":12,"span":{"lo":232,"hi":250},"vis":{"node":"Inherited","span":{"lo":232,"hi":232}},"ident":{"name":"core","span":{"lo":245,"hi":249}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":42,"hi":52},"segments":[{"ident":{"name":"crate_type","span":{"lo":42,"hi":52}},"id":2,"args":null}]},"args":{"variant":"Eq","fields":[{"lo":53,"hi":54},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":55,"hi":60}}]},"NonJoint"]]}]}}]},"id":null,"style":"Inner","span":{"lo":39,"hi":61}}],"span":{"lo":39,"hi":250},"proc_macros":[]}
output: {"module":{"inner":{"lo":39,"hi":250},"items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":4,"args":null}]},"args":"Empty"}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":5,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":6,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":7,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":8,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":9,"args":null}]},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":10,"args":null}]},"args":"Empty"}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":11,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":12,"span":{"lo":232,"hi":250},"vis":{"node":"Inherited","span":{"lo":232,"hi":232}},"ident":{"name":"core","span":{"lo":245,"hi":249}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":42,"hi":52},"segments":[{"ident":{"name":"crate_type","span":{"lo":42,"hi":52}},"id":2,"args":null}]},"args":{"variant":"Eq","fields":[{"lo":53,"hi":54},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":55,"hi":60}}]},"NonJoint"]]}]}}]},"id":null,"style":"Inner","span":{"lo":39,"hi":61}}],"span":{"lo":39,"hi":250},"proc_macros":[]}


failures:
    [ui] ui/ast-json/ast-json-noexpand-output.rs
    [ui] ui/ast-json/ast-json-noexpand-output.rs
    [ui] ui/ast-json/ast-json-output.rs

test result: FAILED. 10349 passed; 2 failed; 66 ignored; 0 measured; 0 filtered out

thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:344:22


command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-8/bin/FileCheck" "--nodejs" "/usr/bin/node" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "8.0.0" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"


failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --exclude src/tools/tidy
Build completed unsuccessfully in 1:08:55
Build completed unsuccessfully in 1:08:55
== clock drift check ==
  local time: Sun Jun 28 23:23:01 UTC 2020
  network time: Sun, 28 Jun 2020 23:23:01 GMT
== end clock drift check ==

##[error]Bash exited with code '1'.
##[section]Finishing: Run build
##[section]Starting: Checkout rust-lang/rust@refs/pull/73851/merge to s
Task         : Get sources
Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.
Version      : 1.0.0
Author       : Microsoft
Author       : Microsoft
Help         : [More Information](https://go.microsoft.com/fwlink/?LinkId=798199)
==============================================================================
Cleaning any cached credential from repository: rust-lang/rust (GitHub)
##[section]Finishing: Checkout rust-lang/rust@refs/pull/73851/merge to s
Cleaning up task key
Start cleaning up orphan processes.
Terminate orphan process: pid (4516) (python)
##[section]Finishing: Finalize Job

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)

/// * `Encodable` should be used in crates that don't depend on
/// `librustc_middle`.
/// * `TyEncodable` should be used for types that are only serialized in crate
/// metadata or the incremental cache, except for simple enums.where
Copy link
Contributor

Choose a reason for hiding this comment

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

why except for simple enums, and why does this rule not apply to MetadataEncodable? Also there's a trailing where here.

/// * `Decodable` should be used in crates that don't depend on
/// `librustc_middle`.
/// * `TyDecodable` should be used for types that are only serialized in crate
/// metadata or the incremental cache, except for simple enums.where
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

s.emit_usize(*self)
}
}

impl Decodable for usize {
fn decode<D: Decoder>(d: &mut D) -> Result<usize, D::Error> {
impl<D: Decoder> Decodable<D> for usize {
Copy link
Contributor

Choose a reason for hiding this comment

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

preexisting, but it seems to me like we should have a macro for all these trivial impls in this file.

s.emit_str(self)
}
}

impl Encodable for String {
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
impl<S: Encoder> Encodable<S> for &str {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing a general impl for &T where T: Encodable<S> will conflict with something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It conflicts with the impl for Ty.

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

* If you're adding a new interned type that needs to be en/decodable then the simplest thing way to handle this is:

maybe include this info in the module/crate docs of rustc_serialize

I didn't check the derive code in detail, but since it's working I'm fine merging it.

r=me with the mentioned documentation changes and CI passing

@nikomatsakis
Copy link
Contributor

This seems like an MCP-worthy change.

@Aaron1011
Copy link
Member

Let's see what the perf impact is:

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Jun 29, 2020

⌛ Trying commit fb818d4321dee29e1938c002c1ff79b0e7eaadff with merge 2cbd21174610f0835db8fb3a01bed54dd04d5d63...

@bors
Copy link
Contributor

bors commented Jun 29, 2020

☀️ Try build successful - checks-azure
Build commit: 2cbd21174610f0835db8fb3a01bed54dd04d5d63 (2cbd21174610f0835db8fb3a01bed54dd04d5d63)

@rust-timer
Copy link
Collaborator

Queued 2cbd21174610f0835db8fb3a01bed54dd04d5d63 with parent 0ca7f74, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (2cbd21174610f0835db8fb3a01bed54dd04d5d63): comparison url.

@mark-i-m
Copy link
Member

Should this be added to rustc-dev-guide in some form? We don't really have any documentation about serialization...

@nikomatsakis
Copy link
Contributor

Perf results appear neutral to positive.

@nikomatsakis
Copy link
Contributor

I do think we should have this setup documented in the rustc-dev-guide, yes.

@matthewjasper
Copy link
Contributor Author

I've opened an MCP and a PR to document serialization in rustc in the guide.

@eddyb
Copy link
Member

eddyb commented Jul 6, 2020

cc #36588

Comment on lines +48 to +53
::rustc_serialize::Decoder::read_struct(
__decoder,
#ty_name,
#n_fields,
|__decoder| { ::std::result::Result::Ok(#construct) },
)
Copy link
Member

Choose a reason for hiding this comment

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

It's neat that this works with rustc_serialize, I guess. For #36588 I expected we'd remove all of the features we don't need for the opaque encoding but I don't have anything against being comprehensive.

@bors
Copy link
Contributor

bors commented Jul 14, 2020

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

@matthewjasper matthewjasper force-pushed the serialize-not-special branch 2 times, most recently from ddf030a to 560918b Compare July 20, 2020 18:35
@matthewjasper
Copy link
Contributor Author

@bors p=1 rollup=iffy
This will break code that adds new Rustc(De|En)codable uses.

@bors
Copy link
Contributor

bors commented Jul 23, 2020

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

@bors
Copy link
Contributor

bors commented Aug 14, 2020

💥 Test timed out

@bors bors added 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 Aug 14, 2020
@tmandry
Copy link
Member

tmandry commented Aug 14, 2020

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Aug 14, 2020

💡 This pull request was already approved, no need to approve it again.

  • This pull request previously failed. You should add more commits to fix the bug, or use retry to trigger a build again.
  • There's another pull request that is currently being tested, blocking this pull request: Rollup of 17 pull requests #75538

@bors
Copy link
Contributor

bors commented Aug 14, 2020

📌 Commit c4f91bb has been approved by oli-obk

@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 Aug 14, 2020
@bors
Copy link
Contributor

bors commented Aug 15, 2020

⌛ Testing commit c4f91bb with merge 668a34e...

@bors
Copy link
Contributor

bors commented Aug 15, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: oli-obk
Pushing 668a34e to master...

@ecstatic-morse
Copy link
Contributor

Final perf results show a very slight regression in instruction counts unlike the earlier perf run, which showed a slight improvement. Is this actionable @matthewjasper?

@matthewjasper
Copy link
Contributor Author

I don't think there's anything obvious to do for this. Maybe profiling would show something.

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.