From fdb6bdacfab4d6f52124fa0e81ac3c7db84d35f7 Mon Sep 17 00:00:00 2001 From: Smittyvb Date: Wed, 3 Nov 2021 09:24:50 -0400 Subject: [PATCH 1/7] Add note about x86 instruction prefixes in asm! Since rustc doesn't do the assembly parsing itself, it is unable to detect when inline assembly ends with an instruction prefix, which doesn't make sense since it would apply to instructions from the compiler. This fixes #82314 by mentioning that x86 instruction prefixes must not be used in inline assembly. --- src/doc/unstable-book/src/library-features/asm.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/doc/unstable-book/src/library-features/asm.md b/src/doc/unstable-book/src/library-features/asm.md index 6bf21e8f58b25..6e4164626103e 100644 --- a/src/doc/unstable-book/src/library-features/asm.md +++ b/src/doc/unstable-book/src/library-features/asm.md @@ -885,5 +885,7 @@ The compiler performs some additional checks on options: - You are responsible for switching any target-specific state (e.g. thread-local storage, stack bounds). - The set of memory locations that you may access is the intersection of those allowed by the `asm!` blocks you entered and exited. - You cannot assume that an `asm!` block will appear exactly once in the output binary. The compiler is allowed to instantiate multiple copies of the `asm!` block, for example when the function containing it is inlined in multiple places. +- On x86, inline assembly must not end with an instruction prefix (such as `LOCK`) that would apply to instructions generated by the compiler. + - The compiler is currently unable to detect this due to the way inline assembly is compiled. > **Note**: As a general rule, the flags covered by `preserves_flags` are those which are *not* preserved when performing a function call. From 3f496b5f2e8804465d20651994b8ef4103f5dbb6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 3 Nov 2021 15:44:04 +0100 Subject: [PATCH 2/7] Simplify js tester a bit --- src/tools/rustdoc-js/tester.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js index bb9cd00f3f582..a673e425dfff9 100644 --- a/src/tools/rustdoc-js/tester.js +++ b/src/tools/rustdoc-js/tester.js @@ -414,7 +414,7 @@ function parseOptions(args) { "test_folder": "", "test_file": "", }; - var correspondances = { + var correspondences = { "--resource-suffix": "resource_suffix", "--doc-folder": "doc_folder", "--test-folder": "test_folder", @@ -423,17 +423,13 @@ function parseOptions(args) { }; for (var i = 0; i < args.length; ++i) { - if (args[i] === "--resource-suffix" - || args[i] === "--doc-folder" - || args[i] === "--test-folder" - || args[i] === "--test-file" - || args[i] === "--crate-name") { + if (correspondences.hasOwnProperty(args[i])) { i += 1; if (i >= args.length) { console.log("Missing argument after `" + args[i - 1] + "` option."); return null; } - opts[correspondances[args[i - 1]]] = args[i]; + opts[correspondences[args[i - 1]]] = args[i]; } else if (args[i] === "--help") { showHelp(); process.exit(0); From 754455e4f25bb55dfafc6422f340d6032d3ac0b7 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Wed, 3 Nov 2021 20:00:00 -0700 Subject: [PATCH 3/7] Clean up some `-Z unstable-options` in tests. --- src/test/ui/hello2021.rs | 1 - .../ui/iterators/into-iter-on-arrays-2021.rs | 1 - .../allowed-cli-deny-by-default-lint.rs | 2 +- ...t-group-allowed-cli-warn-by-default-lint.rs | 2 +- .../warn-by-default-lint-two-modules.rs | 2 +- .../ui/lint/force-warn/warnings-lint-group.rs | 2 +- .../lint/force-warn/warnings-lint-group.stderr | 4 +--- .../lint/unused_parens_json_suggestion.fixed | 2 +- .../ui/lint/unused_parens_json_suggestion.rs | 2 +- .../lint/unused_parens_json_suggestion.stderr | 2 +- .../unused_parens_remove_json_suggestion.fixed | 2 +- .../unused_parens_remove_json_suggestion.rs | 2 +- ...unused_parens_remove_json_suggestion.stderr | 18 +++++++++--------- src/test/ui/matches2021.rs | 1 - src/test/ui/privacy/pub-priv-dep/pub-priv1.rs | 1 + .../ui/privacy/pub-priv-dep/pub-priv1.stderr | 8 ++++---- src/test/ui/rust-2021/prelude2021.rs | 1 - .../reserved-prefixes-migration.fixed | 2 +- .../rust-2021/reserved-prefixes-migration.rs | 2 +- .../extern-loc-missing-loc.rs | 2 +- src/tools/compiletest/src/header.rs | 3 --- src/tools/compiletest/src/runtest.rs | 3 --- 22 files changed, 27 insertions(+), 38 deletions(-) diff --git a/src/test/ui/hello2021.rs b/src/test/ui/hello2021.rs index 738f151b0f60b..134d8af5bfb8a 100644 --- a/src/test/ui/hello2021.rs +++ b/src/test/ui/hello2021.rs @@ -1,6 +1,5 @@ // run-pass // edition:2021 -// compile-flags: -Zunstable-options fn main() { println!("hello, 2021"); diff --git a/src/test/ui/iterators/into-iter-on-arrays-2021.rs b/src/test/ui/iterators/into-iter-on-arrays-2021.rs index ec54ed005173b..158317efe4782 100644 --- a/src/test/ui/iterators/into-iter-on-arrays-2021.rs +++ b/src/test/ui/iterators/into-iter-on-arrays-2021.rs @@ -1,6 +1,5 @@ // check-pass // edition:2021 -// compile-flags: -Zunstable-options use std::array::IntoIter; use std::ops::Deref; diff --git a/src/test/ui/lint/force-warn/allowed-cli-deny-by-default-lint.rs b/src/test/ui/lint/force-warn/allowed-cli-deny-by-default-lint.rs index 3fab9148392be..3a3d81176d691 100644 --- a/src/test/ui/lint/force-warn/allowed-cli-deny-by-default-lint.rs +++ b/src/test/ui/lint/force-warn/allowed-cli-deny-by-default-lint.rs @@ -1,6 +1,6 @@ // --force-warn $LINT causes $LINT (which is deny-by-default) to warn // despite $LINT being allowed on command line -// compile-flags: -A const_err --force-warn const_err -Zunstable-options +// compile-flags: -A const_err --force-warn const_err // check-pass const C: i32 = 1 / 0; diff --git a/src/test/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.rs b/src/test/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.rs index 4eb05b538b0ba..9736027452a8d 100644 --- a/src/test/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.rs +++ b/src/test/ui/lint/force-warn/lint-group-allowed-cli-warn-by-default-lint.rs @@ -1,6 +1,6 @@ // --force-warn $LINT_GROUP causes $LINT (which is warn-by-default) to warn // despite $LINT being allowed on command line -// compile-flags: -A bare-trait-objects --force-warn rust-2018-idioms -Zunstable-options +// compile-flags: -A bare-trait-objects --force-warn rust-2018-idioms // check-pass pub trait SomeTrait {} diff --git a/src/test/ui/lint/force-warn/warn-by-default-lint-two-modules.rs b/src/test/ui/lint/force-warn/warn-by-default-lint-two-modules.rs index d2cb3417be68a..267e7b45f0c21 100644 --- a/src/test/ui/lint/force-warn/warn-by-default-lint-two-modules.rs +++ b/src/test/ui/lint/force-warn/warn-by-default-lint-two-modules.rs @@ -1,6 +1,6 @@ // --force-warn $LINT causes $LINT (which is warn-by-default) to warn // despite being allowed in one submodule (but not the other) -// compile-flags: --force-warn dead_code -Zunstable-options +// compile-flags: --force-warn dead_code // check-pass mod one { diff --git a/src/test/ui/lint/force-warn/warnings-lint-group.rs b/src/test/ui/lint/force-warn/warnings-lint-group.rs index fa25a1f8a842a..d1d4f5602f271 100644 --- a/src/test/ui/lint/force-warn/warnings-lint-group.rs +++ b/src/test/ui/lint/force-warn/warnings-lint-group.rs @@ -1,5 +1,5 @@ // --force-warn warnings is an error -// compile-flags: --force-warn warnings -Zunstable-options +// compile-flags: --force-warn warnings // error-pattern: `warnings` lint group is not supported fn main() {} diff --git a/src/test/ui/lint/force-warn/warnings-lint-group.stderr b/src/test/ui/lint/force-warn/warnings-lint-group.stderr index 03f5788b527d3..1faeed3370451 100644 --- a/src/test/ui/lint/force-warn/warnings-lint-group.stderr +++ b/src/test/ui/lint/force-warn/warnings-lint-group.stderr @@ -2,8 +2,6 @@ error[E0602]: `warnings` lint group is not supported with ´--force-warn´ error[E0602]: `warnings` lint group is not supported with ´--force-warn´ -error[E0602]: `warnings` lint group is not supported with ´--force-warn´ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0602`. diff --git a/src/test/ui/lint/unused_parens_json_suggestion.fixed b/src/test/ui/lint/unused_parens_json_suggestion.fixed index 15ee19755bffc..c400454046748 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.fixed +++ b/src/test/ui/lint/unused_parens_json_suggestion.fixed @@ -1,4 +1,4 @@ -// compile-flags: --error-format json -Zunstable-options +// compile-flags: --error-format json // run-rustfix // The output for humans should just highlight the whole span without showing diff --git a/src/test/ui/lint/unused_parens_json_suggestion.rs b/src/test/ui/lint/unused_parens_json_suggestion.rs index d72df21e09ae2..962c8bdd7d789 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.rs +++ b/src/test/ui/lint/unused_parens_json_suggestion.rs @@ -1,4 +1,4 @@ -// compile-flags: --error-format json -Zunstable-options +// compile-flags: --error-format json // run-rustfix // The output for humans should just highlight the whole span without showing diff --git a/src/test/ui/lint/unused_parens_json_suggestion.stderr b/src/test/ui/lint/unused_parens_json_suggestion.stderr index 498c25d2e1c44..169fb824021ed 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.stderr +++ b/src/test/ui/lint/unused_parens_json_suggestion.stderr @@ -1,4 +1,4 @@ -{"message":"unnecessary parentheses around assigned value","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":596,"byte_end":597,"line_start":16,"line_end":16,"column_start":14,"column_end":15,"is_primary":true,"text":[{"text":" let _a = (1 / (2 + 3)); +{"message":"unnecessary parentheses around assigned value","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":577,"byte_end":578,"line_start":16,"line_end":16,"column_start":14,"column_end":15,"is_primary":true,"text":[{"text":" let _a = (1 / (2 + 3)); --> $DIR/unused_parens_json_suggestion.rs:16:14 | LL | let _a = (1 / (2 + 3)); diff --git a/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed b/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed index 1d891d328dd5a..8a57cd57385f3 100644 --- a/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed +++ b/src/test/ui/lint/unused_parens_remove_json_suggestion.fixed @@ -1,4 +1,4 @@ -// compile-flags: --error-format json -Zunstable-options +// compile-flags: --error-format json // run-rustfix // The output for humans should just highlight the whole span without showing diff --git a/src/test/ui/lint/unused_parens_remove_json_suggestion.rs b/src/test/ui/lint/unused_parens_remove_json_suggestion.rs index 494cd18450630..952332d54e9c1 100644 --- a/src/test/ui/lint/unused_parens_remove_json_suggestion.rs +++ b/src/test/ui/lint/unused_parens_remove_json_suggestion.rs @@ -1,4 +1,4 @@ -// compile-flags: --error-format json -Zunstable-options +// compile-flags: --error-format json // run-rustfix // The output for humans should just highlight the whole span without showing diff --git a/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr b/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr index 08291b10fcc20..43367aaa9113b 100644 --- a/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr +++ b/src/test/ui/lint/unused_parens_remove_json_suggestion.stderr @@ -1,4 +1,4 @@ -{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":500,"byte_end":501,"line_start":17,"line_end":17,"column_start":8,"column_end":9,"is_primary":true,"text":[{"text":" if (_b) { +{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":481,"byte_end":482,"line_start":17,"line_end":17,"column_start":8,"column_end":9,"is_primary":true,"text":[{"text":" if (_b) { --> $DIR/unused_parens_remove_json_suggestion.rs:17:8 | LL | if (_b) { @@ -16,7 +16,7 @@ LL + if _b { | "} -{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":631,"byte_end":632,"line_start":28,"line_end":28,"column_start":7,"column_end":8,"is_primary":true,"text":[{"text":" if(c) { +{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":612,"byte_end":613,"line_start":28,"line_end":28,"column_start":7,"column_end":8,"is_primary":true,"text":[{"text":" if(c) { --> $DIR/unused_parens_remove_json_suggestion.rs:28:7 | LL | if(c) { @@ -29,7 +29,7 @@ LL + if c { | "} -{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":711,"byte_end":712,"line_start":32,"line_end":32,"column_start":8,"column_end":9,"is_primary":true,"text":[{"text":" if (c){ +{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":692,"byte_end":693,"line_start":32,"line_end":32,"column_start":8,"column_end":9,"is_primary":true,"text":[{"text":" if (c){ --> $DIR/unused_parens_remove_json_suggestion.rs:32:8 | LL | if (c){ @@ -42,7 +42,7 @@ LL + if c { | "} -{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":793,"byte_end":794,"line_start":36,"line_end":36,"column_start":11,"column_end":12,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":11,"highlight_end":12}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":807,"byte_end":808,"line_start":36,"line_end":36,"column_start":25,"column_end":26,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":25,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"remove these parentheses","code":null,"level":"help","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":793,"byte_end":794,"line_start":36,"line_end":36,"column_start":11,"column_end":12,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":11,"highlight_end":12}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null},{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":807,"byte_end":808,"line_start":36,"line_end":36,"column_start":25,"column_end":26,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":25,"highlight_end":26}],"label":null,"suggested_replacement":" ","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error: unnecessary parentheses around `while` condition +{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":774,"byte_end":775,"line_start":36,"line_end":36,"column_start":11,"column_end":12,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":11,"highlight_end":12}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":788,"byte_end":789,"line_start":36,"line_end":36,"column_start":25,"column_end":26,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":25,"highlight_end":26}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"remove these parentheses","code":null,"level":"help","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":774,"byte_end":775,"line_start":36,"line_end":36,"column_start":11,"column_end":12,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":11,"highlight_end":12}],"label":null,"suggested_replacement":"","suggestion_applicability":"MachineApplicable","expansion":null},{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":788,"byte_end":789,"line_start":36,"line_end":36,"column_start":25,"column_end":26,"is_primary":true,"text":[{"text":" while (false && true){","highlight_start":25,"highlight_end":26}],"label":null,"suggested_replacement":" ","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error: unnecessary parentheses around `while` condition --> $DIR/unused_parens_remove_json_suggestion.rs:36:11 | LL | while (false && true){ @@ -55,7 +55,7 @@ LL + while false && true { | "} -{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":821,"byte_end":822,"line_start":37,"line_end":37,"column_start":12,"column_end":13,"is_primary":true,"text":[{"text":" if (c) { +{"message":"unnecessary parentheses around `if` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":802,"byte_end":803,"line_start":37,"line_end":37,"column_start":12,"column_end":13,"is_primary":true,"text":[{"text":" if (c) { --> $DIR/unused_parens_remove_json_suggestion.rs:37:12 | LL | if (c) { @@ -68,7 +68,7 @@ LL + if c { | "} -{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":918,"byte_end":919,"line_start":43,"line_end":43,"column_start":10,"column_end":11,"is_primary":true,"text":[{"text":" while(true && false) { +{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":899,"byte_end":900,"line_start":43,"line_end":43,"column_start":10,"column_end":11,"is_primary":true,"text":[{"text":" while(true && false) { --> $DIR/unused_parens_remove_json_suggestion.rs:43:10 | LL | while(true && false) { @@ -81,7 +81,7 @@ LL + while true && false { | "} -{"message":"unnecessary parentheses around `for` iterator expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":987,"byte_end":988,"line_start":44,"line_end":44,"column_start":18,"column_end":19,"is_primary":true,"text":[{"text":" for _ in (0 .. 3){ +{"message":"unnecessary parentheses around `for` iterator expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":968,"byte_end":969,"line_start":44,"line_end":44,"column_start":18,"column_end":19,"is_primary":true,"text":[{"text":" for _ in (0 .. 3){ --> $DIR/unused_parens_remove_json_suggestion.rs:44:18 | LL | for _ in (0 .. 3){ @@ -94,7 +94,7 @@ LL + for _ in 0 .. 3 { | "} -{"message":"unnecessary parentheses around `for` iterator expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":1088,"byte_end":1089,"line_start":49,"line_end":49,"column_start":14,"column_end":15,"is_primary":true,"text":[{"text":" for _ in (0 .. 3) { +{"message":"unnecessary parentheses around `for` iterator expression","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":1069,"byte_end":1070,"line_start":49,"line_end":49,"column_start":14,"column_end":15,"is_primary":true,"text":[{"text":" for _ in (0 .. 3) { --> $DIR/unused_parens_remove_json_suggestion.rs:49:14 | LL | for _ in (0 .. 3) { @@ -107,7 +107,7 @@ LL + for _ in 0 .. 3 { | "} -{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":1147,"byte_end":1148,"line_start":50,"line_end":50,"column_start":15,"column_end":16,"is_primary":true,"text":[{"text":" while (true && false) { +{"message":"unnecessary parentheses around `while` condition","code":{"code":"unused_parens","explanation":null},"level":"error","spans":[{"file_name":"$DIR/unused_parens_remove_json_suggestion.rs","byte_start":1128,"byte_end":1129,"line_start":50,"line_end":50,"column_start":15,"column_end":16,"is_primary":true,"text":[{"text":" while (true && false) { --> $DIR/unused_parens_remove_json_suggestion.rs:50:15 | LL | while (true && false) { diff --git a/src/test/ui/matches2021.rs b/src/test/ui/matches2021.rs index f5497c1d16de6..9143a8cdd59bc 100644 --- a/src/test/ui/matches2021.rs +++ b/src/test/ui/matches2021.rs @@ -1,6 +1,5 @@ // run-pass // edition:2021 -// compile-flags: -Zunstable-options // regression test for https://github.com/rust-lang/rust/pull/85678 diff --git a/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs b/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs index f926eee9d92b2..ec8666f93f096 100644 --- a/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs +++ b/src/test/ui/privacy/pub-priv-dep/pub-priv1.rs @@ -1,5 +1,6 @@ // aux-crate:priv:priv_dep=priv_dep.rs // aux-build:pub_dep.rs +// compile-flags: -Zunstable-options #![deny(exported_private_dependencies)] // This crate is a private dependency diff --git a/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr b/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr index e6b4d33f10316..f64b8569015d8 100644 --- a/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr +++ b/src/test/ui/privacy/pub-priv-dep/pub-priv1.stderr @@ -1,23 +1,23 @@ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:20:5 + --> $DIR/pub-priv1.rs:21:5 | LL | pub field: OtherType, | ^^^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/pub-priv1.rs:3:9 + --> $DIR/pub-priv1.rs:4:9 | LL | #![deny(exported_private_dependencies)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type `OtherType` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:27:5 + --> $DIR/pub-priv1.rs:28:5 | LL | pub fn pub_fn(param: OtherType) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trait `OtherTrait` from private dependency 'priv_dep' in public interface - --> $DIR/pub-priv1.rs:34:5 + --> $DIR/pub-priv1.rs:35:5 | LL | type Foo: OtherTrait; | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/rust-2021/prelude2021.rs b/src/test/ui/rust-2021/prelude2021.rs index 3a9fd69322869..a63b6fcf2627a 100644 --- a/src/test/ui/rust-2021/prelude2021.rs +++ b/src/test/ui/rust-2021/prelude2021.rs @@ -1,6 +1,5 @@ // check-pass // edition:2021 -// compile-flags: -Zunstable-options fn main() { let _: u16 = 123i32.try_into().unwrap(); diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.fixed b/src/test/ui/rust-2021/reserved-prefixes-migration.fixed index e026f01e93fb0..eed2f313abe6e 100644 --- a/src/test/ui/rust-2021/reserved-prefixes-migration.fixed +++ b/src/test/ui/rust-2021/reserved-prefixes-migration.fixed @@ -1,6 +1,6 @@ // check-pass // run-rustfix -// compile-flags: -Z unstable-options --edition 2018 +// edition:2018 #![warn(rust_2021_prefixes_incompatible_syntax)] diff --git a/src/test/ui/rust-2021/reserved-prefixes-migration.rs b/src/test/ui/rust-2021/reserved-prefixes-migration.rs index d24f29634806d..0565db793df66 100644 --- a/src/test/ui/rust-2021/reserved-prefixes-migration.rs +++ b/src/test/ui/rust-2021/reserved-prefixes-migration.rs @@ -1,6 +1,6 @@ // check-pass // run-rustfix -// compile-flags: -Z unstable-options --edition 2018 +// edition:2018 #![warn(rust_2021_prefixes_incompatible_syntax)] diff --git a/src/test/ui/unused-crate-deps/extern-loc-missing-loc.rs b/src/test/ui/unused-crate-deps/extern-loc-missing-loc.rs index 9339a004d3b74..6ac558974d0c5 100644 --- a/src/test/ui/unused-crate-deps/extern-loc-missing-loc.rs +++ b/src/test/ui/unused-crate-deps/extern-loc-missing-loc.rs @@ -1,7 +1,7 @@ // --extern-location with a raw reference // aux-crate:bar=bar.rs -// compile-flags:--extern-location bar +// compile-flags:--extern-location bar -Zunstable-options #![warn(unused_crate_dependencies)] diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 98d1ee19f69a1..5fcaa452ca30e 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -242,9 +242,6 @@ impl TestProps { if let Some(edition) = config.parse_edition(ln) { self.compile_flags.push(format!("--edition={}", edition)); has_edition = true; - if edition == "2021" { - self.compile_flags.push("-Zunstable-options".to_string()); - } } config.parse_and_update_revisions(ln, &mut self.revisions); diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 4470272a9f866..3c85b9076dd1a 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1607,9 +1607,6 @@ impl<'test> TestCx<'test> { get_lib_name(&aux_path.trim_end_matches(".rs").replace('-', "_"), is_dylib); rustc.arg("--extern").arg(format!("{}={}/{}", aux_name, aux_dir.display(), lib_name)); } - if !self.props.aux_crates.is_empty() { - rustc.arg("-Zunstable-options"); - } aux_dir } From dc2c2603c61fc5513ec05b9835000b4d8942c3f7 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Thu, 4 Nov 2021 00:51:45 -0700 Subject: [PATCH 4/7] Add more text and examples to `carrying_{add|mul}" --- library/core/src/num/mod.rs | 63 ++++++++++++++++++++++------- library/core/src/num/uint_macros.rs | 15 +++++++ 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs index 18ebf1cbb1063..9861530c19443 100644 --- a/library/core/src/num/mod.rs +++ b/library/core/src/num/mod.rs @@ -94,7 +94,13 @@ depending on the target pointer size. } macro_rules! widening_impl { - ($SelfT:ty, $WideT:ty, $BITS:literal) => { + ($SelfT:ty, $WideT:ty, $BITS:literal, unsigned) => { + widening_impl!($SelfT, $WideT, $BITS, ""); + }; + ($SelfT:ty, $WideT:ty, $BITS:literal, signed) => { + widening_impl!($SelfT, $WideT, $BITS, "# //"); + }; + ($SelfT:ty, $WideT:ty, $BITS:literal, $AdaptiveTestPrefix:literal) => { /// Calculates the complete product `self * rhs` without the possibility to overflow. /// /// This returns the low-order (wrapping) bits and the high-order (overflow) bits @@ -148,6 +154,33 @@ macro_rules! widening_impl { /// assert_eq!(5u32.carrying_mul(2, 10), (20, 0)); /// assert_eq!(1_000_000_000u32.carrying_mul(10, 0), (1410065408, 2)); /// assert_eq!(1_000_000_000u32.carrying_mul(10, 10), (1410065418, 2)); + #[doc = concat!($AdaptiveTestPrefix, "assert_eq!(", + stringify!($SelfT), "::MAX.carrying_mul(", stringify!($SelfT), "::MAX, ", stringify!($SelfT), "::MAX), ", + "(0, ", stringify!($SelfT), "::MAX));" + )] + /// ``` + /// + /// If `carry` is zero, this is similar to [`overflowing_mul`](Self::overflowing_mul), + /// except that it gives the value of the overflow instead of just whether one happened: + /// + /// ``` + /// #![feature(bigint_helper_methods)] + /// let r = u8::carrying_mul(7, 13, 0); + /// assert_eq!((r.0, r.1 != 0), u8::overflowing_mul(7, 13)); + /// let r = u8::carrying_mul(13, 42, 0); + /// assert_eq!((r.0, r.1 != 0), u8::overflowing_mul(13, 42)); + /// ``` + /// + /// The value of the first field in the returned tuple matches what you'd get + /// by combining the [`wrapping_mul`](Self::wrapping_mul) and + /// [`wrapping_add`](Self::wrapping_add) methods: + /// + /// ``` + /// #![feature(bigint_helper_methods)] + /// assert_eq!( + /// 789_u16.carrying_mul(456, 123).0, + /// 789_u16.wrapping_mul(456).wrapping_add(123), + /// ); /// ``` #[unstable(feature = "bigint_helper_methods", issue = "85532")] #[rustc_const_unstable(feature = "bigint_helper_methods", issue = "85532")] @@ -168,21 +201,21 @@ macro_rules! widening_impl { #[lang = "i8"] impl i8 { - widening_impl! { i8, i16, 8 } + widening_impl! { i8, i16, 8, signed } int_impl! { i8, i8, u8, 8, 7, -128, 127, 2, "-0x7e", "0xa", "0x12", "0x12", "0x48", "[0x12]", "[0x12]", "", "" } } #[lang = "i16"] impl i16 { - widening_impl! { i16, i32, 16 } + widening_impl! { i16, i32, 16, signed } int_impl! { i16, i16, u16, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234", "0x3412", "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", "", "" } } #[lang = "i32"] impl i32 { - widening_impl! { i32, i64, 32 } + widening_impl! { i32, i64, 32, signed } int_impl! { i32, i32, u32, 32, 31, -2147483648, 2147483647, 8, "0x10000b3", "0xb301", "0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "", "" } @@ -190,7 +223,7 @@ impl i32 { #[lang = "i64"] impl i64 { - widening_impl! { i64, i128, 64 } + widening_impl! { i64, i128, 64, signed } int_impl! { i64, i64, u64, 64, 63, -9223372036854775808, 9223372036854775807, 12, "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]", @@ -212,7 +245,7 @@ impl i128 { #[cfg(target_pointer_width = "16")] #[lang = "isize"] impl isize { - widening_impl! { isize, i32, 16 } + widening_impl! { isize, i32, 16, signed } int_impl! { isize, i16, usize, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234", "0x3412", "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() } @@ -221,7 +254,7 @@ impl isize { #[cfg(target_pointer_width = "32")] #[lang = "isize"] impl isize { - widening_impl! { isize, i64, 32 } + widening_impl! { isize, i64, 32, signed } int_impl! { isize, i32, usize, 32, 31, -2147483648, 2147483647, 8, "0x10000b3", "0xb301", "0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", @@ -231,7 +264,7 @@ impl isize { #[cfg(target_pointer_width = "64")] #[lang = "isize"] impl isize { - widening_impl! { isize, i128, 64 } + widening_impl! { isize, i128, 64, signed } int_impl! { isize, i64, usize, 64, 63, -9223372036854775808, 9223372036854775807, 12, "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]", @@ -244,7 +277,7 @@ const ASCII_CASE_MASK: u8 = 0b0010_0000; #[lang = "u8"] impl u8 { - widening_impl! { u8, u16, 8 } + widening_impl! { u8, u16, 8, unsigned } uint_impl! { u8, u8, i8, 8, 255, 2, "0x82", "0xa", "0x12", "0x12", "0x48", "[0x12]", "[0x12]", "", "" } @@ -793,21 +826,21 @@ impl u8 { #[lang = "u16"] impl u16 { - widening_impl! { u16, u32, 16 } + widening_impl! { u16, u32, 16, unsigned } uint_impl! { u16, u16, i16, 16, 65535, 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", "", "" } } #[lang = "u32"] impl u32 { - widening_impl! { u32, u64, 32 } + widening_impl! { u32, u64, 32, unsigned } uint_impl! { u32, u32, i32, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "", "" } } #[lang = "u64"] impl u64 { - widening_impl! { u64, u128, 64 } + widening_impl! { u64, u128, 64, unsigned } uint_impl! { u64, u64, i64, 64, 18446744073709551615, 12, "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]", @@ -830,7 +863,7 @@ impl u128 { #[cfg(target_pointer_width = "16")] #[lang = "usize"] impl usize { - widening_impl! { usize, u32, 16 } + widening_impl! { usize, u32, 16, unsigned } uint_impl! { usize, u16, isize, 16, 65535, 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() } @@ -838,7 +871,7 @@ impl usize { #[cfg(target_pointer_width = "32")] #[lang = "usize"] impl usize { - widening_impl! { usize, u64, 32 } + widening_impl! { usize, u64, 32, unsigned } uint_impl! { usize, u32, isize, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() } @@ -847,7 +880,7 @@ impl usize { #[cfg(target_pointer_width = "64")] #[lang = "usize"] impl usize { - widening_impl! { usize, u128, 64 } + widening_impl! { usize, u128, 64, unsigned } uint_impl! { usize, u64, isize, 64, 18446744073709551615, 12, "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]", diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 691d0891b1448..a15eabf7966d8 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -1504,6 +1504,8 @@ macro_rules! uint_impl { /// additional bit of overflow. This allows for chaining together multiple additions /// to create "big integers" which represent larger values. /// + #[doc = concat!("This can be thought of as a ", stringify!($BITS), "-bit \"full adder\", in the electronics sense.")] + /// /// # Examples /// /// Basic usage @@ -1513,7 +1515,20 @@ macro_rules! uint_impl { #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".carrying_add(2, false), (7, false));")] #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".carrying_add(2, true), (8, false));")] #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(1, false), (0, true));")] + #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(0, true), (0, true));")] #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(1, true), (1, true));")] + #[doc = concat!("assert_eq!(", + stringify!($SelfT), "::MAX.carrying_add(", stringify!($SelfT), "::MAX, true), ", + "(", stringify!($SelfT), "::MAX, true));" + )] + /// ``` + /// + /// If `carry` is false, this method is equivalent to [`overflowing_add`](Self::overflowing_add): + /// + /// ``` + /// #![feature(bigint_helper_methods)] + #[doc = concat!("assert_eq!(5_", stringify!($SelfT), ".carrying_add(2, false), 5_", stringify!($SelfT), ".overflowing_add(2));")] + #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(1, false), ", stringify!($SelfT), "::MAX.overflowing_add(1));")] /// ``` #[unstable(feature = "bigint_helper_methods", issue = "85532")] #[rustc_const_unstable(feature = "const_bigint_helper_methods", issue = "85532")] From 056af9dbc80519f2e3100c78cfd7b1164379c1a1 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 4 Nov 2021 13:34:10 +0100 Subject: [PATCH 5/7] rustbot: Allow applying relnotes label Inspired by https://github.com/rust-lang/rust/pull/90521 , and by the various `must_use` PRs; in all of those cases, the submitter of the PR could know that `relnotes` applied, but couldn't apply it themselves. --- triagebot.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/triagebot.toml b/triagebot.toml index 48c7a00de7830..3f151ba169500 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -2,6 +2,7 @@ allow-unauthenticated = [ "C-*", "A-*", "E-*", "NLL-*", "O-*", "S-*", "T-*", "WG-*", "F-*", "D-*", + "relnotes", "requires-nightly", "regression-*", "perf-*", From 7e0293428fd9118a04e54beb8fc5f4bd24b5386b Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 4 Nov 2021 13:35:10 +0100 Subject: [PATCH 6/7] rustbot: Allow applying needs-fcp label People should be able to help triage by observing that a change needs an FCP before we can apply it. --- triagebot.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/triagebot.toml b/triagebot.toml index 3f151ba169500..7a9908fe8c075 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -2,6 +2,7 @@ allow-unauthenticated = [ "C-*", "A-*", "E-*", "NLL-*", "O-*", "S-*", "T-*", "WG-*", "F-*", "D-*", + "needs-fcp", "relnotes", "requires-nightly", "regression-*", From 773cc4f52b7f6bfa5b9ad0878583fb0ac9e9f2ea Mon Sep 17 00:00:00 2001 From: Smittyvb Date: Thu, 4 Nov 2021 11:31:03 -0400 Subject: [PATCH 7/7] Mention possible future rejections Co-authored-by: Josh Triplett --- src/doc/unstable-book/src/library-features/asm.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/unstable-book/src/library-features/asm.md b/src/doc/unstable-book/src/library-features/asm.md index 6e4164626103e..84fc6dcc33979 100644 --- a/src/doc/unstable-book/src/library-features/asm.md +++ b/src/doc/unstable-book/src/library-features/asm.md @@ -886,6 +886,6 @@ The compiler performs some additional checks on options: - The set of memory locations that you may access is the intersection of those allowed by the `asm!` blocks you entered and exited. - You cannot assume that an `asm!` block will appear exactly once in the output binary. The compiler is allowed to instantiate multiple copies of the `asm!` block, for example when the function containing it is inlined in multiple places. - On x86, inline assembly must not end with an instruction prefix (such as `LOCK`) that would apply to instructions generated by the compiler. - - The compiler is currently unable to detect this due to the way inline assembly is compiled. + - The compiler is currently unable to detect this due to the way inline assembly is compiled, but may catch and reject this in the future. > **Note**: As a general rule, the flags covered by `preserves_flags` are those which are *not* preserved when performing a function call.