From d2d89b10de394b4a1d5e2491dfffd3d65d1741b3 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Thu, 16 May 2019 17:09:04 -0700 Subject: [PATCH 01/14] error: remove StringError from Debug output Seeing `StringError("something something")` in debug output can cause someone to think there was an error dealing with `String`s, not that the error type is just a string. So, remove that noise. --- src/libstd/error.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libstd/error.rs b/src/libstd/error.rs index 7cb830e751a77..9424e059a14fd 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -300,7 +300,6 @@ impl From for Box { /// mem::size_of::>() == mem::size_of_val(&a_boxed_error)) /// ``` fn from(err: String) -> Box { - #[derive(Debug)] struct StringError(String); impl Error for StringError { @@ -313,6 +312,13 @@ impl From for Box { } } + // Purposefully skip printing "StringError(..)" + impl Debug for StringError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + Debug::fmt(&self.0, f) + } + } + Box::new(StringError(err)) } } From 642e8d4434c4f6214a908eea0019b3185323431f Mon Sep 17 00:00:00 2001 From: Jason Shirk Date: Tue, 28 May 2019 22:57:12 -0700 Subject: [PATCH 02/14] Speed up Azure CI installing Windows dependencies There is known issue where PowerShell is unreasonably slow downloading files due to an issue with rendering the progress bar, see: https://github.com/PowerShell/PowerShell/issues/2138 That issue is fixed in PowerShell Core (available in Azure Pipelines as pwsh.exe) but it can also be worked around by setting: $ProgressPreference = 'SilentlyContinue' --- .azure-pipelines/steps/install-clang.yml | 2 +- .azure-pipelines/steps/install-sccache.yml | 2 +- .azure-pipelines/steps/install-windows-build-deps.yml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.azure-pipelines/steps/install-clang.yml b/.azure-pipelines/steps/install-clang.yml index 26a223282cd87..7a662c498f4b5 100644 --- a/.azure-pipelines/steps/install-clang.yml +++ b/.azure-pipelines/steps/install-clang.yml @@ -27,7 +27,7 @@ steps: # Original downloaded here came from # http://releases.llvm.org/7.0.0/LLVM-7.0.0-win64.exe - script: | - powershell -Command "iwr -outf %TEMP%\LLVM-7.0.0-win64.exe https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/LLVM-7.0.0-win64.exe" + powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf %TEMP%\LLVM-7.0.0-win64.exe https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/LLVM-7.0.0-win64.exe" set CLANG_DIR=%CD%\citools\clang-rust %TEMP%\LLVM-7.0.0-win64.exe /S /NCRC /D=%CLANG_DIR% set RUST_CONFIGURE_ARGS=%RUST_CONFIGURE_ARGS% --set llvm.clang-cl=%CLANG_DIR%\bin\clang-cl.exe diff --git a/.azure-pipelines/steps/install-sccache.yml b/.azure-pipelines/steps/install-sccache.yml index 39f58002a7358..8f80c955f7e49 100644 --- a/.azure-pipelines/steps/install-sccache.yml +++ b/.azure-pipelines/steps/install-sccache.yml @@ -9,7 +9,7 @@ steps: - script: | md sccache - powershell -Command "iwr -outf sccache\sccache.exe https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2018-04-26-sccache-x86_64-pc-windows-msvc" + powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf sccache\sccache.exe https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2018-04-26-sccache-x86_64-pc-windows-msvc" echo ##vso[task.prependpath]%CD%\sccache displayName: Install sccache (Windows) condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) diff --git a/.azure-pipelines/steps/install-windows-build-deps.yml b/.azure-pipelines/steps/install-windows-build-deps.yml index 037c8daa2a80a..0e9c0b99b46f1 100644 --- a/.azure-pipelines/steps/install-windows-build-deps.yml +++ b/.azure-pipelines/steps/install-windows-build-deps.yml @@ -54,9 +54,9 @@ steps: # Note that we don't literally overwrite the gdb.exe binary because it appears # to just use gdborig.exe, so that's the binary we deal with instead. - script: | - powershell -Command "iwr -outf %MINGW_ARCHIVE% %MINGW_URL%/%MINGW_ARCHIVE%" + powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf %MINGW_ARCHIVE% %MINGW_URL%/%MINGW_ARCHIVE%" 7z x -y %MINGW_ARCHIVE% > nul - powershell -Command "iwr -outf 2017-04-20-%MSYS_BITS%bit-gdborig.exe %MINGW_URL%/2017-04-20-%MSYS_BITS%bit-gdborig.exe" + powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf 2017-04-20-%MSYS_BITS%bit-gdborig.exe %MINGW_URL%/2017-04-20-%MSYS_BITS%bit-gdborig.exe" mv 2017-04-20-%MSYS_BITS%bit-gdborig.exe %MINGW_DIR%\bin\gdborig.exe echo ##vso[task.prependpath]%CD%\%MINGW_DIR%\bin condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), ne(variables['MINGW_URL'],'')) @@ -81,7 +81,7 @@ steps: # Note that this is originally from the github releases patch of Ninja - script: | md ninja - powershell -Command "iwr -outf 2017-03-15-ninja-win.zip https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-15-ninja-win.zip" + powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf 2017-03-15-ninja-win.zip https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/2017-03-15-ninja-win.zip" 7z x -oninja 2017-03-15-ninja-win.zip del 2017-03-15-ninja-win.zip set RUST_CONFIGURE_ARGS=%RUST_CONFIGURE_ARGS% --enable-ninja From bf0da6c6ce77b43add5a391f4d5090ad6b4c444e Mon Sep 17 00:00:00 2001 From: memoryruins Date: Thu, 30 May 2019 04:13:55 -0400 Subject: [PATCH 03/14] Set ellipsis_inclusive_range_patterns lint to warn --- src/librustc_lint/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index d184c671bbaf8..434a1498a1c93 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -1275,7 +1275,7 @@ declare_lint_pass!( declare_lint! { pub ELLIPSIS_INCLUSIVE_RANGE_PATTERNS, - Allow, + Warn, "`...` range patterns are deprecated" } From e18885e21ff3e5abaaf702c9f2109323e2e5a659 Mon Sep 17 00:00:00 2001 From: memoryruins Date: Thu, 30 May 2019 06:20:30 -0400 Subject: [PATCH 04/14] Update ui and run-pass for ellipsis_inclusive_range_patterns lint --- .../associated-const-range-match-patterns.rs | 14 +++++ src/test/run-pass/binding/pat-ranges.rs | 6 +++ src/test/run-pass/inc-range-pat.rs | 2 + .../issue-15881-model-lexer-dotdotdot.rs | 1 + .../mir/mir_build_match_comparisons.rs | 2 +- .../ui/lint/issue-54538-unused-parens-lint.rs | 28 ++++++++-- .../issue-54538-unused-parens-lint.stderr | 52 ++++++++++++++++--- .../ui/match/match-range-fail-dominate.rs | 18 +++---- .../ui/match/match-range-fail-dominate.stderr | 14 ++--- src/test/ui/nll/issue-57960.rs | 6 +-- 10 files changed, 112 insertions(+), 31 deletions(-) diff --git a/src/test/run-pass/associated-consts/associated-const-range-match-patterns.rs b/src/test/run-pass/associated-consts/associated-const-range-match-patterns.rs index 4801369cfd1a8..5276869a702ee 100644 --- a/src/test/run-pass/associated-consts/associated-const-range-match-patterns.rs +++ b/src/test/run-pass/associated-consts/associated-const-range-match-patterns.rs @@ -1,5 +1,6 @@ // run-pass #![allow(dead_code, unreachable_patterns)] +#![allow(ellipsis_inclusive_range_patterns)] struct Foo; @@ -23,4 +24,17 @@ fn main() { ::NUM ... ::NUM => true, _ => false, }); + + assert!(match 2 { + Foo::NUM ..= 3 => true, + _ => false, + }); + assert!(match 0 { + -1 ..= ::NUM => true, + _ => false, + }); + assert!(match 1 { + ::NUM ..= ::NUM => true, + _ => false, + }); } diff --git a/src/test/run-pass/binding/pat-ranges.rs b/src/test/run-pass/binding/pat-ranges.rs index b3729a79615a6..19b3045784f86 100644 --- a/src/test/run-pass/binding/pat-ranges.rs +++ b/src/test/run-pass/binding/pat-ranges.rs @@ -1,6 +1,8 @@ // run-pass // Parsing of range patterns +#![allow(ellipsis_inclusive_range_patterns)] + const NUM1: i32 = 10; mod m { @@ -11,4 +13,8 @@ fn main() { if let NUM1 ... m::NUM2 = 10 {} else { panic!() } if let ::NUM1 ... ::m::NUM2 = 11 {} else { panic!() } if let -13 ... -10 = 12 { panic!() } else {} + + if let NUM1 ..= m::NUM2 = 10 {} else { panic!() } + if let ::NUM1 ..= ::m::NUM2 = 11 {} else { panic!() } + if let -13 ..= -10 = 12 { panic!() } else {} } diff --git a/src/test/run-pass/inc-range-pat.rs b/src/test/run-pass/inc-range-pat.rs index 6bf857a11f816..a648ff17492ee 100644 --- a/src/test/run-pass/inc-range-pat.rs +++ b/src/test/run-pass/inc-range-pat.rs @@ -1,5 +1,7 @@ // Test old and new syntax for inclusive range patterns. +#![allow(ellipsis_inclusive_range_patterns)] + fn main() { assert!(match 42 { 0 ... 100 => true, _ => false }); assert!(match 42 { 0 ..= 100 => true, _ => false }); diff --git a/src/test/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs b/src/test/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs index 2470e37e1820b..dee7f25d7bb3a 100644 --- a/src/test/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs +++ b/src/test/run-pass/issues/issue-15881-model-lexer-dotdotdot.rs @@ -1,5 +1,6 @@ // run-pass #![allow(illegal_floating_point_literal_pattern)] // FIXME #41620 +#![allow(ellipsis_inclusive_range_patterns)] // regression test for the model lexer handling the DOTDOTDOT syntax (#15877) diff --git a/src/test/run-pass/mir/mir_build_match_comparisons.rs b/src/test/run-pass/mir/mir_build_match_comparisons.rs index 8913009f69156..04570055763a9 100644 --- a/src/test/run-pass/mir/mir_build_match_comparisons.rs +++ b/src/test/run-pass/mir/mir_build_match_comparisons.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] fn test1(x: i8) -> i32 { match x { - 1...10 => 0, + 1..=10 => 0, _ => 1, } } diff --git a/src/test/ui/lint/issue-54538-unused-parens-lint.rs b/src/test/ui/lint/issue-54538-unused-parens-lint.rs index 6ca53816e3c6b..3a52996195c0d 100644 --- a/src/test/ui/lint/issue-54538-unused-parens-lint.rs +++ b/src/test/ui/lint/issue-54538-unused-parens-lint.rs @@ -1,10 +1,32 @@ // compile-pass +#![allow(ellipsis_inclusive_range_patterns)] #![allow(unreachable_patterns)] #![allow(unused_variables)] #![warn(unused_parens)] fn main() { + match 1 { + (_) => {} //~ WARNING: unnecessary parentheses around pattern + (y) => {} //~ WARNING: unnecessary parentheses around pattern + (ref r) => {} //~ WARNING: unnecessary parentheses around pattern + (e @ 1...2) => {} //~ WARNING: unnecessary parentheses around outer pattern + (1...2) => {} // Non ambiguous range pattern should not warn + e @ (3...4) => {} // Non ambiguous range pattern should not warn + } + + match &1 { + (e @ &(1...2)) => {} //~ WARNING: unnecessary parentheses around outer pattern + &(_) => {} //~ WARNING: unnecessary parentheses around pattern + e @ &(1...2) => {} // Ambiguous range pattern should not warn + &(1...2) => {} // Ambiguous range pattern should not warn + } + + match &1 { + e @ &(1...2) | e @ &(3...4) => {} // Complex ambiguous pattern should not warn + &_ => {} + } + match 1 { (_) => {} //~ WARNING: unnecessary parentheses around pattern (y) => {} //~ WARNING: unnecessary parentheses around pattern @@ -15,14 +37,14 @@ fn main() { } match &1 { - (e @ &(1...2)) => {} //~ WARNING: unnecessary parentheses around outer pattern + (e @ &(1..=2)) => {} //~ WARNING: unnecessary parentheses around outer pattern &(_) => {} //~ WARNING: unnecessary parentheses around pattern - e @ &(1...2) => {} // Ambiguous range pattern should not warn + e @ &(1..=2) => {} // Ambiguous range pattern should not warn &(1..=2) => {} // Ambiguous range pattern should not warn } match &1 { - e @ &(1...2) | e @ &(3..=4) => {} // Complex ambiguous pattern should not warn + e @ &(1..=2) | e @ &(3..=4) => {} // Complex ambiguous pattern should not warn &_ => {} } } diff --git a/src/test/ui/lint/issue-54538-unused-parens-lint.stderr b/src/test/ui/lint/issue-54538-unused-parens-lint.stderr index 3cf321b072f40..3b312198952a5 100644 --- a/src/test/ui/lint/issue-54538-unused-parens-lint.stderr +++ b/src/test/ui/lint/issue-54538-unused-parens-lint.stderr @@ -1,41 +1,77 @@ warning: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:9:9 + --> $DIR/issue-54538-unused-parens-lint.rs:10:9 | LL | (_) => {} | ^^^ help: remove these parentheses | note: lint level defined here - --> $DIR/issue-54538-unused-parens-lint.rs:5:9 + --> $DIR/issue-54538-unused-parens-lint.rs:6:9 | LL | #![warn(unused_parens)] | ^^^^^^^^^^^^^ warning: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:10:9 + --> $DIR/issue-54538-unused-parens-lint.rs:11:9 | LL | (y) => {} | ^^^ help: remove these parentheses warning: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:11:9 + --> $DIR/issue-54538-unused-parens-lint.rs:12:9 | LL | (ref r) => {} | ^^^^^^^ help: remove these parentheses warning: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:12:9 + --> $DIR/issue-54538-unused-parens-lint.rs:13:9 | -LL | (e @ 1..=2) => {} +LL | (e @ 1...2) => {} | ^^^^^^^^^^^ help: remove these parentheses warning: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:18:9 + --> $DIR/issue-54538-unused-parens-lint.rs:19:9 | LL | (e @ &(1...2)) => {} | ^^^^^^^^^^^^^^ help: remove these parentheses warning: unnecessary parentheses around pattern - --> $DIR/issue-54538-unused-parens-lint.rs:19:10 + --> $DIR/issue-54538-unused-parens-lint.rs:20:10 + | +LL | &(_) => {} + | ^^^ help: remove these parentheses + +warning: unnecessary parentheses around pattern + --> $DIR/issue-54538-unused-parens-lint.rs:31:9 + | +LL | (_) => {} + | ^^^ help: remove these parentheses + +warning: unnecessary parentheses around pattern + --> $DIR/issue-54538-unused-parens-lint.rs:32:9 + | +LL | (y) => {} + | ^^^ help: remove these parentheses + +warning: unnecessary parentheses around pattern + --> $DIR/issue-54538-unused-parens-lint.rs:33:9 + | +LL | (ref r) => {} + | ^^^^^^^ help: remove these parentheses + +warning: unnecessary parentheses around pattern + --> $DIR/issue-54538-unused-parens-lint.rs:34:9 + | +LL | (e @ 1..=2) => {} + | ^^^^^^^^^^^ help: remove these parentheses + +warning: unnecessary parentheses around pattern + --> $DIR/issue-54538-unused-parens-lint.rs:40:9 + | +LL | (e @ &(1..=2)) => {} + | ^^^^^^^^^^^^^^ help: remove these parentheses + +warning: unnecessary parentheses around pattern + --> $DIR/issue-54538-unused-parens-lint.rs:41:10 | LL | &(_) => {} | ^^^ help: remove these parentheses diff --git a/src/test/ui/match/match-range-fail-dominate.rs b/src/test/ui/match/match-range-fail-dominate.rs index 99069183e4eda..a0cc773d20edd 100644 --- a/src/test/ui/match/match-range-fail-dominate.rs +++ b/src/test/ui/match/match-range-fail-dominate.rs @@ -8,31 +8,31 @@ fn main() { match 5 { - 1 ... 10 => { } - 5 ... 6 => { } + 1 ..= 10 => { } + 5 ..= 6 => { } _ => {} }; match 5 { - 3 ... 6 => { } - 4 ... 6 => { } + 3 ..= 6 => { } + 4 ..= 6 => { } _ => {} }; match 5 { - 4 ... 6 => { } - 4 ... 6 => { } + 4 ..= 6 => { } + 4 ..= 6 => { } _ => {} }; match 'c' { - 'A' ... 'z' => {} - 'a' ... 'z' => {} + 'A' ..= 'z' => {} + 'a' ..= 'z' => {} _ => {} }; match 1.0f64 { - 0.01f64 ... 6.5f64 => {} + 0.01f64 ..= 6.5f64 => {} 0.02f64 => {} _ => {} }; diff --git a/src/test/ui/match/match-range-fail-dominate.stderr b/src/test/ui/match/match-range-fail-dominate.stderr index 0f5ab7fff3840..f481e56c85e56 100644 --- a/src/test/ui/match/match-range-fail-dominate.stderr +++ b/src/test/ui/match/match-range-fail-dominate.stderr @@ -1,7 +1,7 @@ error: unreachable pattern --> $DIR/match-range-fail-dominate.rs:12:7 | -LL | 5 ... 6 => { } +LL | 5 ..= 6 => { } | ^^^^^^^ | note: lint level defined here @@ -13,25 +13,25 @@ LL | #![deny(unreachable_patterns)] error: unreachable pattern --> $DIR/match-range-fail-dominate.rs:18:7 | -LL | 4 ... 6 => { } +LL | 4 ..= 6 => { } | ^^^^^^^ error: unreachable pattern --> $DIR/match-range-fail-dominate.rs:24:7 | -LL | 4 ... 6 => { } +LL | 4 ..= 6 => { } | ^^^^^^^ error: unreachable pattern --> $DIR/match-range-fail-dominate.rs:30:7 | -LL | 'a' ... 'z' => {} +LL | 'a' ..= 'z' => {} | ^^^^^^^^^^^ warning: floating-point types cannot be used in patterns --> $DIR/match-range-fail-dominate.rs:35:7 | -LL | 0.01f64 ... 6.5f64 => {} +LL | 0.01f64 ..= 6.5f64 => {} | ^^^^^^^ | = note: #[warn(illegal_floating_point_literal_pattern)] on by default @@ -41,7 +41,7 @@ LL | 0.01f64 ... 6.5f64 => {} warning: floating-point types cannot be used in patterns --> $DIR/match-range-fail-dominate.rs:35:19 | -LL | 0.01f64 ... 6.5f64 => {} +LL | 0.01f64 ..= 6.5f64 => {} | ^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! @@ -65,7 +65,7 @@ LL | 0.02f64 => {} warning: floating-point types cannot be used in patterns --> $DIR/match-range-fail-dominate.rs:35:7 | -LL | 0.01f64 ... 6.5f64 => {} +LL | 0.01f64 ..= 6.5f64 => {} | ^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! diff --git a/src/test/ui/nll/issue-57960.rs b/src/test/ui/nll/issue-57960.rs index 0b52e46c45989..1399694a79b6a 100644 --- a/src/test/ui/nll/issue-57960.rs +++ b/src/test/ui/nll/issue-57960.rs @@ -27,9 +27,9 @@ impl Range for ThreeDigits { fn digits(x: u8) -> u32 { match x { - OneDigit::FIRST...OneDigit::LAST => 1, - TwoDigits::FIRST...TwoDigits::LAST => 2, - ThreeDigits::FIRST...ThreeDigits::LAST => 3, + OneDigit::FIRST..=OneDigit::LAST => 1, + TwoDigits::FIRST..=TwoDigits::LAST => 2, + ThreeDigits::FIRST..=ThreeDigits::LAST => 3, _ => unreachable!(), } } From 3ffab36462e9da9842ffc6ab538be198fa8c0e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Thu, 30 May 2019 13:59:12 +0200 Subject: [PATCH 05/14] Migrate unstable-book to MdBook2 --- src/bootstrap/doc.rs | 2 +- src/doc/unstable-book/src/language-features/asm.md | 2 +- .../src/language-features/box-patterns.md | 2 +- .../unstable-book/src/language-features/box-syntax.md | 2 +- .../unstable-book/src/language-features/global-asm.md | 2 +- .../unstable-book/src/language-features/lang-items.md | 2 +- .../src/language-features/non-ascii-idents.md | 2 +- .../src/language-features/plugin-registrar.md | 2 +- src/doc/unstable-book/src/language-features/plugin.md | 10 +++++----- .../src/language-features/unboxed-closures.md | 2 +- .../unstable-book/src/library-features/fn-traits.md | 2 +- src/doc/unstable-book/src/library-features/fnbox.md | 2 +- src/doc/unstable-book/src/the-unstable-book.md | 2 +- 13 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 12bdfa5691dc7..b98a6b5e1814b 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -134,7 +134,7 @@ impl Step for UnstableBook { target: self.target, name: INTERNER.intern_str("unstable-book"), src: builder.md_doc_out(self.target), - version: RustbookVersion::MdBook1, + version: RustbookVersion::MdBook2, }) } } diff --git a/src/doc/unstable-book/src/language-features/asm.md b/src/doc/unstable-book/src/language-features/asm.md index f22095fe5de2e..2a1b6397781f9 100644 --- a/src/doc/unstable-book/src/language-features/asm.md +++ b/src/doc/unstable-book/src/language-features/asm.md @@ -190,4 +190,4 @@ constraints, etc. [llvm-docs]: http://llvm.org/docs/LangRef.html#inline-assembler-expressions If you need more power and don't mind losing some of the niceties of -`asm!`, check out [global_asm](language-features/global-asm.html). +`asm!`, check out [global_asm](global-asm.md). diff --git a/src/doc/unstable-book/src/language-features/box-patterns.md b/src/doc/unstable-book/src/language-features/box-patterns.md index 0896627acae1b..bf0819ec920b7 100644 --- a/src/doc/unstable-book/src/language-features/box-patterns.md +++ b/src/doc/unstable-book/src/language-features/box-patterns.md @@ -4,7 +4,7 @@ The tracking issue for this feature is: [#29641] [#29641]: https://github.com/rust-lang/rust/issues/29641 -See also [`box_syntax`](language-features/box-syntax.html) +See also [`box_syntax`](box-syntax.md) ------------------------ diff --git a/src/doc/unstable-book/src/language-features/box-syntax.md b/src/doc/unstable-book/src/language-features/box-syntax.md index 414dc48e557d3..9569974d22ca2 100644 --- a/src/doc/unstable-book/src/language-features/box-syntax.md +++ b/src/doc/unstable-book/src/language-features/box-syntax.md @@ -4,7 +4,7 @@ The tracking issue for this feature is: [#49733] [#49733]: https://github.com/rust-lang/rust/issues/49733 -See also [`box_patterns`](language-features/box-patterns.html) +See also [`box_patterns`](box-patterns.md) ------------------------ diff --git a/src/doc/unstable-book/src/language-features/global-asm.md b/src/doc/unstable-book/src/language-features/global-asm.md index f1ef74a63b513..bc55fe80fa64c 100644 --- a/src/doc/unstable-book/src/language-features/global-asm.md +++ b/src/doc/unstable-book/src/language-features/global-asm.md @@ -75,4 +75,4 @@ usages and placed the larger, single usage in the crate root. If you don't need quite as much power and flexibility as `global_asm!` provides, and you don't mind restricting your inline assembly to `fn` bodies only, you might try the -[asm](language-features/asm.html) feature instead. +[asm](asm.md) feature instead. diff --git a/src/doc/unstable-book/src/language-features/lang-items.md b/src/doc/unstable-book/src/language-features/lang-items.md index b16739b4743a9..3ee024c6b5883 100644 --- a/src/doc/unstable-book/src/language-features/lang-items.md +++ b/src/doc/unstable-book/src/language-features/lang-items.md @@ -192,7 +192,7 @@ such as "```undefined reference to `__rust_probestack'```". Using this crate also requires enabling the library feature `compiler_builtins_lib`. You can read more about this [here][compiler-builtins-lib]. -[compiler-builtins-lib]: library-features/compiler-builtins-lib.html +[compiler-builtins-lib]: ../library-features/compiler-builtins-lib.md ## More about the language items diff --git a/src/doc/unstable-book/src/language-features/non-ascii-idents.md b/src/doc/unstable-book/src/language-features/non-ascii-idents.md index 46957c00bf95c..22dae0c89a6ff 100644 --- a/src/doc/unstable-book/src/language-features/non-ascii-idents.md +++ b/src/doc/unstable-book/src/language-features/non-ascii-idents.md @@ -45,4 +45,4 @@ that does _not_ occur in the set of [strict keywords]. [`XID_start`]: http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%3AXID_Start%3A%5D&abb=on&g=&i= [`XID_continue`]: http://unicode.org/cldr/utility/list-unicodeset.jsp?a=%5B%3AXID_Continue%3A%5D&abb=on&g=&i= -[strict keywords]: ../reference/keywords.html#strict-keywords +[strict keywords]: ../../reference/keywords.md#strict-keywords diff --git a/src/doc/unstable-book/src/language-features/plugin-registrar.md b/src/doc/unstable-book/src/language-features/plugin-registrar.md index b16e2ac2d221c..bf5dd81d735af 100644 --- a/src/doc/unstable-book/src/language-features/plugin-registrar.md +++ b/src/doc/unstable-book/src/language-features/plugin-registrar.md @@ -8,6 +8,6 @@ This feature is part of "compiler plugins." It will often be used with the [`plugin`] and `rustc_private` features as well. For more details, see their docs. -[`plugin`]: language-features/plugin.html +[`plugin`]: plugin.md ------------------------ diff --git a/src/doc/unstable-book/src/language-features/plugin.md b/src/doc/unstable-book/src/language-features/plugin.md index 49fe7c9e994fe..43fffd680372f 100644 --- a/src/doc/unstable-book/src/language-features/plugin.md +++ b/src/doc/unstable-book/src/language-features/plugin.md @@ -8,7 +8,7 @@ The tracking issue for this feature is: [#29597] This feature is part of "compiler plugins." It will often be used with the [`plugin_registrar`] and `rustc_private` features. -[`plugin_registrar`]: language-features/plugin-registrar.html +[`plugin_registrar`]: plugin-registrar.md ------------------------ @@ -39,7 +39,7 @@ of a library. Plugins can extend Rust's syntax in various ways. One kind of syntax extension is the procedural macro. These are invoked the same way as [ordinary -macros](../book/macros.html), but the expansion is performed by arbitrary Rust +macros](../../book/macros.md), but the expansion is performed by arbitrary Rust code that manipulates syntax trees at compile time. @@ -130,7 +130,7 @@ The advantages over a simple `fn(&str) -> u32` are: a way to define new literal syntax for any data type. In addition to procedural macros, you can define new -[`derive`](../reference/attributes/derive.html)-like attributes and other kinds +[`derive`](../../reference/attributes/derive.md)-like attributes and other kinds of extensions. See `Registry::register_syntax_extension` and the `SyntaxExtension` enum. For a more involved macro example, see [`regex_macros`](https://github.com/rust-lang/regex/blob/master/regex_macros/src/lib.rs). @@ -174,7 +174,7 @@ quasiquote as an ordinary plugin library. # Lint plugins Plugins can extend [Rust's lint -infrastructure](../reference/attributes/diagnostics.html#lint-check-attributes) with +infrastructure](../../reference/attributes/diagnostics.md#lint-check-attributes) with additional checks for code style, safety, etc. Now let's write a plugin [`lint_plugin_test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui-fulldeps/auxiliary/lint_plugin_test.rs) that warns about any item named `lintme`. @@ -253,7 +253,7 @@ mostly use the same infrastructure as lint plugins, and provide examples of how to access type information. Lints defined by plugins are controlled by the usual [attributes and compiler -flags](../reference/attributes/diagnostics.html#lint-check-attributes), e.g. +flags](../../reference/attributes/diagnostics.md#lint-check-attributes), e.g. `#[allow(test_lint)]` or `-A test-lint`. These identifiers are derived from the first argument to `declare_lint!`, with appropriate case and punctuation conversion. diff --git a/src/doc/unstable-book/src/language-features/unboxed-closures.md b/src/doc/unstable-book/src/language-features/unboxed-closures.md index d845c99a88a69..71003fba00ba2 100644 --- a/src/doc/unstable-book/src/language-features/unboxed-closures.md +++ b/src/doc/unstable-book/src/language-features/unboxed-closures.md @@ -2,7 +2,7 @@ The tracking issue for this feature is [#29625] -See Also: [`fn_traits`](library-features/fn-traits.html) +See Also: [`fn_traits`](../library-features/fn-traits.md) [#29625]: https://github.com/rust-lang/rust/issues/29625 diff --git a/src/doc/unstable-book/src/library-features/fn-traits.md b/src/doc/unstable-book/src/library-features/fn-traits.md index 72a3f36c10b69..29a8aecee6c2f 100644 --- a/src/doc/unstable-book/src/library-features/fn-traits.md +++ b/src/doc/unstable-book/src/library-features/fn-traits.md @@ -2,7 +2,7 @@ The tracking issue for this feature is [#29625] -See Also: [`unboxed_closures`](language-features/unboxed-closures.html) +See Also: [`unboxed_closures`](../language-features/unboxed-closures.md) [#29625]: https://github.com/rust-lang/rust/issues/29625 diff --git a/src/doc/unstable-book/src/library-features/fnbox.md b/src/doc/unstable-book/src/library-features/fnbox.md index cb3386b715211..97e32cc0acb12 100644 --- a/src/doc/unstable-book/src/library-features/fnbox.md +++ b/src/doc/unstable-book/src/library-features/fnbox.md @@ -27,6 +27,6 @@ impl Fn for &F where F: Fn + ?Sized {} Before the introduction of [`unsized_locals`][unsized_locals], we had been unable to provide the former impls. That means, unlike `&dyn Fn()` or `&mut dyn FnMut()` we could not use `Box` at that time. -[unsized_locals]: language-features/unsized-locals.html +[unsized_locals]: ../language-features/unsized-locals.md `FnBox()` is an alternative approach to `Box` is delegated to `FnBox::call_box` which doesn't need unsized locals. As we now have `Box` working, the `fnbox` feature is going to be removed. diff --git a/src/doc/unstable-book/src/the-unstable-book.md b/src/doc/unstable-book/src/the-unstable-book.md index 604b449f16379..554c52c3c9c27 100644 --- a/src/doc/unstable-book/src/the-unstable-book.md +++ b/src/doc/unstable-book/src/the-unstable-book.md @@ -14,7 +14,7 @@ fn main() { The `box_syntax` feature [has a chapter][box] describing how to use it. -[box]: language-features/box-syntax.html +[box]: language-features/box-syntax.md Because this documentation relates to unstable features, we make no guarantees that what is contained here is accurate or up to date. It's developed on a From 5f929be1624fdf6fc49cb36eac54db5e6b38e275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Thu, 30 May 2019 14:22:33 +0200 Subject: [PATCH 06/14] Migrate rustdoc book to MdBook2 --- src/bootstrap/doc.rs | 2 +- src/doc/rustdoc/src/command-line-arguments.md | 8 ++++---- src/doc/rustdoc/src/passes.md | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index b98a6b5e1814b..5cd9f99d12108 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -66,7 +66,7 @@ book!( Reference, "src/doc/reference", "reference", RustbookVersion::MdBook1; RustByExample, "src/doc/rust-by-example", "rust-by-example", RustbookVersion::MdBook1; RustcBook, "src/doc/rustc", "rustc", RustbookVersion::MdBook1; - RustdocBook, "src/doc/rustdoc", "rustdoc", RustbookVersion::MdBook1; + RustdocBook, "src/doc/rustdoc", "rustdoc", RustbookVersion::MdBook2; ); #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] diff --git a/src/doc/rustdoc/src/command-line-arguments.md b/src/doc/rustdoc/src/command-line-arguments.md index aba485f752ab2..b21defaedc313 100644 --- a/src/doc/rustdoc/src/command-line-arguments.md +++ b/src/doc/rustdoc/src/command-line-arguments.md @@ -178,7 +178,7 @@ $ rustdoc src/lib.rs --passes strip-priv-imports An argument of "list" will print a list of possible "rustdoc passes", and other arguments will be the name of which passes to run in addition to the defaults. -For more details on passes, see [the chapter on them](passes.html). +For more details on passes, see [the chapter on them](passes.md). See also `--no-defaults`. @@ -194,7 +194,7 @@ By default, `rustdoc` will run several passes over your code. This removes those defaults, allowing you to use `--passes` to specify exactly which passes you want. -For more details on passes, see [the chapter on them](passes.html). +For more details on passes, see [the chapter on them](passes.md). See also `--passes`. @@ -207,7 +207,7 @@ $ rustdoc src/lib.rs --test ``` This flag will run your code examples as tests. For more, see [the chapter -on documentation tests](documentation-tests.html). +on documentation tests](documentation-tests.md). See also `--test-args`. @@ -220,7 +220,7 @@ $ rustdoc src/lib.rs --test --test-args ignored ``` This flag will pass options to the test runner when running documentation tests. -For more, see [the chapter on documentation tests](documentation-tests.html). +For more, see [the chapter on documentation tests](documentation-tests.md). See also `--test`. diff --git a/src/doc/rustdoc/src/passes.md b/src/doc/rustdoc/src/passes.md index 615b3dca199f1..12d4ea205b31e 100644 --- a/src/doc/rustdoc/src/passes.md +++ b/src/doc/rustdoc/src/passes.md @@ -5,8 +5,8 @@ Rustdoc has a concept called "passes". These are transformations that In addition to the passes below, check out the docs for these flags: -* [`--passes`](command-line-arguments.html#a--passes-add-more-rustdoc-passes) -* [`--no-defaults`](command-line-arguments.html#a--no-defaults-dont-run-default-passes) +* [`--passes`](command-line-arguments.md#--passes-add-more-rustdoc-passes) +* [`--no-defaults`](command-line-arguments.md#--no-defaults-dont-run-default-passes) ## Default passes From dacf19cb5922f92aaa9ffca085656018ce4ffe0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Thu, 30 May 2019 14:30:59 +0200 Subject: [PATCH 07/14] Migrate nomicon book to MdBook2 --- src/bootstrap/doc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 5cd9f99d12108..2a3577a3d2044 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -62,7 +62,7 @@ macro_rules! book { book!( EditionGuide, "src/doc/edition-guide", "edition-guide", RustbookVersion::MdBook2; EmbeddedBook, "src/doc/embedded-book", "embedded-book", RustbookVersion::MdBook2; - Nomicon, "src/doc/nomicon", "nomicon", RustbookVersion::MdBook1; + Nomicon, "src/doc/nomicon", "nomicon", RustbookVersion::MdBook2; Reference, "src/doc/reference", "reference", RustbookVersion::MdBook1; RustByExample, "src/doc/rust-by-example", "rust-by-example", RustbookVersion::MdBook1; RustcBook, "src/doc/rustc", "rustc", RustbookVersion::MdBook1; From 436c9bee79d34b5d6637f87e415d90bd82029236 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 30 May 2019 19:06:23 +0200 Subject: [PATCH 08/14] Fix links in Deref documentation --- src/libcore/ops/deref.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libcore/ops/deref.rs b/src/libcore/ops/deref.rs index e44a6c4d2a0e9..ce0d3fd01f78f 100644 --- a/src/libcore/ops/deref.rs +++ b/src/libcore/ops/deref.rs @@ -23,9 +23,9 @@ /// * Values of type `&T` are coerced to values of type `&U` /// * `T` implicitly implements all the (immutable) methods of the type `U`. /// -/// For more details, visit [the chapter in *The Rust Programming Language*] -/// [book] as well as the reference sections on [the dereference operator] -/// [ref-deref-op], [method resolution] and [type coercions]. +/// For more details, visit [the chapter in *The Rust Programming Language*][book] +/// as well as the reference sections on [the dereference operator][ref-deref-op], +/// [method resolution] and [type coercions]. /// /// [book]: ../../book/ch15-02-deref.html /// [`DerefMut`]: trait.DerefMut.html @@ -113,9 +113,9 @@ impl Deref for &mut T { /// * Values of type `&mut T` are coerced to values of type `&mut U` /// * `T` implicitly implements all the (mutable) methods of the type `U`. /// -/// For more details, visit [the chapter in *The Rust Programming Language*] -/// [book] as well as the reference sections on [the dereference operator] -/// [ref-deref-op], [method resolution] and [type coercions]. +/// For more details, visit [the chapter in *The Rust Programming Language*][book] +/// as well as the reference sections on [the dereference operator][ref-deref-op], +/// [method resolution] and [type coercions]. /// /// [book]: ../../book/ch15-02-deref.html /// [`Deref`]: trait.Deref.html From 0c35c699d43ba24943bb8f38986f84c4be676dc3 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Thu, 30 May 2019 18:00:17 +0000 Subject: [PATCH 09/14] Stabilize iter_nth_back feature --- src/liballoc/lib.rs | 1 - src/libcore/iter/traits/double_ended.rs | 5 +---- src/libcore/tests/lib.rs | 1 - 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index d90036eaf49b8..bfc008e14a486 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -112,7 +112,6 @@ #![feature(maybe_uninit_extra, maybe_uninit_slice, maybe_uninit_array)] #![feature(alloc_layout_extra)] #![feature(try_trait)] -#![feature(iter_nth_back)] // Allow testing this library diff --git a/src/libcore/iter/traits/double_ended.rs b/src/libcore/iter/traits/double_ended.rs index 06de95c082724..2c1aeb5690a58 100644 --- a/src/libcore/iter/traits/double_ended.rs +++ b/src/libcore/iter/traits/double_ended.rs @@ -88,7 +88,6 @@ pub trait DoubleEndedIterator: Iterator { /// Basic usage: /// /// ``` - /// #![feature(iter_nth_back)] /// let a = [1, 2, 3]; /// assert_eq!(a.iter().nth_back(2), Some(&1)); /// ``` @@ -96,7 +95,6 @@ pub trait DoubleEndedIterator: Iterator { /// Calling `nth_back()` multiple times doesn't rewind the iterator: /// /// ``` - /// #![feature(iter_nth_back)] /// let a = [1, 2, 3]; /// /// let mut iter = a.iter(); @@ -108,12 +106,11 @@ pub trait DoubleEndedIterator: Iterator { /// Returning `None` if there are less than `n + 1` elements: /// /// ``` - /// #![feature(iter_nth_back)] /// let a = [1, 2, 3]; /// assert_eq!(a.iter().nth_back(10), None); /// ``` #[inline] - #[unstable(feature = "iter_nth_back", issue = "56995")] + #[stable(feature = "iter_nth_back", since = "1.37.0")] fn nth_back(&mut self, mut n: usize) -> Option { for x in self.rev() { if n == 0 { return Some(x) } diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index c617596aba801..0dba2bed62c93 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -10,7 +10,6 @@ #![feature(fmt_internals)] #![feature(hashmap_internals)] #![feature(is_sorted)] -#![feature(iter_nth_back)] #![feature(iter_once_with)] #![feature(pattern)] #![feature(range_is_empty)] From 0fdd4191adb998991742c7f63f49b1a6c4e4ec3d Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 30 May 2019 19:55:43 +0100 Subject: [PATCH 10/14] Add regression test for const generics ICE Co-Authored-By: Mazdak Farrokhzad --- .../const-generic-array-wrapper.rs | 18 ++++++++++++++++++ .../const-generic-array-wrapper.stderr | 6 ++++++ 2 files changed, 24 insertions(+) create mode 100644 src/test/ui/const-generics/const-generic-array-wrapper.rs create mode 100644 src/test/ui/const-generics/const-generic-array-wrapper.stderr diff --git a/src/test/ui/const-generics/const-generic-array-wrapper.rs b/src/test/ui/const-generics/const-generic-array-wrapper.rs new file mode 100644 index 0000000000000..adffe32d67a30 --- /dev/null +++ b/src/test/ui/const-generics/const-generic-array-wrapper.rs @@ -0,0 +1,18 @@ +// run-pass + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +struct Foo([T; {N}]); + +impl Foo { + fn foo(&self) -> usize { + {N} + } +} + +fn main() { + let foo = Foo([0u32; 21]); + assert_eq!(foo.0, [0u32; 21]); + assert_eq!(foo.foo(), 21); +} diff --git a/src/test/ui/const-generics/const-generic-array-wrapper.stderr b/src/test/ui/const-generics/const-generic-array-wrapper.stderr new file mode 100644 index 0000000000000..f92e11d47ed37 --- /dev/null +++ b/src/test/ui/const-generics/const-generic-array-wrapper.stderr @@ -0,0 +1,6 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/const-generic-array-wrapper.rs:3:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + From 66aa18bb44d04b5e0371c4bab240100ad80faebb Mon Sep 17 00:00:00 2001 From: Christian Vallentin Date: Thu, 30 May 2019 21:29:32 +0200 Subject: [PATCH 11/14] Fixed lifetime misspelling --- src/librustc_codegen_ssa/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_codegen_ssa/README.md b/src/librustc_codegen_ssa/README.md index 9e1d429180367..11fac239edf12 100644 --- a/src/librustc_codegen_ssa/README.md +++ b/src/librustc_codegen_ssa/README.md @@ -26,7 +26,7 @@ While the LLVM-specific code will be left in `rustc_codegen_llvm`, all the new t @irinagpopa started to parametrize the types of `rustc_codegen_llvm` by a generic `Value` type, implemented in LLVM by a reference `&'ll Value`. This work has been extended to all structures inside the `mir` folder and elsewhere, as well as for LLVM's `BasicBlock` and `Type` types. -The two most important structures for the LLVM codegen are `CodegenCx` and `Builder`. They are parametrized by multiple liftime parameters and the type for `Value`. +The two most important structures for the LLVM codegen are `CodegenCx` and `Builder`. They are parametrized by multiple lifetime parameters and the type for `Value`. ```rust struct CodegenCx<'ll, 'tcx: 'll> { From 4c5eb8ecfc1accda036053d50c8c44b3c5eebb3b Mon Sep 17 00:00:00 2001 From: Janusz Marcinkiewicz Date: Thu, 30 May 2019 22:41:09 +0200 Subject: [PATCH 12/14] Explicitly suggest 'type_ascription' feature --- src/libsyntax/parse/diagnostics.rs | 4 ++-- src/test/ui/issues/issue-22644.stderr | 2 +- src/test/ui/issues/issue-34255-1.stderr | 2 +- src/test/ui/lifetime_starts_expressions.stderr | 2 +- src/test/ui/parser/recover-from-bad-variant.stderr | 2 +- .../ui/type/type-ascription-instead-of-statement-end.stderr | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libsyntax/parse/diagnostics.rs b/src/libsyntax/parse/diagnostics.rs index b3d49524d7668..2e4d4c091398e 100644 --- a/src/libsyntax/parse/diagnostics.rs +++ b/src/libsyntax/parse/diagnostics.rs @@ -858,8 +858,8 @@ impl<'a> Parser<'a> { Applicability::MaybeIncorrect, ); } else { - err.note("type ascription is a nightly-only feature that lets \ - you annotate an expression with a type: `: `") + err.note("#![feature(type_ascription)] lets you annotate an \ + expression with a type: `: `") .span_note( lhs_span, "this expression expects an ascribed type after the colon", diff --git a/src/test/ui/issues/issue-22644.stderr b/src/test/ui/issues/issue-22644.stderr index a28ea0d09f8f0..cf36953546549 100644 --- a/src/test/ui/issues/issue-22644.stderr +++ b/src/test/ui/issues/issue-22644.stderr @@ -89,7 +89,7 @@ error: expected type, found `4` LL | println!("{}", a: &mut 4); | ^ expecting a type here because of type ascription | - = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` + = note: #![feature(type_ascription)] lets you annotate an expression with a type: `: ` note: this expression expects an ascribed type after the colon --> $DIR/issue-22644.rs:34:20 | diff --git a/src/test/ui/issues/issue-34255-1.stderr b/src/test/ui/issues/issue-34255-1.stderr index 7899c8d30f1dd..01f3953777017 100644 --- a/src/test/ui/issues/issue-34255-1.stderr +++ b/src/test/ui/issues/issue-34255-1.stderr @@ -4,7 +4,7 @@ error: expected type, found `42` LL | Test::Drill(field: 42); | ^^ expecting a type here because of type ascription | - = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` + = note: #![feature(type_ascription)] lets you annotate an expression with a type: `: ` note: this expression expects an ascribed type after the colon --> $DIR/issue-34255-1.rs:8:17 | diff --git a/src/test/ui/lifetime_starts_expressions.stderr b/src/test/ui/lifetime_starts_expressions.stderr index cb5a52a3e081a..8ae8018c2ff25 100644 --- a/src/test/ui/lifetime_starts_expressions.stderr +++ b/src/test/ui/lifetime_starts_expressions.stderr @@ -14,7 +14,7 @@ error: expected type, found keyword `loop` LL | loop { break 'label: loop { break 'label 42; }; } | ^^^^ expecting a type here because of type ascription | - = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` + = note: #![feature(type_ascription)] lets you annotate an expression with a type: `: ` note: this expression expects an ascribed type after the colon --> $DIR/lifetime_starts_expressions.rs:6:12 | diff --git a/src/test/ui/parser/recover-from-bad-variant.stderr b/src/test/ui/parser/recover-from-bad-variant.stderr index 1eba6d7d52877..150d74f07428d 100644 --- a/src/test/ui/parser/recover-from-bad-variant.stderr +++ b/src/test/ui/parser/recover-from-bad-variant.stderr @@ -4,7 +4,7 @@ error: expected type, found `3` LL | let x = Enum::Foo(a: 3, b: 4); | ^ expecting a type here because of type ascription | - = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` + = note: #![feature(type_ascription)] lets you annotate an expression with a type: `: ` note: this expression expects an ascribed type after the colon --> $DIR/recover-from-bad-variant.rs:7:23 | diff --git a/src/test/ui/type/type-ascription-instead-of-statement-end.stderr b/src/test/ui/type/type-ascription-instead-of-statement-end.stderr index 2084cbcce4f62..4929922c83fe6 100644 --- a/src/test/ui/type/type-ascription-instead-of-statement-end.stderr +++ b/src/test/ui/type/type-ascription-instead-of-statement-end.stderr @@ -12,7 +12,7 @@ error: expected type, found `0` LL | println!("test"): 0; | ^ expecting a type here because of type ascription | - = note: type ascription is a nightly-only feature that lets you annotate an expression with a type: `: ` + = note: #![feature(type_ascription)] lets you annotate an expression with a type: `: ` note: this expression expects an ascribed type after the colon --> $DIR/type-ascription-instead-of-statement-end.rs:9:5 | From 2ebfbb4fabda543f090890a889914df025ccbb77 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Wed, 29 May 2019 16:53:48 +0200 Subject: [PATCH 13/14] Parse 'async unsafe fn' instead of 'unsafe async fn'. --- src/libsyntax/parse/parser.rs | 71 ++++++++++++-------------- src/test/ui/async-await/async-await.rs | 2 +- src/test/ui/async-await/await-macro.rs | 2 +- 3 files changed, 36 insertions(+), 39 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 746e9cad4962c..92c27f883d1a9 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -7205,44 +7205,41 @@ impl<'a> Parser<'a> { return Ok(Some(item)); } - // `unsafe async fn` or `async fn` - if ( - self.check_keyword(kw::Unsafe) && - self.is_keyword_ahead(1, &[kw::Async]) - ) || ( - self.check_keyword(kw::Async) && - self.is_keyword_ahead(1, &[kw::Fn]) - ) - { - // ASYNC FUNCTION ITEM - let unsafety = self.parse_unsafety(); - self.expect_keyword(kw::Async)?; - let async_span = self.prev_span; - self.expect_keyword(kw::Fn)?; - let fn_span = self.prev_span; - let (ident, item_, extra_attrs) = - self.parse_item_fn(unsafety, - respan(async_span, IsAsync::Async { - closure_id: ast::DUMMY_NODE_ID, - return_impl_trait_id: ast::DUMMY_NODE_ID, - arguments: Vec::new(), - }), - respan(fn_span, Constness::NotConst), - Abi::Rust)?; - let prev_span = self.prev_span; - let item = self.mk_item(lo.to(prev_span), - ident, - item_, - visibility, - maybe_append(attrs, extra_attrs)); - if self.span.rust_2015() { - self.diagnostic().struct_span_err_with_code( - async_span, - "`async fn` is not permitted in the 2015 edition", - DiagnosticId::Error("E0670".into()) - ).emit(); + // Parse `async unsafe? fn`. + if self.check_keyword(kw::Async) { + let async_span = self.span; + if self.is_keyword_ahead(1, &[kw::Fn]) + || self.is_keyword_ahead(2, &[kw::Fn]) + { + // ASYNC FUNCTION ITEM + self.bump(); // `async` + let unsafety = self.parse_unsafety(); // `unsafe`? + self.expect_keyword(kw::Fn)?; // `fn` + let fn_span = self.prev_span; + let (ident, item_, extra_attrs) = + self.parse_item_fn(unsafety, + respan(async_span, IsAsync::Async { + closure_id: ast::DUMMY_NODE_ID, + return_impl_trait_id: ast::DUMMY_NODE_ID, + arguments: Vec::new(), + }), + respan(fn_span, Constness::NotConst), + Abi::Rust)?; + let prev_span = self.prev_span; + let item = self.mk_item(lo.to(prev_span), + ident, + item_, + visibility, + maybe_append(attrs, extra_attrs)); + if self.span.rust_2015() { + self.diagnostic().struct_span_err_with_code( + async_span, + "`async fn` is not permitted in the 2015 edition", + DiagnosticId::Error("E0670".into()) + ).emit(); + } + return Ok(Some(item)); } - return Ok(Some(item)); } if self.check_keyword(kw::Unsafe) && self.is_keyword_ahead(1, &[kw::Trait, kw::Auto]) diff --git a/src/test/ui/async-await/async-await.rs b/src/test/ui/async-await/async-await.rs index 6fa013e5c54ca..38261ca4570eb 100644 --- a/src/test/ui/async-await/async-await.rs +++ b/src/test/ui/async-await/async-await.rs @@ -122,7 +122,7 @@ fn async_fn_with_internal_borrow(y: u8) -> impl Future { } } -unsafe async fn unsafe_async_fn(x: u8) -> u8 { +async unsafe fn unsafe_async_fn(x: u8) -> u8 { wake_and_yield_once().await; x } diff --git a/src/test/ui/async-await/await-macro.rs b/src/test/ui/async-await/await-macro.rs index 1b807588d6ac2..7d8b7a257dad9 100644 --- a/src/test/ui/async-await/await-macro.rs +++ b/src/test/ui/async-await/await-macro.rs @@ -122,7 +122,7 @@ fn async_fn_with_internal_borrow(y: u8) -> impl Future { } } -unsafe async fn unsafe_async_fn(x: u8) -> u8 { +async unsafe fn unsafe_async_fn(x: u8) -> u8 { await!(wake_and_yield_once()); x } From fc21f33d4db9e2f0317c277851c05954e476d1ac Mon Sep 17 00:00:00 2001 From: OptimisticPeach Date: Thu, 30 May 2019 19:37:23 -0400 Subject: [PATCH 14/14] Fixed some typos. --- src/libcore/convert.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index b3ff447be5ee4..a2796ad0cf0b0 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -177,8 +177,8 @@ pub trait AsRef { /// /// Using `AsMut` as trait bound for a generic function we can accept all mutable references /// that can be converted to type `&mut T`. Because [`Box`] implements `AsMut` we can -/// write a function `add_one`that takes all arguments that can be converted to `&mut u64`. -/// Because [`Box`] implements `AsMut` `add_one` accepts arguments of type +/// write a function `add_one` that takes all arguments that can be converted to `&mut u64`. +/// Because [`Box`] implements `AsMut`, `add_one` accepts arguments of type /// `&mut Box` as well: /// /// ```