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

fix `is_non_exhaustive` confusion between structs and enums #53721

Merged
merged 2 commits into from Sep 6, 2018

Conversation

Projects
None yet
6 participants
@arielb1
Contributor

arielb1 commented Aug 26, 2018

Structs and enums can both be non-exhaustive, with a very different
meaning. This PR splits is_non_exhaustive to 2 separate functions - 1
for structs, and another for enums, and fixes the places that got the
usage confused.

Fixes #53549.

r? @eddyb

@rust-highfive

This comment was marked as outdated.

Show comment
Hide comment
@rust-highfive

rust-highfive Aug 26, 2018

Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (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.

[00:04:39] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:39] tidy error: /checkout/src/librustc_privacy/lib.rs:687: line longer than 100 chars
[00:04:40] some tidy checks failed
[00:04:40] 
[00:04:40] 
[00:04:40] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:40] 
[00:04:40] 
[00:04:40] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:40] Build completed unsuccessfully in 0:00:48
[00:04:40] Build completed unsuccessfully in 0:00:48
[00:04:40] Makefile:79: recipe for target 'tidy' failed
[00:04:40] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:05148440
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:0b59def7:start=1535292533405894303,finish=1535292533412867920,duration=6973617
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:052ac7ef
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:22a9a5a1
travis_time:start:22a9a5a1
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:05e56f00
$ dmesg | grep -i kill

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 @TimNN. (Feature Requests)

Collaborator

rust-highfive commented Aug 26, 2018

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (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.

[00:04:39] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:39] tidy error: /checkout/src/librustc_privacy/lib.rs:687: line longer than 100 chars
[00:04:40] some tidy checks failed
[00:04:40] 
[00:04:40] 
[00:04:40] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:40] 
[00:04:40] 
[00:04:40] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:40] Build completed unsuccessfully in 0:00:48
[00:04:40] Build completed unsuccessfully in 0:00:48
[00:04:40] Makefile:79: recipe for target 'tidy' failed
[00:04:40] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:05148440
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:0b59def7:start=1535292533405894303,finish=1535292533412867920,duration=6973617
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:052ac7ef
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:22a9a5a1
travis_time:start:22a9a5a1
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:05e56f00
$ dmesg | grep -i kill

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 @TimNN. (Feature Requests)

fix `is_non_exhaustive` confusion between structs and enums
Structs and enums can both be non-exhaustive, with a very different
meaning. This PR splits `is_non_exhaustive` to 2 separate functions - 1
for structs, and another for enums, and fixes the places that got the
usage confused.

Fixes #53549.
Show outdated Hide outdated src/librustc/ty/mod.rs
Show outdated Hide outdated src/librustc/ty/mod.rs
Show outdated Hide outdated src/librustc/ty/mod.rs

@nikomatsakis nikomatsakis self-assigned this Aug 30, 2018

move the is_field_list_non_exhaustive flag to VariantDef
This completely splits the IS_NON_EXHAUSTIVE flag. No functional
changes intended.
@arielb1

This comment has been minimized.

Show comment
Hide comment
@arielb1

arielb1 Sep 1, 2018

Contributor

pushed..

Contributor

arielb1 commented Sep 1, 2018

pushed..

@nikomatsakis

This comment has been minimized.

Show comment
Hide comment
@nikomatsakis

nikomatsakis Sep 5, 2018

Contributor

@bors r+

Contributor

nikomatsakis commented Sep 5, 2018

@bors r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Sep 5, 2018

Contributor

📌 Commit ae2ad30 has been approved by nikomatsakis

Contributor

bors commented Sep 5, 2018

📌 Commit ae2ad30 has been approved by nikomatsakis

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Sep 6, 2018

Contributor

⌛️ Testing commit ae2ad30 with merge 20ca025...

Contributor

bors commented Sep 6, 2018

⌛️ Testing commit ae2ad30 with merge 20ca025...

bors added a commit that referenced this pull request Sep 6, 2018

Auto merge of #53721 - arielb1:exhaustively-unpun, r=nikomatsakis
fix `is_non_exhaustive` confusion between structs and enums

Structs and enums can both be non-exhaustive, with a very different
meaning. This PR splits `is_non_exhaustive` to 2 separate functions - 1
for structs, and another for enums, and fixes the places that got the
usage confused.

Fixes #53549.

r? @eddyb
@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Sep 6, 2018

Contributor

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 20ca025 to master...

Contributor

bors commented Sep 6, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 20ca025 to master...

@bors bors merged commit ae2ad30 into rust-lang:master Sep 6, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@nnethercote

This comment has been minimized.

Show comment
Hide comment
@nnethercote
Contributor

nnethercote commented Sep 22, 2018

@arielb1

This comment has been minimized.

Show comment
Hide comment
@arielb1

arielb1 Sep 22, 2018

Contributor

Some bug? This commit should not change performance.

Contributor

arielb1 commented Sep 22, 2018

Some bug? This commit should not change performance.

@arielb1

This comment has been minimized.

Show comment
Hide comment
@arielb1

arielb1 Sep 22, 2018

Contributor

Looks like alloc_adt_def is taking much more time for some reason - at least on my callgrind. This at least makes sense.

Contributor

arielb1 commented Sep 22, 2018

Looks like alloc_adt_def is taking much more time for some reason - at least on my callgrind. This at least makes sense.

@arielb1

This comment has been minimized.

Show comment
Hide comment
@arielb1

arielb1 Sep 22, 2018

Contributor

Ah decoding of item attrs is duplicated between a struct and its constructor:
https://github.com/rust-lang/rust/blob/master/src/librustc_metadata/decoder.rs#L925-L930

The code I have written uses the constructor's attrs in VariantDef::new, and the ADT's attrs in AdtDef::new, which causes the double decoding.

Contributor

arielb1 commented Sep 22, 2018

Ah decoding of item attrs is duplicated between a struct and its constructor:
https://github.com/rust-lang/rust/blob/master/src/librustc_metadata/decoder.rs#L925-L930

The code I have written uses the constructor's attrs in VariantDef::new, and the ADT's attrs in AdtDef::new, which causes the double decoding.

arielb1 added a commit to arielb1/rust that referenced this pull request Sep 22, 2018

avoid loading constructor attributes in AdtDef decoding
During metadata loading, the AdtDefs for every ADT in the universe need
to be loaded (for example, for coherence of builtin traits). For that,
the attributes of the AdtDef need to be loaded too.

The attributes of a struct are duplicated between 2 def ids - the
constructor def-id, and the "type" def id. Loading attributes for both
def-ids, which was done in #53721, slowed the compilation of small
crates by 2-3%. This PR makes sure we only load the attributes for the
"type" def-id, avoiding the slowdown.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment