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

Rollup of 10 pull requests #59550

Merged
merged 35 commits into from
Mar 30, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4187560
Add comments for new `AdtDef` functions.
davidtwco Mar 22, 2019
4e7ec07
Account for short-hand field syntax when suggesting borrow
estebank Mar 27, 2019
a51ca02
Expand test
estebank Mar 27, 2019
e3918cf
Recover from parse error in tuple syntax
estebank Mar 27, 2019
8fd3be5
fix broken download link in the armhf-gnu image
pietroalbini Mar 28, 2019
3a88cd7
Implement `#[non_exhaustive]` on variants.
davidtwco Mar 22, 2019
b7dc8e7
fix text after rebase
estebank Mar 29, 2019
9ea6790
Deduplicate parse recovery code
estebank Mar 29, 2019
07857f7
review comments
estebank Mar 28, 2019
e995fa8
implement `AsRawFd` for stdio locks
euclio Mar 29, 2019
1893841
Update documentation.
davidtwco Mar 23, 2019
49a6da2
Support non-exhaustive enum variants in rustdoc.
davidtwco Mar 23, 2019
ff33b27
Whitelist `rustc_on_unimplemented` to avoid erroneous flagging as an …
pnkfelix Mar 29, 2019
3592079
revert change to test file as per review request
estebank Mar 29, 2019
0b96697
Regression test for incremental treatment of rustc_on_unimplemented.
pnkfelix Mar 29, 2019
7642f10
Whitelist rustc_layout_scalar_valid_range_{start,end} so incr comp do…
pnkfelix Mar 29, 2019
cbbd4d5
Regression test for incremental treatment of rustc_scalar_valid_range…
pnkfelix Mar 29, 2019
f10e444
Edited the dbg! docs stating that dbg! works the same way in release …
Mar 29, 2019
9240092
Adjusted the indentation.
Mar 29, 2019
fe210d0
Update src/libstd/macros.rs
Centril Mar 29, 2019
8705de4
Update src/libstd/macros.rs
Centril Mar 29, 2019
ddfa47f
Fix incorrect code
estebank Mar 29, 2019
9e4ec7a
Collapse blanket impls in the same way as normal impls
laurmaedje Mar 29, 2019
b6fb3e3
In doc examples, don't ignore read/write results
mbrubeck Mar 29, 2019
7ce0b67
Fix OnceWith docstring.
goffrie Mar 29, 2019
d050a15
Rollup merge of #59376 - davidtwco:finally-rfc-2008-variants, r=petro…
Centril Mar 30, 2019
c28704c
Rollup merge of #59453 - estebank:recover-tuple-parse, r=petrochenkov
Centril Mar 30, 2019
41e64b6
Rollup merge of #59455 - estebank:borrow-sugg-shorthand-field, r=davi…
Centril Mar 30, 2019
3de2821
Rollup merge of #59499 - pietroalbini:fix-arm-broken-link, r=alexcric…
Centril Mar 30, 2019
1b1b864
Rollup merge of #59512 - euclio:stdio-locks, r=sfackler
Centril Mar 30, 2019
11e1b3e
Rollup merge of #59525 - pnkfelix:whitelist-some-rustc-attrs, r=petro…
Centril Mar 30, 2019
183afcd
Rollup merge of #59528 - DevQps:improve-dbg-macro-docs, r=Centril
Centril Mar 30, 2019
931151f
Rollup merge of #59532 - mbrubeck:docs, r=Centril
Centril Mar 30, 2019
ca14c56
Rollup merge of #59534 - laurmaedje:collapse-blanket-impls, r=Guillau…
Centril Mar 30, 2019
62a78c4
Rollup merge of #59537 - goffrie:patch-3, r=Centril
Centril Mar 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update documentation.
This commit updates the unstable book and diagnostics to reflect that
the `#[non_exhaustive]` attribute is now available for enum variants.
  • Loading branch information
davidtwco committed Mar 29, 2019
commit 18938416e4d34d7f7d64d11decd87ce47036bb75
11 changes: 6 additions & 5 deletions src/doc/unstable-book/src/language-features/non-exhaustive.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ The tracking issue for this feature is: [#44109]
------------------------

The `non_exhaustive` gate allows you to use the `#[non_exhaustive]` attribute
on structs and enums. When applied within a crate, users of the crate will need
to use the `_` pattern when matching enums and use the `..` pattern when
matching structs. Structs marked as `non_exhaustive` will not be able to be
created normally outside of the defining crate. This is demonstrated below:
on structs, enums and enum variants. When applied within a crate, users of the
crate will need to use the `_` pattern when matching enums and use the `..`
pattern when matching structs. Enum variants cannot be matched against.
Structs and enum variants marked as `non_exhaustive` will not be able to
be created normally outside of the defining crate. This is demonstrated
below:

```rust,ignore (pseudo-Rust)
use std::error::Error as StdError;
Expand Down Expand Up @@ -72,4 +74,3 @@ let config = Config { window_width: 640, window_height: 480 };
// when marked non_exhaustive.
let &Config { window_width, window_height, .. } = config;
```

13 changes: 7 additions & 6 deletions src/librustc_typeck/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4341,11 +4341,12 @@ foo.method(); // Ok!
"##,

E0638: r##"
This error indicates that the struct or enum must be matched non-exhaustively
as it has been marked as `non_exhaustive`.
This error indicates that the struct, enum or enum variant must be matched
non-exhaustively as it has been marked as `non_exhaustive`.

When applied within a crate, downstream users of the crate will need to use the
`_` pattern when matching enums and use the `..` pattern when matching structs.
Downstream crates cannot match against non-exhaustive enum variants.

For example, in the below example, since the enum is marked as
`non_exhaustive`, it is required that downstream crates match non-exhaustively
Expand Down Expand Up @@ -4390,10 +4391,10 @@ Similarly, for structs, match with `..` to avoid this error.
"##,

E0639: r##"
This error indicates that the struct or enum cannot be instantiated from
outside of the defining crate as it has been marked as `non_exhaustive` and as
such more fields/variants may be added in future that could cause adverse side
effects for this code.
This error indicates that the struct, enum or enum variant cannot be
instantiated from outside of the defining crate as it has been marked
as `non_exhaustive` and as such more fields/variants may be added in
future that could cause adverse side effects for this code.

It is recommended that you look for a `new` function or equivalent in the
crate's documentation.
Expand Down