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

Warn if include macro fails to include entire file #64284

Merged
merged 1 commit into from Oct 9, 2019

Conversation

@Mark-Simulacrum
Copy link
Member

Mark-Simulacrum commented Sep 8, 2019

This currently introduces an error, mainly because that was just simpler, and I'm not entirely certain if we can introduce a lint without an RFC and such.

This is primarily to get feedback on the approach and overall aim -- in particular, do we think this is helpful? If so, we probably will need lang-team sign off and decide if it should be an error (as currently introduced by this PR), a lint, or a warning.

r? @petrochenkov

cc #35560

@Centril

This comment has been minimized.

Copy link
Member

Centril commented Sep 8, 2019

Ostensibly we could do what the user wants by switching to parsing a block implicitly and putting a bunch of statements in there. On the other hand, this might actually change the dynamic semantics of some programs (but that's probably a bug-fix if it does...).

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Sep 8, 2019

As far as I know, we can't just switch to parsing it as a block of statements because of how macro expansion works, but I could well be wrong about that.

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Sep 8, 2019

The job x86_64-gnu-llvm-6.0 of your PR failed (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.
2019-09-08T14:04:18.5712221Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-09-08T14:04:19.1231077Z ##[command]git config gc.auto 0
2019-09-08T14:04:19.1234231Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-09-08T14:04:19.1238117Z ##[command]git config --get-all http.proxy
2019-09-08T14:04:19.1240934Z ##[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/64284/merge:refs/remotes/pull/64284/merge
---
2019-09-08T15:06:55.2664405Z .................................................................................................... 1500/9010
2019-09-08T15:07:01.3497022Z .................................................................................................... 1600/9010
2019-09-08T15:07:14.6085009Z ......................................................i...............i............................. 1700/9010
2019-09-08T15:07:22.7830712Z .................................................................................................... 1800/9010
2019-09-08T15:07:37.8033660Z .............................................iiiii.................................................. 1900/9010
2019-09-08T15:07:49.2113822Z .................................................................................................... 2100/9010
2019-09-08T15:07:51.9008483Z .................................................................................................... 2200/9010
2019-09-08T15:07:55.6027288Z .................................................................................................... 2300/9010
2019-09-08T15:08:03.8255475Z .................................................................................................... 2400/9010
---
2019-09-08T15:11:08.7747209Z ....................................i...............i............................................... 4700/9010
2019-09-08T15:11:20.7531977Z .................................................................................................... 4800/9010
2019-09-08T15:11:27.5177727Z .................................................................................................... 4900/9010
2019-09-08T15:11:38.7041884Z .................................................................................................... 5000/9010
2019-09-08T15:11:44.9406332Z ..................ii.ii............................................................................. 5100/9010
2019-09-08T15:11:55.4317892Z .................................................................................................... 5300/9010
2019-09-08T15:12:05.5932347Z .................................................................................i.................. 5400/9010
2019-09-08T15:12:13.6481149Z .................................................................................................... 5500/9010
2019-09-08T15:12:19.5536481Z .................................................................................................... 5600/9010
2019-09-08T15:12:19.5536481Z .................................................................................................... 5600/9010
2019-09-08T15:12:30.2442665Z ...........................................................................ii...i..ii...........i... 5700/9010
2019-09-08T15:12:55.6672312Z .................................................................................................... 5900/9010
2019-09-08T15:13:05.9877704Z .................................................................................................... 6000/9010
2019-09-08T15:13:05.9877704Z .................................................................................................... 6000/9010
2019-09-08T15:13:12.1997583Z .............................................................................i..ii.................. 6100/9010
2019-09-08T15:13:42.3286823Z .................................................................................................... 6300/9010
2019-09-08T15:13:44.5266327Z ....................................i............................................................... 6400/9010
2019-09-08T15:13:46.7752707Z .................................................................................................... 6500/9010
2019-09-08T15:13:49.4428699Z ........i........................................................................................... 6600/9010
---
2019-09-08T15:18:40.4477551Z  finished in 20.631
2019-09-08T15:18:40.4674552Z Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-09-08T15:18:40.6368657Z 
2019-09-08T15:18:40.6369791Z running 150 tests
2019-09-08T15:18:44.0381111Z i....iii......iii..iiii....i.............................i..i..................i....i.........ii.i.i 100/150
2019-09-08T15:18:46.1175664Z ..iiii..............i.........iii.i.......ii......
2019-09-08T15:18:46.1176211Z 
2019-09-08T15:18:46.1186830Z  finished in 5.651
2019-09-08T15:18:46.1398038Z Check compiletest suite=codegen-units mode=codegen-units (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-09-08T15:18:46.3122578Z 
---
2019-09-08T15:18:48.4946458Z  finished in 2.354
2019-09-08T15:18:48.5161047Z Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-09-08T15:18:48.6905867Z 
2019-09-08T15:18:48.6908948Z running 9 tests
2019-09-08T15:18:48.6911995Z iiiiiiiii
2019-09-08T15:18:48.6913071Z 
2019-09-08T15:18:48.6914557Z  finished in 0.175
2019-09-08T15:18:48.7119034Z Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-09-08T15:18:48.8884926Z 
---
2019-09-08T15:19:07.8357788Z  finished in 19.120
2019-09-08T15:19:07.8523364Z Check compiletest suite=debuginfo mode=debuginfo-gdb+lldb (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-09-08T15:19:08.0263915Z 
2019-09-08T15:19:08.0264191Z running 123 tests
2019-09-08T15:19:32.5293892Z .iiiii...i.....i..i...i..i.i.i..i.ii..i.i.....i..i....ii..........iiii..........i...ii...i.......ii. 100/123
2019-09-08T15:19:37.1391967Z i.i.i......iii.i.....ii
2019-09-08T15:19:37.1394078Z 
2019-09-08T15:19:37.1397366Z  finished in 29.287
2019-09-08T15:19:37.1407666Z Uplifting stage1 rustc (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-09-08T15:19:37.1407991Z Copying stage2 rustc from stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-gnu)
---
2019-09-08T15:33:35.2144178Z 
2019-09-08T15:33:35.2145496Z    Doc-tests core
2019-09-08T15:33:40.4703679Z 
2019-09-08T15:33:40.4704763Z running 2397 tests
2019-09-08T15:33:51.6803935Z ......iiiii......................................................................................... 100/2397
2019-09-08T15:34:02.5789657Z ...........................................................................ii....................... 200/2397
2019-09-08T15:34:14.9547328Z .................................................................................................i.. 300/2397
2019-09-08T15:34:28.4206131Z .................................................................................................... 400/2397
2019-09-08T15:34:38.9199343Z .........................................i..i.................iiii.................................. 500/2397
2019-09-08T15:34:59.0869248Z .................................................................................................... 700/2397
2019-09-08T15:35:09.4896362Z .................................................................................................... 800/2397
2019-09-08T15:35:19.9219821Z .................................................................................................... 900/2397
2019-09-08T15:35:30.4559422Z .................................................................................................... 1000/2397
---
2019-09-08T15:40:34.9966160Z 
2019-09-08T15:40:34.9967940Z running 991 tests
2019-09-08T15:40:56.5240671Z i................................................................................................... 100/991
2019-09-08T15:41:08.3312912Z .................................................................................................... 200/991
2019-09-08T15:41:16.7055947Z .................iii......i......i...i......i....................................................... 300/991
2019-09-08T15:41:22.6627641Z .................................................................................................... 400/991
2019-09-08T15:41:30.7494088Z ..................................i..i.................................ii........................... 500/991
2019-09-08T15:41:46.0596628Z .................................................................................................... 700/991
2019-09-08T15:41:46.0596628Z .................................................................................................... 700/991
2019-09-08T15:41:54.2941175Z .................iiii............................................................................... 800/991
2019-09-08T15:42:09.4575259Z .................................................................................................... 900/991
2019-09-08T15:42:17.1620426Z .......................................iiii................................................
2019-09-08T15:42:17.1621956Z 
2019-09-08T15:42:17.1714938Z  finished in 249.419
2019-09-08T15:42:17.1732586Z Testing term stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
2019-09-08T15:42:17.5085834Z    Compiling term v0.0.0 (/checkout/src/libterm)
---
2019-09-08T15:57:30.0517914Z Building stage2 tool error_index_generator (x86_64-unknown-linux-gnu)
2019-09-08T15:57:30.2560446Z    Compiling same-file v1.0.4
2019-09-08T15:57:30.3723515Z    Compiling walkdir v2.2.7
2019-09-08T15:57:31.8101763Z    Compiling error_index_generator v0.0.0 (/checkout/src/tools/error_index_generator)
2019-09-08T15:57:32.9460804Z error: include macro expected single expression in source
2019-09-08T15:57:32.9462281Z    --> /checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/build/error_index_generator-87d009c7e595704d/out/error_0.rs:455:5
2019-09-08T15:57:32.9463672Z 455 | })();
2019-09-08T15:57:32.9463948Z     |     ^
2019-09-08T15:57:32.9465956Z 
2019-09-08T15:57:32.9470884Z error: aborting due to previous error
---
2019-09-08T15:57:32.9685469Z == clock drift check ==
2019-09-08T15:57:32.9726524Z   local time: Sun Sep  8 15:57:32 UTC 2019
2019-09-08T15:57:33.0561600Z   network time: Sun, 08 Sep 2019 15:57:33 GMT
2019-09-08T15:57:33.0564184Z == end clock drift check ==
2019-09-08T15:57:37.9632405Z ##[error]Bash exited with code '1'.
2019-09-08T15:57:37.9671669Z ##[section]Starting: Checkout
2019-09-08T15:57:37.9674459Z ==============================================================================
2019-09-08T15:57:37.9674520Z Task         : Get sources
2019-09-08T15:57:37.9674591Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@Mark-Simulacrum Mark-Simulacrum force-pushed the Mark-Simulacrum:include-warn branch from 1eb6922 to 2a92dc7 Sep 8, 2019
@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Sep 8, 2019

Seems like an obvious bugfix to me (compare with with fn make_items below which does perform the token::Eof check for item position include!s).

The end goal is to migrate built-in macros to the token-based model (which is currently in effect for proc macros).
In that model the macro returns tokens, and those tokens are parsed into an AST fragment depending on the macro's position (expresstion, type, items or whatever). If the tokens don't fit into that fragment's grammar, then it's an error. (In this particular case the tokens don't fit into expression grammar.)

Why include!("include-single-expr-helper.rs"); is treated as an expression position macro and not a statement position macro is an separate question though, probably related to #61733.
It should be addressed by the upcoming invocation collector rewrite.
I'd expect include-single-expr.rs to compile successfully and expand into three statements.

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Sep 8, 2019

Yeah, I agree that the specific test case might not be quite ideal -- open to suggestions, I'm not sure how to structure a good test case. Maybe just 10 10 10 would be fine since it's multiple expressions (and invalid Rust grammar, I believe, as such, since expressions need some delimiter).

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Sep 9, 2019

Maybe just 10 10 10 would be fine since it's multiple expressions

I'd change the test to something like that, yes.

@joshtriplett

This comment has been minimized.

Copy link
Member

joshtriplett commented Sep 12, 2019

I can see two reasonable behaviors here:

  • Error (not warn/lint) if we don't parse and include the entire file. (Note, though, that comments shouldn't cause an error here.)
  • Actually parse and include the entire file.
@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Sep 12, 2019

@Mark-Simulacrum

do we have a test for trailing comments -- can we add a test for a file like

22; /* this is a comment */

I don't think this should error. I'm not sure whether it will or not, I think it will actually work.

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Sep 12, 2019

I think we don't formally have such a test but I believe I locally tested that behavior (and can/will add such a test).

Did lang team get a chance to discuss this yet? I'd prefer to avoid throwing work at it if there's no need to (if lang team decides we're not ready to turn this into an error/warning).

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Sep 19, 2019

The rough consensus from the lang team meeting was that we should probably change the behavior.

  • In the long term, we probably want to error if there are extra tokens (beyond the first expression) in the file.
    • We didn't discuss trailing comments specifically, to my knowledge, but the use of the language "tokens" and not "characters"/"text" in the notes leads me to think that trailing comments and other whitespace-like things should be acceptable on its own.
  • In the short term, we should probably implement this as a future-compat warning, to reduce risk of injecting breakage for clients of the macro.
@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Sep 19, 2019

I will work on getting the tests in this PR updated and the error moved to a future compat warning (I imagine that might be a bit hard given we're pre-Session and such, but presumably worst case we just always emit it or so...). Since it's a future compat warning I'll file a tracking issue for moving it over to a hard error in the future.

Do we want to do a crater run first before we move to that? To get an initial idea of breakage?

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Sep 19, 2019

@bors try

Let's actually get a try build here on this commit and then that way we can always en-queue crater later with the commit results

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Sep 19, 2019

⌛️ Trying commit 2a92dc7 with merge c3890be...

bors added a commit that referenced this pull request Sep 19, 2019
Warn if include macro fails to include entire file

This currently introduces an error, mainly because that was just simpler, and I'm not entirely certain if we can introduce a lint without an RFC and such.

This is primarily to get feedback on the approach and overall aim -- in particular, do we think this is helpful? If so, we probably will need lang-team sign off and decide if it should be an error (as currently introduced by this PR), a lint, or a warning.

r? @petrochenkov

cc #35560
@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Sep 19, 2019

Do we want to do a crater run first before we move to that? To get an initial idea of breakage?

That seems prudent. This bug is long-standing (right?), so we don't need to rush a PR in for a backport or anything.

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Sep 19, 2019

Yes, this bug has existed since 2016 and likely much earlier.

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Sep 19, 2019

☀️ Try build successful - checks-azure
Build commit: c3890be

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Sep 19, 2019

@craterbot run mode=check-only

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Oct 4, 2019

All the cases are trailing semicolons (i.e., include! in an expression context with the file containing ...;) - no false positives.

I am not sure that it is wise to land this as an error since that will break people in practice, but I think a non-allowable warning (i.e., span_warn or so) would make sense since we believe all cases to not be false positive.

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Oct 4, 2019

Hard-coded warnings are generally discouraged (and existing ones need to be converted to lints or errors), I'd personally went with a deny-by-default deprecation lint.

bors bot added a commit to georust/geo that referenced this pull request Oct 4, 2019
Merge #386
386: Remove stray semicolon r=urschrei a=Mark-Simulacrum

This semicolon is currently silently ignored, but we may be changing that in the future.

cc rust-lang/rust#64284

Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Oct 4, 2019

Am I correct that I'll need to add a lint here https://github.com/rust-lang/rust/blob/master/src/libsyntax/early_buffered_lints.rs and then thread that through into librustc? A bit annoying to need to use that infrastructure but I guess it's not too bad...

@Mark-Simulacrum Mark-Simulacrum force-pushed the Mark-Simulacrum:include-warn branch from 2a92dc7 to e068cec Oct 7, 2019
@Mark-Simulacrum

This comment has been minimized.

Copy link
Member Author

Mark-Simulacrum commented Oct 7, 2019

r? @petrochenkov

Pushed up patch which switches to using a lint and adds a test case which should not emit a lint, despite having trailing characters in the form of a comment. Also amends the preexisting test case to have newline delimited instead of ; per earlier discussion.

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Oct 8, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 8, 2019

📌 Commit e068cec has been approved by petrochenkov

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 8, 2019

⌛️ Testing commit e068cec with merge 724316f...

bors added a commit that referenced this pull request Oct 8, 2019
Warn if include macro fails to include entire file

This currently introduces an error, mainly because that was just simpler, and I'm not entirely certain if we can introduce a lint without an RFC and such.

This is primarily to get feedback on the approach and overall aim -- in particular, do we think this is helpful? If so, we probably will need lang-team sign off and decide if it should be an error (as currently introduced by this PR), a lint, or a warning.

r? @petrochenkov

cc #35560
Centril added a commit to Centril/rust that referenced this pull request Oct 8, 2019
…rochenkov

Warn if include macro fails to include entire file

This currently introduces an error, mainly because that was just simpler, and I'm not entirely certain if we can introduce a lint without an RFC and such.

This is primarily to get feedback on the approach and overall aim -- in particular, do we think this is helpful? If so, we probably will need lang-team sign off and decide if it should be an error (as currently introduced by this PR), a lint, or a warning.

r? @petrochenkov

cc rust-lang#35560
@Centril

This comment has been minimized.

Copy link
Member

Centril commented Oct 8, 2019

@bors retry rolled up.

bors added a commit that referenced this pull request Oct 8, 2019
Rollup of 7 pull requests

Successful merges:

 - #64284 (Warn if include macro fails to include entire file)
 - #65081 (Remove -Zprofile-queries)
 - #65133 (typeck: prohibit foreign statics w/ generics)
 - #65135 (Add check for missing tests for error codes)
 - #65141 (Replace code of conduct with link)
 - #65194 (Use structured suggestion for removal of `as_str()` call)
 - #65213 (Ignore `ExprKind::DropTemps` for some ref suggestions)

Failed merges:

r? @ghost
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Oct 9, 2019

⌛️ Testing commit e068cec with merge b5bd31e...

@bors bors merged commit e068cec into rust-lang:master Oct 9, 2019
4 of 5 checks passed
4 of 5 checks passed
homu Testing commit e068cec13e2a63dba29d40f0130527d980f83f7c with merge b5bd31ec6db6a249311888a93fc176f06dcb6aa6...
Details
pr Build #20191007.50 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (LinuxTools) LinuxTools succeeded
Details
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jan 6, 2020
Version 1.40.0 (2019-12-19)
===========================

Language
--------
- [You can now use tuple `struct`s and tuple `enum` variant's constructors in
  `const` contexts.][65188] e.g.

  ```rust
  pub struct Point(i32, i32);

  const ORIGIN: Point = {
      let constructor = Point;

      constructor(0, 0)
  };
  ```

- [You can now mark `struct`s, `enum`s, and `enum` variants with the `#[non_exhaustive]` attribute to
  indicate that there may be variants or fields added in the future.][64639]
  For example this requires adding a wild-card branch (`_ => {}`) to any match
  statements on a non-exhaustive `enum`. [(RFC 2008)]
- [You can now use function-like procedural macros in `extern` blocks and in
  type positions.][63931] e.g. `type Generated = macro!();`
- [Function-like and attribute procedural macros can now emit
  `macro_rules!` items, so you can now have your macros generate macros.][64035]
- [The `meta` pattern matcher in `macro_rules!` now correctly matches the modern
  attribute syntax.][63674] For example `(#[$m:meta])` now matches `#[attr]`,
  `#[attr{tokens}]`, `#[attr[tokens]]`, and `#[attr(tokens)]`.

Compiler
--------
- [Added tier 3 support\* for the
  `thumbv7neon-unknown-linux-musleabihf` target.][66103]
- [Added tier 3 support for the
  `aarch64-unknown-none-softfloat` target.][64589]
- [Added tier 3 support for the `mips64-unknown-linux-muslabi64`, and
  `mips64el-unknown-linux-muslabi64` targets.][65843]

\* Refer to Rust's [platform support page][forge-platform-support] for more
  information on Rust's tiered platform support.

Libraries
---------
- [The `is_power_of_two` method on unsigned numeric types is now a `const` function.][65092]

Stabilized APIs
---------------
- [`BTreeMap::get_key_value`]
- [`HashMap::get_key_value`]
- [`Option::as_deref_mut`]
- [`Option::as_deref`]
- [`Option::flatten`]
- [`UdpSocket::peer_addr`]
- [`f32::to_be_bytes`]
- [`f32::to_le_bytes`]
- [`f32::to_ne_bytes`]
- [`f64::to_be_bytes`]
- [`f64::to_le_bytes`]
- [`f64::to_ne_bytes`]
- [`f32::from_be_bytes`]
- [`f32::from_le_bytes`]
- [`f32::from_ne_bytes`]
- [`f64::from_be_bytes`]
- [`f64::from_le_bytes`]
- [`f64::from_ne_bytes`]
- [`mem::take`]
- [`slice::repeat`]
- [`todo!`]

Cargo
-----
- [Cargo will now always display warnings, rather than only on
  fresh builds.][cargo/7450]
- [Feature flags (except `--all-features`) passed to a virtual workspace will
  now produce an error.][cargo/7507] Previously these flags were ignored.
- [You can now publish `dev-dependencies` without including
  a `version`.][cargo/7333]

Misc
----
- [You can now specify the `#[cfg(doctest)]` attribute to include an item only
  when running documentation tests with `rustdoc`.][63803]

Compatibility Notes
-------------------
- [As previously announced, any previous NLL warnings in the 2015 edition are
  now hard errors.][64221]
- [The `include!` macro will now warn if it failed to include the
  entire file.][64284] The `include!` macro unintentionally only includes the
  first _expression_ in a file, and this can be unintuitive. This will become
  either a hard error in a future release, or the behavior may be fixed to include all expressions as expected.
- [Using `#[inline]` on function prototypes and consts now emits a warning under
  `unused_attribute` lint.][65294] Using `#[inline]` anywhere else inside traits
  or `extern` blocks now correctly emits a hard error.

[65294]: rust-lang/rust#65294
[66103]: rust-lang/rust#66103
[65843]: rust-lang/rust#65843
[65188]: rust-lang/rust#65188
[65092]: rust-lang/rust#65092
[64589]: rust-lang/rust#64589
[64639]: rust-lang/rust#64639
[64221]: rust-lang/rust#64221
[64284]: rust-lang/rust#64284
[63931]: rust-lang/rust#63931
[64035]: rust-lang/rust#64035
[63674]: rust-lang/rust#63674
[63803]: rust-lang/rust#63803
[cargo/7450]: rust-lang/cargo#7450
[cargo/7507]: rust-lang/cargo#7507
[cargo/7525]: rust-lang/cargo#7525
[cargo/7333]: rust-lang/cargo#7333
[(rfc 2008)]: https://rust-lang.github.io/rfcs/2008-non-exhaustive.html
[`f32::to_be_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.to_be_bytes
[`f32::to_le_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.to_le_bytes
[`f32::to_ne_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.to_ne_bytes
[`f64::to_be_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.to_be_bytes
[`f64::to_le_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.to_le_bytes
[`f64::to_ne_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.to_ne_bytes
[`f32::from_be_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.from_be_bytes
[`f32::from_le_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.from_le_bytes
[`f32::from_ne_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.from_ne_bytes
[`f64::from_be_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.from_be_bytes
[`f64::from_le_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.from_le_bytes
[`f64::from_ne_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.from_ne_bytes
[`option::flatten`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.flatten
[`option::as_deref`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.as_deref
[`option::as_deref_mut`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.as_deref_mut
[`hashmap::get_key_value`]: https://doc.rust-lang.org/std/collections/struct.HashMap.html#method.get_key_value
[`btreemap::get_key_value`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.get_key_value
[`slice::repeat`]: https://doc.rust-lang.org/std/primitive.slice.html#method.repeat
[`mem::take`]: https://doc.rust-lang.org/std/mem/fn.take.html
[`udpsocket::peer_addr`]: https://doc.rust-lang.org/std/net/struct.UdpSocket.html#method.peer_addr
[`todo!`]: https://doc.rust-lang.org/std/macro.todo.html
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Jan 14, 2020
Version 1.40.0 (2019-12-19)
===========================

Language
--------
- [You can now use tuple `struct`s and tuple `enum` variant's constructors in
  `const` contexts.][65188] e.g.

  ```rust
  pub struct Point(i32, i32);

  const ORIGIN: Point = {
      let constructor = Point;

      constructor(0, 0)
  };
  ```

- [You can now mark `struct`s, `enum`s, and `enum` variants with the `#[non_exhaustive]` attribute to
  indicate that there may be variants or fields added in the future.][64639]
  For example this requires adding a wild-card branch (`_ => {}`) to any match
  statements on a non-exhaustive `enum`. [(RFC 2008)]
- [You can now use function-like procedural macros in `extern` blocks and in
  type positions.][63931] e.g. `type Generated = macro!();`
- [Function-like and attribute procedural macros can now emit
  `macro_rules!` items, so you can now have your macros generate macros.][64035]
- [The `meta` pattern matcher in `macro_rules!` now correctly matches the modern
  attribute syntax.][63674] For example `(#[$m:meta])` now matches `#[attr]`,
  `#[attr{tokens}]`, `#[attr[tokens]]`, and `#[attr(tokens)]`.

Compiler
--------
- [Added tier 3 support\* for the
  `thumbv7neon-unknown-linux-musleabihf` target.][66103]
- [Added tier 3 support for the
  `aarch64-unknown-none-softfloat` target.][64589]
- [Added tier 3 support for the `mips64-unknown-linux-muslabi64`, and
  `mips64el-unknown-linux-muslabi64` targets.][65843]

\* Refer to Rust's [platform support page][forge-platform-support] for more
  information on Rust's tiered platform support.

Libraries
---------
- [The `is_power_of_two` method on unsigned numeric types is now a `const` function.][65092]

Stabilized APIs
---------------
- [`BTreeMap::get_key_value`]
- [`HashMap::get_key_value`]
- [`Option::as_deref_mut`]
- [`Option::as_deref`]
- [`Option::flatten`]
- [`UdpSocket::peer_addr`]
- [`f32::to_be_bytes`]
- [`f32::to_le_bytes`]
- [`f32::to_ne_bytes`]
- [`f64::to_be_bytes`]
- [`f64::to_le_bytes`]
- [`f64::to_ne_bytes`]
- [`f32::from_be_bytes`]
- [`f32::from_le_bytes`]
- [`f32::from_ne_bytes`]
- [`f64::from_be_bytes`]
- [`f64::from_le_bytes`]
- [`f64::from_ne_bytes`]
- [`mem::take`]
- [`slice::repeat`]
- [`todo!`]

Cargo
-----
- [Cargo will now always display warnings, rather than only on
  fresh builds.][cargo/7450]
- [Feature flags (except `--all-features`) passed to a virtual workspace will
  now produce an error.][cargo/7507] Previously these flags were ignored.
- [You can now publish `dev-dependencies` without including
  a `version`.][cargo/7333]

Misc
----
- [You can now specify the `#[cfg(doctest)]` attribute to include an item only
  when running documentation tests with `rustdoc`.][63803]

Compatibility Notes
-------------------
- [As previously announced, any previous NLL warnings in the 2015 edition are
  now hard errors.][64221]
- [The `include!` macro will now warn if it failed to include the
  entire file.][64284] The `include!` macro unintentionally only includes the
  first _expression_ in a file, and this can be unintuitive. This will become
  either a hard error in a future release, or the behavior may be fixed to include all expressions as expected.
- [Using `#[inline]` on function prototypes and consts now emits a warning under
  `unused_attribute` lint.][65294] Using `#[inline]` anywhere else inside traits
  or `extern` blocks now correctly emits a hard error.

[65294]: rust-lang/rust#65294
[66103]: rust-lang/rust#66103
[65843]: rust-lang/rust#65843
[65188]: rust-lang/rust#65188
[65092]: rust-lang/rust#65092
[64589]: rust-lang/rust#64589
[64639]: rust-lang/rust#64639
[64221]: rust-lang/rust#64221
[64284]: rust-lang/rust#64284
[63931]: rust-lang/rust#63931
[64035]: rust-lang/rust#64035
[63674]: rust-lang/rust#63674
[63803]: rust-lang/rust#63803
[cargo/7450]: rust-lang/cargo#7450
[cargo/7507]: rust-lang/cargo#7507
[cargo/7525]: rust-lang/cargo#7525
[cargo/7333]: rust-lang/cargo#7333
[(rfc 2008)]: https://rust-lang.github.io/rfcs/2008-non-exhaustive.html
[`f32::to_be_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.to_be_bytes
[`f32::to_le_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.to_le_bytes
[`f32::to_ne_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.to_ne_bytes
[`f64::to_be_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.to_be_bytes
[`f64::to_le_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.to_le_bytes
[`f64::to_ne_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.to_ne_bytes
[`f32::from_be_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.from_be_bytes
[`f32::from_le_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.from_le_bytes
[`f32::from_ne_bytes`]: https://doc.rust-lang.org/std/primitive.f32.html#method.from_ne_bytes
[`f64::from_be_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.from_be_bytes
[`f64::from_le_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.from_le_bytes
[`f64::from_ne_bytes`]: https://doc.rust-lang.org/std/primitive.f64.html#method.from_ne_bytes
[`option::flatten`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.flatten
[`option::as_deref`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.as_deref
[`option::as_deref_mut`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.as_deref_mut
[`hashmap::get_key_value`]: https://doc.rust-lang.org/std/collections/struct.HashMap.html#method.get_key_value
[`btreemap::get_key_value`]: https://doc.rust-lang.org/std/collections/struct.BTreeMap.html#method.get_key_value
[`slice::repeat`]: https://doc.rust-lang.org/std/primitive.slice.html#method.repeat
[`mem::take`]: https://doc.rust-lang.org/std/mem/fn.take.html
[`udpsocket::peer_addr`]: https://doc.rust-lang.org/std/net/struct.UdpSocket.html#method.peer_addr
[`todo!`]: https://doc.rust-lang.org/std/macro.todo.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.