From c30eac51c4406abe916479f49210beee9abd38b7 Mon Sep 17 00:00:00 2001 From: Camelid Date: Tue, 13 Apr 2021 19:18:23 -0700 Subject: [PATCH 001/441] Fix ICE during type layout when there's a `[type error]` Based on estebank's [comment], except I used `delay_span_bug` because it should work in more cases, and I think it expresses its intent more clearly. [comment]: https://github.com/rust-lang/rust/issues/84108#issuecomment-818916848 --- compiler/rustc_middle/src/ty/layout.rs | 9 +++++- src/test/ui/layout/issue-84108.rs | 14 ++++++++ src/test/ui/layout/issue-84108.stderr | 44 ++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/layout/issue-84108.rs create mode 100644 src/test/ui/layout/issue-84108.stderr diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index c2e9dba6c8e8..0fada3e6c847 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -367,7 +367,14 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { for &i in &inverse_memory_index { let field = fields[i as usize]; if !sized { - bug!("univariant: field #{} of `{}` comes after unsized field", offsets.len(), ty); + self.tcx.sess.delay_span_bug( + DUMMY_SP, + &format!( + "univariant: field #{} of `{}` comes after unsized field", + offsets.len(), + ty + ), + ); } if field.is_unsized() { diff --git a/src/test/ui/layout/issue-84108.rs b/src/test/ui/layout/issue-84108.rs new file mode 100644 index 000000000000..dd025c9b443f --- /dev/null +++ b/src/test/ui/layout/issue-84108.rs @@ -0,0 +1,14 @@ +// See issue #84108 -- this is a test to ensure we do not ICE +// on this invalid code. + +#![crate_type = "lib"] + +static FOO: (dyn AsRef, u8) = ("hello", 42); +//~^ ERROR cannot find type `OsStr` in this scope + +const BAR: (&Path, [u8], usize) = ("hello", [], 42); +//~^ ERROR cannot find type `Path` in this scope +//~| ERROR the size for values of type `[u8]` cannot be known at compilation time + +static BAZ: ([u8], usize) = ([], 0); +//~^ ERROR the size for values of type `[u8]` cannot be known at compilation time diff --git a/src/test/ui/layout/issue-84108.stderr b/src/test/ui/layout/issue-84108.stderr new file mode 100644 index 000000000000..36be64241100 --- /dev/null +++ b/src/test/ui/layout/issue-84108.stderr @@ -0,0 +1,44 @@ +error[E0412]: cannot find type `OsStr` in this scope + --> $DIR/issue-84108.rs:6:24 + | +LL | static FOO: (dyn AsRef, u8) = ("hello", 42); + | ^^^^^ not found in this scope + | +help: consider importing this struct + | +LL | use std::ffi::OsStr; + | + +error[E0412]: cannot find type `Path` in this scope + --> $DIR/issue-84108.rs:9:14 + | +LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42); + | ^^^^ not found in this scope + | +help: consider importing this struct + | +LL | use std::path::Path; + | + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/issue-84108.rs:9:12 + | +LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42); + | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: only the last element of a tuple may have a dynamically sized type + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/issue-84108.rs:13:13 + | +LL | static BAZ: ([u8], usize) = ([], 0); + | ^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` + = note: only the last element of a tuple may have a dynamically sized type + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0277, E0412. +For more information about an error, try `rustc --explain E0277`. From 347ed001e81607f609f7c47a6d7cd5f723c288a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=C3=A9nore=20Bouttefeux?= Date: Mon, 3 May 2021 14:55:22 +0200 Subject: [PATCH 002/441] proof of concept add test type on prints --- compiler/rustc_builtin_macros/src/test.rs | 4 ++ library/test/src/formatters/pretty.rs | 2 +- library/test/src/formatters/terse.rs | 2 +- library/test/src/tests.rs | 38 +++++++++++++++++++ library/test/src/types.rs | 24 ++++++++++++ src/librustdoc/doctest.rs | 4 +- src/test/rustdoc-ui/cfg-test.stdout | 4 +- .../doc-test-doctest-feature.stdout | 2 +- .../doc-test-rustdoc-feature.stdout | 2 +- src/test/rustdoc-ui/doctest-output.stdout | 6 +-- .../failed-doctest-compile-fail.stdout | 2 +- .../failed-doctest-missing-codes.stdout | 2 +- .../rustdoc-ui/failed-doctest-output.stdout | 4 +- .../failed-doctest-should-panic.stdout | 2 +- src/test/rustdoc-ui/issue-80992.stdout | 2 +- .../rustdoc-ui/issue-81662-shortness.stdout | 2 +- src/test/rustdoc-ui/no-run-flag.stdout | 14 +++---- .../rustdoc-ui/run-directory.correct.stdout | 2 +- .../rustdoc-ui/run-directory.incorrect.stdout | 2 +- src/test/rustdoc-ui/test-no_std.stdout | 2 +- src/test/rustdoc-ui/test-type.rs | 26 +++++++++++++ src/test/rustdoc-ui/test-type.stdout | 10 +++++ .../rustdoc-ui/unparseable-doc-test.stdout | 2 +- .../test-filter-multiple.run.stdout | 4 +- src/test/ui/test-attrs/test-type.rs | 28 ++++++++++++++ src/test/ui/test-attrs/test-type.run.stdout | 8 ++++ .../ui/test-panic-abort-nocapture.run.stdout | 8 ++-- src/test/ui/test-panic-abort.run.stdout | 10 ++--- src/test/ui/test-passed.run.stdout | 4 +- src/test/ui/test-thread-capture.run.stdout | 4 +- src/test/ui/test-thread-nocapture.run.stdout | 4 +- src/tools/compiletest/src/main.rs | 2 + 32 files changed, 187 insertions(+), 45 deletions(-) create mode 100644 src/test/rustdoc-ui/test-type.rs create mode 100644 src/test/rustdoc-ui/test-type.stdout create mode 100644 src/test/ui/test-attrs/test-type.rs create mode 100644 src/test/ui/test-attrs/test-type.run.stdout diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index e845f9ec55ad..99544ddb66e6 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -254,6 +254,10 @@ pub fn expand_test_or_bench( "allow_fail", cx.expr_bool(sp, should_fail(&cx.sess, &item)), ), + // compile_fail: true | false + field("compile_fail", cx.expr_bool(sp, false)), + // no_run: true | false + field("no_run", cx.expr_bool(sp, false)), // should_panic: ... field( "should_panic", diff --git a/library/test/src/formatters/pretty.rs b/library/test/src/formatters/pretty.rs index 5e41d6d96923..00d4b18b3023 100644 --- a/library/test/src/formatters/pretty.rs +++ b/library/test/src/formatters/pretty.rs @@ -169,7 +169,7 @@ impl PrettyFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); - self.write_plain(&format!("test {} ... ", name))?; + self.write_plain(&format!("test {} {} ... ", name, desc.test_mode_string()))?; Ok(()) } diff --git a/library/test/src/formatters/terse.rs b/library/test/src/formatters/terse.rs index 6f46f7255a47..a68ceb404f9f 100644 --- a/library/test/src/formatters/terse.rs +++ b/library/test/src/formatters/terse.rs @@ -158,7 +158,7 @@ impl TerseFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); - self.write_plain(&format!("test {} ... ", name))?; + self.write_plain(&format!("test {} {} ... ", name, desc.test_mode_string()))?; Ok(()) } diff --git a/library/test/src/tests.rs b/library/test/src/tests.rs index 6a3f31b74ea5..794f72770047 100644 --- a/library/test/src/tests.rs +++ b/library/test/src/tests.rs @@ -61,6 +61,8 @@ fn one_ignored_one_unignored_test() -> Vec { ignore: true, should_panic: ShouldPanic::No, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }, testfn: DynTestFn(Box::new(move || {})), @@ -71,6 +73,8 @@ fn one_ignored_one_unignored_test() -> Vec { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }, testfn: DynTestFn(Box::new(move || {})), @@ -89,6 +93,8 @@ pub fn do_not_run_ignored_tests() { ignore: true, should_panic: ShouldPanic::No, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }, testfn: DynTestFn(Box::new(f)), @@ -108,6 +114,8 @@ pub fn ignored_tests_result_in_ignored() { ignore: true, should_panic: ShouldPanic::No, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }, testfn: DynTestFn(Box::new(f)), @@ -131,6 +139,8 @@ fn test_should_panic() { ignore: false, should_panic: ShouldPanic::Yes, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }, testfn: DynTestFn(Box::new(f)), @@ -154,6 +164,8 @@ fn test_should_panic_good_message() { ignore: false, should_panic: ShouldPanic::YesWithMessage("error message"), allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }, testfn: DynTestFn(Box::new(f)), @@ -182,6 +194,8 @@ fn test_should_panic_bad_message() { ignore: false, should_panic: ShouldPanic::YesWithMessage(expected), allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }, testfn: DynTestFn(Box::new(f)), @@ -214,6 +228,8 @@ fn test_should_panic_non_string_message_type() { ignore: false, should_panic: ShouldPanic::YesWithMessage(expected), allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }, testfn: DynTestFn(Box::new(f)), @@ -238,6 +254,8 @@ fn test_should_panic_but_succeeds() { ignore: false, should_panic, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }, testfn: DynTestFn(Box::new(f)), @@ -270,6 +288,8 @@ fn report_time_test_template(report_time: bool) -> Option { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }, testfn: DynTestFn(Box::new(f)), @@ -303,6 +323,8 @@ fn time_test_failure_template(test_type: TestType) -> TestResult { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + compile_fail: false, + no_run: false, test_type, }, testfn: DynTestFn(Box::new(f)), @@ -340,6 +362,8 @@ fn typed_test_desc(test_type: TestType) -> TestDesc { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + compile_fail: false, + no_run: false, test_type, } } @@ -451,6 +475,8 @@ pub fn exclude_should_panic_option() { ignore: false, should_panic: ShouldPanic::Yes, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }, testfn: DynTestFn(Box::new(move || {})), @@ -473,6 +499,8 @@ pub fn exact_filter_match() { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }, testfn: DynTestFn(Box::new(move || {})), @@ -565,6 +593,8 @@ pub fn sort_tests() { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }, testfn: DynTestFn(Box::new(testfn)), @@ -642,6 +672,8 @@ pub fn test_bench_no_iter() { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }; @@ -662,6 +694,8 @@ pub fn test_bench_iter() { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }; @@ -676,6 +710,8 @@ fn should_sort_failures_before_printing_them() { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }; @@ -684,6 +720,8 @@ fn should_sort_failures_before_printing_them() { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + compile_fail: false, + no_run: false, test_type: TestType::Unknown, }; diff --git a/library/test/src/types.rs b/library/test/src/types.rs index c5d91f653b35..61c644f7972f 100644 --- a/library/test/src/types.rs +++ b/library/test/src/types.rs @@ -124,6 +124,8 @@ pub struct TestDesc { pub ignore: bool, pub should_panic: options::ShouldPanic, pub allow_fail: bool, + pub compile_fail: bool, + pub no_run: bool, pub test_type: TestType, } @@ -140,6 +142,28 @@ impl TestDesc { } } } + + pub fn test_mode_string(&self) -> String { + if self.ignore { + return "ignore".to_string(); + } + match self.should_panic { + options::ShouldPanic::Yes | options::ShouldPanic::YesWithMessage(_) => { + return "should panic".to_string(); + } + _ => {} + } + if self.allow_fail { + return "allow fail".to_string(); + } + if self.compile_fail { + return "compile fail".to_string(); + } + if self.no_run { + return "compile".to_string(); + } + "run".to_string() + } } #[derive(Debug)] diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index c0157121e192..8ef9170f9194 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -879,6 +879,7 @@ impl Tester for Collector { let target = self.options.target.clone(); let target_str = target.to_string(); let unused_externs = self.unused_extern_reports.clone(); + let no_run = config.no_run || options.no_run; if !config.compile_fail { self.compiling_test_count.fetch_add(1, Ordering::SeqCst); } @@ -934,13 +935,14 @@ impl Tester for Collector { // compiler failures are test failures should_panic: testing::ShouldPanic::No, allow_fail: config.allow_fail, + compile_fail: config.compile_fail, + no_run, test_type: testing::TestType::DocTest, }, testfn: testing::DynTestFn(box move || { let report_unused_externs = |uext| { unused_externs.lock().unwrap().push(uext); }; - let no_run = config.no_run || options.no_run; let res = run_test( &test, &cratename, diff --git a/src/test/rustdoc-ui/cfg-test.stdout b/src/test/rustdoc-ui/cfg-test.stdout index 2960ff8d3b47..fdd754609ef8 100644 --- a/src/test/rustdoc-ui/cfg-test.stdout +++ b/src/test/rustdoc-ui/cfg-test.stdout @@ -1,7 +1,7 @@ running 2 tests -test $DIR/cfg-test.rs - Bar (line 27) ... ok -test $DIR/cfg-test.rs - Foo (line 19) ... ok +test $DIR/cfg-test.rs - Bar (line 27) run ... ok +test $DIR/cfg-test.rs - Foo (line 19) run ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/doc-test-doctest-feature.stdout b/src/test/rustdoc-ui/doc-test-doctest-feature.stdout index d7de1f105228..ecf5dcd056a3 100644 --- a/src/test/rustdoc-ui/doc-test-doctest-feature.stdout +++ b/src/test/rustdoc-ui/doc-test-doctest-feature.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/doc-test-doctest-feature.rs - Foo (line 9) ... ok +test $DIR/doc-test-doctest-feature.rs - Foo (line 9) run ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout b/src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout index 5b07fc4c87af..7f900cb28580 100644 --- a/src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout +++ b/src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/doc-test-rustdoc-feature.rs - Foo (line 10) ... ok +test $DIR/doc-test-rustdoc-feature.rs - Foo (line 10) run ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/doctest-output.stdout b/src/test/rustdoc-ui/doctest-output.stdout index 35b0e366fb5c..1b5857d251b4 100644 --- a/src/test/rustdoc-ui/doctest-output.stdout +++ b/src/test/rustdoc-ui/doctest-output.stdout @@ -1,8 +1,8 @@ running 3 tests -test $DIR/doctest-output.rs - (line 8) ... ok -test $DIR/doctest-output.rs - ExpandedStruct (line 24) ... ok -test $DIR/doctest-output.rs - foo::bar (line 18) ... ok +test $DIR/doctest-output.rs - (line 8) run ... ok +test $DIR/doctest-output.rs - ExpandedStruct (line 24) run ... ok +test $DIR/doctest-output.rs - foo::bar (line 18) run ... ok test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/failed-doctest-compile-fail.stdout b/src/test/rustdoc-ui/failed-doctest-compile-fail.stdout index b8bb5ccb4032..dc811df609cc 100644 --- a/src/test/rustdoc-ui/failed-doctest-compile-fail.stdout +++ b/src/test/rustdoc-ui/failed-doctest-compile-fail.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/failed-doctest-compile-fail.rs - Foo (line 9) ... FAILED +test $DIR/failed-doctest-compile-fail.rs - Foo (line 9) compile fail ... FAILED failures: diff --git a/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout b/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout index 7367a7d65191..a76511eb29e7 100644 --- a/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout +++ b/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/failed-doctest-missing-codes.rs - Foo (line 9) ... FAILED +test $DIR/failed-doctest-missing-codes.rs - Foo (line 9) compile fail ... FAILED failures: diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index 6dfe648f8549..83c8c5301e00 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -1,7 +1,7 @@ running 2 tests -test $DIR/failed-doctest-output.rs - OtherStruct (line 22) ... FAILED -test $DIR/failed-doctest-output.rs - SomeStruct (line 12) ... FAILED +test $DIR/failed-doctest-output.rs - OtherStruct (line 22) run ... FAILED +test $DIR/failed-doctest-output.rs - SomeStruct (line 12) run ... FAILED failures: diff --git a/src/test/rustdoc-ui/failed-doctest-should-panic.stdout b/src/test/rustdoc-ui/failed-doctest-should-panic.stdout index 57a20092a5d6..e3d0216441b8 100644 --- a/src/test/rustdoc-ui/failed-doctest-should-panic.stdout +++ b/src/test/rustdoc-ui/failed-doctest-should-panic.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/failed-doctest-should-panic.rs - Foo (line 9) ... FAILED +test $DIR/failed-doctest-should-panic.rs - Foo (line 9) run ... FAILED failures: diff --git a/src/test/rustdoc-ui/issue-80992.stdout b/src/test/rustdoc-ui/issue-80992.stdout index 1dd19f468274..e7110dee4fb0 100644 --- a/src/test/rustdoc-ui/issue-80992.stdout +++ b/src/test/rustdoc-ui/issue-80992.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/issue-80992.rs - test (line 7) ... ok +test $DIR/issue-80992.rs - test (line 7) compile fail ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/issue-81662-shortness.stdout b/src/test/rustdoc-ui/issue-81662-shortness.stdout index 748113be3a26..3c2901e70f0e 100644 --- a/src/test/rustdoc-ui/issue-81662-shortness.stdout +++ b/src/test/rustdoc-ui/issue-81662-shortness.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/issue-81662-shortness.rs - foo (line 6) ... FAILED +test $DIR/issue-81662-shortness.rs - foo (line 6) run ... FAILED failures: diff --git a/src/test/rustdoc-ui/no-run-flag.stdout b/src/test/rustdoc-ui/no-run-flag.stdout index d92f5da83356..418691e4f0cb 100644 --- a/src/test/rustdoc-ui/no-run-flag.stdout +++ b/src/test/rustdoc-ui/no-run-flag.stdout @@ -1,12 +1,12 @@ running 7 tests -test $DIR/no-run-flag.rs - f (line 11) ... ok -test $DIR/no-run-flag.rs - f (line 14) ... ignored -test $DIR/no-run-flag.rs - f (line 17) ... ok -test $DIR/no-run-flag.rs - f (line 23) ... ok -test $DIR/no-run-flag.rs - f (line 28) ... ok -test $DIR/no-run-flag.rs - f (line 32) ... ok -test $DIR/no-run-flag.rs - f (line 8) ... ok +test $DIR/no-run-flag.rs - f (line 11) compile ... ok +test $DIR/no-run-flag.rs - f (line 14) ignore ... ignored +test $DIR/no-run-flag.rs - f (line 17) compile ... ok +test $DIR/no-run-flag.rs - f (line 23) compile fail ... ok +test $DIR/no-run-flag.rs - f (line 28) compile ... ok +test $DIR/no-run-flag.rs - f (line 32) compile ... ok +test $DIR/no-run-flag.rs - f (line 8) compile ... ok test result: ok. 6 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/run-directory.correct.stdout b/src/test/rustdoc-ui/run-directory.correct.stdout index e9b2754794a7..a5bc41ece991 100644 --- a/src/test/rustdoc-ui/run-directory.correct.stdout +++ b/src/test/rustdoc-ui/run-directory.correct.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/run-directory.rs - foo (line 10) ... ok +test $DIR/run-directory.rs - foo (line 10) run ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/run-directory.incorrect.stdout b/src/test/rustdoc-ui/run-directory.incorrect.stdout index 97a5dbc5c0cd..542043bc4375 100644 --- a/src/test/rustdoc-ui/run-directory.incorrect.stdout +++ b/src/test/rustdoc-ui/run-directory.incorrect.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/run-directory.rs - foo (line 19) ... ok +test $DIR/run-directory.rs - foo (line 19) run ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/test-no_std.stdout b/src/test/rustdoc-ui/test-no_std.stdout index 8d5a30804c1e..82dbffcbd55d 100644 --- a/src/test/rustdoc-ui/test-no_std.stdout +++ b/src/test/rustdoc-ui/test-no_std.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/test-no_std.rs - f (line 10) ... ok +test $DIR/test-no_std.rs - f (line 10) run ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/test-type.rs b/src/test/rustdoc-ui/test-type.rs new file mode 100644 index 000000000000..882da5c2503f --- /dev/null +++ b/src/test/rustdoc-ui/test-type.rs @@ -0,0 +1,26 @@ +// compile-flags: --test --test-args=--test-threads=1 +// check-pass +// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" +// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" + +/// ``` +/// let a = true; +/// ``` +/// ```should_panic +/// panic!() +/// ``` +/// ```ignore (incomplete-code) +/// fn foo() { +/// ``` +/// ```no_run +/// loop { +/// println!("Hello, world"); +/// } +/// ``` +/// fails to compile +/// ```compile_fail +/// let x = 5; +/// x += 2; // shouldn't compile! +/// ``` + +pub fn f() {} diff --git a/src/test/rustdoc-ui/test-type.stdout b/src/test/rustdoc-ui/test-type.stdout new file mode 100644 index 000000000000..8f36d643b2f9 --- /dev/null +++ b/src/test/rustdoc-ui/test-type.stdout @@ -0,0 +1,10 @@ + +running 5 tests +test $DIR/test-type.rs - f (line 12) ignore ... ignored +test $DIR/test-type.rs - f (line 15) compile ... ok +test $DIR/test-type.rs - f (line 21) compile fail ... ok +test $DIR/test-type.rs - f (line 6) run ... ok +test $DIR/test-type.rs - f (line 9) run ... ok + +test result: ok. 4 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME + diff --git a/src/test/rustdoc-ui/unparseable-doc-test.stdout b/src/test/rustdoc-ui/unparseable-doc-test.stdout index 2641c66f25e7..dbbb6541b971 100644 --- a/src/test/rustdoc-ui/unparseable-doc-test.stdout +++ b/src/test/rustdoc-ui/unparseable-doc-test.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/unparseable-doc-test.rs - foo (line 7) ... FAILED +test $DIR/unparseable-doc-test.rs - foo (line 7) run ... FAILED failures: diff --git a/src/test/ui/test-attrs/test-filter-multiple.run.stdout b/src/test/ui/test-attrs/test-filter-multiple.run.stdout index 1aa684ed5073..6389d7f998ff 100644 --- a/src/test/ui/test-attrs/test-filter-multiple.run.stdout +++ b/src/test/ui/test-attrs/test-filter-multiple.run.stdout @@ -1,7 +1,7 @@ running 2 tests -test test1 ... ok -test test2 ... ok +test test1 run ... ok +test test2 run ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in $TIME diff --git a/src/test/ui/test-attrs/test-type.rs b/src/test/ui/test-attrs/test-type.rs new file mode 100644 index 000000000000..3f0fa81373f1 --- /dev/null +++ b/src/test/ui/test-attrs/test-type.rs @@ -0,0 +1,28 @@ +// compile-flags: --test +// run-flags: --test-threads=1 +// check-run-results +// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" +// ignore-emscripten no threads support +// run-pass + + +#[test] +fn test_ok() { + let _a = true; +} + +#[test] +#[should_panic] +fn test_panic() { + panic!(); +} + +#[test] +#[ignore] +fn test_no_run() { + loop{ + println!("Hello, world"); + } +} + +fn main() {} diff --git a/src/test/ui/test-attrs/test-type.run.stdout b/src/test/ui/test-attrs/test-type.run.stdout new file mode 100644 index 000000000000..5f10c784f891 --- /dev/null +++ b/src/test/ui/test-attrs/test-type.run.stdout @@ -0,0 +1,8 @@ + +running 3 tests +test test_no_run ignore ... ignored +test test_ok run ... ok +test test_panic should panic ... ok + +test result: ok. 2 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME + diff --git a/src/test/ui/test-panic-abort-nocapture.run.stdout b/src/test/ui/test-panic-abort-nocapture.run.stdout index 15b19676a7c2..29d5172ce8c8 100644 --- a/src/test/ui/test-panic-abort-nocapture.run.stdout +++ b/src/test/ui/test-panic-abort-nocapture.run.stdout @@ -1,12 +1,12 @@ running 4 tests -test it_fails ... about to fail +test it_fails run ... about to fail FAILED -test it_panics ... about to panic +test it_panics should panic ... about to panic ok -test it_works ... about to succeed +test it_works run ... about to succeed ok -test it_writes_to_stdio ... hello, world +test it_writes_to_stdio run ... hello, world testing123 ok diff --git a/src/test/ui/test-panic-abort.run.stdout b/src/test/ui/test-panic-abort.run.stdout index 467f834afecb..2842f08f6cc0 100644 --- a/src/test/ui/test-panic-abort.run.stdout +++ b/src/test/ui/test-panic-abort.run.stdout @@ -1,10 +1,10 @@ running 5 tests -test it_exits ... FAILED -test it_fails ... FAILED -test it_panics ... ok -test it_works ... ok -test no_residual_environment ... ok +test it_exits run ... FAILED +test it_fails run ... FAILED +test it_panics should panic ... ok +test it_works run ... ok +test no_residual_environment run ... ok failures: diff --git a/src/test/ui/test-passed.run.stdout b/src/test/ui/test-passed.run.stdout index 17f70d607494..cd4b0e466a3f 100644 --- a/src/test/ui/test-passed.run.stdout +++ b/src/test/ui/test-passed.run.stdout @@ -1,7 +1,7 @@ running 2 tests -test it_works ... ok -test it_works_too ... ok +test it_works run ... ok +test it_works_too run ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/ui/test-thread-capture.run.stdout b/src/test/ui/test-thread-capture.run.stdout index 487cfb55eb47..db9d90f20f2d 100644 --- a/src/test/ui/test-thread-capture.run.stdout +++ b/src/test/ui/test-thread-capture.run.stdout @@ -1,7 +1,7 @@ running 2 tests -test thready_fail ... FAILED -test thready_pass ... ok +test thready_fail run ... FAILED +test thready_pass run ... ok failures: diff --git a/src/test/ui/test-thread-nocapture.run.stdout b/src/test/ui/test-thread-nocapture.run.stdout index 9d2da50826c2..42e6d40a4d11 100644 --- a/src/test/ui/test-thread-nocapture.run.stdout +++ b/src/test/ui/test-thread-nocapture.run.stdout @@ -1,11 +1,11 @@ running 2 tests -test thready_fail ... fee +test thready_fail run ... fee fie foe fum FAILED -test thready_pass ... fee +test thready_pass run ... fee fie foe fum diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index d1798a52df7c..f3751ff244fd 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -649,6 +649,8 @@ fn make_test(config: &Config, testpaths: &TestPaths, inputs: &Stamp) -> Vec Date: Mon, 3 May 2021 20:16:44 +0200 Subject: [PATCH 003/441] change based on review --- library/test/src/formatters/pretty.rs | 2 +- library/test/src/formatters/terse.rs | 2 +- library/test/src/types.rs | 16 ++++++++-------- src/test/rustdoc-ui/cfg-test.stdout | 4 ++-- .../rustdoc-ui/doc-test-doctest-feature.stdout | 2 +- .../rustdoc-ui/doc-test-rustdoc-feature.stdout | 2 +- src/test/rustdoc-ui/doctest-output.stdout | 6 +++--- .../failed-doctest-compile-fail.stdout | 2 +- .../failed-doctest-missing-codes.stdout | 2 +- src/test/rustdoc-ui/failed-doctest-output.stdout | 4 ++-- .../failed-doctest-should-panic.stdout | 2 +- src/test/rustdoc-ui/issue-80992.stdout | 2 +- src/test/rustdoc-ui/issue-81662-shortness.stdout | 2 +- src/test/rustdoc-ui/no-run-flag.stdout | 14 +++++++------- src/test/rustdoc-ui/run-directory.correct.stdout | 2 +- .../rustdoc-ui/run-directory.incorrect.stdout | 2 +- src/test/rustdoc-ui/test-no_std.stdout | 2 +- src/test/rustdoc-ui/test-type.stdout | 10 +++++----- src/test/rustdoc-ui/unparseable-doc-test.stdout | 2 +- .../test-attrs/test-filter-multiple.run.stdout | 4 ++-- src/test/ui/test-attrs/test-type.run.stdout | 6 +++--- .../ui/test-panic-abort-nocapture.run.stdout | 8 ++++---- src/test/ui/test-panic-abort.run.stdout | 10 +++++----- src/test/ui/test-passed.run.stdout | 4 ++-- src/test/ui/test-thread-capture.run.stdout | 4 ++-- src/test/ui/test-thread-nocapture.run.stdout | 4 ++-- 26 files changed, 60 insertions(+), 60 deletions(-) diff --git a/library/test/src/formatters/pretty.rs b/library/test/src/formatters/pretty.rs index 00d4b18b3023..543b9a6924ac 100644 --- a/library/test/src/formatters/pretty.rs +++ b/library/test/src/formatters/pretty.rs @@ -169,7 +169,7 @@ impl PrettyFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); - self.write_plain(&format!("test {} {} ... ", name, desc.test_mode_string()))?; + self.write_plain(&format!("test {} - {} ... ", name, desc.test_mode_string()))?; Ok(()) } diff --git a/library/test/src/formatters/terse.rs b/library/test/src/formatters/terse.rs index a68ceb404f9f..286b50b525d4 100644 --- a/library/test/src/formatters/terse.rs +++ b/library/test/src/formatters/terse.rs @@ -158,7 +158,7 @@ impl TerseFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); - self.write_plain(&format!("test {} {} ... ", name, desc.test_mode_string()))?; + self.write_plain(&format!("test {} - {} ... ", name, desc.test_mode_string()))?; Ok(()) } diff --git a/library/test/src/types.rs b/library/test/src/types.rs index 61c644f7972f..a2c3d5fa8eeb 100644 --- a/library/test/src/types.rs +++ b/library/test/src/types.rs @@ -143,26 +143,26 @@ impl TestDesc { } } - pub fn test_mode_string(&self) -> String { + pub fn test_mode_string(&self) -> &'static str { if self.ignore { - return "ignore".to_string(); + return &"ignore"; } match self.should_panic { options::ShouldPanic::Yes | options::ShouldPanic::YesWithMessage(_) => { - return "should panic".to_string(); + return &"should panic"; } - _ => {} + options::ShouldPanic::No => {} } if self.allow_fail { - return "allow fail".to_string(); + return &"allow fail"; } if self.compile_fail { - return "compile fail".to_string(); + return &"compile fail"; } if self.no_run { - return "compile".to_string(); + return &"compile"; } - "run".to_string() + &"run" } } diff --git a/src/test/rustdoc-ui/cfg-test.stdout b/src/test/rustdoc-ui/cfg-test.stdout index fdd754609ef8..42d3fbb48dd8 100644 --- a/src/test/rustdoc-ui/cfg-test.stdout +++ b/src/test/rustdoc-ui/cfg-test.stdout @@ -1,7 +1,7 @@ running 2 tests -test $DIR/cfg-test.rs - Bar (line 27) run ... ok -test $DIR/cfg-test.rs - Foo (line 19) run ... ok +test $DIR/cfg-test.rs - Bar (line 27) - run ... ok +test $DIR/cfg-test.rs - Foo (line 19) - run ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/doc-test-doctest-feature.stdout b/src/test/rustdoc-ui/doc-test-doctest-feature.stdout index ecf5dcd056a3..cfcb60332f46 100644 --- a/src/test/rustdoc-ui/doc-test-doctest-feature.stdout +++ b/src/test/rustdoc-ui/doc-test-doctest-feature.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/doc-test-doctest-feature.rs - Foo (line 9) run ... ok +test $DIR/doc-test-doctest-feature.rs - Foo (line 9) - run ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout b/src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout index 7f900cb28580..8d7f1ad21d1d 100644 --- a/src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout +++ b/src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/doc-test-rustdoc-feature.rs - Foo (line 10) run ... ok +test $DIR/doc-test-rustdoc-feature.rs - Foo (line 10) - run ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/doctest-output.stdout b/src/test/rustdoc-ui/doctest-output.stdout index 1b5857d251b4..7a07d273e269 100644 --- a/src/test/rustdoc-ui/doctest-output.stdout +++ b/src/test/rustdoc-ui/doctest-output.stdout @@ -1,8 +1,8 @@ running 3 tests -test $DIR/doctest-output.rs - (line 8) run ... ok -test $DIR/doctest-output.rs - ExpandedStruct (line 24) run ... ok -test $DIR/doctest-output.rs - foo::bar (line 18) run ... ok +test $DIR/doctest-output.rs - (line 8) - run ... ok +test $DIR/doctest-output.rs - ExpandedStruct (line 24) - run ... ok +test $DIR/doctest-output.rs - foo::bar (line 18) - run ... ok test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/failed-doctest-compile-fail.stdout b/src/test/rustdoc-ui/failed-doctest-compile-fail.stdout index dc811df609cc..af3a90a74100 100644 --- a/src/test/rustdoc-ui/failed-doctest-compile-fail.stdout +++ b/src/test/rustdoc-ui/failed-doctest-compile-fail.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/failed-doctest-compile-fail.rs - Foo (line 9) compile fail ... FAILED +test $DIR/failed-doctest-compile-fail.rs - Foo (line 9) - compile fail ... FAILED failures: diff --git a/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout b/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout index a76511eb29e7..bacbb47b5f9f 100644 --- a/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout +++ b/src/test/rustdoc-ui/failed-doctest-missing-codes.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/failed-doctest-missing-codes.rs - Foo (line 9) compile fail ... FAILED +test $DIR/failed-doctest-missing-codes.rs - Foo (line 9) - compile fail ... FAILED failures: diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index 83c8c5301e00..7ba599ff11b9 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -1,7 +1,7 @@ running 2 tests -test $DIR/failed-doctest-output.rs - OtherStruct (line 22) run ... FAILED -test $DIR/failed-doctest-output.rs - SomeStruct (line 12) run ... FAILED +test $DIR/failed-doctest-output.rs - OtherStruct (line 22) - run ... FAILED +test $DIR/failed-doctest-output.rs - SomeStruct (line 12) - run ... FAILED failures: diff --git a/src/test/rustdoc-ui/failed-doctest-should-panic.stdout b/src/test/rustdoc-ui/failed-doctest-should-panic.stdout index e3d0216441b8..6bd21423e69e 100644 --- a/src/test/rustdoc-ui/failed-doctest-should-panic.stdout +++ b/src/test/rustdoc-ui/failed-doctest-should-panic.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/failed-doctest-should-panic.rs - Foo (line 9) run ... FAILED +test $DIR/failed-doctest-should-panic.rs - Foo (line 9) - run ... FAILED failures: diff --git a/src/test/rustdoc-ui/issue-80992.stdout b/src/test/rustdoc-ui/issue-80992.stdout index e7110dee4fb0..d2b1cd1d550c 100644 --- a/src/test/rustdoc-ui/issue-80992.stdout +++ b/src/test/rustdoc-ui/issue-80992.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/issue-80992.rs - test (line 7) compile fail ... ok +test $DIR/issue-80992.rs - test (line 7) - compile fail ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/issue-81662-shortness.stdout b/src/test/rustdoc-ui/issue-81662-shortness.stdout index 3c2901e70f0e..f9fdf7048d88 100644 --- a/src/test/rustdoc-ui/issue-81662-shortness.stdout +++ b/src/test/rustdoc-ui/issue-81662-shortness.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/issue-81662-shortness.rs - foo (line 6) run ... FAILED +test $DIR/issue-81662-shortness.rs - foo (line 6) - run ... FAILED failures: diff --git a/src/test/rustdoc-ui/no-run-flag.stdout b/src/test/rustdoc-ui/no-run-flag.stdout index 418691e4f0cb..22d927317b31 100644 --- a/src/test/rustdoc-ui/no-run-flag.stdout +++ b/src/test/rustdoc-ui/no-run-flag.stdout @@ -1,12 +1,12 @@ running 7 tests -test $DIR/no-run-flag.rs - f (line 11) compile ... ok -test $DIR/no-run-flag.rs - f (line 14) ignore ... ignored -test $DIR/no-run-flag.rs - f (line 17) compile ... ok -test $DIR/no-run-flag.rs - f (line 23) compile fail ... ok -test $DIR/no-run-flag.rs - f (line 28) compile ... ok -test $DIR/no-run-flag.rs - f (line 32) compile ... ok -test $DIR/no-run-flag.rs - f (line 8) compile ... ok +test $DIR/no-run-flag.rs - f (line 11) - compile ... ok +test $DIR/no-run-flag.rs - f (line 14) - ignore ... ignored +test $DIR/no-run-flag.rs - f (line 17) - compile ... ok +test $DIR/no-run-flag.rs - f (line 23) - compile fail ... ok +test $DIR/no-run-flag.rs - f (line 28) - compile ... ok +test $DIR/no-run-flag.rs - f (line 32) - compile ... ok +test $DIR/no-run-flag.rs - f (line 8) - compile ... ok test result: ok. 6 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/run-directory.correct.stdout b/src/test/rustdoc-ui/run-directory.correct.stdout index a5bc41ece991..1bb84a868a41 100644 --- a/src/test/rustdoc-ui/run-directory.correct.stdout +++ b/src/test/rustdoc-ui/run-directory.correct.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/run-directory.rs - foo (line 10) run ... ok +test $DIR/run-directory.rs - foo (line 10) - run ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/run-directory.incorrect.stdout b/src/test/rustdoc-ui/run-directory.incorrect.stdout index 542043bc4375..7f6bba8fe471 100644 --- a/src/test/rustdoc-ui/run-directory.incorrect.stdout +++ b/src/test/rustdoc-ui/run-directory.incorrect.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/run-directory.rs - foo (line 19) run ... ok +test $DIR/run-directory.rs - foo (line 19) - run ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/test-no_std.stdout b/src/test/rustdoc-ui/test-no_std.stdout index 82dbffcbd55d..35d44fa6bbd0 100644 --- a/src/test/rustdoc-ui/test-no_std.stdout +++ b/src/test/rustdoc-ui/test-no_std.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/test-no_std.rs - f (line 10) run ... ok +test $DIR/test-no_std.rs - f (line 10) - run ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/test-type.stdout b/src/test/rustdoc-ui/test-type.stdout index 8f36d643b2f9..fb6c036a6081 100644 --- a/src/test/rustdoc-ui/test-type.stdout +++ b/src/test/rustdoc-ui/test-type.stdout @@ -1,10 +1,10 @@ running 5 tests -test $DIR/test-type.rs - f (line 12) ignore ... ignored -test $DIR/test-type.rs - f (line 15) compile ... ok -test $DIR/test-type.rs - f (line 21) compile fail ... ok -test $DIR/test-type.rs - f (line 6) run ... ok -test $DIR/test-type.rs - f (line 9) run ... ok +test $DIR/test-type.rs - f (line 12) - ignore ... ignored +test $DIR/test-type.rs - f (line 15) - compile ... ok +test $DIR/test-type.rs - f (line 21) - compile fail ... ok +test $DIR/test-type.rs - f (line 6) - run ... ok +test $DIR/test-type.rs - f (line 9) - run ... ok test result: ok. 4 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/unparseable-doc-test.stdout b/src/test/rustdoc-ui/unparseable-doc-test.stdout index dbbb6541b971..13526acfc479 100644 --- a/src/test/rustdoc-ui/unparseable-doc-test.stdout +++ b/src/test/rustdoc-ui/unparseable-doc-test.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/unparseable-doc-test.rs - foo (line 7) run ... FAILED +test $DIR/unparseable-doc-test.rs - foo (line 7) - run ... FAILED failures: diff --git a/src/test/ui/test-attrs/test-filter-multiple.run.stdout b/src/test/ui/test-attrs/test-filter-multiple.run.stdout index 6389d7f998ff..5d6d5cbd3c3f 100644 --- a/src/test/ui/test-attrs/test-filter-multiple.run.stdout +++ b/src/test/ui/test-attrs/test-filter-multiple.run.stdout @@ -1,7 +1,7 @@ running 2 tests -test test1 run ... ok -test test2 run ... ok +test test1 - run ... ok +test test2 - run ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in $TIME diff --git a/src/test/ui/test-attrs/test-type.run.stdout b/src/test/ui/test-attrs/test-type.run.stdout index 5f10c784f891..9f789526615d 100644 --- a/src/test/ui/test-attrs/test-type.run.stdout +++ b/src/test/ui/test-attrs/test-type.run.stdout @@ -1,8 +1,8 @@ running 3 tests -test test_no_run ignore ... ignored -test test_ok run ... ok -test test_panic should panic ... ok +test test_no_run - ignore ... ignored +test test_ok - run ... ok +test test_panic - should panic ... ok test result: ok. 2 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/ui/test-panic-abort-nocapture.run.stdout b/src/test/ui/test-panic-abort-nocapture.run.stdout index 29d5172ce8c8..e335cf05153b 100644 --- a/src/test/ui/test-panic-abort-nocapture.run.stdout +++ b/src/test/ui/test-panic-abort-nocapture.run.stdout @@ -1,12 +1,12 @@ running 4 tests -test it_fails run ... about to fail +test it_fails - run ... about to fail FAILED -test it_panics should panic ... about to panic +test it_panics - should panic ... about to panic ok -test it_works run ... about to succeed +test it_works - run ... about to succeed ok -test it_writes_to_stdio run ... hello, world +test it_writes_to_stdio - run ... hello, world testing123 ok diff --git a/src/test/ui/test-panic-abort.run.stdout b/src/test/ui/test-panic-abort.run.stdout index 2842f08f6cc0..0d9de10c9818 100644 --- a/src/test/ui/test-panic-abort.run.stdout +++ b/src/test/ui/test-panic-abort.run.stdout @@ -1,10 +1,10 @@ running 5 tests -test it_exits run ... FAILED -test it_fails run ... FAILED -test it_panics should panic ... ok -test it_works run ... ok -test no_residual_environment run ... ok +test it_exits - run ... FAILED +test it_fails - run ... FAILED +test it_panics - should panic ... ok +test it_works - run ... ok +test no_residual_environment - run ... ok failures: diff --git a/src/test/ui/test-passed.run.stdout b/src/test/ui/test-passed.run.stdout index cd4b0e466a3f..995643a62c88 100644 --- a/src/test/ui/test-passed.run.stdout +++ b/src/test/ui/test-passed.run.stdout @@ -1,7 +1,7 @@ running 2 tests -test it_works run ... ok -test it_works_too run ... ok +test it_works - run ... ok +test it_works_too - run ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/ui/test-thread-capture.run.stdout b/src/test/ui/test-thread-capture.run.stdout index db9d90f20f2d..ce9ec63b526c 100644 --- a/src/test/ui/test-thread-capture.run.stdout +++ b/src/test/ui/test-thread-capture.run.stdout @@ -1,7 +1,7 @@ running 2 tests -test thready_fail run ... FAILED -test thready_pass run ... ok +test thready_fail - run ... FAILED +test thready_pass - run ... ok failures: diff --git a/src/test/ui/test-thread-nocapture.run.stdout b/src/test/ui/test-thread-nocapture.run.stdout index 42e6d40a4d11..bd1971ab7d31 100644 --- a/src/test/ui/test-thread-nocapture.run.stdout +++ b/src/test/ui/test-thread-nocapture.run.stdout @@ -1,11 +1,11 @@ running 2 tests -test thready_fail run ... fee +test thready_fail - run ... fee fie foe fum FAILED -test thready_pass run ... fee +test thready_pass - run ... fee fie foe fum From 4029a03b345ae9fcc8e981ac181f00332b7711ed Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 3 May 2021 14:57:51 -0400 Subject: [PATCH 004/441] Make match in `register_res` easier to read - Don't duplicate DefKind -> ItemType handling; that's a good way to get bugs - Use exhaustive match - Add comments This found that register_res is very wrong in at least one way: if it registers a Res for `Variant`, it should also register one for `Field`. But I don't know whether the one for Variant should be removed or Field added. Maybe someone has ideas? --- src/librustdoc/clean/utils.rs | 53 ++++++++++++++++++----------- src/test/rustdoc/intra-doc/field.rs | 4 +++ 2 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 src/test/rustdoc/intra-doc/field.rs diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 7df8b442e5ac..c751356879a7 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -2,7 +2,7 @@ use crate::clean::auto_trait::AutoTraitFinder; use crate::clean::blanket_impl::BlanketImplFinder; use crate::clean::{ inline, Clean, Crate, Generic, GenericArg, GenericArgs, ImportSource, Item, ItemKind, Lifetime, - MacroKind, Path, PathSegment, Primitive, PrimitiveType, ResolvedPath, Type, TypeBinding, + Path, PathSegment, Primitive, PrimitiveType, ResolvedPath, Type, TypeBinding, }; use crate::core::DocContext; use crate::formats::item_type::ItemType; @@ -431,35 +431,48 @@ crate fn get_auto_trait_and_blanket_impls( auto_impls.into_iter().chain(blanket_impls) } +/// If `res` has a documentation page associated, store it in the cache. +/// +/// This is later used by [`href()`] to determine the HTML link for the item. +/// +/// [`href()`]: crate::html::format::href crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId { + use DefKind::*; debug!("register_res({:?})", res); let (did, kind) = match res { - Res::Def(DefKind::Fn, i) => (i, ItemType::Function), - Res::Def(DefKind::TyAlias, i) => (i, ItemType::Typedef), - Res::Def(DefKind::Enum, i) => (i, ItemType::Enum), - Res::Def(DefKind::Trait, i) => (i, ItemType::Trait), Res::Def(DefKind::AssocTy | DefKind::AssocFn | DefKind::AssocConst, i) => { + // associated items are documented, but on the page of their parent (cx.tcx.parent(i).unwrap(), ItemType::Trait) } - Res::Def(DefKind::Struct, i) => (i, ItemType::Struct), - Res::Def(DefKind::Union, i) => (i, ItemType::Union), - Res::Def(DefKind::Mod, i) => (i, ItemType::Module), - Res::Def(DefKind::ForeignTy, i) => (i, ItemType::ForeignType), - Res::Def(DefKind::Const, i) => (i, ItemType::Constant), - Res::Def(DefKind::Static, i) => (i, ItemType::Static), Res::Def(DefKind::Variant, i) => { + // variant items are documented, but on the page of their parent (cx.tcx.parent(i).expect("cannot get parent def id"), ItemType::Enum) } - Res::Def(DefKind::Macro(mac_kind), i) => match mac_kind { - MacroKind::Bang => (i, ItemType::Macro), - MacroKind::Attr => (i, ItemType::ProcAttribute), - MacroKind::Derive => (i, ItemType::ProcDerive), - }, - Res::Def(DefKind::TraitAlias, i) => (i, ItemType::TraitAlias), - Res::SelfTy(Some(def_id), _) => (def_id, ItemType::Trait), - Res::SelfTy(_, Some((impl_def_id, _))) => return impl_def_id, - _ => return res.def_id(), + // Each of these have their own page. + Res::Def( + kind + @ + (Fn | TyAlias | Enum | Trait | Struct | Union | Mod | ForeignTy | Const | Static + | Macro(..) | TraitAlias), + i, + ) => (i, kind.into()), + // This is part of a trait definition; document the trait. + Res::SelfTy(Some(trait_def_id), _) => (trait_def_id, ItemType::Trait), + // This is an inherent impl; it doesn't have its own page. + Res::SelfTy(None, Some((impl_def_id, _))) => return impl_def_id, + Res::SelfTy(None, None) + | Res::PrimTy(_) + | Res::ToolMod + | Res::SelfCtor(_) + | Res::Local(_) + | Res::NonMacroAttr(_) + | Res::Err => return res.def_id(), + Res::Def( + TyParam | ConstParam | Ctor(..) | ExternCrate | Use | ForeignMod | AnonConst | OpaqueTy + | Field | LifetimeParam | GlobalAsm | Impl | Closure | Generator, + id, + ) => return id, }; if did.is_local() { return did; diff --git a/src/test/rustdoc/intra-doc/field.rs b/src/test/rustdoc/intra-doc/field.rs new file mode 100644 index 000000000000..c67c40a77edb --- /dev/null +++ b/src/test/rustdoc/intra-doc/field.rs @@ -0,0 +1,4 @@ +// @has field/index.html '//a[@href="https://doc.rust-lang.org/nightly/core/ops/range/struct.Range.html#structfield.start"]' 'start' +// @has field/index.html '//a[@href="https://doc.rust-lang.org/nightly/std/io/error/enum.ErrorKind.html#variant.NotFound"]' 'not_found' +//! [start][std::ops::Range::start] +//! [not_found][std::io::ErrorKind::NotFound] From f6b8b780633798477bf0b13e01bfec8e1ab76856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=C3=A9nore=20Bouttefeux?= Date: Sun, 9 May 2021 13:37:09 +0200 Subject: [PATCH 005/441] add bootstrap cfg --- library/test/src/formatters/pretty.rs | 2 +- library/test/src/formatters/terse.rs | 2 +- library/test/src/tests.rs | 38 +++++++++++++++++++++++++++ library/test/src/types.rs | 10 ++++++- src/librustdoc/doctest.rs | 2 ++ src/tools/compiletest/src/main.rs | 2 ++ 6 files changed, 53 insertions(+), 3 deletions(-) diff --git a/library/test/src/formatters/pretty.rs b/library/test/src/formatters/pretty.rs index 543b9a6924ac..c1a0bb9f3e1e 100644 --- a/library/test/src/formatters/pretty.rs +++ b/library/test/src/formatters/pretty.rs @@ -169,7 +169,7 @@ impl PrettyFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); - self.write_plain(&format!("test {} - {} ... ", name, desc.test_mode_string()))?; + self.write_plain(&format!("test {} - {} ... ", name, desc.test_mode()))?; Ok(()) } diff --git a/library/test/src/formatters/terse.rs b/library/test/src/formatters/terse.rs index 286b50b525d4..a9589829ad27 100644 --- a/library/test/src/formatters/terse.rs +++ b/library/test/src/formatters/terse.rs @@ -158,7 +158,7 @@ impl TerseFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); - self.write_plain(&format!("test {} - {} ... ", name, desc.test_mode_string()))?; + self.write_plain(&format!("test {} - {} ... ", name, desc.test_mode()))?; Ok(()) } diff --git a/library/test/src/tests.rs b/library/test/src/tests.rs index 794f72770047..5a4a540b04eb 100644 --- a/library/test/src/tests.rs +++ b/library/test/src/tests.rs @@ -61,7 +61,9 @@ fn one_ignored_one_unignored_test() -> Vec { ignore: true, should_panic: ShouldPanic::No, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }, @@ -73,7 +75,9 @@ fn one_ignored_one_unignored_test() -> Vec { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }, @@ -93,7 +97,9 @@ pub fn do_not_run_ignored_tests() { ignore: true, should_panic: ShouldPanic::No, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }, @@ -114,7 +120,9 @@ pub fn ignored_tests_result_in_ignored() { ignore: true, should_panic: ShouldPanic::No, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }, @@ -139,7 +147,9 @@ fn test_should_panic() { ignore: false, should_panic: ShouldPanic::Yes, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }, @@ -164,7 +174,9 @@ fn test_should_panic_good_message() { ignore: false, should_panic: ShouldPanic::YesWithMessage("error message"), allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }, @@ -194,7 +206,9 @@ fn test_should_panic_bad_message() { ignore: false, should_panic: ShouldPanic::YesWithMessage(expected), allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }, @@ -228,7 +242,9 @@ fn test_should_panic_non_string_message_type() { ignore: false, should_panic: ShouldPanic::YesWithMessage(expected), allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }, @@ -254,7 +270,9 @@ fn test_should_panic_but_succeeds() { ignore: false, should_panic, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }, @@ -288,7 +306,9 @@ fn report_time_test_template(report_time: bool) -> Option { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }, @@ -323,7 +343,9 @@ fn time_test_failure_template(test_type: TestType) -> TestResult { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type, }, @@ -362,7 +384,9 @@ fn typed_test_desc(test_type: TestType) -> TestDesc { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type, } @@ -475,7 +499,9 @@ pub fn exclude_should_panic_option() { ignore: false, should_panic: ShouldPanic::Yes, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }, @@ -499,7 +525,9 @@ pub fn exact_filter_match() { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }, @@ -593,7 +621,9 @@ pub fn sort_tests() { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }, @@ -672,7 +702,9 @@ pub fn test_bench_no_iter() { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }; @@ -694,7 +726,9 @@ pub fn test_bench_iter() { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }; @@ -710,7 +744,9 @@ fn should_sort_failures_before_printing_them() { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }; @@ -720,7 +756,9 @@ fn should_sort_failures_before_printing_them() { ignore: false, should_panic: ShouldPanic::No, allow_fail: false, + #[cfg(not(bootstrap))] compile_fail: false, + #[cfg(not(bootstrap))] no_run: false, test_type: TestType::Unknown, }; diff --git a/library/test/src/types.rs b/library/test/src/types.rs index a2c3d5fa8eeb..4cbdc7affc65 100644 --- a/library/test/src/types.rs +++ b/library/test/src/types.rs @@ -124,7 +124,9 @@ pub struct TestDesc { pub ignore: bool, pub should_panic: options::ShouldPanic, pub allow_fail: bool, + #[cfg(not(bootstrap))] pub compile_fail: bool, + #[cfg(not(bootstrap))] pub no_run: bool, pub test_type: TestType, } @@ -143,7 +145,8 @@ impl TestDesc { } } - pub fn test_mode_string(&self) -> &'static str { + #[cfg(not(bootstrap))] + pub fn test_mode(&self) -> &'static str { if self.ignore { return &"ignore"; } @@ -164,6 +167,11 @@ impl TestDesc { } &"run" } + + #[cfg(bootstrap)] + pub fn test_mode(&self) -> &'static str { + &"" + } } #[derive(Debug)] diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 8ef9170f9194..c33d0ba4e574 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -935,7 +935,9 @@ impl Tester for Collector { // compiler failures are test failures should_panic: testing::ShouldPanic::No, allow_fail: config.allow_fail, + #[cfg(not(bootstrap))] compile_fail: config.compile_fail, + #[cfg(not(bootstrap))] no_run, test_type: testing::TestType::DocTest, }, diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index f3751ff244fd..0aa1f336b6d4 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -649,7 +649,9 @@ fn make_test(config: &Config, testpaths: &TestPaths, inputs: &Stamp) -> Vec Date: Sun, 9 May 2021 14:46:00 +0200 Subject: [PATCH 006/441] fix compiletest to search for two dash and run make fulldeps test --- src/test/run-make-fulldeps/issue-22131/Makefile | 2 +- src/test/run-make-fulldeps/test-harness/Makefile | 2 +- src/tools/compiletest/src/runtest.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/run-make-fulldeps/issue-22131/Makefile b/src/test/run-make-fulldeps/issue-22131/Makefile index d76aaf5c146d..5f721ef31305 100644 --- a/src/test/run-make-fulldeps/issue-22131/Makefile +++ b/src/test/run-make-fulldeps/issue-22131/Makefile @@ -4,4 +4,4 @@ all: foo.rs $(RUSTC) --cfg 'feature="bar"' --crate-type lib foo.rs $(RUSTDOC) --test --cfg 'feature="bar"' \ -L $(TMPDIR) foo.rs |\ - $(CGREP) 'foo.rs - foo (line 1) ... ok' + $(CGREP) 'foo.rs - foo (line 1) - run ... ok' diff --git a/src/test/run-make-fulldeps/test-harness/Makefile b/src/test/run-make-fulldeps/test-harness/Makefile index 39477c07ced7..1f3b112d6afe 100644 --- a/src/test/run-make-fulldeps/test-harness/Makefile +++ b/src/test/run-make-fulldeps/test-harness/Makefile @@ -3,6 +3,6 @@ all: # check that #[cfg_attr(..., ignore)] does the right thing. $(RUSTC) --test test-ignore-cfg.rs --cfg ignorecfg - $(call RUN,test-ignore-cfg) | $(CGREP) 'shouldnotignore ... ok' 'shouldignore ... ignored' + $(call RUN,test-ignore-cfg) | $(CGREP) 'shouldnotignore - run ... ok' 'shouldignore - ignore ... ignored' $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -e "^i\.$$" $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -v 'should' diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index ecbaccf744dc..0898e9ef2f63 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2638,7 +2638,7 @@ impl<'test> TestCx<'test> { let mut tested = 0; for _ in res.stdout.split('\n').filter(|s| s.starts_with("test ")).inspect(|s| { let tmp: Vec<&str> = s.split(" - ").collect(); - if tmp.len() == 2 { + if tmp.len() == 3 { let path = tmp[0].rsplit("test ").next().unwrap(); if let Some(ref mut v) = files.get_mut(&path.replace('\\', "/")) { tested += 1; From da093d713ad43ed918a667e48f62ad285d9924d1 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 15 May 2021 13:20:42 +0200 Subject: [PATCH 007/441] Remove `label` in dirty/clean annotations. --- .../src/persist/dirty_clean.rs | 48 +- .../struct_point.rs | 10 +- .../callee_caller_cross_crate/b.rs | 4 +- .../change_add_field/struct_point.rs | 14 +- .../change_private_fn/struct_point.rs | 10 +- .../change_private_fn_cc/struct_point.rs | 10 +- .../struct_point.rs | 10 +- .../struct_point.rs | 10 +- .../struct_point.rs | 10 +- .../struct_point.rs | 10 +- src/test/incremental/crate_hash_reorder.rs | 4 +- src/test/incremental/dirty_clean.rs | 12 +- .../incremental/hashes/call_expressions.rs | 8 +- .../hashes/indexing_expressions.rs | 42 +- src/test/incremental/hashes/struct_defs.rs | 252 ++--------- src/test/incremental/hashes/trait_defs.rs | 420 +++++++++--------- src/test/incremental/hashes/trait_impls.rs | 152 +++---- src/test/incremental/hello_world.rs | 4 +- .../hygiene/auxiliary/cached_hygiene.rs | 2 +- .../ich_method_call_trait_scope.rs | 8 +- src/test/incremental/ich_nested_items.rs | 6 +- src/test/incremental/ich_resolve_results.rs | 12 +- src/test/incremental/rlib_cross_crate/b.rs | 8 +- src/test/incremental/source_loc_macros.rs | 15 +- .../span_hash_stable/auxiliary/sub1.rs | 2 +- .../span_hash_stable/auxiliary/sub2.rs | 2 +- .../spans_significant_w_debuginfo.rs | 3 +- .../incremental/spans_significant_w_panic.rs | 2 +- src/test/incremental/string_constant.rs | 9 +- src/test/incremental/struct_add_field.rs | 6 +- .../incremental/struct_change_field_name.rs | 6 +- .../incremental/struct_change_field_type.rs | 6 +- .../struct_change_field_type_cross_crate/b.rs | 6 +- src/test/incremental/struct_change_nothing.rs | 6 +- src/test/incremental/struct_remove_field.rs | 6 +- .../incremental/type_alias_cross_crate/b.rs | 8 +- src/test/incremental/unchecked_dirty_clean.rs | 8 +- 37 files changed, 452 insertions(+), 699 deletions(-) diff --git a/compiler/rustc_incremental/src/persist/dirty_clean.rs b/compiler/rustc_incremental/src/persist/dirty_clean.rs index e7bd488af8eb..b4963e2e4601 100644 --- a/compiler/rustc_incremental/src/persist/dirty_clean.rs +++ b/compiler/rustc_incremental/src/persist/dirty_clean.rs @@ -30,7 +30,6 @@ use std::iter::FromIterator; use std::vec::Vec; const EXCEPT: Symbol = sym::except; -const LABEL: Symbol = sym::label; const CFG: Symbol = sym::cfg; // Base and Extra labels to build up the labels @@ -122,16 +121,6 @@ struct Assertion { dirty: Labels, } -impl Assertion { - fn from_clean_labels(labels: Labels) -> Assertion { - Assertion { clean: labels, dirty: Labels::default() } - } - - fn from_dirty_labels(labels: Labels) -> Assertion { - Assertion { clean: Labels::default(), dirty: labels } - } -} - pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) { if !tcx.sess.opts.debugging_opts.query_dep_graph { return; @@ -181,15 +170,7 @@ impl DirtyCleanVisitor<'tcx> { // skip: not the correct `cfg=` return None; } - let assertion = if let Some(labels) = self.labels(attr) { - if is_clean { - Assertion::from_clean_labels(labels) - } else { - Assertion::from_dirty_labels(labels) - } - } else { - self.assertion_auto(item_id, attr, is_clean) - }; + let assertion = self.assertion_auto(item_id, attr, is_clean); Some(assertion) } @@ -218,16 +199,6 @@ impl DirtyCleanVisitor<'tcx> { } } - fn labels(&self, attr: &Attribute) -> Option { - for item in attr.meta_item_list().unwrap_or_else(Vec::new) { - if item.has_name(LABEL) { - let value = expect_associated_value(self.tcx, &item); - return Some(self.resolve_labels(&item, value)); - } - } - None - } - /// `except=` attribute value fn except(&self, attr: &Attribute) -> Labels { for item in attr.meta_item_list().unwrap_or_else(Vec::new) { @@ -437,30 +408,19 @@ impl ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> { /// Given a `#[rustc_dirty]` or `#[rustc_clean]` attribute, scan /// for a `cfg="foo"` attribute and check whether we have a cfg /// flag called `foo`. -/// -/// Also make sure that the `label` and `except` fields do not -/// both exist. fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool { debug!("check_config(attr={:?})", attr); let config = &tcx.sess.parse_sess.config; debug!("check_config: config={:?}", config); - let (mut cfg, mut except, mut label) = (None, false, false); + let mut cfg = None; for item in attr.meta_item_list().unwrap_or_else(Vec::new) { if item.has_name(CFG) { let value = expect_associated_value(tcx, &item); debug!("check_config: searching for cfg {:?}", value); cfg = Some(config.contains(&(value, None))); + } else if !item.has_name(EXCEPT) { + tcx.sess.span_err(attr.span, &format!("unknown item `{}`", item.name_or_empty())); } - if item.has_name(LABEL) { - label = true; - } - if item.has_name(EXCEPT) { - except = true; - } - } - - if label && except { - tcx.sess.span_fatal(attr.span, "must specify only one of: `label`, `except`"); } match cfg { diff --git a/src/test/incremental/add_private_fn_at_krate_root_cc/struct_point.rs b/src/test/incremental/add_private_fn_at_krate_root_cc/struct_point.rs index f698f8835a26..ea1ea1943e97 100644 --- a/src/test/incremental/add_private_fn_at_krate_root_cc/struct_point.rs +++ b/src/test/incremental/add_private_fn_at_krate_root_cc/struct_point.rs @@ -24,7 +24,7 @@ extern crate point; pub mod fn_calls_methods_in_same_impl { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn check() { let x = Point { x: 2.0, y: 2.0 }; x.distance_from_origin(); @@ -35,7 +35,7 @@ pub mod fn_calls_methods_in_same_impl { pub mod fn_calls_free_fn { use point::{self, Point}; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn check() { let x = Point { x: 2.0, y: 2.0 }; point::distance_squared(&x); @@ -46,7 +46,7 @@ pub mod fn_calls_free_fn { pub mod fn_make_struct { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn make_origin() -> Point { Point { x: 2.0, y: 2.0 } } @@ -56,7 +56,7 @@ pub mod fn_make_struct { pub mod fn_read_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn get_x(p: Point) -> f32 { p.x } @@ -66,7 +66,7 @@ pub mod fn_read_field { pub mod fn_write_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn inc_x(p: &mut Point) { p.x += 1.0; } diff --git a/src/test/incremental/callee_caller_cross_crate/b.rs b/src/test/incremental/callee_caller_cross_crate/b.rs index 024537400798..084ed232a55e 100644 --- a/src/test/incremental/callee_caller_cross_crate/b.rs +++ b/src/test/incremental/callee_caller_cross_crate/b.rs @@ -6,12 +6,12 @@ extern crate a; -#[rustc_dirty(label="typeck", cfg="rpass2")] +#[rustc_clean(except="typeck", cfg="rpass2")] pub fn call_function0() { a::function0(77); } -#[rustc_clean(label="typeck", cfg="rpass2")] +#[rustc_clean(cfg="rpass2")] pub fn call_function1() { a::function1(77); } diff --git a/src/test/incremental/change_add_field/struct_point.rs b/src/test/incremental/change_add_field/struct_point.rs index 8d98cfac8a4d..3308ea56222f 100644 --- a/src/test/incremental/change_add_field/struct_point.rs +++ b/src/test/incremental/change_add_field/struct_point.rs @@ -70,7 +70,7 @@ pub mod point { pub mod fn_with_type_in_sig { use point::Point; - #[rustc_dirty(label="typeck", cfg="cfail2")] + #[rustc_clean(except="typeck,fn_sig,optimized_mir", cfg="cfail2")] pub fn boop(p: Option<&Point>) -> f32 { p.map(|p| p.total()).unwrap_or(0.0) } @@ -86,7 +86,7 @@ pub mod fn_with_type_in_sig { pub mod call_fn_with_type_in_sig { use fn_with_type_in_sig; - #[rustc_dirty(label="typeck", cfg="cfail2")] + #[rustc_clean(except="typeck,optimized_mir", cfg="cfail2")] pub fn bip() -> f32 { fn_with_type_in_sig::boop(None) } @@ -102,7 +102,7 @@ pub mod call_fn_with_type_in_sig { pub mod fn_with_type_in_body { use point::Point; - #[rustc_dirty(label="typeck", cfg="cfail2")] + #[rustc_clean(except="typeck,optimized_mir", cfg="cfail2")] pub fn boop() -> f32 { Point::origin().total() } @@ -115,7 +115,7 @@ pub mod fn_with_type_in_body { pub mod call_fn_with_type_in_body { use fn_with_type_in_body; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn bip() -> f32 { fn_with_type_in_body::boop() } @@ -125,7 +125,7 @@ pub mod call_fn_with_type_in_body { pub mod fn_make_struct { use point::Point; - #[rustc_dirty(label="typeck", cfg="cfail2")] + #[rustc_clean(except="typeck,fn_sig,optimized_mir", cfg="cfail2")] pub fn make_origin(p: Point) -> Point { Point { ..p } } @@ -135,7 +135,7 @@ pub mod fn_make_struct { pub mod fn_read_field { use point::Point; - #[rustc_dirty(label="typeck", cfg="cfail2")] + #[rustc_clean(except="typeck,fn_sig,optimized_mir", cfg="cfail2")] pub fn get_x(p: Point) -> f32 { p.x } @@ -145,7 +145,7 @@ pub mod fn_read_field { pub mod fn_write_field { use point::Point; - #[rustc_dirty(label="typeck", cfg="cfail2")] + #[rustc_clean(except="typeck,fn_sig,optimized_mir", cfg="cfail2")] pub fn inc_x(p: &mut Point) { p.x += 1.0; } diff --git a/src/test/incremental/change_private_fn/struct_point.rs b/src/test/incremental/change_private_fn/struct_point.rs index ba4bf4e7b7d2..1791c089cfa8 100644 --- a/src/test/incremental/change_private_fn/struct_point.rs +++ b/src/test/incremental/change_private_fn/struct_point.rs @@ -51,7 +51,7 @@ pub mod point { pub mod fn_calls_methods_in_same_impl { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn check() { let x = Point { x: 2.0, y: 2.0 }; x.distance_from_origin(); @@ -62,7 +62,7 @@ pub mod fn_calls_methods_in_same_impl { pub mod fn_calls_methods_in_another_impl { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn check() { let mut x = Point { x: 2.0, y: 2.0 }; x.translate(3.0, 3.0); @@ -73,7 +73,7 @@ pub mod fn_calls_methods_in_another_impl { pub mod fn_make_struct { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn make_origin() -> Point { Point { x: 2.0, y: 2.0 } } @@ -83,7 +83,7 @@ pub mod fn_make_struct { pub mod fn_read_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn get_x(p: Point) -> f32 { p.x } @@ -93,7 +93,7 @@ pub mod fn_read_field { pub mod fn_write_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn inc_x(p: &mut Point) { p.x += 1.0; } diff --git a/src/test/incremental/change_private_fn_cc/struct_point.rs b/src/test/incremental/change_private_fn_cc/struct_point.rs index 5072ef609e2c..1c27ec3a3f7e 100644 --- a/src/test/incremental/change_private_fn_cc/struct_point.rs +++ b/src/test/incremental/change_private_fn_cc/struct_point.rs @@ -23,7 +23,7 @@ extern crate point; pub mod fn_calls_methods_in_same_impl { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn check() { let x = Point { x: 2.0, y: 2.0 }; x.distance_from_origin(); @@ -34,7 +34,7 @@ pub mod fn_calls_methods_in_same_impl { pub mod fn_calls_methods_in_another_impl { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn check() { let mut x = Point { x: 2.0, y: 2.0 }; x.translate(3.0, 3.0); @@ -45,7 +45,7 @@ pub mod fn_calls_methods_in_another_impl { pub mod fn_make_struct { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn make_origin() -> Point { Point { x: 2.0, y: 2.0 } } @@ -55,7 +55,7 @@ pub mod fn_make_struct { pub mod fn_read_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn get_x(p: Point) -> f32 { p.x } @@ -65,7 +65,7 @@ pub mod fn_read_field { pub mod fn_write_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn inc_x(p: &mut Point) { p.x += 1.0; } diff --git a/src/test/incremental/change_private_impl_method/struct_point.rs b/src/test/incremental/change_private_impl_method/struct_point.rs index 11ba96a8c8d5..cf43e4757cb8 100644 --- a/src/test/incremental/change_private_impl_method/struct_point.rs +++ b/src/test/incremental/change_private_impl_method/struct_point.rs @@ -51,7 +51,7 @@ pub mod point { pub mod fn_calls_methods_in_same_impl { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn check() { let x = Point { x: 2.0, y: 2.0 }; x.distance_from_origin(); @@ -62,7 +62,7 @@ pub mod fn_calls_methods_in_same_impl { pub mod fn_calls_methods_in_another_impl { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn check() { let mut x = Point { x: 2.0, y: 2.0 }; x.translate(3.0, 3.0); @@ -73,7 +73,7 @@ pub mod fn_calls_methods_in_another_impl { pub mod fn_make_struct { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn make_origin() -> Point { Point { x: 2.0, y: 2.0 } } @@ -83,7 +83,7 @@ pub mod fn_make_struct { pub mod fn_read_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn get_x(p: Point) -> f32 { p.x } @@ -93,7 +93,7 @@ pub mod fn_read_field { pub mod fn_write_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn inc_x(p: &mut Point) { p.x += 1.0; } diff --git a/src/test/incremental/change_private_impl_method_cc/struct_point.rs b/src/test/incremental/change_private_impl_method_cc/struct_point.rs index 2aeecfc89d5c..9fe8b5df93a2 100644 --- a/src/test/incremental/change_private_impl_method_cc/struct_point.rs +++ b/src/test/incremental/change_private_impl_method_cc/struct_point.rs @@ -24,7 +24,7 @@ extern crate point; pub mod fn_calls_methods_in_same_impl { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn check() { let x = Point { x: 2.0, y: 2.0 }; x.distance_from_origin(); @@ -35,7 +35,7 @@ pub mod fn_calls_methods_in_same_impl { pub mod fn_calls_methods_in_another_impl { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn dirty() { let mut x = Point { x: 2.0, y: 2.0 }; x.translate(3.0, 3.0); @@ -46,7 +46,7 @@ pub mod fn_calls_methods_in_another_impl { pub mod fn_make_struct { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn make_origin() -> Point { Point { x: 2.0, y: 2.0 } } @@ -56,7 +56,7 @@ pub mod fn_make_struct { pub mod fn_read_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn get_x(p: Point) -> f32 { p.x } @@ -66,7 +66,7 @@ pub mod fn_read_field { pub mod fn_write_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn inc_x(p: &mut Point) { p.x += 1.0; } diff --git a/src/test/incremental/change_pub_inherent_method_body/struct_point.rs b/src/test/incremental/change_pub_inherent_method_body/struct_point.rs index a192dff19e9f..1b87b18fcd42 100644 --- a/src/test/incremental/change_pub_inherent_method_body/struct_point.rs +++ b/src/test/incremental/change_pub_inherent_method_body/struct_point.rs @@ -42,7 +42,7 @@ pub mod point { pub mod fn_calls_changed_method { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn check() { let p = Point { x: 2.0, y: 2.0 }; p.distance_from_origin(); @@ -53,7 +53,7 @@ pub mod fn_calls_changed_method { pub mod fn_calls_another_method { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn check() { let p = Point { x: 2.0, y: 2.0 }; p.x(); @@ -64,7 +64,7 @@ pub mod fn_calls_another_method { pub mod fn_make_struct { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn make_origin() -> Point { Point { x: 2.0, y: 2.0 } } @@ -74,7 +74,7 @@ pub mod fn_make_struct { pub mod fn_read_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn get_x(p: Point) -> f32 { p.x } @@ -84,7 +84,7 @@ pub mod fn_read_field { pub mod fn_write_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn inc_x(p: &mut Point) { p.x += 1.0; } diff --git a/src/test/incremental/change_pub_inherent_method_sig/struct_point.rs b/src/test/incremental/change_pub_inherent_method_sig/struct_point.rs index b04761685558..0a672956768a 100644 --- a/src/test/incremental/change_pub_inherent_method_sig/struct_point.rs +++ b/src/test/incremental/change_pub_inherent_method_sig/struct_point.rs @@ -52,7 +52,7 @@ pub mod point { pub mod fn_calls_changed_method { use point::Point; - #[rustc_dirty(label="typeck", cfg="cfail2")] + #[rustc_clean(except="typeck,optimized_mir", cfg="cfail2")] pub fn check() { let p = Point { x: 2.0, y: 2.0 }; p.distance_from_point(None); @@ -63,7 +63,7 @@ pub mod fn_calls_changed_method { pub mod fn_calls_another_method { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn check() { let p = Point { x: 2.0, y: 2.0 }; p.x(); @@ -74,7 +74,7 @@ pub mod fn_calls_another_method { pub mod fn_make_struct { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn make_origin() -> Point { Point { x: 2.0, y: 2.0 } } @@ -84,7 +84,7 @@ pub mod fn_make_struct { pub mod fn_read_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn get_x(p: Point) -> f32 { p.x } @@ -94,7 +94,7 @@ pub mod fn_read_field { pub mod fn_write_field { use point::Point; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn inc_x(p: &mut Point) { p.x += 1.0; } diff --git a/src/test/incremental/crate_hash_reorder.rs b/src/test/incremental/crate_hash_reorder.rs index 6e06e67b6682..ca476b4d2db1 100644 --- a/src/test/incremental/crate_hash_reorder.rs +++ b/src/test/incremental/crate_hash_reorder.rs @@ -7,9 +7,9 @@ // Check that reordering otherwise identical items is not considered a // change at all. -#[rustc_clean(label = "hir_crate", cfg = "rpass2")] +#[rustc_clean(cfg = "rpass2")] // But removing an item, naturally, is. -#[rustc_dirty(label = "hir_crate", cfg = "rpass3")] +#[rustc_clean(except="hir_crate", cfg = "rpass3")] #[cfg(rpass1)] pub struct X { pub x: u32, diff --git a/src/test/incremental/dirty_clean.rs b/src/test/incremental/dirty_clean.rs index 02c9a0c57988..5f7832828a9d 100644 --- a/src/test/incremental/dirty_clean.rs +++ b/src/test/incremental/dirty_clean.rs @@ -25,15 +25,21 @@ mod x { mod y { use x; - #[rustc_clean(label="typeck", cfg="cfail2")] + #[rustc_dirty(except="typeck", cfg="cfail2")] pub fn y() { - //[cfail2]~^ ERROR `typeck(y)` should be clean but is not + //[cfail2]~^ ERROR `hir_owner(y)` should be dirty but is not + //[cfail2]~| ERROR `hir_owner_nodes(y)` should be dirty but is not + //[cfail2]~| ERROR `generics_of(y)` should be dirty but is not + //[cfail2]~| ERROR `predicates_of(y)` should be dirty but is not + //[cfail2]~| ERROR `type_of(y)` should be dirty but is not + //[cfail2]~| ERROR `fn_sig(y)` should be dirty but is not + //[cfail2]~| ERROR `typeck(y)` should be clean but is not x::x(); } } mod z { - #[rustc_dirty(label="typeck", cfg="cfail2")] + #[rustc_clean(except="typeck", cfg="cfail2")] pub fn z() { //[cfail2]~^ ERROR `typeck(z)` should be dirty but is not } diff --git a/src/test/incremental/hashes/call_expressions.rs b/src/test/incremental/hashes/call_expressions.rs index d4511cee75bb..d4201400f0fc 100644 --- a/src/test/incremental/hashes/call_expressions.rs +++ b/src/test/incremental/hashes/call_expressions.rs @@ -55,12 +55,8 @@ mod change_callee_indirectly_function { #[cfg(not(cfail1))] use super::callee2 as callee; - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] - #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] - - + #[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] pub fn change_callee_indirectly_function() { callee(1, 2) } diff --git a/src/test/incremental/hashes/indexing_expressions.rs b/src/test/incremental/hashes/indexing_expressions.rs index 7a8cbc3566ee..49ee7a9cac09 100644 --- a/src/test/incremental/hashes/indexing_expressions.rs +++ b/src/test/incremental/hashes/indexing_expressions.rs @@ -20,10 +20,8 @@ fn change_simple_index(slice: &[u32]) -> u32 { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] +#[rustc_clean(except="hir_owner_nodes", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] fn change_simple_index(slice: &[u32]) -> u32 { slice[4] } @@ -37,10 +35,8 @@ fn change_lower_bound(slice: &[u32]) -> &[u32] { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] +#[rustc_clean(except="hir_owner_nodes", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] fn change_lower_bound(slice: &[u32]) -> &[u32] { &slice[2..5] } @@ -54,10 +50,8 @@ fn change_upper_bound(slice: &[u32]) -> &[u32] { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] +#[rustc_clean(except="hir_owner_nodes", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] fn change_upper_bound(slice: &[u32]) -> &[u32] { &slice[3..7] } @@ -71,10 +65,8 @@ fn add_lower_bound(slice: &[u32]) -> &[u32] { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] +#[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] fn add_lower_bound(slice: &[u32]) -> &[u32] { &slice[3..4] } @@ -88,10 +80,8 @@ fn add_upper_bound(slice: &[u32]) -> &[u32] { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] +#[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] fn add_upper_bound(slice: &[u32]) -> &[u32] { &slice[3..7] } @@ -105,10 +95,8 @@ fn change_mutability(slice: &mut [u32]) -> u32 { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] +#[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] fn change_mutability(slice: &mut [u32]) -> u32 { (&slice[3..5])[0] } @@ -122,10 +110,8 @@ fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] +#[rustc_clean(except="hir_owner_nodes,typeck", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] fn exclusive_to_inclusive_range(slice: &[u32]) -> &[u32] { &slice[3..=7] } diff --git a/src/test/incremental/hashes/struct_defs.rs b/src/test/incremental/hashes/struct_defs.rs index 1339a1e5bf21..0ce5aeaaf502 100644 --- a/src/test/incremental/hashes/struct_defs.rs +++ b/src/test/incremental/hashes/struct_defs.rs @@ -24,16 +24,8 @@ pub struct LayoutPacked; #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_clean(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="type_of", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] #[repr(packed)] pub struct LayoutPacked; @@ -41,16 +33,8 @@ pub struct LayoutPacked; struct LayoutC; #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_clean(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="type_of", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] #[repr(C)] struct LayoutC; @@ -61,16 +45,8 @@ struct LayoutC; struct TupleStructFieldType(i32); #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_clean(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] // Note that changing the type of a field does not change the type of the struct or enum, but // adding/removing fields or changing a fields name or visibility does. struct TupleStructFieldType( @@ -84,16 +60,8 @@ struct TupleStructFieldType( struct TupleStructAddField(i32); #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_clean(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,type_of", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] struct TupleStructAddField( i32, u32 @@ -106,16 +74,8 @@ struct TupleStructAddField( struct TupleStructFieldVisibility(char); #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_clean(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,type_of", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] struct TupleStructFieldVisibility(pub char); @@ -125,16 +85,8 @@ struct TupleStructFieldVisibility(pub char); struct RecordStructFieldType { x: f32 } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_clean(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] // Note that changing the type of a field does not change the type of the struct or enum, but // adding/removing fields or changing a fields name or visibility does. struct RecordStructFieldType { @@ -148,16 +100,8 @@ struct RecordStructFieldType { struct RecordStructFieldName { x: f32 } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_clean(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,type_of", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] struct RecordStructFieldName { y: f32 } @@ -167,16 +111,8 @@ struct RecordStructFieldName { y: f32 } struct RecordStructAddField { x: f32 } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_clean(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,type_of", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] struct RecordStructAddField { x: f32, y: () } @@ -188,16 +124,8 @@ struct RecordStructAddField { struct RecordStructFieldVisibility { x: f32 } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_clean(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,type_of", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] struct RecordStructFieldVisibility { pub x: f32 } @@ -209,16 +137,8 @@ struct RecordStructFieldVisibility { struct AddLifetimeParameter<'a>(&'a f32, &'a f64); #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] -#[rustc_dirty(label="generics_of", cfg="cfail2")] -#[rustc_clean(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,type_of,generics_of", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] struct AddLifetimeParameter<'a, 'b>(&'a f32, &'b f64); @@ -228,16 +148,8 @@ struct AddLifetimeParameter<'a, 'b>(&'a f32, &'b f64); struct AddLifetimeParameterBound<'a, 'b>(&'a f32, &'b f64); #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_dirty(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] struct AddLifetimeParameterBound<'a, 'b: 'a>( &'a f32, &'b f64 @@ -247,16 +159,8 @@ struct AddLifetimeParameterBound<'a, 'b: 'a>( struct AddLifetimeParameterBoundWhereClause<'a, 'b>(&'a f32, &'b f64); #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_dirty(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] struct AddLifetimeParameterBoundWhereClause<'a, 'b>( &'a f32, &'b f64) @@ -269,16 +173,8 @@ struct AddLifetimeParameterBoundWhereClause<'a, 'b>( struct AddTypeParameter(T1, T1); #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_dirty(label="type_of", cfg="cfail2")] -#[rustc_dirty(label="generics_of", cfg="cfail2")] -#[rustc_dirty(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,type_of,generics_of,predicates_of", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] struct AddTypeParameter( // The field contains the parent's Generics, so it's dirty even though its // type hasn't changed. @@ -293,16 +189,8 @@ struct AddTypeParameter( struct AddTypeParameterBound(T); #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_dirty(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] struct AddTypeParameterBound( T ); @@ -312,16 +200,8 @@ struct AddTypeParameterBound( struct AddTypeParameterBoundWhereClause(T); #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_dirty(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] struct AddTypeParameterBoundWhereClause( T ) where T: Sync; @@ -332,16 +212,8 @@ struct AddTypeParameterBoundWhereClause( // fingerprint is stable (i.e., that there are no random influences like memory // addresses taken into account by the hashing algorithm). // Note: there is no #[cfg(...)], so this is ALWAYS compiled -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_clean(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] pub struct EmptyStruct; @@ -351,16 +223,8 @@ pub struct EmptyStruct; struct Visibility; #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] -#[rustc_clean(label="type_of", cfg="cfail2")] -#[rustc_clean(label="generics_of", cfg="cfail2")] -#[rustc_clean(label="predicates_of", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] -#[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] -#[rustc_clean(label="type_of", cfg="cfail3")] -#[rustc_clean(label="generics_of", cfg="cfail3")] -#[rustc_clean(label="predicates_of", cfg="cfail3")] +#[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] pub struct Visibility; struct ReferencedType1; @@ -373,16 +237,8 @@ mod tuple_struct_change_field_type_indirectly { #[cfg(not(cfail1))] use super::ReferencedType2 as FieldType; - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_clean(label="type_of", cfg="cfail2")] - #[rustc_clean(label="generics_of", cfg="cfail2")] - #[rustc_clean(label="predicates_of", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] - #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] - #[rustc_clean(label="type_of", cfg="cfail3")] - #[rustc_clean(label="generics_of", cfg="cfail3")] - #[rustc_clean(label="predicates_of", cfg="cfail3")] + #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] struct TupleStruct( FieldType ); @@ -396,16 +252,8 @@ mod record_struct_change_field_type_indirectly { #[cfg(not(cfail1))] use super::ReferencedType2 as FieldType; - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_clean(label="type_of", cfg="cfail2")] - #[rustc_clean(label="generics_of", cfg="cfail2")] - #[rustc_clean(label="predicates_of", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] - #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] - #[rustc_clean(label="type_of", cfg="cfail3")] - #[rustc_clean(label="generics_of", cfg="cfail3")] - #[rustc_clean(label="predicates_of", cfg="cfail3")] + #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] struct RecordStruct { _x: FieldType } @@ -424,16 +272,8 @@ mod change_trait_bound_indirectly { #[cfg(not(cfail1))] use super::ReferencedTrait2 as Trait; - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_clean(label="type_of", cfg="cfail2")] - #[rustc_clean(label="generics_of", cfg="cfail2")] - #[rustc_dirty(label="predicates_of", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] - #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] - #[rustc_clean(label="type_of", cfg="cfail3")] - #[rustc_clean(label="generics_of", cfg="cfail3")] - #[rustc_clean(label="predicates_of", cfg="cfail3")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] struct Struct(T); } @@ -444,15 +284,7 @@ mod change_trait_bound_indirectly_in_where_clause { #[cfg(not(cfail1))] use super::ReferencedTrait2 as Trait; - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_clean(label="type_of", cfg="cfail2")] - #[rustc_clean(label="generics_of", cfg="cfail2")] - #[rustc_dirty(label="predicates_of", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] - #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] - #[rustc_clean(label="type_of", cfg="cfail3")] - #[rustc_clean(label="generics_of", cfg="cfail3")] - #[rustc_clean(label="predicates_of", cfg="cfail3")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] struct Struct(T) where T : Trait; } diff --git a/src/test/incremental/hashes/trait_defs.rs b/src/test/incremental/hashes/trait_defs.rs index 4dab032e47f3..73d836484967 100644 --- a/src/test/incremental/hashes/trait_defs.rs +++ b/src/test/incremental/hashes/trait_defs.rs @@ -25,8 +25,8 @@ trait TraitVisibility { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] pub trait TraitVisibility { } @@ -36,8 +36,8 @@ pub trait TraitVisibility { } trait TraitUnsafety { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] unsafe trait TraitUnsafety { } @@ -48,8 +48,8 @@ trait TraitAddMethod { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] pub trait TraitAddMethod { fn method(); } @@ -63,8 +63,8 @@ trait TraitChangeMethodName { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitChangeMethodName { fn methodChanged(); } @@ -78,11 +78,11 @@ trait TraitAddReturnType { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddReturnType { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method() -> u32; } @@ -95,11 +95,11 @@ trait TraitChangeReturnType { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitChangeReturnType { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method() -> u64; } @@ -112,11 +112,11 @@ trait TraitAddParameterToMethod { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddParameterToMethod { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(a: u32); } @@ -130,18 +130,16 @@ trait TraitChangeMethodParameterName { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitChangeMethodParameterName { // FIXME(#38501) This should preferably always be clean. - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(b: u32); - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] - #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] + #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn with_default(y: i32) {} } @@ -154,11 +152,11 @@ trait TraitChangeMethodParameterType { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitChangeMethodParameterType { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(a: i64); } @@ -171,11 +169,11 @@ trait TraitChangeMethodParameterTypeRef { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitChangeMethodParameterTypeRef { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(a: &mut i32); } @@ -188,11 +186,11 @@ trait TraitChangeMethodParametersOrder { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitChangeMethodParametersOrder { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(b: i64, a: i32); } @@ -205,11 +203,11 @@ trait TraitAddMethodAutoImplementation { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddMethodAutoImplementation { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method() { } } @@ -223,8 +221,8 @@ trait TraitChangeOrderOfMethods { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitChangeOrderOfMethods { fn method1(); fn method0(); @@ -239,11 +237,11 @@ trait TraitChangeModeSelfRefToMut { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitChangeModeSelfRefToMut { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(&mut self); } @@ -255,13 +253,11 @@ trait TraitChangeModeSelfOwnToMut: Sized { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitChangeModeSelfOwnToMut: Sized { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] - #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] + #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(mut self) {} } @@ -273,11 +269,11 @@ trait TraitChangeModeSelfOwnToRef { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitChangeModeSelfOwnToRef { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(&self); } @@ -290,11 +286,11 @@ trait TraitAddUnsafeModifier { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddUnsafeModifier { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] unsafe fn method(); } @@ -307,11 +303,11 @@ trait TraitAddExternModifier { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddExternModifier { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] extern "C" fn method(); } @@ -324,11 +320,11 @@ trait TraitChangeExternCToRustIntrinsic { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitChangeExternCToRustIntrinsic { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] extern "stdcall" fn method(); } @@ -341,11 +337,11 @@ trait TraitAddTypeParameterToMethod { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddTypeParameterToMethod { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(); } @@ -358,11 +354,11 @@ trait TraitAddLifetimeParameterToMethod { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeParameterToMethod { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method<'a>(); } @@ -379,11 +375,11 @@ trait TraitAddTraitBoundToMethodTypeParameter { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddTraitBoundToMethodTypeParameter { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(); } @@ -396,11 +392,11 @@ trait TraitAddBuiltinBoundToMethodTypeParameter { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddBuiltinBoundToMethodTypeParameter { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(); } @@ -413,11 +409,11 @@ trait TraitAddLifetimeBoundToMethodLifetimeParameter { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeBoundToMethodLifetimeParameter { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method<'a, 'b: 'a>(a: &'a u32, b: &'b u32); } @@ -430,11 +426,11 @@ trait TraitAddSecondTraitBoundToMethodTypeParameter { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSecondTraitBoundToMethodTypeParameter { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(); } @@ -447,11 +443,11 @@ trait TraitAddSecondBuiltinBoundToMethodTypeParameter { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSecondBuiltinBoundToMethodTypeParameter { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(); } @@ -464,11 +460,11 @@ trait TraitAddSecondLifetimeBoundToMethodLifetimeParameter { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSecondLifetimeBoundToMethodLifetimeParameter { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method<'a, 'b, 'c: 'a + 'b>(a: &'a u32, b: &'b u32, c: &'c u32); } @@ -478,14 +474,14 @@ trait TraitAddSecondLifetimeBoundToMethodLifetimeParameter { #[cfg(cfail1)] trait TraitAddAssociatedType { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(); } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddAssociatedType { type Associated; @@ -506,11 +502,11 @@ trait TraitAddTraitBoundToAssociatedType { // Apparently the type bound contributes to the predicates of the trait, but // does not change the associated item itself. #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddTraitBoundToAssociatedType { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] type Associated: ReferencedTrait0; fn method(); @@ -527,11 +523,11 @@ trait TraitAddLifetimeBoundToAssociatedType<'a> { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeBoundToAssociatedType<'a> { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] type Associated: 'a; fn method(); @@ -548,11 +544,11 @@ trait TraitAddDefaultToAssociatedType { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddDefaultToAssociatedType { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] type Associated = ReferenceType0; fn method(); @@ -567,8 +563,8 @@ trait TraitAddAssociatedConstant { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddAssociatedConstant { const Value: u32; @@ -586,15 +582,15 @@ trait TraitAddInitializerToAssociatedConstant { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddInitializerToAssociatedConstant { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] const Value: u32 = 1; - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(); } @@ -609,15 +605,15 @@ trait TraitChangeTypeOfAssociatedConstant { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitChangeTypeOfAssociatedConstant { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] const Value: f64; - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(); } @@ -628,8 +624,8 @@ trait TraitChangeTypeOfAssociatedConstant { trait TraitAddSuperTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSuperTrait : ReferencedTrait0 { } @@ -639,8 +635,8 @@ trait TraitAddSuperTrait : ReferencedTrait0 { } trait TraitAddBuiltiBound { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddBuiltiBound : Send { } @@ -650,8 +646,8 @@ trait TraitAddBuiltiBound : Send { } trait TraitAddStaticLifetimeBound { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddStaticLifetimeBound : 'static { } @@ -661,16 +657,16 @@ trait TraitAddStaticLifetimeBound : 'static { } trait TraitAddTraitAsSecondBound : ReferencedTrait0 { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddTraitAsSecondBound : ReferencedTrait0 + ReferencedTrait1 { } #[cfg(cfail1)] trait TraitAddTraitAsSecondBoundFromBuiltin : Send { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddTraitAsSecondBoundFromBuiltin : Send + ReferencedTrait0 { } @@ -680,16 +676,16 @@ trait TraitAddTraitAsSecondBoundFromBuiltin : Send + ReferencedTrait0 { } trait TraitAddBuiltinBoundAsSecondBound : ReferencedTrait0 { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddBuiltinBoundAsSecondBound : ReferencedTrait0 + Send { } #[cfg(cfail1)] trait TraitAddBuiltinBoundAsSecondBoundFromBuiltin : Send { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddBuiltinBoundAsSecondBoundFromBuiltin: Send + Copy { } @@ -699,16 +695,16 @@ trait TraitAddBuiltinBoundAsSecondBoundFromBuiltin: Send + Copy { } trait TraitAddStaticBoundAsSecondBound : ReferencedTrait0 { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddStaticBoundAsSecondBound : ReferencedTrait0 + 'static { } #[cfg(cfail1)] trait TraitAddStaticBoundAsSecondBoundFromBuiltin : Send { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddStaticBoundAsSecondBoundFromBuiltin : Send + 'static { } @@ -718,8 +714,8 @@ trait TraitAddStaticBoundAsSecondBoundFromBuiltin : Send + 'static { } trait TraitAddTypeParameterToTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddTypeParameterToTrait { } @@ -729,8 +725,8 @@ trait TraitAddTypeParameterToTrait { } trait TraitAddLifetimeParameterToTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeParameterToTrait<'a> { } @@ -740,8 +736,8 @@ trait TraitAddLifetimeParameterToTrait<'a> { } trait TraitAddTraitBoundToTypeParameterOfTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddTraitBoundToTypeParameterOfTrait { } @@ -751,8 +747,8 @@ trait TraitAddTraitBoundToTypeParameterOfTrait { } trait TraitAddLifetimeBoundToTypeParameterOfTrait<'a, T> { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeBoundToTypeParameterOfTrait<'a, T: 'a> { } @@ -762,8 +758,8 @@ trait TraitAddLifetimeBoundToTypeParameterOfTrait<'a, T: 'a> { } trait TraitAddLifetimeBoundToLifetimeParameterOfTrait<'a, 'b> { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeBoundToLifetimeParameterOfTrait<'a: 'b, 'b> { } @@ -773,8 +769,8 @@ trait TraitAddLifetimeBoundToLifetimeParameterOfTrait<'a: 'b, 'b> { } trait TraitAddBuiltinBoundToTypeParameterOfTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddBuiltinBoundToTypeParameterOfTrait { } @@ -784,8 +780,8 @@ trait TraitAddBuiltinBoundToTypeParameterOfTrait { } trait TraitAddSecondTypeParameterToTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSecondTypeParameterToTrait { } @@ -795,8 +791,8 @@ trait TraitAddSecondTypeParameterToTrait { } trait TraitAddSecondLifetimeParameterToTrait<'a> { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSecondLifetimeParameterToTrait<'a, 'b> { } @@ -806,8 +802,8 @@ trait TraitAddSecondLifetimeParameterToTrait<'a, 'b> { } trait TraitAddSecondTraitBoundToTypeParameterOfTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSecondTraitBoundToTypeParameterOfTrait { } @@ -817,8 +813,8 @@ trait TraitAddSecondTraitBoundToTypeParameterOfTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSecondLifetimeBoundToTypeParameterOfTrait<'a, 'b, T: 'a + 'b> { } @@ -828,8 +824,8 @@ trait TraitAddSecondLifetimeBoundToTypeParameterOfTrait<'a, 'b, T: 'a + 'b> { } trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTrait<'a: 'b, 'b, 'c> { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTrait<'a: 'b + 'c, 'b, 'c> { } @@ -839,8 +835,8 @@ trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTrait<'a: 'b + 'c, 'b, 'c> trait TraitAddSecondBuiltinBoundToTypeParameterOfTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSecondBuiltinBoundToTypeParameterOfTrait { } @@ -855,8 +851,8 @@ struct ReferenceType1 {} trait TraitAddTraitBoundToTypeParameterOfTraitWhere { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 { } @@ -866,8 +862,8 @@ trait TraitAddTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> where T: 'a { } @@ -877,8 +873,8 @@ trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> where T: 'a { } trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> where 'a: 'b { } @@ -888,8 +884,8 @@ trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> where 'a: 'b trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere where T: Send { } @@ -899,8 +895,8 @@ trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere where T: Send { } trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 + ReferencedTrait1 { } @@ -911,8 +907,8 @@ trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: 'a { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: 'a + 'b { } @@ -922,8 +918,8 @@ trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> where 'a: 'b { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> where 'a: 'b + 'c { } @@ -933,8 +929,8 @@ trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> whe trait TraitAddSecondBuiltinBoundToTypeParameterOfTraitWhere where T: Send { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] trait TraitAddSecondBuiltinBoundToTypeParameterOfTraitWhere where T: Send + Sync { } @@ -945,11 +941,11 @@ mod change_return_type_of_method_indirectly_use { #[cfg(not(cfail1))] use super::ReferenceType1 as ReturnType; - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] trait TraitChangeReturnType { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method() -> ReturnType; } } @@ -963,11 +959,11 @@ mod change_method_parameter_type_indirectly_by_use { #[cfg(not(cfail1))] use super::ReferenceType1 as ArgType; - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] trait TraitChangeArgType { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(a: ArgType); } } @@ -981,11 +977,11 @@ mod change_method_parameter_type_bound_indirectly_by_use { #[cfg(not(cfail1))] use super::ReferencedTrait1 as Bound; - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] trait TraitChangeBoundOfMethodTypeParameter { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(a: T); } } @@ -1000,11 +996,11 @@ mod change_method_parameter_type_bound_indirectly_by_use_where { #[cfg(not(cfail1))] use super::ReferencedTrait1 as Bound; - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] trait TraitChangeBoundOfMethodTypeParameterWhere { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method(a: T) where T: Bound; } } @@ -1018,8 +1014,8 @@ mod change_method_type_parameter_bound_indirectly { #[cfg(not(cfail1))] use super::ReferencedTrait1 as Bound; - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] trait TraitChangeTraitBound { fn method(a: T); } @@ -1035,8 +1031,8 @@ mod change_method_type_parameter_bound_indirectly_where { #[cfg(not(cfail1))] use super::ReferencedTrait1 as Bound; - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] trait TraitChangeTraitBoundWhere where T: Bound { fn method(a: T); } diff --git a/src/test/incremental/hashes/trait_impls.rs b/src/test/incremental/hashes/trait_impls.rs index e9118da5a613..4cbbb0e6858a 100644 --- a/src/test/incremental/hashes/trait_impls.rs +++ b/src/test/incremental/hashes/trait_impls.rs @@ -30,18 +30,18 @@ impl ChangeMethodNameTrait for Foo { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] pub trait ChangeMethodNameTrait { - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(cfg="cfail3")] fn method_name2(); } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl ChangeMethodNameTrait for Foo { - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(cfg="cfail3")] fn method_name2() { } } @@ -59,13 +59,11 @@ impl ChangeMethodBodyTrait for Foo { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl ChangeMethodBodyTrait for Foo { - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] - #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] + #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method_name() { () } @@ -86,13 +84,11 @@ impl ChangeMethodBodyTraitInlined for Foo { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl ChangeMethodBodyTraitInlined for Foo { - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] - #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_clean(label="hir_owner_nodes", cfg="cfail3")] + #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] #[inline] fn method_name() { panic!() @@ -117,11 +113,11 @@ pub trait ChangeMethodSelfnessTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl ChangeMethodSelfnessTrait for Foo { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method_name(&self) { () } @@ -145,11 +141,11 @@ pub trait RemoveMethodSelfnessTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl RemoveMethodSelfnessTrait for Foo { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method_name() {} } @@ -171,11 +167,11 @@ pub trait ChangeMethodSelfmutnessTrait { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl ChangeMethodSelfmutnessTrait for Foo { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method_name(&mut self) {} } @@ -197,8 +193,8 @@ pub trait ChangeItemKindTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl ChangeItemKindTrait for Foo { type name = (); } @@ -223,8 +219,8 @@ pub trait RemoveItemTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl RemoveItemTrait for Foo { type TypeName = (); } @@ -248,8 +244,8 @@ pub trait AddItemTrait { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl AddItemTrait for Foo { type TypeName = (); fn method_name() { } @@ -268,17 +264,17 @@ impl ChangeHasValueTrait for Foo { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] pub trait ChangeHasValueTrait { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method_name() { } } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl ChangeHasValueTrait for Foo { fn method_name() { } } @@ -295,11 +291,11 @@ impl AddDefaultTrait for Foo { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl AddDefaultTrait for Foo { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] default fn method_name() { } } @@ -321,11 +317,11 @@ pub trait AddArgumentTrait { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl AddArgumentTrait for Foo { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method_name(&self, _x: u32) { } } @@ -347,11 +343,11 @@ pub trait ChangeArgumentTypeTrait { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl ChangeArgumentTypeTrait for Foo { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn method_name(&self, _x: char) { } } @@ -370,11 +366,11 @@ impl AddTypeParameterToImpl for Bar { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl AddTypeParameterToImpl for Bar { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn id(t: T) -> T { t } } @@ -391,11 +387,11 @@ impl ChangeSelfTypeOfImpl for u32 { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl ChangeSelfTypeOfImpl for u64 { - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn id(self) -> Self { self } } @@ -412,11 +408,11 @@ impl AddLifetimeBoundToImplParameter for T { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl AddLifetimeBoundToImplParameter for T { - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn id(self) -> Self { self } } @@ -433,11 +429,11 @@ impl AddTraitBoundToImplParameter for T { } #[cfg(not(cfail1))] -#[rustc_dirty(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl AddTraitBoundToImplParameter for T { - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] fn id(self) -> Self { self } } @@ -454,11 +450,11 @@ impl AddNoMangleToMethod for Foo { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl AddNoMangleToMethod for Foo { - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] #[no_mangle] fn add_no_mangle_to_method(&self) { } } @@ -475,11 +471,11 @@ impl MakeMethodInline for Foo { } #[cfg(not(cfail1))] -#[rustc_clean(label="hir_owner", cfg="cfail2")] -#[rustc_clean(label="hir_owner", cfg="cfail3")] +#[rustc_clean(cfg="cfail2")] +#[rustc_clean(cfg="cfail3")] impl MakeMethodInline for Foo { - #[rustc_clean(label="hir_owner", cfg="cfail2")] - #[rustc_clean(label="hir_owner", cfg="cfail3")] + #[rustc_clean(cfg="cfail2")] + #[rustc_clean(cfg="cfail3")] #[inline] fn make_method_inline(&self) -> u8 { 0 } } diff --git a/src/test/incremental/hello_world.rs b/src/test/incremental/hello_world.rs index 4c60d7bd9d52..d5ec6e92bc0e 100644 --- a/src/test/incremental/hello_world.rs +++ b/src/test/incremental/hello_world.rs @@ -21,7 +21,7 @@ mod x { mod y { use x; - #[rustc_clean(label="typeck", cfg="rpass2")] + #[rustc_clean(cfg="rpass2")] pub fn yyyy() { x::xxxx(); } @@ -30,7 +30,7 @@ mod y { mod z { use y; - #[rustc_clean(label="typeck", cfg="rpass2")] + #[rustc_clean(cfg="rpass2")] pub fn z() { y::yyyy(); } diff --git a/src/test/incremental/hygiene/auxiliary/cached_hygiene.rs b/src/test/incremental/hygiene/auxiliary/cached_hygiene.rs index 91a9f63d39bf..b31f60e972bf 100644 --- a/src/test/incremental/hygiene/auxiliary/cached_hygiene.rs +++ b/src/test/incremental/hygiene/auxiliary/cached_hygiene.rs @@ -13,7 +13,7 @@ macro_rules! first_macro { } } -#[rustc_dirty(label="typeck", cfg="rpass2")] +#[rustc_clean(except="hir_owner_nodes,typeck,optimized_mir,promoted_mir", cfg="rpass2")] #[inline(always)] pub fn changed_fn() { // This will cause additional hygiene to be generate, diff --git a/src/test/incremental/ich_method_call_trait_scope.rs b/src/test/incremental/ich_method_call_trait_scope.rs index 6d7d446cb7c5..5566506c039d 100644 --- a/src/test/incremental/ich_method_call_trait_scope.rs +++ b/src/test/incremental/ich_method_call_trait_scope.rs @@ -26,16 +26,12 @@ mod mod3 { #[cfg(rpass2)] use Trait2; - #[rustc_clean(label="hir_owner", cfg="rpass2")] - #[rustc_clean(label="hir_owner_nodes", cfg="rpass2")] - #[rustc_dirty(label="typeck", cfg="rpass2")] + #[rustc_clean(except="typeck", cfg="rpass2")] fn bar() { ().method(); } - #[rustc_clean(label="hir_owner", cfg="rpass2")] - #[rustc_clean(label="hir_owner_nodes", cfg="rpass2")] - #[rustc_clean(label="typeck", cfg="rpass2")] + #[rustc_clean(cfg="rpass2")] fn baz() { 22; // no method call, traits in scope don't matter } diff --git a/src/test/incremental/ich_nested_items.rs b/src/test/incremental/ich_nested_items.rs index 8df54467e5e5..379c09575edf 100644 --- a/src/test/incremental/ich_nested_items.rs +++ b/src/test/incremental/ich_nested_items.rs @@ -8,14 +8,12 @@ #![crate_type = "rlib"] #![feature(rustc_attrs)] -#[rustc_clean(label = "hir_owner", cfg = "cfail2")] -#[rustc_dirty(label = "hir_owner_nodes", cfg = "cfail2")] +#[rustc_clean(except = "hir_owner_nodes", cfg = "cfail2")] pub fn foo() { #[cfg(cfail1)] pub fn baz() {} // order is different... - #[rustc_clean(label = "hir_owner", cfg = "cfail2")] - #[rustc_clean(label = "hir_owner_nodes", cfg = "cfail2")] + #[rustc_clean(cfg = "cfail2")] pub fn bar() {} // but that doesn't matter. #[cfg(cfail2)] diff --git a/src/test/incremental/ich_resolve_results.rs b/src/test/incremental/ich_resolve_results.rs index 1fb0f8aa84d1..e6ab6bcebae0 100644 --- a/src/test/incremental/ich_resolve_results.rs +++ b/src/test/incremental/ich_resolve_results.rs @@ -29,18 +29,14 @@ mod mod3 { #[cfg(rpass3)] use mod2::Foo; - #[rustc_clean(label="hir_owner", cfg="rpass2")] - #[rustc_clean(label="hir_owner_nodes", cfg="rpass2")] - #[rustc_clean(label="hir_owner", cfg="rpass3")] - #[rustc_dirty(label="hir_owner_nodes", cfg="rpass3")] + #[rustc_clean(cfg="rpass2")] + #[rustc_clean(except="hir_owner_nodes,typeck", cfg="rpass3")] fn in_expr() { Foo(0); } - #[rustc_clean(label="hir_owner", cfg="rpass2")] - #[rustc_clean(label="hir_owner_nodes", cfg="rpass2")] - #[rustc_clean(label="hir_owner", cfg="rpass3")] - #[rustc_dirty(label="hir_owner_nodes", cfg="rpass3")] + #[rustc_clean(cfg="rpass2")] + #[rustc_clean(except="hir_owner_nodes,typeck", cfg="rpass3")] fn in_type() { test::(); } diff --git a/src/test/incremental/rlib_cross_crate/b.rs b/src/test/incremental/rlib_cross_crate/b.rs index 73846712b596..639cfc918cb4 100644 --- a/src/test/incremental/rlib_cross_crate/b.rs +++ b/src/test/incremental/rlib_cross_crate/b.rs @@ -12,15 +12,15 @@ extern crate a; -#[rustc_dirty(label="typeck", cfg="rpass2")] -#[rustc_clean(label="typeck", cfg="rpass3")] +#[rustc_clean(except="typeck,optimized_mir", cfg="rpass2")] +#[rustc_clean(cfg="rpass3")] pub fn use_X() -> u32 { let x: a::X = 22; x as u32 } -#[rustc_clean(label="typeck", cfg="rpass2")] -#[rustc_clean(label="typeck", cfg="rpass3")] +#[rustc_clean(cfg="rpass2")] +#[rustc_clean(cfg="rpass3")] pub fn use_Y() { let x: a::Y = 'c'; } diff --git a/src/test/incremental/source_loc_macros.rs b/src/test/incremental/source_loc_macros.rs index f18d2fdaf0a0..e5f04e5dc581 100644 --- a/src/test/incremental/source_loc_macros.rs +++ b/src/test/incremental/source_loc_macros.rs @@ -7,26 +7,22 @@ #![feature(rustc_attrs)] -#[rustc_clean(label="hir_owner", cfg="rpass2")] -#[rustc_clean(label="hir_owner_nodes", cfg="rpass2")] +#[rustc_clean(cfg="rpass2")] fn line_same() { let _ = line!(); } -#[rustc_clean(label="hir_owner", cfg="rpass2")] -#[rustc_clean(label="hir_owner_nodes", cfg="rpass2")] +#[rustc_clean(cfg="rpass2")] fn col_same() { let _ = column!(); } -#[rustc_clean(label="hir_owner", cfg="rpass2")] -#[rustc_clean(label="hir_owner_nodes", cfg="rpass2")] +#[rustc_clean(cfg="rpass2")] fn file_same() { let _ = file!(); } -#[rustc_clean(label="hir_owner", cfg="rpass2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="rpass2")] +#[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="rpass2")] fn line_different() { #[cfg(rpass1)] { @@ -38,8 +34,7 @@ fn line_different() { } } -#[rustc_clean(label="hir_owner", cfg="rpass2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="rpass2")] +#[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="rpass2")] fn col_different() { #[cfg(rpass1)] { diff --git a/src/test/incremental/span_hash_stable/auxiliary/sub1.rs b/src/test/incremental/span_hash_stable/auxiliary/sub1.rs index 2927ddec4e52..70e2ea06b7ec 100644 --- a/src/test/incremental/span_hash_stable/auxiliary/sub1.rs +++ b/src/test/incremental/span_hash_stable/auxiliary/sub1.rs @@ -1,4 +1,4 @@ -#[rustc_clean(label="hir_owner", cfg="rpass2")] +#[rustc_clean(cfg="rpass2")] pub struct SomeType { pub x: u32, pub y: i64, diff --git a/src/test/incremental/span_hash_stable/auxiliary/sub2.rs b/src/test/incremental/span_hash_stable/auxiliary/sub2.rs index aa635077db8e..1167cdb0a82a 100644 --- a/src/test/incremental/span_hash_stable/auxiliary/sub2.rs +++ b/src/test/incremental/span_hash_stable/auxiliary/sub2.rs @@ -1,4 +1,4 @@ -#[rustc_clean(label="hir_owner", cfg="rpass2")] +#[rustc_clean(cfg="rpass2")] pub struct SomeOtherType { pub a: i32, pub b: u64, diff --git a/src/test/incremental/spans_significant_w_debuginfo.rs b/src/test/incremental/spans_significant_w_debuginfo.rs index aff2be830fff..8506636e22b7 100644 --- a/src/test/incremental/spans_significant_w_debuginfo.rs +++ b/src/test/incremental/spans_significant_w_debuginfo.rs @@ -12,6 +12,5 @@ pub fn main() {} #[cfg(rpass2)] -#[rustc_dirty(label="hir_owner", cfg="rpass2")] -#[rustc_dirty(label="hir_owner_nodes", cfg="rpass2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,optimized_mir", cfg="rpass2")] pub fn main() {} diff --git a/src/test/incremental/spans_significant_w_panic.rs b/src/test/incremental/spans_significant_w_panic.rs index 37728af95164..a29b61ab153d 100644 --- a/src/test/incremental/spans_significant_w_panic.rs +++ b/src/test/incremental/spans_significant_w_panic.rs @@ -13,7 +13,7 @@ pub fn main() { } #[cfg(rpass2)] -#[rustc_dirty(label="optimized_mir", cfg="rpass2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,optimized_mir", cfg="rpass2")] pub fn main() { let _ = 0u8 + 1; } diff --git a/src/test/incremental/string_constant.rs b/src/test/incremental/string_constant.rs index 2fc725294313..866f51d759ec 100644 --- a/src/test/incremental/string_constant.rs +++ b/src/test/incremental/string_constant.rs @@ -18,8 +18,7 @@ pub mod x { } #[cfg(cfail2)] - #[rustc_dirty(label="hir_owner_nodes", cfg="cfail2")] - #[rustc_dirty(label="optimized_mir", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,optimized_mir,promoted_mir", cfg="cfail2")] pub fn x() { println!("{}", "2"); } @@ -28,8 +27,7 @@ pub mod x { pub mod y { use x; - #[rustc_clean(label="typeck", cfg="cfail2")] - #[rustc_clean(label="optimized_mir", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn y() { x::x(); } @@ -38,8 +36,7 @@ pub mod y { pub mod z { use y; - #[rustc_clean(label="typeck", cfg="cfail2")] - #[rustc_clean(label="optimized_mir", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] pub fn z() { y::y(); } diff --git a/src/test/incremental/struct_add_field.rs b/src/test/incremental/struct_add_field.rs index 4c29f196f67c..720854f16052 100644 --- a/src/test/incremental/struct_add_field.rs +++ b/src/test/incremental/struct_add_field.rs @@ -21,17 +21,17 @@ pub struct Y { pub y: char } -#[rustc_dirty(label="typeck", cfg="rpass2")] +#[rustc_clean(except="fn_sig,typeck", cfg="rpass2")] pub fn use_X(x: X) -> u32 { x.x as u32 } -#[rustc_dirty(label="typeck", cfg="rpass2")] +#[rustc_clean(except="typeck", cfg="rpass2")] pub fn use_EmbedX(embed: EmbedX) -> u32 { embed.x.x as u32 } -#[rustc_clean(label="typeck", cfg="rpass2")] +#[rustc_clean(cfg="rpass2")] pub fn use_Y() { let x: Y = Y { y: 'c' }; } diff --git a/src/test/incremental/struct_change_field_name.rs b/src/test/incremental/struct_change_field_name.rs index ee88fbdf5927..7498d0305e0b 100644 --- a/src/test/incremental/struct_change_field_name.rs +++ b/src/test/incremental/struct_change_field_name.rs @@ -24,7 +24,7 @@ pub struct Y { pub y: char } -#[rustc_dirty(label="typeck", cfg="cfail2")] +#[rustc_clean(except="typeck", cfg="cfail2")] pub fn use_X() -> u32 { let x: X = X { x: 22 }; //[cfail2]~^ ERROR struct `X` has no field named `x` @@ -32,13 +32,13 @@ pub fn use_X() -> u32 { //[cfail2]~^ ERROR no field `x` on type `X` } -#[rustc_dirty(label="typeck", cfg="cfail2")] +#[rustc_clean(except="typeck", cfg="cfail2")] pub fn use_EmbedX(embed: EmbedX) -> u32 { embed.x.x as u32 //[cfail2]~^ ERROR no field `x` on type `X` } -#[rustc_clean(label="typeck", cfg="cfail2")] +#[rustc_clean(cfg="cfail2")] pub fn use_Y() { let x: Y = Y { y: 'c' }; } diff --git a/src/test/incremental/struct_change_field_type.rs b/src/test/incremental/struct_change_field_type.rs index b60b4b311eeb..37d2fba9901a 100644 --- a/src/test/incremental/struct_change_field_type.rs +++ b/src/test/incremental/struct_change_field_type.rs @@ -24,19 +24,19 @@ pub struct Y { pub y: char } -#[rustc_dirty(label="typeck", cfg="rpass2")] +#[rustc_clean(except="typeck", cfg="rpass2")] pub fn use_X() -> u32 { let x: X = X { x: 22 }; x.x as u32 } -#[rustc_dirty(label="typeck", cfg="rpass2")] +#[rustc_clean(except="typeck", cfg="rpass2")] pub fn use_EmbedX(x: EmbedX) -> u32 { let x: X = X { x: 22 }; x.x as u32 } -#[rustc_clean(label="typeck", cfg="rpass2")] +#[rustc_clean(cfg="rpass2")] pub fn use_Y() { let x: Y = Y { y: 'c' }; } diff --git a/src/test/incremental/struct_change_field_type_cross_crate/b.rs b/src/test/incremental/struct_change_field_type_cross_crate/b.rs index 0221d510eaba..c78207bcb1a1 100644 --- a/src/test/incremental/struct_change_field_type_cross_crate/b.rs +++ b/src/test/incremental/struct_change_field_type_cross_crate/b.rs @@ -8,18 +8,18 @@ extern crate a; use a::*; -#[rustc_dirty(label="typeck", cfg="rpass2")] +#[rustc_clean(except="typeck", cfg="rpass2")] pub fn use_X() -> u32 { let x: X = X { x: 22 }; x.x as u32 } -#[rustc_dirty(label="typeck", cfg="rpass2")] +#[rustc_clean(except="typeck", cfg="rpass2")] pub fn use_EmbedX(embed: EmbedX) -> u32 { embed.x.x as u32 } -#[rustc_clean(label="typeck", cfg="rpass2")] +#[rustc_clean(cfg="rpass2")] pub fn use_Y() { let x: Y = Y { y: 'c' }; } diff --git a/src/test/incremental/struct_change_nothing.rs b/src/test/incremental/struct_change_nothing.rs index 3ab90e966fb6..de30c818cfe0 100644 --- a/src/test/incremental/struct_change_nothing.rs +++ b/src/test/incremental/struct_change_nothing.rs @@ -24,19 +24,19 @@ pub struct Y { pub y: char } -#[rustc_clean(label="typeck", cfg="rpass2")] +#[rustc_clean(cfg="rpass2")] pub fn use_X() -> u32 { let x: X = X { x: 22 }; x.x as u32 } -#[rustc_clean(label="typeck", cfg="rpass2")] +#[rustc_clean(cfg="rpass2")] pub fn use_EmbedX(x: EmbedX) -> u32 { let x: X = X { x: 22 }; x.x as u32 } -#[rustc_clean(label="typeck", cfg="rpass2")] +#[rustc_clean(cfg="rpass2")] pub fn use_Y() { let x: Y = Y { y: 'c' }; } diff --git a/src/test/incremental/struct_remove_field.rs b/src/test/incremental/struct_remove_field.rs index f6017b1b1c3a..b97a87e09629 100644 --- a/src/test/incremental/struct_remove_field.rs +++ b/src/test/incremental/struct_remove_field.rs @@ -25,17 +25,17 @@ pub struct Y { pub y: char } -#[rustc_dirty(label="typeck", cfg="rpass2")] +#[rustc_clean(except="typeck,fn_sig", cfg="rpass2")] pub fn use_X(x: X) -> u32 { x.x as u32 } -#[rustc_dirty(label="typeck", cfg="rpass2")] +#[rustc_clean(except="typeck", cfg="rpass2")] pub fn use_EmbedX(embed: EmbedX) -> u32 { embed.x.x as u32 } -#[rustc_clean(label="typeck", cfg="rpass2")] +#[rustc_clean(cfg="rpass2")] pub fn use_Y() { let x: Y = Y { y: 'c' }; } diff --git a/src/test/incremental/type_alias_cross_crate/b.rs b/src/test/incremental/type_alias_cross_crate/b.rs index 05c926fdded7..f6c2526841c2 100644 --- a/src/test/incremental/type_alias_cross_crate/b.rs +++ b/src/test/incremental/type_alias_cross_crate/b.rs @@ -6,15 +6,15 @@ extern crate a; -#[rustc_dirty(label="typeck", cfg="rpass2")] -#[rustc_clean(label="typeck", cfg="rpass3")] +#[rustc_clean(except="typeck", cfg="rpass2")] +#[rustc_clean(cfg="rpass3")] pub fn use_X() -> u32 { let x: a::X = 22; x as u32 } -#[rustc_clean(label="typeck", cfg="rpass2")] -#[rustc_clean(label="typeck", cfg="rpass3")] +#[rustc_clean(cfg="rpass2")] +#[rustc_clean(cfg="rpass3")] pub fn use_Y() { let x: a::Y = 'c'; } diff --git a/src/test/incremental/unchecked_dirty_clean.rs b/src/test/incremental/unchecked_dirty_clean.rs index 3bc8818aa6f4..d913342f8254 100644 --- a/src/test/incremental/unchecked_dirty_clean.rs +++ b/src/test/incremental/unchecked_dirty_clean.rs @@ -10,13 +10,13 @@ fn main() { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] //[cfail2]~^ ERROR found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute { // empty block } - #[rustc_clean(label="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] //[cfail2]~^ ERROR found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute { // empty block @@ -24,11 +24,11 @@ fn main() { } struct _Struct { - #[rustc_dirty(label="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner", cfg="cfail2")] //[cfail2]~^ ERROR found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute _field1: i32, - #[rustc_clean(label="hir_owner", cfg="cfail2")] + #[rustc_clean(cfg="cfail2")] //[cfail2]~^ ERROR found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute _field2: i32, } From 175345b8640e774089fd89cddc000f677c4fb316 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 15 May 2021 14:38:32 +0200 Subject: [PATCH 008/441] Fix tests on traits. --- .../src/persist/dirty_clean.rs | 21 +-- src/test/incremental/hashes/trait_defs.rs | 136 +++++++++--------- src/test/incremental/hashes/trait_impls.rs | 49 ++++--- 3 files changed, 107 insertions(+), 99 deletions(-) diff --git a/compiler/rustc_incremental/src/persist/dirty_clean.rs b/compiler/rustc_incremental/src/persist/dirty_clean.rs index b4963e2e4601..1a08d6e58d26 100644 --- a/compiler/rustc_incremental/src/persist/dirty_clean.rs +++ b/compiler/rustc_incremental/src/persist/dirty_clean.rs @@ -100,6 +100,12 @@ const LABELS_FN_IN_TRAIT: &[&[&str]] = /// For generic cases like inline-assembly, modules, etc. const LABELS_HIR_ONLY: &[&[&str]] = &[BASE_HIR]; +/// Impl `DepNode`s. +const LABELS_TRAIT: &[&[&str]] = &[ + BASE_HIR, + &[label_strs::associated_item_def_ids, label_strs::predicates_of, label_strs::generics_of], +]; + /// Impl `DepNode`s. const LABELS_IMPL: &[&[&str]] = &[BASE_HIR, BASE_IMPL]; @@ -259,20 +265,7 @@ impl DirtyCleanVisitor<'tcx> { HirItem::Union(..) => ("ItemUnion", LABELS_ADT), // Represents a Trait Declaration - // FIXME(michaelwoerister): trait declaration is buggy because sometimes some of - // the depnodes don't exist (because they legitimately didn't need to be - // calculated) - // - // michaelwoerister and vitiral came up with a possible solution, - // to just do this before every query - // ``` - // ::rustc_middle::ty::query::plumbing::force_from_dep_node(tcx, dep_node) - // ``` - // - // However, this did not seem to work effectively and more bugs were hit. - // Nebie @vitiral gave up :) - // - //HirItem::Trait(..) => ("ItemTrait", LABELS_TRAIT), + HirItem::Trait(..) => ("ItemTrait", LABELS_TRAIT), // An implementation, eg `impl Trait for Foo { .. }` HirItem::Impl { .. } => ("ItemKind::Impl", LABELS_IMPL), diff --git a/src/test/incremental/hashes/trait_defs.rs b/src/test/incremental/hashes/trait_defs.rs index 73d836484967..a604ca5ca82d 100644 --- a/src/test/incremental/hashes/trait_defs.rs +++ b/src/test/incremental/hashes/trait_defs.rs @@ -48,7 +48,7 @@ trait TraitAddMethod { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] pub trait TraitAddMethod { fn method(); @@ -63,7 +63,7 @@ trait TraitChangeMethodName { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeMethodName { fn methodChanged(); @@ -81,7 +81,7 @@ trait TraitAddReturnType { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddReturnType { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method() -> u32; } @@ -98,7 +98,7 @@ trait TraitChangeReturnType { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeReturnType { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method() -> u64; } @@ -115,7 +115,7 @@ trait TraitAddParameterToMethod { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddParameterToMethod { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(a: u32); } @@ -138,7 +138,7 @@ trait TraitChangeMethodParameterName { #[rustc_clean(cfg="cfail3")] fn method(b: u32); - #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")] + #[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn with_default(y: i32) {} } @@ -155,7 +155,7 @@ trait TraitChangeMethodParameterType { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeMethodParameterType { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(a: i64); } @@ -172,7 +172,7 @@ trait TraitChangeMethodParameterTypeRef { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeMethodParameterTypeRef { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(a: &mut i32); } @@ -189,7 +189,7 @@ trait TraitChangeMethodParametersOrder { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeMethodParametersOrder { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(b: i64, a: i32); } @@ -206,7 +206,7 @@ trait TraitAddMethodAutoImplementation { #[rustc_clean(except="hir_owner", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddMethodAutoImplementation { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,associated_item", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method() { } } @@ -221,7 +221,7 @@ trait TraitChangeOrderOfMethods { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeOrderOfMethods { fn method1(); @@ -240,7 +240,7 @@ trait TraitChangeModeSelfRefToMut { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeModeSelfRefToMut { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(&mut self); } @@ -256,7 +256,7 @@ trait TraitChangeModeSelfOwnToMut: Sized { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeModeSelfOwnToMut: Sized { - #[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,typeck,optimized_mir", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(mut self) {} } @@ -272,7 +272,7 @@ trait TraitChangeModeSelfOwnToRef { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeModeSelfOwnToRef { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,fn_sig,generics_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(&self); } @@ -289,7 +289,7 @@ trait TraitAddUnsafeModifier { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddUnsafeModifier { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] unsafe fn method(); } @@ -306,7 +306,7 @@ trait TraitAddExternModifier { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddExternModifier { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] extern "C" fn method(); } @@ -323,7 +323,7 @@ trait TraitChangeExternCToRustIntrinsic { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeExternCToRustIntrinsic { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] extern "stdcall" fn method(); } @@ -340,7 +340,7 @@ trait TraitAddTypeParameterToMethod { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddTypeParameterToMethod { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,generics_of,predicates_of,type_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(); } @@ -357,7 +357,7 @@ trait TraitAddLifetimeParameterToMethod { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeParameterToMethod { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,fn_sig,generics_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method<'a>(); } @@ -378,7 +378,7 @@ trait TraitAddTraitBoundToMethodTypeParameter { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddTraitBoundToMethodTypeParameter { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(); } @@ -395,7 +395,7 @@ trait TraitAddBuiltinBoundToMethodTypeParameter { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddBuiltinBoundToMethodTypeParameter { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(); } @@ -412,7 +412,10 @@ trait TraitAddLifetimeBoundToMethodLifetimeParameter { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeBoundToMethodLifetimeParameter { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean( + except="hir_owner,hir_owner_nodes,generics_of,predicates_of,fn_sig,type_of", + cfg="cfail2", + )] #[rustc_clean(cfg="cfail3")] fn method<'a, 'b: 'a>(a: &'a u32, b: &'b u32); } @@ -429,7 +432,7 @@ trait TraitAddSecondTraitBoundToMethodTypeParameter { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSecondTraitBoundToMethodTypeParameter { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(); } @@ -446,7 +449,7 @@ trait TraitAddSecondBuiltinBoundToMethodTypeParameter { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSecondBuiltinBoundToMethodTypeParameter { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(); } @@ -463,7 +466,10 @@ trait TraitAddSecondLifetimeBoundToMethodLifetimeParameter { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSecondLifetimeBoundToMethodLifetimeParameter { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean( + except="hir_owner,hir_owner_nodes,generics_of,predicates_of,fn_sig,type_of", + cfg="cfail2", + )] #[rustc_clean(cfg="cfail3")] fn method<'a, 'b, 'c: 'a + 'b>(a: &'a u32, b: &'b u32, c: &'c u32); } @@ -480,7 +486,7 @@ trait TraitAddAssociatedType { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddAssociatedType { type Associated; @@ -547,7 +553,7 @@ trait TraitAddDefaultToAssociatedType { #[rustc_clean(except="hir_owner", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddDefaultToAssociatedType { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,associated_item", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] type Associated = ReferenceType0; @@ -563,7 +569,7 @@ trait TraitAddAssociatedConstant { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddAssociatedConstant { const Value: u32; @@ -585,7 +591,7 @@ trait TraitAddInitializerToAssociatedConstant { #[rustc_clean(except="hir_owner", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddInitializerToAssociatedConstant { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,associated_item", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] const Value: u32 = 1; @@ -608,7 +614,7 @@ trait TraitChangeTypeOfAssociatedConstant { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeTypeOfAssociatedConstant { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,type_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] const Value: f64; @@ -624,7 +630,7 @@ trait TraitChangeTypeOfAssociatedConstant { trait TraitAddSuperTrait { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSuperTrait : ReferencedTrait0 { } @@ -635,7 +641,7 @@ trait TraitAddSuperTrait : ReferencedTrait0 { } trait TraitAddBuiltiBound { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddBuiltiBound : Send { } @@ -646,7 +652,7 @@ trait TraitAddBuiltiBound : Send { } trait TraitAddStaticLifetimeBound { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddStaticLifetimeBound : 'static { } @@ -657,7 +663,7 @@ trait TraitAddStaticLifetimeBound : 'static { } trait TraitAddTraitAsSecondBound : ReferencedTrait0 { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddTraitAsSecondBound : ReferencedTrait0 + ReferencedTrait1 { } @@ -665,7 +671,7 @@ trait TraitAddTraitAsSecondBound : ReferencedTrait0 + ReferencedTrait1 { } trait TraitAddTraitAsSecondBoundFromBuiltin : Send { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddTraitAsSecondBoundFromBuiltin : Send + ReferencedTrait0 { } @@ -676,7 +682,7 @@ trait TraitAddTraitAsSecondBoundFromBuiltin : Send + ReferencedTrait0 { } trait TraitAddBuiltinBoundAsSecondBound : ReferencedTrait0 { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddBuiltinBoundAsSecondBound : ReferencedTrait0 + Send { } @@ -684,7 +690,7 @@ trait TraitAddBuiltinBoundAsSecondBound : ReferencedTrait0 + Send { } trait TraitAddBuiltinBoundAsSecondBoundFromBuiltin : Send { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddBuiltinBoundAsSecondBoundFromBuiltin: Send + Copy { } @@ -695,7 +701,7 @@ trait TraitAddBuiltinBoundAsSecondBoundFromBuiltin: Send + Copy { } trait TraitAddStaticBoundAsSecondBound : ReferencedTrait0 { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddStaticBoundAsSecondBound : ReferencedTrait0 + 'static { } @@ -703,7 +709,7 @@ trait TraitAddStaticBoundAsSecondBound : ReferencedTrait0 + 'static { } trait TraitAddStaticBoundAsSecondBoundFromBuiltin : Send { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddStaticBoundAsSecondBoundFromBuiltin : Send + 'static { } @@ -714,7 +720,7 @@ trait TraitAddStaticBoundAsSecondBoundFromBuiltin : Send + 'static { } trait TraitAddTypeParameterToTrait { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,generics_of,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddTypeParameterToTrait { } @@ -725,7 +731,7 @@ trait TraitAddTypeParameterToTrait { } trait TraitAddLifetimeParameterToTrait { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,generics_of,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeParameterToTrait<'a> { } @@ -736,7 +742,7 @@ trait TraitAddLifetimeParameterToTrait<'a> { } trait TraitAddTraitBoundToTypeParameterOfTrait { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddTraitBoundToTypeParameterOfTrait { } @@ -747,7 +753,7 @@ trait TraitAddTraitBoundToTypeParameterOfTrait { } trait TraitAddLifetimeBoundToTypeParameterOfTrait<'a, T> { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeBoundToTypeParameterOfTrait<'a, T: 'a> { } @@ -758,7 +764,7 @@ trait TraitAddLifetimeBoundToTypeParameterOfTrait<'a, T: 'a> { } trait TraitAddLifetimeBoundToLifetimeParameterOfTrait<'a, 'b> { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeBoundToLifetimeParameterOfTrait<'a: 'b, 'b> { } @@ -769,7 +775,7 @@ trait TraitAddLifetimeBoundToLifetimeParameterOfTrait<'a: 'b, 'b> { } trait TraitAddBuiltinBoundToTypeParameterOfTrait { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddBuiltinBoundToTypeParameterOfTrait { } @@ -780,7 +786,7 @@ trait TraitAddBuiltinBoundToTypeParameterOfTrait { } trait TraitAddSecondTypeParameterToTrait { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSecondTypeParameterToTrait { } @@ -791,7 +797,7 @@ trait TraitAddSecondTypeParameterToTrait { } trait TraitAddSecondLifetimeParameterToTrait<'a> { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSecondLifetimeParameterToTrait<'a, 'b> { } @@ -802,7 +808,7 @@ trait TraitAddSecondLifetimeParameterToTrait<'a, 'b> { } trait TraitAddSecondTraitBoundToTypeParameterOfTrait { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSecondTraitBoundToTypeParameterOfTrait { } @@ -813,7 +819,7 @@ trait TraitAddSecondTraitBoundToTypeParameterOfTrait { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSecondLifetimeBoundToTypeParameterOfTrait<'a, 'b, T: 'a + 'b> { } @@ -824,7 +830,7 @@ trait TraitAddSecondLifetimeBoundToTypeParameterOfTrait<'a, 'b, T: 'a + 'b> { } trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTrait<'a: 'b, 'b, 'c> { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTrait<'a: 'b + 'c, 'b, 'c> { } @@ -835,7 +841,7 @@ trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTrait<'a: 'b + 'c, 'b, 'c> trait TraitAddSecondBuiltinBoundToTypeParameterOfTrait { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSecondBuiltinBoundToTypeParameterOfTrait { } @@ -851,7 +857,7 @@ struct ReferenceType1 {} trait TraitAddTraitBoundToTypeParameterOfTraitWhere { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 { } @@ -862,7 +868,7 @@ trait TraitAddTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> where T: 'a { } @@ -873,7 +879,7 @@ trait TraitAddLifetimeBoundToTypeParameterOfTraitWhere<'a, T> where T: 'a { } trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> where 'a: 'b { } @@ -884,7 +890,7 @@ trait TraitAddLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b> where 'a: 'b trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere where T: Send { } @@ -895,7 +901,7 @@ trait TraitAddBuiltinBoundToTypeParameterOfTraitWhere where T: Send { } trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere where T: ReferencedTrait0 + ReferencedTrait1 { } @@ -907,7 +913,7 @@ trait TraitAddSecondTraitBoundToTypeParameterOfTraitWhere trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: 'a { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,generics_of,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: 'a + 'b { } @@ -918,7 +924,7 @@ trait TraitAddSecondLifetimeBoundToTypeParameterOfTraitWhere<'a, 'b, T> where T: trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> where 'a: 'b { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> where 'a: 'b + 'c { } @@ -929,7 +935,7 @@ trait TraitAddSecondLifetimeBoundToLifetimeParameterOfTraitWhere<'a, 'b, 'c> whe trait TraitAddSecondBuiltinBoundToTypeParameterOfTraitWhere where T: Send { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitAddSecondBuiltinBoundToTypeParameterOfTraitWhere where T: Send + Sync { } @@ -944,7 +950,7 @@ mod change_return_type_of_method_indirectly_use { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeReturnType { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method() -> ReturnType; } @@ -962,7 +968,7 @@ mod change_method_parameter_type_indirectly_by_use { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeArgType { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,fn_sig", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(a: ArgType); } @@ -980,7 +986,7 @@ mod change_method_parameter_type_bound_indirectly_by_use { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeBoundOfMethodTypeParameter { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(a: T); } @@ -999,7 +1005,7 @@ mod change_method_parameter_type_bound_indirectly_by_use_where { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeBoundOfMethodTypeParameterWhere { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method(a: T) where T: Bound; } @@ -1014,7 +1020,7 @@ mod change_method_type_parameter_bound_indirectly { #[cfg(not(cfail1))] use super::ReferencedTrait1 as Bound; - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeTraitBound { fn method(a: T); @@ -1031,7 +1037,7 @@ mod change_method_type_parameter_bound_indirectly_where { #[cfg(not(cfail1))] use super::ReferencedTrait1 as Bound; - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,predicates_of", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] trait TraitChangeTraitBoundWhere where T: Bound { fn method(a: T); diff --git a/src/test/incremental/hashes/trait_impls.rs b/src/test/incremental/hashes/trait_impls.rs index 4cbbb0e6858a..c9a3de1f6ae4 100644 --- a/src/test/incremental/hashes/trait_impls.rs +++ b/src/test/incremental/hashes/trait_impls.rs @@ -30,7 +30,7 @@ impl ChangeMethodNameTrait for Foo { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] pub trait ChangeMethodNameTrait { #[rustc_clean(cfg="cfail3")] @@ -38,7 +38,7 @@ pub trait ChangeMethodNameTrait { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl ChangeMethodNameTrait for Foo { #[rustc_clean(cfg="cfail3")] @@ -62,7 +62,7 @@ impl ChangeMethodBodyTrait for Foo { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl ChangeMethodBodyTrait for Foo { - #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")] + #[rustc_clean(except="hir_owner_nodes,typeck,optimized_mir", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method_name() { () @@ -87,7 +87,7 @@ impl ChangeMethodBodyTraitInlined for Foo { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl ChangeMethodBodyTraitInlined for Foo { - #[rustc_clean(except="hir_owner_nodes", cfg="cfail2")] + #[rustc_clean(except="hir_owner_nodes,typeck,optimized_mir", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] #[inline] fn method_name() { @@ -116,7 +116,10 @@ pub trait ChangeMethodSelfnessTrait { #[rustc_clean(except="hir_owner", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl ChangeMethodSelfnessTrait for Foo { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean( + except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir", + cfg="cfail2", + )] #[rustc_clean(cfg="cfail3")] fn method_name(&self) { () @@ -144,7 +147,10 @@ pub trait RemoveMethodSelfnessTrait { #[rustc_clean(except="hir_owner", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl RemoveMethodSelfnessTrait for Foo { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean( + except="hir_owner,hir_owner_nodes,associated_item,generics_of,fn_sig,typeck,optimized_mir", + cfg="cfail2", + )] #[rustc_clean(cfg="cfail3")] fn method_name() {} } @@ -170,7 +176,7 @@ pub trait ChangeMethodSelfmutnessTrait { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl ChangeMethodSelfmutnessTrait for Foo { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method_name(&mut self) {} } @@ -193,7 +199,7 @@ pub trait ChangeItemKindTrait { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl ChangeItemKindTrait for Foo { type name = (); @@ -219,7 +225,7 @@ pub trait RemoveItemTrait { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl RemoveItemTrait for Foo { type TypeName = (); @@ -244,7 +250,7 @@ pub trait AddItemTrait { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,associated_item_def_ids", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl AddItemTrait for Foo { type TypeName = (); @@ -267,7 +273,7 @@ impl ChangeHasValueTrait for Foo { #[rustc_clean(except="hir_owner", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] pub trait ChangeHasValueTrait { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,associated_item", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method_name() { } } @@ -294,7 +300,7 @@ impl AddDefaultTrait for Foo { #[rustc_clean(except="hir_owner", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl AddDefaultTrait for Foo { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,associated_item", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] default fn method_name() { } } @@ -320,7 +326,7 @@ pub trait AddArgumentTrait { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl AddArgumentTrait for Foo { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method_name(&self, _x: u32) { } } @@ -346,7 +352,7 @@ pub trait ChangeArgumentTypeTrait { #[rustc_clean(cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl ChangeArgumentTypeTrait for Foo { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean(except="hir_owner,hir_owner_nodes,fn_sig,typeck,optimized_mir", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn method_name(&self, _x: char) { } } @@ -366,10 +372,13 @@ impl AddTypeParameterToImpl for Bar { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,generics_of,impl_trait_ref", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl AddTypeParameterToImpl for Bar { - #[rustc_clean(except="hir_owner", cfg="cfail2")] + #[rustc_clean( + except="hir_owner,hir_owner_nodes,generics_of,fn_sig,type_of,typeck,optimized_mir", + cfg="cfail2", + )] #[rustc_clean(cfg="cfail3")] fn id(t: T) -> T { t } } @@ -387,10 +396,10 @@ impl ChangeSelfTypeOfImpl for u32 { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,impl_trait_ref", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl ChangeSelfTypeOfImpl for u64 { - #[rustc_clean(cfg="cfail2")] + #[rustc_clean(except="fn_sig,typeck,optimized_mir", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] fn id(self) -> Self { self } } @@ -408,7 +417,7 @@ impl AddLifetimeBoundToImplParameter for T { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl AddLifetimeBoundToImplParameter for T { #[rustc_clean(cfg="cfail2")] @@ -429,7 +438,7 @@ impl AddTraitBoundToImplParameter for T { } #[cfg(not(cfail1))] -#[rustc_clean(except="hir_owner", cfg="cfail2")] +#[rustc_clean(except="hir_owner,hir_owner_nodes", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] impl AddTraitBoundToImplParameter for T { #[rustc_clean(cfg="cfail2")] From fc069d3241bae47273c969c34fa2d95113dc0b0d Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 16 May 2021 10:14:57 +0200 Subject: [PATCH 009/441] Remove remains of rustc_dirty. --- compiler/rustc_feature/src/builtin_attrs.rs | 4 -- .../src/persist/dirty_clean.rs | 61 ++++++------------- src/test/incremental/dirty_clean.rs | 5 +- src/test/incremental/hashes/enum_defs.rs | 20 +++--- src/test/incremental/hashes/extern_mods.rs | 26 ++++---- src/test/incremental/hashes/inherent_impls.rs | 5 +- src/test/incremental/unchecked_dirty_clean.rs | 10 +-- src/test/ui/dep-graph/dep-graph-check-attr.rs | 2 +- .../ui/dep-graph/dep-graph-check-attr.stderr | 2 +- 9 files changed, 56 insertions(+), 79 deletions(-) diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index a8719be84c2a..987efdc1f7ad 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -567,10 +567,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ rustc_attr!(TEST, rustc_dump_user_substs, AssumedUsed, template!(Word)), rustc_attr!(TEST, rustc_if_this_changed, AssumedUsed, template!(Word, List: "DepNode")), rustc_attr!(TEST, rustc_then_this_would_need, AssumedUsed, template!(List: "DepNode")), - rustc_attr!( - TEST, rustc_dirty, AssumedUsed, - template!(List: r#"cfg = "...", /*opt*/ label = "...", /*opt*/ except = "...""#), - ), rustc_attr!( TEST, rustc_clean, AssumedUsed, template!(List: r#"cfg = "...", /*opt*/ label = "...", /*opt*/ except = "...""#), diff --git a/compiler/rustc_incremental/src/persist/dirty_clean.rs b/compiler/rustc_incremental/src/persist/dirty_clean.rs index 1a08d6e58d26..9abd4eae914b 100644 --- a/compiler/rustc_incremental/src/persist/dirty_clean.rs +++ b/compiler/rustc_incremental/src/persist/dirty_clean.rs @@ -1,6 +1,5 @@ -//! Debugging code to test fingerprints computed for query results. -//! For each node marked with `#[rustc_clean]` or `#[rustc_dirty]`, -//! we will compare the fingerprint from the current and from the previous +//! Debugging code to test fingerprints computed for query results. For each node marked with +//! `#[rustc_clean]` we will compare the fingerprint from the current and from the previous //! compilation session as appropriate: //! //! - `#[rustc_clean(cfg="rev2", except="typeck")]` if we are @@ -132,7 +131,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) { return; } - // can't add `#[rustc_dirty]` etc without opting in to this feature + // can't add `#[rustc_clean]` etc without opting in to this feature if !tcx.features().rustc_attrs { return; } @@ -142,11 +141,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) { let mut dirty_clean_visitor = DirtyCleanVisitor { tcx, checked_attrs: Default::default() }; krate.visit_all_item_likes(&mut dirty_clean_visitor); - let mut all_attrs = FindAllAttrs { - tcx, - attr_names: &[sym::rustc_dirty, sym::rustc_clean], - found_attrs: vec![], - }; + let mut all_attrs = FindAllAttrs { tcx, found_attrs: vec![] }; intravisit::walk_crate(&mut all_attrs, krate); // Note that we cannot use the existing "unused attribute"-infrastructure @@ -164,29 +159,20 @@ pub struct DirtyCleanVisitor<'tcx> { impl DirtyCleanVisitor<'tcx> { /// Possibly "deserialize" the attribute into a clean/dirty assertion fn assertion_maybe(&mut self, item_id: LocalDefId, attr: &Attribute) -> Option { - let is_clean = if self.tcx.sess.check_name(attr, sym::rustc_dirty) { - false - } else if self.tcx.sess.check_name(attr, sym::rustc_clean) { - true - } else { + if !self.tcx.sess.check_name(attr, sym::rustc_clean) { // skip: not rustc_clean/dirty return None; - }; + } if !check_config(self.tcx, attr) { // skip: not the correct `cfg=` return None; } - let assertion = self.assertion_auto(item_id, attr, is_clean); + let assertion = self.assertion_auto(item_id, attr); Some(assertion) } /// Gets the "auto" assertion on pre-validated attr, along with the `except` labels. - fn assertion_auto( - &mut self, - item_id: LocalDefId, - attr: &Attribute, - is_clean: bool, - ) -> Assertion { + fn assertion_auto(&mut self, item_id: LocalDefId, attr: &Attribute) -> Assertion { let (name, mut auto) = self.auto_labels(item_id, attr); let except = self.except(attr); for e in except.iter() { @@ -198,11 +184,7 @@ impl DirtyCleanVisitor<'tcx> { self.tcx.sess.span_fatal(attr.span, &msg); } } - if is_clean { - Assertion { clean: auto, dirty: except } - } else { - Assertion { clean: except, dirty: auto } - } + Assertion { clean: auto, dirty: except } } /// `except=` attribute value @@ -398,9 +380,8 @@ impl ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'tcx> { } } -/// Given a `#[rustc_dirty]` or `#[rustc_clean]` attribute, scan -/// for a `cfg="foo"` attribute and check whether we have a cfg -/// flag called `foo`. +/// Given a `#[rustc_clean]` attribute, scan for a `cfg="foo"` attribute and check whether we have +/// a cfg flag called `foo`. fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool { debug!("check_config(attr={:?})", attr); let config = &tcx.sess.parse_sess.config; @@ -436,21 +417,18 @@ fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol { } } -// A visitor that collects all #[rustc_dirty]/#[rustc_clean] attributes from +// A visitor that collects all #[rustc_clean] attributes from // the HIR. It is used to verify that we really ran checks for all annotated // nodes. -pub struct FindAllAttrs<'a, 'tcx> { +pub struct FindAllAttrs<'tcx> { tcx: TyCtxt<'tcx>, - attr_names: &'a [Symbol], found_attrs: Vec<&'tcx Attribute>, } -impl FindAllAttrs<'_, 'tcx> { +impl FindAllAttrs<'tcx> { fn is_active_attr(&mut self, attr: &Attribute) -> bool { - for attr_name in self.attr_names { - if self.tcx.sess.check_name(attr, *attr_name) && check_config(self.tcx, attr) { - return true; - } + if self.tcx.sess.check_name(attr, sym::rustc_clean) && check_config(self.tcx, attr) { + return true; } false @@ -459,17 +437,14 @@ impl FindAllAttrs<'_, 'tcx> { fn report_unchecked_attrs(&self, mut checked_attrs: FxHashSet) { for attr in &self.found_attrs { if !checked_attrs.contains(&attr.id) { - self.tcx.sess.span_err( - attr.span, - "found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute", - ); + self.tcx.sess.span_err(attr.span, "found unchecked `#[rustc_clean]` attribute"); checked_attrs.insert(attr.id); } } } } -impl intravisit::Visitor<'tcx> for FindAllAttrs<'_, 'tcx> { +impl intravisit::Visitor<'tcx> for FindAllAttrs<'tcx> { type Map = Map<'tcx>; fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap { diff --git a/src/test/incremental/dirty_clean.rs b/src/test/incremental/dirty_clean.rs index 5f7832828a9d..11d999ab3285 100644 --- a/src/test/incremental/dirty_clean.rs +++ b/src/test/incremental/dirty_clean.rs @@ -25,7 +25,10 @@ mod x { mod y { use x; - #[rustc_dirty(except="typeck", cfg="cfail2")] + #[rustc_clean( + except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of,fn_sig", + cfg="cfail2", + )] pub fn y() { //[cfail2]~^ ERROR `hir_owner(y)` should be dirty but is not //[cfail2]~| ERROR `hir_owner_nodes(y)` should be dirty but is not diff --git a/src/test/incremental/hashes/enum_defs.rs b/src/test/incremental/hashes/enum_defs.rs index c73c03ca14e5..76bff3cad388 100644 --- a/src/test/incremental/hashes/enum_defs.rs +++ b/src/test/incremental/hashes/enum_defs.rs @@ -370,7 +370,7 @@ enum EnumChangeNameOfTypeParameter { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")] #[rustc_clean(cfg="cfail3")] enum EnumChangeNameOfTypeParameter { Variant1(T), @@ -386,7 +386,7 @@ enum EnumAddTypeParameter { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddTypeParameter { Variant1(S), @@ -402,7 +402,7 @@ enum EnumChangeNameOfLifetimeParameter<'a> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2", except="predicates_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,type_of")] #[rustc_clean(cfg="cfail3")] enum EnumChangeNameOfLifetimeParameter<'b> { Variant1(&'b u32), @@ -418,7 +418,7 @@ enum EnumAddLifetimeParameter<'a> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2", except="predicates_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,type_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddLifetimeParameter<'a, 'b> { Variant1(&'a u32), @@ -435,7 +435,7 @@ enum EnumAddLifetimeParameterBound<'a, 'b> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2", except="generics_of,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddLifetimeParameterBound<'a, 'b: 'a> { Variant1(&'a u32), @@ -450,7 +450,7 @@ enum EnumAddLifetimeBoundToParameter<'a, T> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2", except="type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddLifetimeBoundToParameter<'a, T: 'a> { Variant1(T), @@ -466,7 +466,7 @@ enum EnumAddTraitBound { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddTraitBound { Variant1(T), @@ -482,7 +482,7 @@ enum EnumAddLifetimeParameterBoundWhere<'a, 'b> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2", except="generics_of,type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,predicates_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddLifetimeParameterBoundWhere<'a, 'b> where 'b: 'a { Variant1(&'a u32), @@ -499,7 +499,7 @@ enum EnumAddLifetimeBoundToParameterWhere<'a, T> { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2", except="type_of")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddLifetimeBoundToParameterWhere<'a, T> where T: 'a { Variant1(T), @@ -515,7 +515,7 @@ enum EnumAddTraitBoundWhere { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg="cfail2")] +#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,generics_of,predicates_of,type_of")] #[rustc_clean(cfg="cfail3")] enum EnumAddTraitBoundWhere where T: Sync { Variant1(T), diff --git a/src/test/incremental/hashes/extern_mods.rs b/src/test/incremental/hashes/extern_mods.rs index 93e70d3792ce..1160bc376c49 100644 --- a/src/test/incremental/hashes/extern_mods.rs +++ b/src/test/incremental/hashes/extern_mods.rs @@ -21,7 +21,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] +#[rustc_clean(cfg = "cfail2", except = "hir_owner")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn change_function_name2(c: i64) -> i32; @@ -34,7 +34,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg = "cfail2")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn change_parameter_name(d: i64) -> i32; @@ -47,7 +47,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg = "cfail2")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn change_parameter_type(c: i32) -> i32; @@ -60,7 +60,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg = "cfail2")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn change_return_type(c: i32) -> i8; @@ -73,7 +73,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg = "cfail2")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn add_parameter(c: i32, d: i32) -> i32; @@ -86,7 +86,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg = "cfail2")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn add_return_type(c: i32) -> i32; @@ -99,7 +99,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg = "cfail2")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn make_function_variadic(c: i32, ...); @@ -112,7 +112,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] +#[rustc_clean(cfg = "cfail2", except = "hir_owner")] #[rustc_clean(cfg = "cfail3")] extern "rust-call" { pub fn change_calling_convention(c: i32); @@ -125,7 +125,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] +#[rustc_clean(cfg = "cfail2", except = "hir_owner")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn make_function_public(c: i32); @@ -138,7 +138,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] +#[rustc_clean(cfg = "cfail2", except = "hir_owner")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn add_function1(c: i32); @@ -153,7 +153,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg = "cfail2")] #[rustc_clean(cfg = "cfail3")] #[link(name = "bar")] extern "C" { @@ -170,7 +170,7 @@ mod indirectly_change_parameter_type { #[cfg(not(cfail1))] use super::c_i64 as c_int; - #[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] + #[rustc_clean(cfg = "cfail2")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn indirectly_change_parameter_type(c: c_int); @@ -184,7 +184,7 @@ mod indirectly_change_return_type { #[cfg(not(cfail1))] use super::c_i64 as c_int; - #[rustc_dirty(cfg = "cfail2", except = "hir_owner,hir_owner_nodes")] + #[rustc_clean(cfg = "cfail2")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn indirectly_change_return_type() -> c_int; diff --git a/src/test/incremental/hashes/inherent_impls.rs b/src/test/incremental/hashes/inherent_impls.rs index 70ce81bd473d..284a95f1a68b 100644 --- a/src/test/incremental/hashes/inherent_impls.rs +++ b/src/test/incremental/hashes/inherent_impls.rs @@ -103,7 +103,10 @@ impl Foo { #[rustc_clean(cfg="cfail2", except="hir_owner")] #[rustc_clean(cfg="cfail3")] impl Foo { - #[rustc_dirty(cfg="cfail2", except="type_of,predicates_of,promoted_mir")] + #[rustc_clean( + cfg="cfail2", + except="hir_owner,hir_owner_nodes,fn_sig,generics_of,typeck,associated_item,optimized_mir", + )] #[rustc_clean(cfg="cfail3")] pub fn method_selfness(&self) { } } diff --git a/src/test/incremental/unchecked_dirty_clean.rs b/src/test/incremental/unchecked_dirty_clean.rs index d913342f8254..3c8692a302dd 100644 --- a/src/test/incremental/unchecked_dirty_clean.rs +++ b/src/test/incremental/unchecked_dirty_clean.rs @@ -4,20 +4,20 @@ #![allow(warnings)] #![feature(rustc_attrs)] -// Sanity check for the dirty-clean system. We add #[rustc_dirty]/#[rustc_clean] +// Sanity check for the dirty-clean system. We add #[rustc_clean] // attributes in places that are not checked and make sure that this causes an // error. fn main() { #[rustc_clean(except="hir_owner", cfg="cfail2")] - //[cfail2]~^ ERROR found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute + //[cfail2]~^ ERROR found unchecked `#[rustc_clean]` attribute { // empty block } #[rustc_clean(cfg="cfail2")] - //[cfail2]~^ ERROR found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute + //[cfail2]~^ ERROR found unchecked `#[rustc_clean]` attribute { // empty block } @@ -25,10 +25,10 @@ fn main() { struct _Struct { #[rustc_clean(except="hir_owner", cfg="cfail2")] - //[cfail2]~^ ERROR found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute + //[cfail2]~^ ERROR found unchecked `#[rustc_clean]` attribute _field1: i32, #[rustc_clean(cfg="cfail2")] - //[cfail2]~^ ERROR found unchecked `#[rustc_dirty]` / `#[rustc_clean]` attribute + //[cfail2]~^ ERROR found unchecked `#[rustc_clean]` attribute _field2: i32, } diff --git a/src/test/ui/dep-graph/dep-graph-check-attr.rs b/src/test/ui/dep-graph/dep-graph-check-attr.rs index 1026efc1b1db..a45bf24f8c1f 100644 --- a/src/test/ui/dep-graph/dep-graph-check-attr.rs +++ b/src/test/ui/dep-graph/dep-graph-check-attr.rs @@ -5,7 +5,7 @@ #![allow(dead_code)] #![allow(unused_variables)] -#[rustc_dirty(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph +#[rustc_clean(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph fn main() {} #[rustc_if_this_changed(hir_owner)] //~ ERROR attribute requires -Z query-dep-graph diff --git a/src/test/ui/dep-graph/dep-graph-check-attr.stderr b/src/test/ui/dep-graph/dep-graph-check-attr.stderr index 945a4237c129..46f4e4358cf6 100644 --- a/src/test/ui/dep-graph/dep-graph-check-attr.stderr +++ b/src/test/ui/dep-graph/dep-graph-check-attr.stderr @@ -1,7 +1,7 @@ error: attribute requires -Z query-dep-graph to be enabled --> $DIR/dep-graph-check-attr.rs:8:1 | -LL | #[rustc_dirty(hir_owner)] +LL | #[rustc_clean(hir_owner)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: attribute requires -Z query-dep-graph to be enabled From 3d8180635289437ac96b20ec94419394194f7c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=C3=A9nore=20Bouttefeux?= Date: Sun, 16 May 2021 17:27:30 +0200 Subject: [PATCH 010/441] remove mode for run and ignore tests --- library/test/src/formatters/pretty.rs | 7 ++++++- library/test/src/formatters/terse.rs | 7 ++++++- library/test/src/types.rs | 4 ++-- src/test/run-make-fulldeps/issue-22131/Makefile | 2 +- src/test/run-make-fulldeps/test-harness/Makefile | 2 +- src/test/rustdoc-ui/cfg-test.stdout | 4 ++-- src/test/rustdoc-ui/doc-test-doctest-feature.stdout | 2 +- src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout | 2 +- src/test/rustdoc-ui/doctest-output.stdout | 6 +++--- src/test/rustdoc-ui/failed-doctest-output.stdout | 4 ++-- src/test/rustdoc-ui/failed-doctest-should-panic.stdout | 2 +- src/test/rustdoc-ui/issue-81662-shortness.stdout | 2 +- src/test/rustdoc-ui/no-run-flag.stdout | 2 +- src/test/rustdoc-ui/run-directory.correct.stdout | 2 +- src/test/rustdoc-ui/run-directory.incorrect.stdout | 2 +- src/test/rustdoc-ui/test-no_std.stdout | 2 +- src/test/rustdoc-ui/test-type.stdout | 6 +++--- src/test/rustdoc-ui/unparseable-doc-test.stdout | 2 +- src/test/ui/test-attrs/test-filter-multiple.run.stdout | 4 ++-- src/test/ui/test-attrs/test-type.run.stdout | 4 ++-- src/test/ui/test-panic-abort-nocapture.run.stdout | 6 +++--- src/test/ui/test-panic-abort.run.stdout | 8 ++++---- src/test/ui/test-passed.run.stdout | 4 ++-- src/test/ui/test-thread-capture.run.stdout | 4 ++-- src/test/ui/test-thread-nocapture.run.stdout | 4 ++-- src/tools/compiletest/src/runtest.rs | 7 +++---- 26 files changed, 55 insertions(+), 46 deletions(-) diff --git a/library/test/src/formatters/pretty.rs b/library/test/src/formatters/pretty.rs index c1a0bb9f3e1e..b3efb2c4437a 100644 --- a/library/test/src/formatters/pretty.rs +++ b/library/test/src/formatters/pretty.rs @@ -169,7 +169,12 @@ impl PrettyFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); - self.write_plain(&format!("test {} - {} ... ", name, desc.test_mode()))?; + let test_mode = desc.test_mode(); + if test_mode == "" { + self.write_plain(&format!("test {} ... ", name))?; + } else { + self.write_plain(&format!("test {} - {} ... ", name, test_mode))?; + } Ok(()) } diff --git a/library/test/src/formatters/terse.rs b/library/test/src/formatters/terse.rs index a9589829ad27..ce73f8d3bfba 100644 --- a/library/test/src/formatters/terse.rs +++ b/library/test/src/formatters/terse.rs @@ -158,7 +158,12 @@ impl TerseFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); - self.write_plain(&format!("test {} - {} ... ", name, desc.test_mode()))?; + let test_mode = desc.test_mode(); + if test_mode == "" { + self.write_plain(&format!("test {} ... ", name))?; + } else { + self.write_plain(&format!("test {} - {} ... ", name, test_mode))?; + } Ok(()) } diff --git a/library/test/src/types.rs b/library/test/src/types.rs index 4cbdc7affc65..baf9908669b6 100644 --- a/library/test/src/types.rs +++ b/library/test/src/types.rs @@ -148,7 +148,7 @@ impl TestDesc { #[cfg(not(bootstrap))] pub fn test_mode(&self) -> &'static str { if self.ignore { - return &"ignore"; + return &""; } match self.should_panic { options::ShouldPanic::Yes | options::ShouldPanic::YesWithMessage(_) => { @@ -165,7 +165,7 @@ impl TestDesc { if self.no_run { return &"compile"; } - &"run" + &"" } #[cfg(bootstrap)] diff --git a/src/test/run-make-fulldeps/issue-22131/Makefile b/src/test/run-make-fulldeps/issue-22131/Makefile index 5f721ef31305..d76aaf5c146d 100644 --- a/src/test/run-make-fulldeps/issue-22131/Makefile +++ b/src/test/run-make-fulldeps/issue-22131/Makefile @@ -4,4 +4,4 @@ all: foo.rs $(RUSTC) --cfg 'feature="bar"' --crate-type lib foo.rs $(RUSTDOC) --test --cfg 'feature="bar"' \ -L $(TMPDIR) foo.rs |\ - $(CGREP) 'foo.rs - foo (line 1) - run ... ok' + $(CGREP) 'foo.rs - foo (line 1) ... ok' diff --git a/src/test/run-make-fulldeps/test-harness/Makefile b/src/test/run-make-fulldeps/test-harness/Makefile index 1f3b112d6afe..39477c07ced7 100644 --- a/src/test/run-make-fulldeps/test-harness/Makefile +++ b/src/test/run-make-fulldeps/test-harness/Makefile @@ -3,6 +3,6 @@ all: # check that #[cfg_attr(..., ignore)] does the right thing. $(RUSTC) --test test-ignore-cfg.rs --cfg ignorecfg - $(call RUN,test-ignore-cfg) | $(CGREP) 'shouldnotignore - run ... ok' 'shouldignore - ignore ... ignored' + $(call RUN,test-ignore-cfg) | $(CGREP) 'shouldnotignore ... ok' 'shouldignore ... ignored' $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -e "^i\.$$" $(call RUN,test-ignore-cfg --quiet) | $(CGREP) -v 'should' diff --git a/src/test/rustdoc-ui/cfg-test.stdout b/src/test/rustdoc-ui/cfg-test.stdout index 42d3fbb48dd8..2960ff8d3b47 100644 --- a/src/test/rustdoc-ui/cfg-test.stdout +++ b/src/test/rustdoc-ui/cfg-test.stdout @@ -1,7 +1,7 @@ running 2 tests -test $DIR/cfg-test.rs - Bar (line 27) - run ... ok -test $DIR/cfg-test.rs - Foo (line 19) - run ... ok +test $DIR/cfg-test.rs - Bar (line 27) ... ok +test $DIR/cfg-test.rs - Foo (line 19) ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/doc-test-doctest-feature.stdout b/src/test/rustdoc-ui/doc-test-doctest-feature.stdout index cfcb60332f46..d7de1f105228 100644 --- a/src/test/rustdoc-ui/doc-test-doctest-feature.stdout +++ b/src/test/rustdoc-ui/doc-test-doctest-feature.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/doc-test-doctest-feature.rs - Foo (line 9) - run ... ok +test $DIR/doc-test-doctest-feature.rs - Foo (line 9) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout b/src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout index 8d7f1ad21d1d..5b07fc4c87af 100644 --- a/src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout +++ b/src/test/rustdoc-ui/doc-test-rustdoc-feature.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/doc-test-rustdoc-feature.rs - Foo (line 10) - run ... ok +test $DIR/doc-test-rustdoc-feature.rs - Foo (line 10) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/doctest-output.stdout b/src/test/rustdoc-ui/doctest-output.stdout index 7a07d273e269..35b0e366fb5c 100644 --- a/src/test/rustdoc-ui/doctest-output.stdout +++ b/src/test/rustdoc-ui/doctest-output.stdout @@ -1,8 +1,8 @@ running 3 tests -test $DIR/doctest-output.rs - (line 8) - run ... ok -test $DIR/doctest-output.rs - ExpandedStruct (line 24) - run ... ok -test $DIR/doctest-output.rs - foo::bar (line 18) - run ... ok +test $DIR/doctest-output.rs - (line 8) ... ok +test $DIR/doctest-output.rs - ExpandedStruct (line 24) ... ok +test $DIR/doctest-output.rs - foo::bar (line 18) ... ok test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index 7ba599ff11b9..6dfe648f8549 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -1,7 +1,7 @@ running 2 tests -test $DIR/failed-doctest-output.rs - OtherStruct (line 22) - run ... FAILED -test $DIR/failed-doctest-output.rs - SomeStruct (line 12) - run ... FAILED +test $DIR/failed-doctest-output.rs - OtherStruct (line 22) ... FAILED +test $DIR/failed-doctest-output.rs - SomeStruct (line 12) ... FAILED failures: diff --git a/src/test/rustdoc-ui/failed-doctest-should-panic.stdout b/src/test/rustdoc-ui/failed-doctest-should-panic.stdout index 6bd21423e69e..57a20092a5d6 100644 --- a/src/test/rustdoc-ui/failed-doctest-should-panic.stdout +++ b/src/test/rustdoc-ui/failed-doctest-should-panic.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/failed-doctest-should-panic.rs - Foo (line 9) - run ... FAILED +test $DIR/failed-doctest-should-panic.rs - Foo (line 9) ... FAILED failures: diff --git a/src/test/rustdoc-ui/issue-81662-shortness.stdout b/src/test/rustdoc-ui/issue-81662-shortness.stdout index f9fdf7048d88..748113be3a26 100644 --- a/src/test/rustdoc-ui/issue-81662-shortness.stdout +++ b/src/test/rustdoc-ui/issue-81662-shortness.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/issue-81662-shortness.rs - foo (line 6) - run ... FAILED +test $DIR/issue-81662-shortness.rs - foo (line 6) ... FAILED failures: diff --git a/src/test/rustdoc-ui/no-run-flag.stdout b/src/test/rustdoc-ui/no-run-flag.stdout index 22d927317b31..02f28aaf60da 100644 --- a/src/test/rustdoc-ui/no-run-flag.stdout +++ b/src/test/rustdoc-ui/no-run-flag.stdout @@ -1,7 +1,7 @@ running 7 tests test $DIR/no-run-flag.rs - f (line 11) - compile ... ok -test $DIR/no-run-flag.rs - f (line 14) - ignore ... ignored +test $DIR/no-run-flag.rs - f (line 14) ... ignored test $DIR/no-run-flag.rs - f (line 17) - compile ... ok test $DIR/no-run-flag.rs - f (line 23) - compile fail ... ok test $DIR/no-run-flag.rs - f (line 28) - compile ... ok diff --git a/src/test/rustdoc-ui/run-directory.correct.stdout b/src/test/rustdoc-ui/run-directory.correct.stdout index 1bb84a868a41..e9b2754794a7 100644 --- a/src/test/rustdoc-ui/run-directory.correct.stdout +++ b/src/test/rustdoc-ui/run-directory.correct.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/run-directory.rs - foo (line 10) - run ... ok +test $DIR/run-directory.rs - foo (line 10) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/run-directory.incorrect.stdout b/src/test/rustdoc-ui/run-directory.incorrect.stdout index 7f6bba8fe471..97a5dbc5c0cd 100644 --- a/src/test/rustdoc-ui/run-directory.incorrect.stdout +++ b/src/test/rustdoc-ui/run-directory.incorrect.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/run-directory.rs - foo (line 19) - run ... ok +test $DIR/run-directory.rs - foo (line 19) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/test-no_std.stdout b/src/test/rustdoc-ui/test-no_std.stdout index 35d44fa6bbd0..8d5a30804c1e 100644 --- a/src/test/rustdoc-ui/test-no_std.stdout +++ b/src/test/rustdoc-ui/test-no_std.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/test-no_std.rs - f (line 10) - run ... ok +test $DIR/test-no_std.rs - f (line 10) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/test-type.stdout b/src/test/rustdoc-ui/test-type.stdout index fb6c036a6081..a66fd240d34c 100644 --- a/src/test/rustdoc-ui/test-type.stdout +++ b/src/test/rustdoc-ui/test-type.stdout @@ -1,10 +1,10 @@ running 5 tests -test $DIR/test-type.rs - f (line 12) - ignore ... ignored +test $DIR/test-type.rs - f (line 12) ... ignored test $DIR/test-type.rs - f (line 15) - compile ... ok test $DIR/test-type.rs - f (line 21) - compile fail ... ok -test $DIR/test-type.rs - f (line 6) - run ... ok -test $DIR/test-type.rs - f (line 9) - run ... ok +test $DIR/test-type.rs - f (line 6) ... ok +test $DIR/test-type.rs - f (line 9) ... ok test result: ok. 4 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/rustdoc-ui/unparseable-doc-test.stdout b/src/test/rustdoc-ui/unparseable-doc-test.stdout index 13526acfc479..2641c66f25e7 100644 --- a/src/test/rustdoc-ui/unparseable-doc-test.stdout +++ b/src/test/rustdoc-ui/unparseable-doc-test.stdout @@ -1,6 +1,6 @@ running 1 test -test $DIR/unparseable-doc-test.rs - foo (line 7) - run ... FAILED +test $DIR/unparseable-doc-test.rs - foo (line 7) ... FAILED failures: diff --git a/src/test/ui/test-attrs/test-filter-multiple.run.stdout b/src/test/ui/test-attrs/test-filter-multiple.run.stdout index 5d6d5cbd3c3f..1aa684ed5073 100644 --- a/src/test/ui/test-attrs/test-filter-multiple.run.stdout +++ b/src/test/ui/test-attrs/test-filter-multiple.run.stdout @@ -1,7 +1,7 @@ running 2 tests -test test1 - run ... ok -test test2 - run ... ok +test test1 ... ok +test test2 ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in $TIME diff --git a/src/test/ui/test-attrs/test-type.run.stdout b/src/test/ui/test-attrs/test-type.run.stdout index 9f789526615d..be2fd8ae68c3 100644 --- a/src/test/ui/test-attrs/test-type.run.stdout +++ b/src/test/ui/test-attrs/test-type.run.stdout @@ -1,7 +1,7 @@ running 3 tests -test test_no_run - ignore ... ignored -test test_ok - run ... ok +test test_no_run ... ignored +test test_ok ... ok test test_panic - should panic ... ok test result: ok. 2 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/ui/test-panic-abort-nocapture.run.stdout b/src/test/ui/test-panic-abort-nocapture.run.stdout index e335cf05153b..8a91732a754a 100644 --- a/src/test/ui/test-panic-abort-nocapture.run.stdout +++ b/src/test/ui/test-panic-abort-nocapture.run.stdout @@ -1,12 +1,12 @@ running 4 tests -test it_fails - run ... about to fail +test it_fails ... about to fail FAILED test it_panics - should panic ... about to panic ok -test it_works - run ... about to succeed +test it_works ... about to succeed ok -test it_writes_to_stdio - run ... hello, world +test it_writes_to_stdio ... hello, world testing123 ok diff --git a/src/test/ui/test-panic-abort.run.stdout b/src/test/ui/test-panic-abort.run.stdout index 0d9de10c9818..f608a8cdc556 100644 --- a/src/test/ui/test-panic-abort.run.stdout +++ b/src/test/ui/test-panic-abort.run.stdout @@ -1,10 +1,10 @@ running 5 tests -test it_exits - run ... FAILED -test it_fails - run ... FAILED +test it_exits ... FAILED +test it_fails ... FAILED test it_panics - should panic ... ok -test it_works - run ... ok -test no_residual_environment - run ... ok +test it_works ... ok +test no_residual_environment ... ok failures: diff --git a/src/test/ui/test-passed.run.stdout b/src/test/ui/test-passed.run.stdout index 995643a62c88..17f70d607494 100644 --- a/src/test/ui/test-passed.run.stdout +++ b/src/test/ui/test-passed.run.stdout @@ -1,7 +1,7 @@ running 2 tests -test it_works - run ... ok -test it_works_too - run ... ok +test it_works ... ok +test it_works_too ... ok test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME diff --git a/src/test/ui/test-thread-capture.run.stdout b/src/test/ui/test-thread-capture.run.stdout index ce9ec63b526c..487cfb55eb47 100644 --- a/src/test/ui/test-thread-capture.run.stdout +++ b/src/test/ui/test-thread-capture.run.stdout @@ -1,7 +1,7 @@ running 2 tests -test thready_fail - run ... FAILED -test thready_pass - run ... ok +test thready_fail ... FAILED +test thready_pass ... ok failures: diff --git a/src/test/ui/test-thread-nocapture.run.stdout b/src/test/ui/test-thread-nocapture.run.stdout index bd1971ab7d31..9d2da50826c2 100644 --- a/src/test/ui/test-thread-nocapture.run.stdout +++ b/src/test/ui/test-thread-nocapture.run.stdout @@ -1,11 +1,11 @@ running 2 tests -test thready_fail - run ... fee +test thready_fail ... fee fie foe fum FAILED -test thready_pass - run ... fee +test thready_pass ... fee fie foe fum diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 0898e9ef2f63..18c40a037c57 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2637,12 +2637,11 @@ impl<'test> TestCx<'test> { let mut tested = 0; for _ in res.stdout.split('\n').filter(|s| s.starts_with("test ")).inspect(|s| { - let tmp: Vec<&str> = s.split(" - ").collect(); - if tmp.len() == 3 { - let path = tmp[0].rsplit("test ").next().unwrap(); + if let Some((left, right)) = s.split_once(" - ") { + let path = left.rsplit("test ").next().unwrap(); if let Some(ref mut v) = files.get_mut(&path.replace('\\', "/")) { tested += 1; - let mut iter = tmp[1].split("(line "); + let mut iter = right.split("(line "); iter.next(); let line = iter .next() From a36c6361999ff23d604a5a0e7d06611ad31b6262 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 18 May 2021 07:48:00 -0400 Subject: [PATCH 011/441] Avoid cloning cache key --- compiler/rustc_data_structures/src/obligation_forest/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_data_structures/src/obligation_forest/mod.rs b/compiler/rustc_data_structures/src/obligation_forest/mod.rs index 29d685ab530d..74ceed67807a 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/mod.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/mod.rs @@ -342,7 +342,7 @@ impl ObligationForest { return Ok(()); } - match self.active_cache.entry(cache_key.clone()) { + match self.active_cache.entry(cache_key) { Entry::Occupied(o) => { let node = &mut self.nodes[*o.get()]; if let Some(parent_index) = parent { @@ -366,7 +366,7 @@ impl ObligationForest { && self .error_cache .get(&obligation_tree_id) - .map(|errors| errors.contains(&cache_key)) + .map(|errors| errors.contains(v.key())) .unwrap_or(false); if already_failed { From 42b9d3fb723f33d903e1ef54a3f2439153b3a552 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Tue, 18 May 2021 10:37:42 -0400 Subject: [PATCH 012/441] Simplify `map | unwrap_or` to `map_or` --- compiler/rustc_data_structures/src/obligation_forest/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/rustc_data_structures/src/obligation_forest/mod.rs b/compiler/rustc_data_structures/src/obligation_forest/mod.rs index 74ceed67807a..d8f23aeabc10 100644 --- a/compiler/rustc_data_structures/src/obligation_forest/mod.rs +++ b/compiler/rustc_data_structures/src/obligation_forest/mod.rs @@ -366,8 +366,7 @@ impl ObligationForest { && self .error_cache .get(&obligation_tree_id) - .map(|errors| errors.contains(v.key())) - .unwrap_or(false); + .map_or(false, |errors| errors.contains(v.key())); if already_failed { Err(()) From 6de13c3ffc969ceac87f2a8466c5cd850288721c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=C3=A9nore=20Bouttefeux?= Date: Tue, 18 May 2021 18:17:36 +0200 Subject: [PATCH 013/441] change based on review --- library/test/src/formatters/pretty.rs | 7 +++---- library/test/src/formatters/terse.rs | 7 +++---- library/test/src/types.rs | 20 +++++++++++--------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/library/test/src/formatters/pretty.rs b/library/test/src/formatters/pretty.rs index b3efb2c4437a..e17fc08a9ae9 100644 --- a/library/test/src/formatters/pretty.rs +++ b/library/test/src/formatters/pretty.rs @@ -169,11 +169,10 @@ impl PrettyFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); - let test_mode = desc.test_mode(); - if test_mode == "" { - self.write_plain(&format!("test {} ... ", name))?; - } else { + if let Some(test_mode) = desc.test_mode() { self.write_plain(&format!("test {} - {} ... ", name, test_mode))?; + } else { + self.write_plain(&format!("test {} ... ", name))?; } Ok(()) diff --git a/library/test/src/formatters/terse.rs b/library/test/src/formatters/terse.rs index ce73f8d3bfba..a2c223c494c2 100644 --- a/library/test/src/formatters/terse.rs +++ b/library/test/src/formatters/terse.rs @@ -158,11 +158,10 @@ impl TerseFormatter { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); - let test_mode = desc.test_mode(); - if test_mode == "" { - self.write_plain(&format!("test {} ... ", name))?; - } else { + if let Some(test_mode) = desc.test_mode() { self.write_plain(&format!("test {} - {} ... ", name, test_mode))?; + } else { + self.write_plain(&format!("test {} ... ", name))?; } Ok(()) diff --git a/library/test/src/types.rs b/library/test/src/types.rs index baf9908669b6..63907c71ea7c 100644 --- a/library/test/src/types.rs +++ b/library/test/src/types.rs @@ -145,32 +145,34 @@ impl TestDesc { } } + /// Returns None for ignored test or that that are just run, otherwise give a description of the type of test. + /// Descriptions include "should panic", "compile fail" and "compile". #[cfg(not(bootstrap))] - pub fn test_mode(&self) -> &'static str { + pub fn test_mode(&self) -> Option<&'static str> { if self.ignore { - return &""; + return None; } match self.should_panic { options::ShouldPanic::Yes | options::ShouldPanic::YesWithMessage(_) => { - return &"should panic"; + return Some("should panic"); } options::ShouldPanic::No => {} } if self.allow_fail { - return &"allow fail"; + return Some("allow fail"); } if self.compile_fail { - return &"compile fail"; + return Some("compile fail"); } if self.no_run { - return &"compile"; + return Some("compile"); } - &"" + None } #[cfg(bootstrap)] - pub fn test_mode(&self) -> &'static str { - &"" + pub fn test_mode(&self) -> Option<&'static str> { + None } } From 96a5e6b01e4e6994cff52edfc2d56729ea00894b Mon Sep 17 00:00:00 2001 From: Ximin Luo Date: Wed, 19 May 2021 15:39:50 +0100 Subject: [PATCH 014/441] fix split-debuginfo error message --- compiler/rustc_session/src/options.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index c9f95ed1224d..bb82cf4c45d6 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -368,7 +368,7 @@ mod desc { pub const parse_target_feature: &str = parse_string; pub const parse_wasi_exec_model: &str = "either `command` or `reactor`"; pub const parse_split_debuginfo: &str = - "one of supported split-debuginfo modes (`off` or `dsymutil`)"; + "one of supported split-debuginfo modes (`off`, `packed`, or `unpacked`)"; } mod parse { From 375ca93c475732fa71feacb6d7f65ca191dfa170 Mon Sep 17 00:00:00 2001 From: Liigo Zhuang Date: Thu, 20 May 2021 14:54:28 +0800 Subject: [PATCH 015/441] rustdoc: add tooltips to some buttons --- src/librustdoc/html/layout.rs | 6 +++--- src/librustdoc/html/render/print_item.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index ec04c94dc11f..5d6056b0546b 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -87,7 +87,7 @@ crate fn render( {sidebar}\ \
\ -
\ - -
\ + + \ \"Change\ diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index bac9c21f0f39..5799f5859cef 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -78,7 +78,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer, write!(buf, "{}", item.type_(), item.name.as_ref().unwrap()); write!( buf, - "", static_root_path = page.get_static_root_path(), suffix = page.resource_suffix, From f49251a33e8fb8519c8aa03893962b67152d676e Mon Sep 17 00:00:00 2001 From: flip1995 Date: Mon, 31 May 2021 17:09:21 +0200 Subject: [PATCH 156/441] Remove util/cov.sh script This script hasn't been working and wasn't used for years. --- util/cov.sh | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100755 util/cov.sh diff --git a/util/cov.sh b/util/cov.sh deleted file mode 100755 index 3f9a6b06f725..000000000000 --- a/util/cov.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/bash - -# This run `kcov` on Clippy. The coverage report will be at -# `./target/cov/index.html`. -# `compile-test` is special. `kcov` does not work directly on it so these files -# are compiled manually. - -tests=$(find tests/ -maxdepth 1 -name '*.rs' ! -name compile-test.rs -exec basename {} .rs \;) -tmpdir=$(mktemp -d) - -cargo test --no-run --verbose - -for t in $tests; do - kcov \ - --verify \ - --include-path="$(pwd)/src,$(pwd)/clippy_lints/src" \ - "$tmpdir/$t" \ - cargo test --test "$t" -done - -for t in ./tests/compile-fail/*.rs; do - kcov \ - --verify \ - --include-path="$(pwd)/src,$(pwd)/clippy_lints/src" \ - "$tmpdir/compile-fail-$(basename "$t")" \ - cargo run -- -L target/debug -L target/debug/deps -Z no-trans "$t" -done - -for t in ./tests/run-pass/*.rs; do - kcov \ - --verify \ - --include-path="$(pwd)/src,$(pwd)/clippy_lints/src" \ - "$tmpdir/run-pass-$(basename "$t")" \ - cargo run -- -L target/debug -L target/debug/deps -Z no-trans "$t" -done - -kcov --verify --merge target/cov "$tmpdir"/* From 2970479412783b39aab3792525cb926a609a2d3c Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Mon, 31 May 2021 23:18:53 +0800 Subject: [PATCH 157/441] Fix details rustdoc toggle for blanket impl In the meantime, allow all of the details to have the same top. --- src/librustdoc/html/static/rustdoc.css | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index f3866e211d95..2623ff27a257 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -1468,13 +1468,12 @@ details.rustdoc-toggle > summary.hideme::before { details.rustdoc-toggle > summary:not(.hideme)::before { position: absolute; left: -23px; - top: initial; + top: 3px; } .impl-items > details.rustdoc-toggle > summary:not(.hideme)::before, .undocumented > details.rustdoc-toggle > summary:not(.hideme)::before { position: absolute; - top: 3px; left: -2px; } From a258feb6eb2b069dcb36763513f9f2f98aee04eb Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 31 May 2021 11:53:46 -0500 Subject: [PATCH 158/441] Bump Miri for const_err changes r? @RalfJung --- Cargo.lock | 5 +++-- src/tools/miri | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 954e2e90f3de..df7d84419414 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2135,9 +2135,9 @@ dependencies = [ [[package]] name = "measureme" -version = "9.1.1" +version = "9.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49cf14eb7d2eea897d9949b68f19e165638755e3a1a3c0941b6b6c3e00141f2c" +checksum = "78f7a41bc6f856a2cf0e95094ad5121f82500e2d9a0f3c0171d98f6566d8117d" dependencies = [ "log", "memmap2", @@ -2289,6 +2289,7 @@ dependencies = [ "hex 0.4.2", "libc", "log", + "measureme", "rand 0.8.3", "rustc-workspace-hack", "rustc_version", diff --git a/src/tools/miri b/src/tools/miri index 4fa9363ebba2..453affaaa176 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit 4fa9363ebba236f7c29ae11180db6051d7d2ce3b +Subproject commit 453affaaa1762a065d2857970b8333017211208c From c902fdca459a9ee31a6ea81236cb250bc037255b Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Mon, 31 May 2021 19:18:20 +0200 Subject: [PATCH 159/441] Remove unnecessary SpecFromIter impls --- library/alloc/src/vec/spec_from_iter.rs | 31 ------------------------- 1 file changed, 31 deletions(-) diff --git a/library/alloc/src/vec/spec_from_iter.rs b/library/alloc/src/vec/spec_from_iter.rs index bbfcc68daeff..d7a957d85ff8 100644 --- a/library/alloc/src/vec/spec_from_iter.rs +++ b/library/alloc/src/vec/spec_from_iter.rs @@ -1,6 +1,5 @@ use core::mem::ManuallyDrop; use core::ptr::{self}; -use core::slice::{self}; use super::{IntoIter, SpecExtend, SpecFromIterNested, Vec}; @@ -65,33 +64,3 @@ impl SpecFromIter> for Vec { vec } } - -impl<'a, T: 'a, I> SpecFromIter<&'a T, I> for Vec -where - I: Iterator, - T: Clone, -{ - default fn from_iter(iterator: I) -> Self { - SpecFromIter::from_iter(iterator.cloned()) - } -} - -// This utilizes `iterator.as_slice().to_vec()` since spec_extend -// must take more steps to reason about the final capacity + length -// and thus do more work. `to_vec()` directly allocates the correct amount -// and fills it exactly. -impl<'a, T: 'a + Clone> SpecFromIter<&'a T, slice::Iter<'a, T>> for Vec { - #[cfg(not(test))] - fn from_iter(iterator: slice::Iter<'a, T>) -> Self { - iterator.as_slice().to_vec() - } - - // HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is - // required for this method definition, is not available. Instead use the - // `slice::to_vec` function which is only available with cfg(test) - // NB see the slice::hack module in slice.rs for more information - #[cfg(test)] - fn from_iter(iterator: slice::Iter<'a, T>) -> Self { - crate::slice::to_vec(iterator.as_slice(), crate::alloc::Global) - } -} From 5ea3e733cbd2e4810e00c3e7420d1019456b8970 Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Mon, 31 May 2021 21:07:03 +0200 Subject: [PATCH 160/441] Update documentation of SpecFromIter to reflect the removed impls --- library/alloc/src/vec/spec_from_iter.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/library/alloc/src/vec/spec_from_iter.rs b/library/alloc/src/vec/spec_from_iter.rs index d7a957d85ff8..efa6868473e4 100644 --- a/library/alloc/src/vec/spec_from_iter.rs +++ b/library/alloc/src/vec/spec_from_iter.rs @@ -18,9 +18,7 @@ use super::{IntoIter, SpecExtend, SpecFromIterNested, Vec}; /// |where I: | | |where I: | /// | Iterator (default)----------+ | | Iterator (default) | /// | vec::IntoIter | | | TrustedLen | -/// | SourceIterMarker---fallback-+ | | | -/// | slice::Iter | | | -/// | Iterator | +---------------------+ +/// | SourceIterMarker---fallback-+ | +---------------------+ /// +---------------------------------+ /// ``` pub(super) trait SpecFromIter { From a0228d9b877591d2b94484b1ff9d433e6f0a5d32 Mon Sep 17 00:00:00 2001 From: est31 Date: Tue, 1 Jun 2021 05:04:48 +0200 Subject: [PATCH 161/441] Intra doc link-ify a reference to a function --- library/core/src/num/f32.rs | 4 ++-- library/core/src/num/f64.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 77132cddca27..c47a2e8b05c4 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -727,8 +727,8 @@ impl f32 { /// /// This is currently identical to `transmute::(self)` on all platforms. /// - /// See `from_bits` for some discussion of the portability of this operation - /// (there are almost no issues). + /// See [`from_bits`](Self::from_bits) for some discussion of the + /// portability of this operation (there are almost no issues). /// /// Note that this function is distinct from `as` casting, which attempts to /// preserve the *numeric* value, and not the bitwise value. diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index 4c3f1fd16a0d..cfcc08b9adde 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -741,8 +741,8 @@ impl f64 { /// /// This is currently identical to `transmute::(self)` on all platforms. /// - /// See `from_bits` for some discussion of the portability of this operation - /// (there are almost no issues). + /// See [`from_bits`](Self::from_bits) for some discussion of the + /// portability of this operation (there are almost no issues). /// /// Note that this function is distinct from `as` casting, which attempts to /// preserve the *numeric* value, and not the bitwise value. From 92839563506163bc1bfb9d137782649c8b527bb1 Mon Sep 17 00:00:00 2001 From: csmoe Date: Tue, 1 Jun 2021 13:59:17 +0800 Subject: [PATCH 162/441] skip check_static on rvalue::threadlocalref --- .../src/transform/check_consts/validation.rs | 6 ++- src/test/ui/thread-local-static.rs | 16 +++++++ src/test/ui/thread-local-static.stderr | 45 +++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/thread-local-static.rs create mode 100644 src/test/ui/thread-local-static.stderr diff --git a/compiler/rustc_mir/src/transform/check_consts/validation.rs b/compiler/rustc_mir/src/transform/check_consts/validation.rs index 41d9d0d04b50..9538d2fdd4da 100644 --- a/compiler/rustc_mir/src/transform/check_consts/validation.rs +++ b/compiler/rustc_mir/src/transform/check_consts/validation.rs @@ -732,7 +732,11 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> { if proj_base.is_empty() { if let (local, []) = (place_local, proj_base) { let decl = &self.body.local_decls[local]; - if let Some(box LocalInfo::StaticRef { def_id, .. }) = decl.local_info { + if let Some(box LocalInfo::StaticRef { + def_id, + is_thread_local: false, + }) = decl.local_info + { let span = decl.source_info.span; self.check_static(def_id, span); return; diff --git a/src/test/ui/thread-local-static.rs b/src/test/ui/thread-local-static.rs new file mode 100644 index 000000000000..7f4ead36cd0f --- /dev/null +++ b/src/test/ui/thread-local-static.rs @@ -0,0 +1,16 @@ +// edition:2018 + +#![feature(thread_local)] +#![feature(const_swap)] +#[thread_local] +static mut STATIC_VAR_2: [u32; 8] = [4; 8]; +const fn g(x: &mut [u32; 8]) { + //~^ ERROR mutable references are not allowed + std::mem::swap(x, &mut STATIC_VAR_2) + //~^ ERROR thread-local statics cannot be accessed + //~| ERROR dereferencing raw pointers in constant + //~| ERROR mutable references are not allowed + //~| ERROR use of mutable static is unsafe +} + +fn main() {} diff --git a/src/test/ui/thread-local-static.stderr b/src/test/ui/thread-local-static.stderr new file mode 100644 index 000000000000..ed461fcb7e2f --- /dev/null +++ b/src/test/ui/thread-local-static.stderr @@ -0,0 +1,45 @@ +error[E0658]: mutable references are not allowed in constant functions + --> $DIR/thread-local-static.rs:7:12 + | +LL | const fn g(x: &mut [u32; 8]) { + | ^ + | + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable + +error[E0625]: thread-local statics cannot be accessed at compile-time + --> $DIR/thread-local-static.rs:9:28 + | +LL | std::mem::swap(x, &mut STATIC_VAR_2) + | ^^^^^^^^^^^^ + +error[E0658]: dereferencing raw pointers in constant functions is unstable + --> $DIR/thread-local-static.rs:9:23 + | +LL | std::mem::swap(x, &mut STATIC_VAR_2) + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #51911 for more information + = help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable + +error[E0658]: mutable references are not allowed in constant functions + --> $DIR/thread-local-static.rs:9:23 + | +LL | std::mem::swap(x, &mut STATIC_VAR_2) + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #57349 for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable + +error[E0133]: use of mutable static is unsafe and requires unsafe function or block + --> $DIR/thread-local-static.rs:9:23 + | +LL | std::mem::swap(x, &mut STATIC_VAR_2) + | ^^^^^^^^^^^^^^^^^ use of mutable static + | + = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0133, E0658. +For more information about an error, try `rustc --explain E0133`. From 0f0f3138cb80137b9277b29118c05dbff9a8915e Mon Sep 17 00:00:00 2001 From: Camille Gillot Date: Tue, 1 Jun 2021 09:05:22 +0200 Subject: [PATCH 163/441] Revert "Reduce the amount of untracked state in TyCtxt" --- Cargo.lock | 1 - compiler/rustc_ast/src/expand/allocator.rs | 2 +- compiler/rustc_ast_lowering/src/lib.rs | 19 +-- .../rustc_codegen_cranelift/src/allocator.rs | 2 +- compiler/rustc_codegen_cranelift/src/lib.rs | 1 - .../rustc_codegen_cranelift/src/metadata.rs | 2 +- compiler/rustc_codegen_llvm/Cargo.toml | 1 - compiler/rustc_codegen_llvm/src/base.rs | 2 +- .../src/back/symbol_export.rs | 2 +- compiler/rustc_codegen_ssa/src/base.rs | 2 +- .../src/stable_hasher.rs | 32 ++++ compiler/rustc_hir/src/arena.rs | 1 - compiler/rustc_hir/src/definitions.rs | 4 +- compiler/rustc_hir/src/hir.rs | 7 +- .../src/infer/error_reporting/mod.rs | 2 +- compiler/rustc_interface/src/passes.rs | 2 +- compiler/rustc_lint/src/context.rs | 2 +- compiler/rustc_metadata/src/creader.rs | 6 - compiler/rustc_metadata/src/lib.rs | 2 - .../src/rmeta/decoder/cstore_impl.rs | 14 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 8 +- compiler/rustc_metadata/src/rmeta/mod.rs | 2 +- .../rustc_middle/src/dep_graph/dep_node.rs | 2 +- compiler/rustc_middle/src/hir/map/mod.rs | 50 ++---- compiler/rustc_middle/src/middle/cstore.rs | 4 +- .../src/middle/exported_symbols.rs | 2 +- compiler/rustc_middle/src/query/mod.rs | 32 ++-- compiler/rustc_middle/src/ty/context.rs | 150 +++++++++++------- compiler/rustc_middle/src/ty/mod.rs | 9 +- compiler/rustc_middle/src/ty/print/pretty.rs | 4 +- compiler/rustc_middle/src/ty/query/mod.rs | 2 +- .../src/ty/query/on_disk_cache.rs | 6 +- .../src/interpret/intrinsics/type_name.rs | 2 +- compiler/rustc_passes/src/entry.rs | 29 ++-- compiler/rustc_privacy/src/lib.rs | 2 +- .../rustc_query_impl/src/profiling_support.rs | 2 +- compiler/rustc_query_impl/src/stats.rs | 2 +- compiler/rustc_resolve/src/lib.rs | 13 +- compiler/rustc_symbol_mangling/src/legacy.rs | 2 +- compiler/rustc_symbol_mangling/src/v0.rs | 2 +- .../rustc_trait_selection/src/autoderef.rs | 4 +- .../src/traits/error_reporting/suggestions.rs | 4 +- compiler/rustc_ty_utils/src/ty.rs | 9 +- compiler/rustc_typeck/src/check_unused.rs | 4 +- src/librustdoc/clean/inline.rs | 2 +- src/librustdoc/visit_ast.rs | 3 +- src/test/incremental/hashes/extern_mods.rs | 8 +- src/test/incremental/hashes/inherent_impls.rs | 10 +- src/test/incremental/hashes/type_defs.rs | 14 +- 49 files changed, 255 insertions(+), 234 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1d3b539c682c..df7d84419414 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3677,7 +3677,6 @@ dependencies = [ "rustc_incremental", "rustc_index", "rustc_llvm", - "rustc_metadata", "rustc_middle", "rustc_serialize", "rustc_session", diff --git a/compiler/rustc_ast/src/expand/allocator.rs b/compiler/rustc_ast/src/expand/allocator.rs index 1976e4ad3c9f..cd27f958e464 100644 --- a/compiler/rustc_ast/src/expand/allocator.rs +++ b/compiler/rustc_ast/src/expand/allocator.rs @@ -1,6 +1,6 @@ use rustc_span::symbol::{sym, Symbol}; -#[derive(Clone, Debug, Copy, HashStable_Generic)] +#[derive(Clone, Copy)] pub enum AllocatorKind { Global, Default, diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 0ff1efd8165e..6f1772ff8188 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -43,7 +43,7 @@ use rustc_ast::walk_list; use rustc_ast::{self as ast, *}; use rustc_ast_pretty::pprust; use rustc_data_structures::captures::Captures; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::Lrc; use rustc_errors::{struct_span_err, Applicability}; use rustc_hir as hir; @@ -198,7 +198,7 @@ pub trait ResolverAstLowering { fn next_node_id(&mut self) -> NodeId; - fn take_trait_map(&mut self) -> NodeMap>; + fn trait_map(&self) -> &NodeMap>; fn opt_local_def_id(&self, node: NodeId) -> Option; @@ -501,13 +501,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { let proc_macros = c.proc_macros.iter().map(|id| self.node_id_to_hir_id[*id].unwrap()).collect(); - let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default(); - for (k, v) in self.resolver.take_trait_map().into_iter() { - if let Some(Some(hir_id)) = self.node_id_to_hir_id.get(k) { - let map = trait_map.entry(hir_id.owner).or_default(); - map.insert(hir_id.local_id, v.into_boxed_slice()); - } - } + let trait_map = self + .resolver + .trait_map() + .iter() + .filter_map(|(&k, v)| { + self.node_id_to_hir_id.get(k).and_then(|id| id.as_ref()).map(|id| (*id, v.clone())) + }) + .collect(); let mut def_id_to_hir_id = IndexVec::default(); diff --git a/compiler/rustc_codegen_cranelift/src/allocator.rs b/compiler/rustc_codegen_cranelift/src/allocator.rs index d39486c2f100..357a9f2daf74 100644 --- a/compiler/rustc_codegen_cranelift/src/allocator.rs +++ b/compiler/rustc_codegen_cranelift/src/allocator.rs @@ -19,7 +19,7 @@ pub(crate) fn codegen( }); if any_dynamic_crate { false - } else if let Some(kind) = tcx.allocator_kind(()) { + } else if let Some(kind) = tcx.allocator_kind() { codegen_inner(module, unwind_context, kind); true } else { diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index 637e91f5117d..4ee887cd5afa 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -14,7 +14,6 @@ extern crate rustc_fs_util; extern crate rustc_hir; extern crate rustc_incremental; extern crate rustc_index; -extern crate rustc_metadata; extern crate rustc_session; extern crate rustc_span; extern crate rustc_target; diff --git a/compiler/rustc_codegen_cranelift/src/metadata.rs b/compiler/rustc_codegen_cranelift/src/metadata.rs index db24bf65eb5a..ab238244d68d 100644 --- a/compiler/rustc_codegen_cranelift/src/metadata.rs +++ b/compiler/rustc_codegen_cranelift/src/metadata.rs @@ -10,7 +10,7 @@ pub(crate) fn write_metadata(tcx: TyCtxt<'_>, object: &mut O) use std::io::Write; let metadata = tcx.encode_metadata(); - let mut compressed = rustc_metadata::METADATA_HEADER.to_vec(); + let mut compressed = tcx.metadata_encoding_version(); FrameEncoder::new(&mut compressed).write_all(&metadata.raw_data).unwrap(); object.add_rustc_section( diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index d0eb6913accd..4999cb3c7ab4 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -27,7 +27,6 @@ rustc_hir = { path = "../rustc_hir" } rustc_incremental = { path = "../rustc_incremental" } rustc_index = { path = "../rustc_index" } rustc_llvm = { path = "../rustc_llvm" } -rustc_metadata = { path = "../rustc_metadata" } rustc_session = { path = "../rustc_session" } rustc_serialize = { path = "../rustc_serialize" } rustc_target = { path = "../rustc_target" } diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs index cc3cbea4def5..893c909b2041 100644 --- a/compiler/rustc_codegen_llvm/src/base.rs +++ b/compiler/rustc_codegen_llvm/src/base.rs @@ -63,7 +63,7 @@ pub fn write_compressed_metadata<'tcx>( let section_name = if tcx.sess.target.is_like_osx { "__DATA,.rustc" } else { ".rustc" }; let (metadata_llcx, metadata_llmod) = (&*llvm_module.llcx, llvm_module.llmod()); - let mut compressed = rustc_metadata::METADATA_HEADER.to_vec(); + let mut compressed = tcx.metadata_encoding_version(); FrameEncoder::new(&mut compressed).write_all(&metadata.raw_data).unwrap(); let llmeta = common::bytes_in_context(metadata_llcx, &compressed); diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index b3c674de2c65..14d6f0ba147b 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -180,7 +180,7 @@ fn exported_symbols_provider_local( symbols.push((exported_symbol, SymbolExportLevel::C)); } - if tcx.allocator_kind(()).is_some() { + if tcx.allocator_kind().is_some() { for method in ALLOCATOR_METHODS { let symbol_name = format!("__rust_{}", method.name); let exported_symbol = ExportedSymbol::NoDefId(SymbolName::new(tcx, &symbol_name)); diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index c7f6b9cbd141..b44e74d5ae82 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -517,7 +517,7 @@ pub fn codegen_crate( }); let allocator_module = if any_dynamic_crate { None - } else if let Some(kind) = tcx.allocator_kind(()) { + } else if let Some(kind) = tcx.allocator_kind() { let llmod_id = cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string(); let mut modules = backend.new_metadata(tcx, &llmod_id); diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index 18b352cf3b0b..ff28784a1dc4 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -550,3 +550,35 @@ pub fn hash_stable_hashmap( entries.sort_unstable_by(|&(ref sk1, _), &(ref sk2, _)| sk1.cmp(sk2)); entries.hash_stable(hcx, hasher); } + +/// A vector container that makes sure that its items are hashed in a stable +/// order. +#[derive(Debug)] +pub struct StableVec(Vec); + +impl StableVec { + pub fn new(v: Vec) -> Self { + StableVec(v) + } +} + +impl ::std::ops::Deref for StableVec { + type Target = Vec; + + fn deref(&self) -> &Vec { + &self.0 + } +} + +impl HashStable for StableVec +where + T: HashStable + ToStableHashKey, +{ + fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { + let StableVec(ref v) = *self; + + let mut sorted: Vec<_> = v.iter().map(|x| x.to_stable_hash_key(hcx)).collect(); + sorted.sort_unstable(); + sorted.hash_stable(hcx, hasher); + } +} diff --git a/compiler/rustc_hir/src/arena.rs b/compiler/rustc_hir/src/arena.rs index 54559281d0ae..b05ca381b8ab 100644 --- a/compiler/rustc_hir/src/arena.rs +++ b/compiler/rustc_hir/src/arena.rs @@ -43,7 +43,6 @@ macro_rules! arena_types { [] stmt: rustc_hir::Stmt<$tcx>, [] field_def: rustc_hir::FieldDef<$tcx>, [] trait_item_ref: rustc_hir::TraitItemRef, - [] trait_candidate: rustc_hir::TraitCandidate, [] ty: rustc_hir::Ty<$tcx>, [] type_binding: rustc_hir::TypeBinding<$tcx>, [] variant: rustc_hir::Variant<$tcx>, diff --git a/compiler/rustc_hir/src/definitions.rs b/compiler/rustc_hir/src/definitions.rs index d5275c399455..77aad0baef52 100644 --- a/compiler/rustc_hir/src/definitions.rs +++ b/compiler/rustc_hir/src/definitions.rs @@ -25,7 +25,7 @@ use tracing::debug; /// Internally the `DefPathTable` holds a tree of `DefKey`s, where each `DefKey` /// stores the `DefIndex` of its parent. /// There is one `DefPathTable` for each crate. -#[derive(Clone, Default, Debug)] +#[derive(Clone, Default)] pub struct DefPathTable { index_to_key: IndexVec, def_path_hashes: IndexVec, @@ -107,7 +107,7 @@ impl DefPathTable { /// The definition table containing node definitions. /// It holds the `DefPathTable` for `LocalDefId`s/`DefPath`s. /// It also stores mappings to convert `LocalDefId`s to/from `HirId`s. -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct Definitions { table: DefPathTable, diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index e9055c954108..91fd97a0d402 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1,7 +1,7 @@ // ignore-tidy-filelength use crate::def::{CtorKind, DefKind, Res}; use crate::def_id::DefId; -crate use crate::hir_id::{HirId, ItemLocalId}; +crate use crate::hir_id::HirId; use crate::{itemlikevisit, LangItem}; use rustc_ast::util::parser::ExprPrecedence; @@ -10,7 +10,6 @@ use rustc_ast::{Attribute, FloatTy, IntTy, Label, LitKind, StrStyle, TraitObject pub use rustc_ast::{BorrowKind, ImplPolarity, IsAuto}; pub use rustc_ast::{CaptureBy, Movability, Mutability}; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; -use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::{par_for_each_in, Send, Sync}; use rustc_macros::HashStable_Generic; use rustc_span::source_map::Spanned; @@ -659,9 +658,7 @@ pub struct Crate<'hir> { /// they are declared in the static array generated by proc_macro_harness. pub proc_macros: Vec, - /// Map indicating what traits are in scope for places where this - /// is relevant; generated by resolve. - pub trait_map: FxHashMap>>, + pub trait_map: BTreeMap>, /// Collected attributes from HIR nodes. pub attrs: BTreeMap, diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index fb762d2deba7..680f6af63f26 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -524,7 +524,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } fn path_crate(self, cnum: CrateNum) -> Result { - Ok(vec![self.tcx.crate_name(cnum).to_string()]) + Ok(vec![self.tcx.original_crate_name(cnum).to_string()]) } fn path_qualified( self, diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 1666754d29ac..dd4caab28dc5 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -799,7 +799,7 @@ pub fn create_global_ctxt<'tcx>( query_result_on_disk_cache, queries.as_dyn(), &crate_name, - outputs, + &outputs, ) }) }); diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 862f8374d30d..c1d6a4f1de1f 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -922,7 +922,7 @@ impl<'tcx> LateContext<'tcx> { } fn path_crate(self, cnum: CrateNum) -> Result { - Ok(vec![self.tcx.crate_name(cnum)]) + Ok(vec![self.tcx.original_crate_name(cnum)]) } fn path_qualified( diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index e336dc114b73..42c32219aba4 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -51,12 +51,6 @@ pub struct CStore { unused_externs: Vec, } -impl std::fmt::Debug for CStore { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.debug_struct("CStore").finish_non_exhaustive() - } -} - pub struct CrateLoader<'a> { // Immutable configuration. sess: &'a Session, diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index c5bbb96f777e..15c9eda9902c 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -31,5 +31,3 @@ mod rmeta; pub mod creader; pub mod dynamic_lib; pub mod locator; - -pub use rmeta::METADATA_HEADER; diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index c21c5a8d8dd6..02d1cf9aec79 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -1,7 +1,7 @@ use crate::creader::{CStore, LoadedMacro}; use crate::foreign_modules; use crate::native_libs; -use crate::rmeta::encoder; +use crate::rmeta::{self, encoder}; use rustc_ast as ast; use rustc_ast::expand::allocator::AllocatorKind; @@ -187,8 +187,7 @@ provide! { <'tcx> tcx, def_id, other, cdata, foreign_modules => { cdata.get_foreign_modules(tcx) } crate_hash => { cdata.root.hash } crate_host_hash => { cdata.host_hash } - crate_name => { cdata.root.name } - is_private_dep => { cdata.private_dep } + original_crate_name => { cdata.root.name } extra_filename => { cdata.root.extra_filename.clone() } @@ -205,6 +204,7 @@ provide! { <'tcx> tcx, def_id, other, cdata, let r = *cdata.dep_kind.lock(); r } + crate_name => { cdata.root.name } item_children => { let mut result = SmallVec::<[_; 8]>::new(); cdata.each_child_of_item(def_id.index, |child| result.push(child), tcx.sess); @@ -477,6 +477,10 @@ impl CrateStore for CStore { self.get_crate_data(cnum).root.name } + fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool { + self.get_crate_data(cnum).private_dep + } + fn stable_crate_id_untracked(&self, cnum: CrateNum) -> StableCrateId { self.get_crate_data(cnum).root.stable_crate_id } @@ -524,6 +528,10 @@ impl CrateStore for CStore { encoder::encode_metadata(tcx) } + fn metadata_encoding_version(&self) -> &[u8] { + rmeta::METADATA_HEADER + } + fn allocator_kind(&self) -> Option { self.allocator_kind() } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 8341afb53627..5c45e4130d2d 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -445,7 +445,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { } fn encode_def_path_table(&mut self) { - let table = self.tcx.resolutions(()).definitions.def_path_table(); + let table = self.tcx.hir().definitions().def_path_table(); if self.is_proc_macro { for def_index in std::iter::once(CRATE_DEF_INDEX) .chain(self.tcx.hir().krate().proc_macros.iter().map(|p| p.owner.local_def_index)) @@ -1062,7 +1062,7 @@ impl EncodeContext<'a, 'tcx> { let data = ModData { reexports, - expansion: tcx.resolutions(()).definitions.expansion_that_defined(local_def_id), + expansion: tcx.hir().definitions().expansion_that_defined(local_def_id), }; record!(self.tables.kind[def_id] <- EntryKind::Mod(self.lazy(data))); @@ -1673,7 +1673,7 @@ impl EncodeContext<'a, 'tcx> { .iter() .map(|&cnum| { let dep = CrateDep { - name: self.tcx.crate_name(cnum), + name: self.tcx.original_crate_name(cnum), hash: self.tcx.crate_hash(cnum), host_hash: self.tcx.crate_host_hash(cnum), kind: self.tcx.dep_kind(cnum), @@ -1754,7 +1754,7 @@ impl EncodeContext<'a, 'tcx> { .map(|(trait_def_id, mut impls)| { // Bring everything into deterministic order for hashing impls.sort_by_cached_key(|&(index, _)| { - tcx.hir().def_path_hash(LocalDefId { local_def_index: index }) + tcx.hir().definitions().def_path_hash(LocalDefId { local_def_index: index }) }); TraitImpls { diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index a1819a19097c..9a3a6284c361 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -51,7 +51,7 @@ const METADATA_VERSION: u8 = 5; /// This header is followed by the position of the `CrateRoot`, /// which is encoded as a 32-bit big-endian unsigned integer, /// and further followed by the rustc version string. -pub const METADATA_HEADER: &[u8; 8] = &[b'r', b'u', b's', b't', 0, 0, 0, METADATA_VERSION]; +crate const METADATA_HEADER: &[u8; 8] = &[b'r', b'u', b's', b't', 0, 0, 0, METADATA_VERSION]; /// Additional metadata for a `Lazy` where `T` may not be `Sized`, /// e.g. for `Lazy<[T]>`, this is the length (count of `T` values). diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index 8476929eaece..aa54d1ae7b9d 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -285,7 +285,7 @@ pub type DepNode = rustc_query_system::dep_graph::DepNode; // required that their size stay the same, but we don't want to change // it inadvertently. This assert just ensures we're aware of any change. #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -static_assert_size!(DepNode, 18); +static_assert_size!(DepNode, 17); #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] static_assert_size!(DepNode, 24); diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index c12b0f5587b5..07b39c97c492 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -9,7 +9,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::svh::Svh; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE}; -use rustc_hir::definitions::{DefKey, DefPath, DefPathHash}; +use rustc_hir::definitions::{DefKey, DefPath, Definitions}; use rustc_hir::intravisit; use rustc_hir::intravisit::Visitor; use rustc_hir::itemlikevisit::ItemLikeVisitor; @@ -154,9 +154,13 @@ impl<'hir> Map<'hir> { self.tcx.hir_crate(()) } + #[inline] + pub fn definitions(&self) -> &'hir Definitions { + &self.tcx.definitions + } + pub fn def_key(&self, def_id: LocalDefId) -> DefKey { - // Accessing the DefKey is ok, since it is part of DefPathHash. - self.tcx.untracked_resolutions.definitions.def_key(def_id) + self.tcx.definitions.def_key(def_id) } pub fn def_path_from_hir_id(&self, id: HirId) -> Option { @@ -164,14 +168,7 @@ impl<'hir> Map<'hir> { } pub fn def_path(&self, def_id: LocalDefId) -> DefPath { - // Accessing the DefPath is ok, since it is part of DefPathHash. - self.tcx.untracked_resolutions.definitions.def_path(def_id) - } - - #[inline] - pub fn def_path_hash(self, def_id: LocalDefId) -> DefPathHash { - // Accessing the DefPathHash is ok, it is incr. comp. stable. - self.tcx.untracked_resolutions.definitions.def_path_hash(def_id) + self.tcx.definitions.def_path(def_id) } #[inline] @@ -187,26 +184,16 @@ impl<'hir> Map<'hir> { #[inline] pub fn opt_local_def_id(&self, hir_id: HirId) -> Option { - // Create a dependency to the owner to ensure the query gets re-executed when the amount of - // children changes. - self.tcx.ensure().hir_owner_nodes(hir_id.owner); - self.tcx.untracked_resolutions.definitions.opt_hir_id_to_local_def_id(hir_id) + self.tcx.definitions.opt_hir_id_to_local_def_id(hir_id) } #[inline] pub fn local_def_id_to_hir_id(&self, def_id: LocalDefId) -> HirId { - let ret = self.tcx.untracked_resolutions.definitions.local_def_id_to_hir_id(def_id); - // Create a dependency to the owner to ensure the query gets re-executed when the amount of - // children changes. - self.tcx.ensure().hir_owner_nodes(ret.owner); - ret + self.tcx.definitions.local_def_id_to_hir_id(def_id) } pub fn iter_local_def_id(&self) -> impl Iterator + '_ { - // Create a dependency to the crate to be sure we reexcute this when the amount of - // definitions change. - self.tcx.ensure().hir_crate(()); - self.tcx.untracked_resolutions.definitions.iter_local_def_id() + self.tcx.definitions.iter_local_def_id() } pub fn opt_def_kind(&self, local_def_id: LocalDefId) -> Option { @@ -945,15 +932,9 @@ impl<'hir> intravisit::Map<'hir> for Map<'hir> { pub(super) fn index_hir<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> &'tcx IndexedHir<'tcx> { let _prof_timer = tcx.sess.prof.generic_activity("build_hir_map"); - // We can access untracked state since we are an eval_always query. let hcx = tcx.create_stable_hashing_context(); - let mut collector = NodeCollector::root( - tcx.sess, - &**tcx.arena, - tcx.untracked_crate, - &tcx.untracked_resolutions.definitions, - hcx, - ); + let mut collector = + NodeCollector::root(tcx.sess, &**tcx.arena, tcx.untracked_crate, &tcx.definitions, hcx); intravisit::walk_crate(&mut collector, tcx.untracked_crate); let map = collector.finalize_and_compute_crate_hash(); @@ -963,7 +944,6 @@ pub(super) fn index_hir<'tcx>(tcx: TyCtxt<'tcx>, (): ()) -> &'tcx IndexedHir<'tc pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { assert_eq!(crate_num, LOCAL_CRATE); - // We can access untracked state since we are an eval_always query. let mut hcx = tcx.create_stable_hashing_context(); let mut hir_body_nodes: Vec<_> = tcx @@ -971,7 +951,7 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { .map .iter_enumerated() .filter_map(|(def_id, hod)| { - let def_path_hash = tcx.untracked_resolutions.definitions.def_path_hash(def_id); + let def_path_hash = tcx.definitions.def_path_hash(def_id); let mut hasher = StableHasher::new(); hod.as_ref()?.hash_stable(&mut hcx, &mut hasher); AttributeMap { map: &tcx.untracked_crate.attrs, prefix: def_id } @@ -988,7 +968,7 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { }, ); - let upstream_crates = upstream_crates(&*tcx.untracked_resolutions.cstore); + let upstream_crates = upstream_crates(&*tcx.cstore); // We hash the final, remapped names of all local source files so we // don't have to include the path prefix remapping commandline args. diff --git a/compiler/rustc_middle/src/middle/cstore.rs b/compiler/rustc_middle/src/middle/cstore.rs index f26177e34094..e88b96bde887 100644 --- a/compiler/rustc_middle/src/middle/cstore.rs +++ b/compiler/rustc_middle/src/middle/cstore.rs @@ -182,7 +182,7 @@ pub type MetadataLoaderDyn = dyn MetadataLoader + Sync; /// that it's *not* tracked for dependency information throughout compilation /// (it'd break incremental compilation) and should only be called pre-HIR (e.g. /// during resolve) -pub trait CrateStore: std::fmt::Debug { +pub trait CrateStore { fn as_any(&self) -> &dyn Any; // resolve @@ -199,6 +199,7 @@ pub trait CrateStore: std::fmt::Debug { // "queries" used in resolve that aren't tracked for incremental compilation fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol; + fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool; fn stable_crate_id_untracked(&self, cnum: CrateNum) -> StableCrateId; fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh; @@ -208,6 +209,7 @@ pub trait CrateStore: std::fmt::Debug { // utility functions fn encode_metadata(&self, tcx: TyCtxt<'_>) -> EncodedMetadata; + fn metadata_encoding_version(&self) -> &[u8]; fn allocator_kind(&self) -> Option; } diff --git a/compiler/rustc_middle/src/middle/exported_symbols.rs b/compiler/rustc_middle/src/middle/exported_symbols.rs index 5ea78e087f84..26694afb5139 100644 --- a/compiler/rustc_middle/src/middle/exported_symbols.rs +++ b/compiler/rustc_middle/src/middle/exported_symbols.rs @@ -49,7 +49,7 @@ impl<'tcx> ExportedSymbol<'tcx> { pub fn metadata_symbol_name(tcx: TyCtxt<'_>) -> String { format!( "rust_metadata_{}_{:08x}", - tcx.crate_name(LOCAL_CRATE), + tcx.original_crate_name(LOCAL_CRATE), tcx.sess.local_stable_crate_id().to_u64(), ) } diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 9b20d06e14fb..9974f2bb8cac 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -14,12 +14,6 @@ rustc_queries! { desc { "trigger a delay span bug" } } - query resolutions(_: ()) -> &'tcx ty::ResolverOutputs { - eval_always - no_hash - desc { "get the resolver outputs" } - } - /// Represents crate as a whole (as distinct from the top-level crate module). /// If you call `hir_crate` (e.g., indirectly by calling `tcx.hir().krate()`), /// we will have to assume that any change means that you need to be recompiled. @@ -1133,12 +1127,14 @@ rustc_queries! { desc { "computing whether impls specialize one another" } } query in_scope_traits_map(_: LocalDefId) - -> Option<&'tcx FxHashMap>> { + -> Option<&'tcx FxHashMap>> { + eval_always desc { "traits in scope at a block" } } query module_exports(def_id: LocalDefId) -> Option<&'tcx [Export]> { desc { |tcx| "looking up items exported by `{}`", tcx.def_path_str(def_id.to_def_id()) } + eval_always } query impl_defaultness(def_id: DefId) -> hir::Defaultness { @@ -1252,6 +1248,10 @@ rustc_queries! { eval_always desc { "looking up the hash of a host version of a crate" } } + query original_crate_name(_: CrateNum) -> Symbol { + eval_always + desc { "looking up the original name a crate" } + } query extra_filename(_: CrateNum) -> String { eval_always desc { "looking up the extra filename for a crate" } @@ -1328,6 +1328,7 @@ rustc_queries! { } query visibility(def_id: DefId) -> ty::Visibility { + eval_always desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) } } @@ -1352,6 +1353,8 @@ rustc_queries! { desc { |tcx| "collecting child items of `{}`", tcx.def_path_str(def_id) } } query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option { + // This depends on untracked global state (`tcx.extern_crate_map`) + eval_always desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id.to_def_id()) } } @@ -1412,26 +1415,22 @@ rustc_queries! { eval_always desc { "generating a postorder list of CrateNums" } } - /// Returns whether or not the crate with CrateNum 'cnum' - /// is marked as a private dependency - query is_private_dep(c: CrateNum) -> bool { - desc { "check whether crate {} is a private dependency", c } - } - query allocator_kind(_: ()) -> Option { - desc { "allocator kind for the current crate" } - } query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap> { desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) } eval_always } query maybe_unused_trait_import(def_id: LocalDefId) -> bool { + eval_always desc { |tcx| "maybe_unused_trait_import for `{}`", tcx.def_path_str(def_id.to_def_id()) } } query maybe_unused_extern_crates(_: ()) -> &'tcx [(LocalDefId, Span)] { + eval_always desc { "looking up all possibly unused extern crates" } } - query names_imported_by_glob_use(def_id: LocalDefId) -> &'tcx FxHashSet { + query names_imported_by_glob_use(def_id: LocalDefId) + -> &'tcx FxHashSet { + eval_always desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) } } @@ -1441,6 +1440,7 @@ rustc_queries! { desc { "calculating the stability index for the local crate" } } query all_crate_nums(_: ()) -> &'tcx [CrateNum] { + eval_always desc { "fetching all foreign CrateNum instances" } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 6042a8c55bac..a2b17e97c29d 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2,12 +2,13 @@ use crate::arena::Arena; use crate::dep_graph::DepGraph; +use crate::hir::exports::ExportMap; use crate::hir::place::Place as HirPlace; use crate::ich::{NodeIdHashingMode, StableHashingContext}; use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos}; use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintLevelSource}; use crate::middle; -use crate::middle::cstore::EncodedMetadata; +use crate::middle::cstore::{CrateStoreDyn, EncodedMetadata}; use crate::middle::resolve_lifetime::{self, LifetimeScopeForPath, ObjectLifetimeDefault}; use crate::middle::stability; use crate::mir::interpret::{self, Allocation, ConstValue, Scalar}; @@ -20,22 +21,24 @@ use crate::ty::TyKind::*; use crate::ty::{ self, AdtDef, AdtKind, Binder, BindingMode, BoundVar, CanonicalPolyFnSig, Const, ConstVid, DefIdTree, ExistentialPredicate, FloatTy, FloatVar, FloatVid, GenericParamDefKind, InferConst, - InferTy, IntTy, IntVar, IntVid, List, ParamConst, ParamTy, PolyFnSig, Predicate, - PredicateInner, PredicateKind, ProjectionTy, Region, RegionKind, ReprOptions, - TraitObjectVisitor, Ty, TyKind, TyS, TyVar, TyVid, TypeAndMut, UintTy, + InferTy, IntTy, IntVar, IntVid, List, MainDefinition, ParamConst, ParamTy, PolyFnSig, + Predicate, PredicateInner, PredicateKind, ProjectionTy, Region, RegionKind, ReprOptions, + TraitObjectVisitor, Ty, TyKind, TyS, TyVar, TyVid, TypeAndMut, UintTy, Visibility, }; use rustc_ast as ast; +use rustc_ast::expand::allocator::AllocatorKind; use rustc_attr as attr; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap}; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableVec}; use rustc_data_structures::steal::Steal; use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal}; use rustc_errors::ErrorReported; use rustc_hir as hir; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, LOCAL_CRATE}; +use rustc_hir::definitions::Definitions; use rustc_hir::intravisit::Visitor; use rustc_hir::lang_items::LangItem; use rustc_hir::{ @@ -934,6 +937,8 @@ pub struct GlobalCtxt<'tcx> { interners: CtxtInterners<'tcx>, + pub(crate) cstore: Box, + pub sess: &'tcx Session, /// This only ever stores a `LintStore` but we don't want a dependency on that type here. @@ -955,10 +960,21 @@ pub struct GlobalCtxt<'tcx> { /// Common consts, pre-interned for your convenience. pub consts: CommonConsts<'tcx>, - /// Output of the resolver. - pub(crate) untracked_resolutions: ty::ResolverOutputs, + /// Visibilities produced by resolver. + pub visibilities: FxHashMap, + + /// Resolutions of `extern crate` items produced by resolver. + extern_crate_map: FxHashMap, + + /// Map indicating what traits are in scope for places where this + /// is relevant; generated by resolve. + trait_map: FxHashMap>>, + + /// Export map produced by name resolution. + export_map: ExportMap, pub(crate) untracked_crate: &'tcx hir::Crate<'tcx>, + pub(crate) definitions: Definitions, /// This provides access to the incremental compilation on-disk cache for query results. /// Do not access this directly. It is only meant to be used by @@ -969,6 +985,15 @@ pub struct GlobalCtxt<'tcx> { pub queries: &'tcx dyn query::QueryEngine<'tcx>, pub query_caches: query::QueryCaches<'tcx>, + maybe_unused_trait_imports: FxHashSet, + maybe_unused_extern_crates: Vec<(LocalDefId, Span)>, + /// A map of glob use to a set of names it actually imports. Currently only + /// used in save-analysis. + pub(crate) glob_map: FxHashMap>, + /// Extern prelude entries. The value is `true` if the entry was introduced + /// via `extern crate` item and not `--extern` option or compiler built-in. + pub extern_prelude: FxHashMap, + // Internal caches for metadata decoding. No need to track deps on this. pub ty_rcache: Lock>>, pub pred_rcache: Lock>>, @@ -984,7 +1009,7 @@ pub struct GlobalCtxt<'tcx> { /// The definite name of the current crate after taking into account /// attributes, commandline parameters, etc. - crate_name: Symbol, + pub crate_name: Symbol, /// Data layout specification for the current target. pub data_layout: TargetDataLayout, @@ -1001,6 +1026,8 @@ pub struct GlobalCtxt<'tcx> { layout_interner: ShardedHashMap<&'tcx Layout, ()>, output_filenames: Arc, + + pub main_def: Option, } impl<'tcx> TyCtxt<'tcx> { @@ -1112,7 +1139,7 @@ impl<'tcx> TyCtxt<'tcx> { on_disk_cache: Option>, queries: &'tcx dyn query::QueryEngine<'tcx>, crate_name: &str, - output_filenames: OutputFilenames, + output_filenames: &OutputFilenames, ) -> GlobalCtxt<'tcx> { let data_layout = TargetDataLayout::parse(&s.target).unwrap_or_else(|err| { s.fatal(&err); @@ -1121,19 +1148,35 @@ impl<'tcx> TyCtxt<'tcx> { let common_types = CommonTypes::new(&interners); let common_lifetimes = CommonLifetimes::new(&interners); let common_consts = CommonConsts::new(&interners, &common_types); + let cstore = resolutions.cstore; + + let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default(); + for (hir_id, v) in krate.trait_map.iter() { + let map = trait_map.entry(hir_id.owner).or_default(); + map.insert(hir_id.local_id, StableVec::new(v.to_vec())); + } GlobalCtxt { sess: s, lint_store, + cstore, arena, interners, dep_graph, - untracked_resolutions: resolutions, prof: s.prof.clone(), types: common_types, lifetimes: common_lifetimes, consts: common_consts, + visibilities: resolutions.visibilities, + extern_crate_map: resolutions.extern_crate_map, + trait_map, + export_map: resolutions.export_map, + maybe_unused_trait_imports: resolutions.maybe_unused_trait_imports, + maybe_unused_extern_crates: resolutions.maybe_unused_extern_crates, + glob_map: resolutions.glob_map, + extern_prelude: resolutions.extern_prelude, untracked_crate: krate, + definitions: resolutions.definitions, on_disk_cache, queries, query_caches: query::QueryCaches::default(), @@ -1147,7 +1190,8 @@ impl<'tcx> TyCtxt<'tcx> { stability_interner: Default::default(), const_stability_interner: Default::default(), alloc_map: Lock::new(interpret::AllocMap::new()), - output_filenames: Arc::new(output_filenames), + output_filenames: Arc::new(output_filenames.clone()), + main_def: resolutions.main_def, } } @@ -1206,17 +1250,16 @@ impl<'tcx> TyCtxt<'tcx> { self.all_crate_nums(()) } + pub fn allocator_kind(self) -> Option { + self.cstore.allocator_kind() + } + pub fn features(self) -> &'tcx rustc_feature::Features { self.features_query(()) } pub fn def_key(self, id: DefId) -> rustc_hir::definitions::DefKey { - // Accessing the DefKey is ok, since it is part of DefPathHash. - if let Some(id) = id.as_local() { - self.untracked_resolutions.definitions.def_key(id) - } else { - self.untracked_resolutions.cstore.def_key(id) - } + if let Some(id) = id.as_local() { self.hir().def_key(id) } else { self.cstore.def_key(id) } } /// Converts a `DefId` into its fully expanded `DefPath` (every @@ -1225,21 +1268,25 @@ impl<'tcx> TyCtxt<'tcx> { /// Note that if `id` is not local to this crate, the result will /// be a non-local `DefPath`. pub fn def_path(self, id: DefId) -> rustc_hir::definitions::DefPath { - // Accessing the DefPath is ok, since it is part of DefPathHash. if let Some(id) = id.as_local() { - self.untracked_resolutions.definitions.def_path(id) + self.hir().def_path(id) } else { - self.untracked_resolutions.cstore.def_path(id) + self.cstore.def_path(id) } } + /// Returns whether or not the crate with CrateNum 'cnum' + /// is marked as a private dependency + pub fn is_private_dep(self, cnum: CrateNum) -> bool { + if cnum == LOCAL_CRATE { false } else { self.cstore.crate_is_private_dep_untracked(cnum) } + } + #[inline] pub fn def_path_hash(self, def_id: DefId) -> rustc_hir::definitions::DefPathHash { - // Accessing the DefPathHash is ok, it is incr. comp. stable. if let Some(def_id) = def_id.as_local() { - self.untracked_resolutions.definitions.def_path_hash(def_id) + self.definitions.def_path_hash(def_id) } else { - self.untracked_resolutions.cstore.def_path_hash(def_id) + self.cstore.def_path_hash(def_id) } } @@ -1251,10 +1298,9 @@ impl<'tcx> TyCtxt<'tcx> { let (crate_name, stable_crate_id) = if def_id.is_local() { (self.crate_name, self.sess.local_stable_crate_id()) } else { - let cstore = &self.untracked_resolutions.cstore; ( - cstore.crate_name_untracked(def_id.krate), - cstore.stable_crate_id_untracked(def_id.krate), + self.cstore.crate_name_untracked(def_id.krate), + self.def_path_hash(def_id.krate.as_def_id()).stable_crate_id(), ) }; @@ -1268,36 +1314,33 @@ impl<'tcx> TyCtxt<'tcx> { ) } + pub fn metadata_encoding_version(self) -> Vec { + self.cstore.metadata_encoding_version().to_vec() + } + pub fn encode_metadata(self) -> EncodedMetadata { let _prof_timer = self.prof.verbose_generic_activity("generate_crate_metadata"); - self.untracked_resolutions.cstore.encode_metadata(self) + self.cstore.encode_metadata(self) } // Note that this is *untracked* and should only be used within the query // system if the result is otherwise tracked through queries pub fn cstore_as_any(self) -> &'tcx dyn Any { - self.untracked_resolutions.cstore.as_any() + self.cstore.as_any() } #[inline(always)] pub fn create_stable_hashing_context(self) -> StableHashingContext<'tcx> { let krate = self.gcx.untracked_crate; - let resolutions = &self.gcx.untracked_resolutions; - StableHashingContext::new(self.sess, krate, &resolutions.definitions, &*resolutions.cstore) + StableHashingContext::new(self.sess, krate, &self.definitions, &*self.cstore) } #[inline(always)] pub fn create_no_span_stable_hashing_context(self) -> StableHashingContext<'tcx> { let krate = self.gcx.untracked_crate; - let resolutions = &self.gcx.untracked_resolutions; - StableHashingContext::ignore_spans( - self.sess, - krate, - &resolutions.definitions, - &*resolutions.cstore, - ) + StableHashingContext::ignore_spans(self.sess, krate, &self.definitions, &*self.cstore) } pub fn serialize_query_result_cache(self, encoder: &mut FileEncoder) -> FileEncodeResult { @@ -2619,10 +2662,8 @@ impl<'tcx> TyCtxt<'tcx> { struct_lint_level(self.sess, lint, level, src, None, decorate); } - pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate]> { - let map = self.in_scope_traits_map(id.owner)?; - let candidates = map.get(&id.local_id)?; - Some(&*candidates) + pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx StableVec> { + self.in_scope_traits_map(id.owner).and_then(|map| map.get(&id.local_id)) } pub fn named_region(self, id: HirId) -> Option { @@ -2752,20 +2793,16 @@ fn ptr_eq(t: *const T, u: *const U) -> bool { } pub fn provide(providers: &mut ty::query::Providers) { - providers.in_scope_traits_map = |tcx, id| tcx.hir_crate(()).trait_map.get(&id); - providers.resolutions = |tcx, ()| &tcx.untracked_resolutions; - providers.module_exports = |tcx, id| tcx.resolutions(()).export_map.get(&id).map(|v| &v[..]); + providers.in_scope_traits_map = |tcx, id| tcx.gcx.trait_map.get(&id); + providers.module_exports = |tcx, id| tcx.gcx.export_map.get(&id).map(|v| &v[..]); providers.crate_name = |tcx, id| { assert_eq!(id, LOCAL_CRATE); tcx.crate_name }; - providers.maybe_unused_trait_import = - |tcx, id| tcx.resolutions(()).maybe_unused_trait_imports.contains(&id); - providers.maybe_unused_extern_crates = - |tcx, ()| &tcx.resolutions(()).maybe_unused_extern_crates[..]; - providers.names_imported_by_glob_use = |tcx, id| { - tcx.arena.alloc(tcx.resolutions(()).glob_map.get(&id).cloned().unwrap_or_default()) - }; + providers.maybe_unused_trait_import = |tcx, id| tcx.maybe_unused_trait_imports.contains(&id); + providers.maybe_unused_extern_crates = |tcx, ()| &tcx.maybe_unused_extern_crates[..]; + providers.names_imported_by_glob_use = + |tcx, id| tcx.arena.alloc(tcx.glob_map.get(&id).cloned().unwrap_or_default()); providers.lookup_stability = |tcx, id| { let id = tcx.hir().local_def_id_to_hir_id(id.expect_local()); @@ -2779,10 +2816,8 @@ pub fn provide(providers: &mut ty::query::Providers) { let id = tcx.hir().local_def_id_to_hir_id(id.expect_local()); tcx.stability().local_deprecation_entry(id) }; - providers.extern_mod_stmt_cnum = - |tcx, id| tcx.resolutions(()).extern_crate_map.get(&id).cloned(); - providers.all_crate_nums = - |tcx, ()| tcx.arena.alloc_slice(&tcx.resolutions(()).cstore.crates_untracked()); + providers.extern_mod_stmt_cnum = |tcx, id| tcx.extern_crate_map.get(&id).cloned(); + providers.all_crate_nums = |tcx, ()| tcx.arena.alloc_slice(&tcx.cstore.crates_untracked()); providers.output_filenames = |tcx, ()| tcx.output_filenames.clone(); providers.features_query = |tcx, ()| tcx.sess.features_untracked(); providers.is_panic_runtime = |tcx, cnum| { @@ -2798,9 +2833,4 @@ pub fn provide(providers: &mut ty::query::Providers) { // We want to check if the panic handler was defined in this crate tcx.lang_items().panic_impl().map_or(false, |did| did.is_local()) }; - providers.is_private_dep = |_tcx, cnum| { - assert_eq!(cnum, LOCAL_CRATE); - false - }; - providers.allocator_kind = |tcx, ()| tcx.resolutions(()).cstore.allocator_kind(); } diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 81325021ad49..94e325e9e878 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -112,7 +112,6 @@ mod sty; // Data types -#[derive(Debug)] pub struct ResolverOutputs { pub definitions: rustc_hir::definitions::Definitions, pub cstore: Box, @@ -128,7 +127,7 @@ pub struct ResolverOutputs { pub main_def: Option, } -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy)] pub struct MainDefinition { pub res: Res, pub is_import: bool, @@ -1619,7 +1618,7 @@ impl<'tcx> TyCtxt<'tcx> { fn item_name_from_def_id(self, def_id: DefId) -> Option { if def_id.index == CRATE_DEF_INDEX { - Some(self.crate_name(def_id.krate)) + Some(self.original_crate_name(def_id.krate)) } else { let def_key = self.def_key(def_id); match def_key.disambiguated_data.data { @@ -1867,7 +1866,7 @@ impl<'tcx> TyCtxt<'tcx> { match scope.as_local() { // Parsing and expansion aren't incremental, so we don't // need to go through a query for the same-crate case. - Some(scope) => self.resolutions(()).definitions.expansion_that_defined(scope), + Some(scope) => self.hir().definitions().expansion_that_defined(scope), None => self.expn_that_defined(scope), } } @@ -1887,7 +1886,7 @@ impl<'tcx> TyCtxt<'tcx> { match ident.span.normalize_to_macros_2_0_and_adjust(self.expansion_that_defined(scope)) { Some(actual_expansion) => { - self.resolutions(()).definitions.parent_module_of_macro_def(actual_expansion) + self.hir().definitions().parent_module_of_macro_def(actual_expansion) } None => self.parent_module(block).to_def_id(), }; diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index f48d7819fe05..f514278a11c9 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -452,7 +452,7 @@ pub trait PrettyPrinter<'tcx>: } // Re-exported `extern crate` (#43189). DefPathData::CrateRoot => { - data = DefPathData::TypeNs(self.tcx().crate_name(def_id.krate)); + data = DefPathData::TypeNs(self.tcx().original_crate_name(def_id.krate)); } _ => {} } @@ -2313,7 +2313,7 @@ fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> FxHashMap { let unique_symbols_rev: &mut FxHashMap<(Namespace, Symbol), Option> = &mut FxHashMap::default(); - for symbol_set in tcx.resolutions(()).glob_map.values() { + for symbol_set in tcx.glob_map.values() { for symbol in symbol_set { unique_symbols_rev.insert((Namespace::TypeNS, *symbol), None); unique_symbols_rev.insert((Namespace::ValueNS, *symbol), None); diff --git a/compiler/rustc_middle/src/ty/query/mod.rs b/compiler/rustc_middle/src/ty/query/mod.rs index 247a250a6c05..bec13da017ea 100644 --- a/compiler/rustc_middle/src/ty/query/mod.rs +++ b/compiler/rustc_middle/src/ty/query/mod.rs @@ -33,8 +33,8 @@ use crate::traits::{self, ImplSource}; use crate::ty::subst::{GenericArg, SubstsRef}; use crate::ty::util::AlwaysRequiresDrop; use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt}; -use rustc_ast::expand::allocator::AllocatorKind; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; +use rustc_data_structures::stable_hasher::StableVec; use rustc_data_structures::steal::Steal; use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::Lrc; diff --git a/compiler/rustc_middle/src/ty/query/on_disk_cache.rs b/compiler/rustc_middle/src/ty/query/on_disk_cache.rs index f0edf818d48a..ce10744bfb6b 100644 --- a/compiler/rustc_middle/src/ty/query/on_disk_cache.rs +++ b/compiler/rustc_middle/src/ty/query/on_disk_cache.rs @@ -641,11 +641,7 @@ impl<'sess> OnDiskCache<'sess> { debug_assert_ne!(krate, LOCAL_CRATE); // Try to find a definition in the current session, using the previous `DefIndex` // as an initial guess. - let opt_def_id = tcx.untracked_resolutions.cstore.def_path_hash_to_def_id( - krate, - raw_def_id.index, - hash, - ); + let opt_def_id = tcx.cstore.def_path_hash_to_def_id(krate, raw_def_id.index, hash); debug!("def_path_to_def_id({:?}): opt_def_id = {:?}", hash, opt_def_id); e.insert(opt_def_id); opt_def_id diff --git a/compiler/rustc_mir/src/interpret/intrinsics/type_name.rs b/compiler/rustc_mir/src/interpret/intrinsics/type_name.rs index 756987fd5bc5..4978cc3606dd 100644 --- a/compiler/rustc_mir/src/interpret/intrinsics/type_name.rs +++ b/compiler/rustc_mir/src/interpret/intrinsics/type_name.rs @@ -88,7 +88,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { } fn path_crate(mut self, cnum: CrateNum) -> Result { - self.path.push_str(&self.tcx.crate_name(cnum).as_str()); + self.path.push_str(&self.tcx.original_crate_name(cnum).as_str()); Ok(self) } diff --git a/compiler/rustc_passes/src/entry.rs b/compiler/rustc_passes/src/entry.rs index 781a5fe47834..ca6a7561f3e7 100644 --- a/compiler/rustc_passes/src/entry.rs +++ b/compiler/rustc_passes/src/entry.rs @@ -147,22 +147,19 @@ fn configure_main(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) -> Option<(De Some((tcx.hir().local_def_id(hir_id).to_def_id(), EntryFnType::Start)) } else if let Some((hir_id, _)) = visitor.attr_main_fn { Some((tcx.hir().local_def_id(hir_id).to_def_id(), EntryFnType::Main)) - } else { - if let Some(main_def) = tcx.resolutions(()).main_def { - if let Some(def_id) = main_def.opt_fn_def_id() { - if main_def.is_import && !tcx.features().imported_main { - let span = main_def.span; - feature_err( - &tcx.sess.parse_sess, - sym::imported_main, - span, - "using an imported function as entry point `main` is experimental", - ) - .emit(); - } - return Some((def_id, EntryFnType::Main)); - } + } else if let Some(def_id) = tcx.main_def.and_then(|main_def| main_def.opt_fn_def_id()) { + if tcx.main_def.unwrap().is_import && !tcx.features().imported_main { + let span = tcx.main_def.unwrap().span; + feature_err( + &tcx.sess.parse_sess, + sym::imported_main, + span, + "using an imported function as entry point `main` is experimental", + ) + .emit(); } + Some((def_id, EntryFnType::Main)) + } else { no_main_err(tcx, visitor); None } @@ -212,7 +209,7 @@ fn no_main_err(tcx: TyCtxt<'_>, visitor: &EntryContext<'_, '_>) { err.note(¬e); } - if let Some(main_def) = tcx.resolutions(()).main_def { + if let Some(main_def) = tcx.main_def { if main_def.opt_fn_def_id().is_none() { // There is something at `crate::main`, but it is not a function definition. err.span_label(main_def.span, &format!("non-function item at `crate::main` is found")); diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 54ad9182354f..e64f12ef48f2 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -2030,7 +2030,7 @@ pub fn provide(providers: &mut Providers) { fn visibility(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Visibility { let def_id = def_id.expect_local(); - match tcx.resolutions(()).visibilities.get(&def_id) { + match tcx.visibilities.get(&def_id) { Some(vis) => *vis, None => { let hir_id = tcx.hir().local_def_id_to_hir_id(def_id); diff --git a/compiler/rustc_query_impl/src/profiling_support.rs b/compiler/rustc_query_impl/src/profiling_support.rs index 95edc1e93a53..2517793ecea7 100644 --- a/compiler/rustc_query_impl/src/profiling_support.rs +++ b/compiler/rustc_query_impl/src/profiling_support.rs @@ -61,7 +61,7 @@ impl<'p, 'c, 'tcx> QueryKeyStringBuilder<'p, 'c, 'tcx> { match def_key.disambiguated_data.data { DefPathData::CrateRoot => { - crate_name = self.tcx.crate_name(def_id.krate).as_str(); + crate_name = self.tcx.original_crate_name(def_id.krate).as_str(); name = &*crate_name; dis = ""; end_index = 3; diff --git a/compiler/rustc_query_impl/src/stats.rs b/compiler/rustc_query_impl/src/stats.rs index fa48df3ed45c..e877034bd7b5 100644 --- a/compiler/rustc_query_impl/src/stats.rs +++ b/compiler/rustc_query_impl/src/stats.rs @@ -108,7 +108,7 @@ pub fn print_stats(tcx: TyCtxt<'_>) { queries.iter().filter(|q| q.local_def_id_keys.is_some()).collect(); def_id_density.sort_by_key(|q| q.local_def_id_keys.unwrap()); eprintln!("\nLocal DefId density:"); - let total = tcx.resolutions(()).definitions.def_index_count() as f64; + let total = tcx.hir().definitions().def_index_count() as f64; for q in def_id_density.iter().rev() { let local = q.local_def_id_keys.unwrap(); eprintln!(" {} - {} = ({}%)", q.name, local, (local as f64 * 100.0) / total); diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 5e009d148322..29d4271c475d 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -910,8 +910,6 @@ pub struct Resolver<'a> { extern_crate_map: FxHashMap, export_map: ExportMap, trait_map: NodeMap>, - #[cfg(debug_assertions)] - took_trait_map: bool, /// A map from nodes to anonymous modules. /// Anonymous modules are pseudo-modules that are implicitly created around items @@ -1140,13 +1138,8 @@ impl ResolverAstLowering for Resolver<'_> { self.next_node_id() } - fn take_trait_map(&mut self) -> NodeMap> { - #[cfg(debug_assertions)] - { - debug_assert!(!self.took_trait_map); - self.took_trait_map = true; - } - std::mem::take(&mut self.trait_map) + fn trait_map(&self) -> &NodeMap> { + &self.trait_map } fn opt_local_def_id(&self, node: NodeId) -> Option { @@ -1294,8 +1287,6 @@ impl<'a> Resolver<'a> { extern_crate_map: Default::default(), export_map: FxHashMap::default(), trait_map: Default::default(), - #[cfg(debug_assertions)] - took_trait_map: false, underscore_disambiguator: 0, empty_module, module_map, diff --git a/compiler/rustc_symbol_mangling/src/legacy.rs b/compiler/rustc_symbol_mangling/src/legacy.rs index 0c64fe6ea60a..1addfc8ee67e 100644 --- a/compiler/rustc_symbol_mangling/src/legacy.rs +++ b/compiler/rustc_symbol_mangling/src/legacy.rs @@ -254,7 +254,7 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> { } fn path_crate(mut self, cnum: CrateNum) -> Result { - self.write_str(&self.tcx.crate_name(cnum).as_str())?; + self.write_str(&self.tcx.original_crate_name(cnum).as_str())?; Ok(self) } fn path_qualified( diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs index e7da56ed0f3c..2ab7461fc603 100644 --- a/compiler/rustc_symbol_mangling/src/v0.rs +++ b/compiler/rustc_symbol_mangling/src/v0.rs @@ -594,7 +594,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { self.push("C"); let stable_crate_id = self.tcx.def_path_hash(cnum.as_def_id()).stable_crate_id(); self.push_disambiguator(stable_crate_id.to_u64()); - let name = self.tcx.crate_name(cnum).as_str(); + let name = self.tcx.original_crate_name(cnum).as_str(); self.push_ident(&name); Ok(self) } diff --git a/compiler/rustc_trait_selection/src/autoderef.rs b/compiler/rustc_trait_selection/src/autoderef.rs index ac2e0ebae327..3f24a33f7d57 100644 --- a/compiler/rustc_trait_selection/src/autoderef.rs +++ b/compiler/rustc_trait_selection/src/autoderef.rs @@ -6,7 +6,6 @@ use rustc_infer::infer::InferCtxt; use rustc_middle::ty::{self, TraitRef, Ty, TyCtxt, WithConstness}; use rustc_middle::ty::{ToPredicate, TypeFoldable}; use rustc_session::DiagnosticMessageId; -use rustc_span::def_id::LOCAL_CRATE; use rustc_span::Span; #[derive(Copy, Clone, Debug)] @@ -232,8 +231,7 @@ pub fn report_autoderef_recursion_limit_error<'tcx>(tcx: TyCtxt<'tcx>, span: Spa .span_label(span, "deref recursion limit reached") .help(&format!( "consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate (`{}`)", - suggested_limit, - tcx.crate_name(LOCAL_CRATE), + suggested_limit, tcx.crate_name, )) .emit(); } diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 5c35b515f3d0..8bbd2da53751 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -21,7 +21,6 @@ use rustc_middle::ty::{ Infer, InferTy, ToPredicate, Ty, TyCtxt, TypeFoldable, WithConstness, }; use rustc_middle::ty::{TypeAndMut, TypeckResults}; -use rustc_span::def_id::LOCAL_CRATE; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{BytePos, MultiSpan, Span, DUMMY_SP}; use rustc_target::spec::abi; @@ -2314,8 +2313,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { let suggested_limit = current_limit * 2; err.help(&format!( "consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate (`{}`)", - suggested_limit, - self.tcx.crate_name(LOCAL_CRATE), + suggested_limit, self.tcx.crate_name, )); } diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 07a3132568b8..f38c5d8f2f79 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -1,11 +1,12 @@ use rustc_data_structures::fx::FxIndexSet; use rustc_hir as hir; -use rustc_hir::def_id::{DefId, LocalDefId}; +use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE}; use rustc_middle::hir::map as hir_map; use rustc_middle::ty::subst::Subst; use rustc_middle::ty::{ self, Binder, Predicate, PredicateKind, ToPredicate, Ty, TyCtxt, WithConstness, }; +use rustc_span::symbol::Symbol; use rustc_span::Span; use rustc_trait_selection::traits; @@ -387,6 +388,11 @@ fn param_env_reveal_all_normalized(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamE tcx.param_env(def_id).with_reveal_all_normalized(tcx) } +fn original_crate_name(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Symbol { + assert_eq!(crate_num, LOCAL_CRATE); + tcx.crate_name +} + fn instance_def_size_estimate<'tcx>( tcx: TyCtxt<'tcx>, instance_def: ty::InstanceDef<'tcx>, @@ -532,6 +538,7 @@ pub fn provide(providers: &mut ty::query::Providers) { param_env, param_env_reveal_all_normalized, trait_of_item, + original_crate_name, instance_def_size_estimate, issue33140_self_ty, impl_defaultness, diff --git a/compiler/rustc_typeck/src/check_unused.rs b/compiler/rustc_typeck/src/check_unused.rs index 7e5cc771b319..836bed2a1563 100644 --- a/compiler/rustc_typeck/src/check_unused.rs +++ b/compiler/rustc_typeck/src/check_unused.rs @@ -116,8 +116,6 @@ fn unused_crates_lint(tcx: TyCtxt<'_>) { crates_to_lint: &mut crates_to_lint, }); - let extern_prelude = &tcx.resolutions(()).extern_prelude; - for extern_crate in &crates_to_lint { let def_id = extern_crate.def_id.expect_local(); let id = tcx.hir().local_def_id_to_hir_id(def_id); @@ -157,7 +155,7 @@ fn unused_crates_lint(tcx: TyCtxt<'_>) { // If the extern crate isn't in the extern prelude, // there is no way it can be written as an `use`. let orig_name = extern_crate.orig_name.unwrap_or(item.ident.name); - if !extern_prelude.get(&orig_name).map_or(false, |from_item| !from_item) { + if !tcx.extern_prelude.get(&orig_name).map_or(false, |from_item| !from_item) { continue; } diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 111827aacdff..a14eefaf5714 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -527,7 +527,7 @@ fn build_static(cx: &mut DocContext<'_>, did: DefId, mutable: bool) -> clean::St } fn build_macro(cx: &mut DocContext<'_>, did: DefId, name: Symbol) -> clean::ItemKind { - let imported_from = cx.tcx.crate_name(did.krate); + let imported_from = cx.tcx.original_crate_name(did.krate); match cx.enter_resolver(|r| r.cstore().load_macro_untracked(did, cx.sess())) { LoadedMacro::MacroDef(def, _) => { let matchers: Vec = if let ast::ItemKind::MacroDef(ref def) = def.kind { diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index b563c4f47993..191d8d5a2ea3 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -9,7 +9,6 @@ use rustc_hir::Node; use rustc_middle::middle::privacy::AccessLevel; use rustc_middle::ty::TyCtxt; use rustc_span; -use rustc_span::def_id::LOCAL_CRATE; use rustc_span::source_map::Spanned; use rustc_span::symbol::{kw, sym, Symbol}; @@ -77,7 +76,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { &Spanned { span, node: hir::VisibilityKind::Public }, hir::CRATE_HIR_ID, &krate.item, - self.cx.tcx.crate_name(LOCAL_CRATE), + self.cx.tcx.crate_name, ); // Attach the crate's exported macros to the top-level module. // In the case of macros 2.0 (`pub macro`), and for built-in `derive`s or attributes as diff --git a/src/test/incremental/hashes/extern_mods.rs b/src/test/incremental/hashes/extern_mods.rs index fb3863ed2ef7..93e70d3792ce 100644 --- a/src/test/incremental/hashes/extern_mods.rs +++ b/src/test/incremental/hashes/extern_mods.rs @@ -21,7 +21,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2")] +#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn change_function_name2(c: i64) -> i32; @@ -112,7 +112,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2")] +#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] #[rustc_clean(cfg = "cfail3")] extern "rust-call" { pub fn change_calling_convention(c: i32); @@ -125,7 +125,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2")] +#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn make_function_public(c: i32); @@ -138,7 +138,7 @@ extern "C" { } #[cfg(not(cfail1))] -#[rustc_dirty(cfg = "cfail2")] +#[rustc_dirty(cfg = "cfail2", except = "hir_owner_nodes")] #[rustc_clean(cfg = "cfail3")] extern "C" { pub fn add_function1(c: i32); diff --git a/src/test/incremental/hashes/inherent_impls.rs b/src/test/incremental/hashes/inherent_impls.rs index ee7b258cec4e..70ce81bd473d 100644 --- a/src/test/incremental/hashes/inherent_impls.rs +++ b/src/test/incremental/hashes/inherent_impls.rs @@ -23,7 +23,7 @@ impl Foo { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,associated_item_def_ids")] +#[rustc_clean(cfg="cfail2", except="hir_owner,associated_item_def_ids")] #[rustc_clean(cfg="cfail3")] impl Foo { #[rustc_clean(cfg="cfail3")] @@ -85,7 +85,7 @@ impl Foo { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg="cfail2", except="hir_owner")] #[rustc_clean(cfg="cfail3")] impl Foo { #[rustc_clean(cfg="cfail2", except="associated_item,hir_owner,hir_owner_nodes")] @@ -100,7 +100,7 @@ impl Foo { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg="cfail2", except="hir_owner")] #[rustc_clean(cfg="cfail3")] impl Foo { #[rustc_dirty(cfg="cfail2", except="type_of,predicates_of,promoted_mir")] @@ -135,7 +135,7 @@ impl Foo { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes,associated_item_def_ids")] +#[rustc_clean(cfg="cfail2", except="hir_owner,associated_item_def_ids")] #[rustc_clean(cfg="cfail3")] impl Foo { #[rustc_clean(cfg="cfail2")] @@ -468,7 +468,7 @@ impl Bar { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg="cfail2", except="hir_owner")] #[rustc_clean(cfg="cfail3")] impl Bar { #[rustc_clean(cfg="cfail2", except="fn_sig,optimized_mir,typeck")] diff --git a/src/test/incremental/hashes/type_defs.rs b/src/test/incremental/hashes/type_defs.rs index 495445670c00..d874be060c26 100644 --- a/src/test/incremental/hashes/type_defs.rs +++ b/src/test/incremental/hashes/type_defs.rs @@ -24,7 +24,7 @@ type ChangePrimitiveType = i32; #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg="cfail2", except="hir_owner")] #[rustc_clean(cfg="cfail3")] type ChangePrimitiveType = i64; @@ -35,7 +35,7 @@ type ChangePrimitiveType = i64; type ChangeMutability = &'static i32; #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg="cfail2", except="hir_owner")] #[rustc_clean(cfg="cfail3")] type ChangeMutability = &'static mut i32; @@ -60,7 +60,7 @@ struct Struct2; type ChangeTypeStruct = Struct1; #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg="cfail2", except="hir_owner")] #[rustc_clean(cfg="cfail3")] type ChangeTypeStruct = Struct2; @@ -71,7 +71,7 @@ type ChangeTypeStruct = Struct2; type ChangeTypeTuple = (u32, u64); #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg="cfail2", except="hir_owner")] #[rustc_clean(cfg="cfail3")] type ChangeTypeTuple = (u32, i64); @@ -91,7 +91,7 @@ enum Enum2 { type ChangeTypeEnum = Enum1; #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg="cfail2", except="hir_owner")] #[rustc_clean(cfg="cfail3")] type ChangeTypeEnum = Enum2; @@ -102,7 +102,7 @@ type ChangeTypeEnum = Enum2; type AddTupleField = (i32, i64); #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg="cfail2", except="hir_owner")] #[rustc_clean(cfg="cfail3")] type AddTupleField = (i32, i64, i16); @@ -113,7 +113,7 @@ type AddTupleField = (i32, i64, i16); type ChangeNestedTupleField = (i32, (i64, i16)); #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="hir_owner,hir_owner_nodes")] +#[rustc_clean(cfg="cfail2", except="hir_owner")] #[rustc_clean(cfg="cfail3")] type ChangeNestedTupleField = (i32, (i64, i8)); From ac470e95852336172197810a9a4f6d2e8c8b6574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20du=20Garreau?= Date: Thu, 29 Apr 2021 09:53:19 +0200 Subject: [PATCH 164/441] Multiple improvements to RwLocks - Split `sys_common::RWLock` between `StaticRWLock` and `MovableRWLock` - Unbox `RwLock` on some platforms (Windows, Wasm and unsupported) - Simplify `RwLock::into_inner` --- library/std/src/panicking.rs | 15 ++- library/std/src/sync/rwlock.rs | 34 +----- library/std/src/sys/hermit/rwlock.rs | 2 + library/std/src/sys/sgx/rwlock.rs | 2 + library/std/src/sys/unix/os.rs | 11 +- library/std/src/sys/unix/rwlock.rs | 54 +-------- library/std/src/sys/unsupported/rwlock.rs | 2 + library/std/src/sys/wasm/atomics/rwlock.rs | 2 + library/std/src/sys/windows/rwlock.rs | 2 + library/std/src/sys_common/rwlock.rs | 122 ++++++++++++++------- 10 files changed, 112 insertions(+), 134 deletions(-) diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 02957e75a740..8f08ac9faa68 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -19,7 +19,7 @@ use crate::process; use crate::sync::atomic::{AtomicBool, Ordering}; use crate::sys::stdio::panic_output; use crate::sys_common::backtrace::{self, RustBacktrace}; -use crate::sys_common::rwlock::RWLock; +use crate::sys_common::rwlock::StaticRWLock; use crate::sys_common::thread_info; use crate::thread; @@ -74,7 +74,7 @@ enum Hook { Custom(*mut (dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send)), } -static HOOK_LOCK: RWLock = RWLock::new(); +static HOOK_LOCK: StaticRWLock = StaticRWLock::new(); static mut HOOK: Hook = Hook::Default; /// Registers a custom panic hook, replacing any that was previously registered. @@ -117,10 +117,10 @@ pub fn set_hook(hook: Box) + 'static + Sync + Send>) { } unsafe { - HOOK_LOCK.write(); + let guard = HOOK_LOCK.write(); let old_hook = HOOK; HOOK = Hook::Custom(Box::into_raw(hook)); - HOOK_LOCK.write_unlock(); + drop(guard); if let Hook::Custom(ptr) = old_hook { #[allow(unused_must_use)] @@ -165,10 +165,10 @@ pub fn take_hook() -> Box) + 'static + Sync + Send> { } unsafe { - HOOK_LOCK.write(); + let guard = HOOK_LOCK.write(); let hook = HOOK; HOOK = Hook::Default; - HOOK_LOCK.write_unlock(); + drop(guard); match hook { Hook::Default => Box::new(default_hook), @@ -608,7 +608,7 @@ fn rust_panic_with_hook( unsafe { let mut info = PanicInfo::internal_constructor(message, location); - HOOK_LOCK.read(); + let _guard = HOOK_LOCK.read(); match HOOK { // Some platforms (like wasm) know that printing to stderr won't ever actually // print anything, and if that's the case we can skip the default @@ -626,7 +626,6 @@ fn rust_panic_with_hook( (*ptr)(&info); } }; - HOOK_LOCK.read_unlock(); } if panics > 1 { diff --git a/library/std/src/sync/rwlock.rs b/library/std/src/sync/rwlock.rs index 9d521ab14cbf..0d00f74eaa1e 100644 --- a/library/std/src/sync/rwlock.rs +++ b/library/std/src/sync/rwlock.rs @@ -3,9 +3,7 @@ mod tests; use crate::cell::UnsafeCell; use crate::fmt; -use crate::mem; use crate::ops::{Deref, DerefMut}; -use crate::ptr; use crate::sync::{poison, LockResult, TryLockError, TryLockResult}; use crate::sys_common::rwlock as sys; @@ -66,7 +64,7 @@ use crate::sys_common::rwlock as sys; /// [`Mutex`]: super::Mutex #[stable(feature = "rust1", since = "1.0.0")] pub struct RwLock { - inner: Box, + inner: sys::MovableRWLock, poison: poison::Flag, data: UnsafeCell, } @@ -130,7 +128,7 @@ impl RwLock { #[stable(feature = "rust1", since = "1.0.0")] pub fn new(t: T) -> RwLock { RwLock { - inner: box sys::RWLock::new(), + inner: sys::MovableRWLock::new(), poison: poison::Flag::new(), data: UnsafeCell::new(t), } @@ -376,24 +374,8 @@ impl RwLock { where T: Sized, { - // We know statically that there are no outstanding references to - // `self` so there's no need to lock the inner lock. - // - // To get the inner value, we'd like to call `data.into_inner()`, - // but because `RwLock` impl-s `Drop`, we can't move out of it, so - // we'll have to destructure it manually instead. - unsafe { - // Like `let RwLock { inner, poison, data } = self`. - let (inner, poison, data) = { - let RwLock { ref inner, ref poison, ref data } = self; - (ptr::read(inner), ptr::read(poison), ptr::read(data)) - }; - mem::forget(self); - inner.destroy(); // Keep in sync with the `Drop` impl. - drop(inner); - - poison::map_result(poison.borrow(), |_| data.into_inner()) - } + let data = self.data.into_inner(); + poison::map_result(self.poison.borrow(), |_| data) } /// Returns a mutable reference to the underlying data. @@ -424,14 +406,6 @@ impl RwLock { } } -#[stable(feature = "rust1", since = "1.0.0")] -unsafe impl<#[may_dangle] T: ?Sized> Drop for RwLock { - fn drop(&mut self) { - // IMPORTANT: This code needs to be kept in sync with `RwLock::into_inner`. - unsafe { self.inner.destroy() } - } -} - #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for RwLock { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/library/std/src/sys/hermit/rwlock.rs b/library/std/src/sys/hermit/rwlock.rs index 06442e925f4c..d2058180121d 100644 --- a/library/std/src/sys/hermit/rwlock.rs +++ b/library/std/src/sys/hermit/rwlock.rs @@ -8,6 +8,8 @@ pub struct RWLock { state: UnsafeCell, } +pub type MovableRWLock = Box; + enum State { Unlocked, Reading(usize), diff --git a/library/std/src/sys/sgx/rwlock.rs b/library/std/src/sys/sgx/rwlock.rs index 0c96e3fcddcd..2d038b518965 100644 --- a/library/std/src/sys/sgx/rwlock.rs +++ b/library/std/src/sys/sgx/rwlock.rs @@ -13,6 +13,8 @@ pub struct RWLock { writer: SpinMutex>, } +pub type MovableRWLock = Box; + // Check at compile time that RWLock size matches C definition (see test_c_rwlock_initializer below) // // # Safety diff --git a/library/std/src/sys/unix/os.rs b/library/std/src/sys/unix/os.rs index bbc4691d963c..41ca9762390c 100644 --- a/library/std/src/sys/unix/os.rs +++ b/library/std/src/sys/unix/os.rs @@ -20,8 +20,7 @@ use crate::str; use crate::sys::cvt; use crate::sys::fd; use crate::sys::memchr; -use crate::sys::rwlock::{RWLockReadGuard, StaticRWLock}; -use crate::sys_common::mutex::{StaticMutex, StaticMutexGuard}; +use crate::sys_common::rwlock::{StaticRWLock, StaticRWLockReadGuard}; use crate::vec; use libc::{c_char, c_int, c_void}; @@ -490,8 +489,8 @@ pub unsafe fn environ() -> *mut *const *const c_char { static ENV_LOCK: StaticRWLock = StaticRWLock::new(); -pub fn env_read_lock() -> RWLockReadGuard { - ENV_LOCK.read_with_guard() +pub fn env_read_lock() -> StaticRWLockReadGuard { + ENV_LOCK.read() } /// Returns a vector of (variable, value) byte-vector pairs for all the @@ -551,7 +550,7 @@ pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> { let v = CString::new(v.as_bytes())?; unsafe { - let _guard = ENV_LOCK.write_with_guard(); + let _guard = ENV_LOCK.write(); cvt(libc::setenv(k.as_ptr(), v.as_ptr(), 1)).map(drop) } } @@ -560,7 +559,7 @@ pub fn unsetenv(n: &OsStr) -> io::Result<()> { let nbuf = CString::new(n.as_bytes())?; unsafe { - let _guard = ENV_LOCK.write_with_guard(); + let _guard = ENV_LOCK.write(); cvt(libc::unsetenv(nbuf.as_ptr())).map(drop) } } diff --git a/library/std/src/sys/unix/rwlock.rs b/library/std/src/sys/unix/rwlock.rs index d97d9d712fc9..b1faf12c2261 100644 --- a/library/std/src/sys/unix/rwlock.rs +++ b/library/std/src/sys/unix/rwlock.rs @@ -7,6 +7,8 @@ pub struct RWLock { num_readers: AtomicUsize, } +pub type MovableRWLock = Box; + unsafe impl Send for RWLock {} unsafe impl Sync for RWLock {} @@ -139,55 +141,3 @@ impl RWLock { } } } - -pub struct StaticRWLock(RWLock); - -impl StaticRWLock { - pub const fn new() -> StaticRWLock { - StaticRWLock(RWLock::new()) - } - - /// Acquires shared access to the underlying lock, blocking the current - /// thread to do so. - /// - /// The lock is automatically unlocked when the returned guard is dropped. - #[inline] - pub fn read_with_guard(&'static self) -> RWLockReadGuard { - // SAFETY: All methods require static references, therefore self - // cannot be moved between invocations. - unsafe { - self.0.read(); - } - RWLockReadGuard(&self.0) - } - - /// Acquires write access to the underlying lock, blocking the current thread - /// to do so. - /// - /// The lock is automatically unlocked when the returned guard is dropped. - #[inline] - pub fn write_with_guard(&'static self) -> RWLockWriteGuard { - // SAFETY: All methods require static references, therefore self - // cannot be moved between invocations. - unsafe { - self.0.write(); - } - RWLockWriteGuard(&self.0) - } -} - -pub struct RWLockReadGuard(&'static RWLock); - -impl Drop for RWLockReadGuard { - fn drop(&mut self) { - unsafe { self.0.read_unlock() } - } -} - -pub struct RWLockWriteGuard(&'static RWLock); - -impl Drop for RWLockWriteGuard { - fn drop(&mut self) { - unsafe { self.0.write_unlock() } - } -} diff --git a/library/std/src/sys/unsupported/rwlock.rs b/library/std/src/sys/unsupported/rwlock.rs index 6982b2b155fa..8438adeb5b53 100644 --- a/library/std/src/sys/unsupported/rwlock.rs +++ b/library/std/src/sys/unsupported/rwlock.rs @@ -5,6 +5,8 @@ pub struct RWLock { mode: Cell, } +pub type MovableRWLock = RWLock; + unsafe impl Send for RWLock {} unsafe impl Sync for RWLock {} // no threads on this platform diff --git a/library/std/src/sys/wasm/atomics/rwlock.rs b/library/std/src/sys/wasm/atomics/rwlock.rs index 06442e925f4c..64eaa2fc482d 100644 --- a/library/std/src/sys/wasm/atomics/rwlock.rs +++ b/library/std/src/sys/wasm/atomics/rwlock.rs @@ -8,6 +8,8 @@ pub struct RWLock { state: UnsafeCell, } +pub type MovableRWLock = RWLock; + enum State { Unlocked, Reading(usize), diff --git a/library/std/src/sys/windows/rwlock.rs b/library/std/src/sys/windows/rwlock.rs index a769326352c4..b7a5b1e7accd 100644 --- a/library/std/src/sys/windows/rwlock.rs +++ b/library/std/src/sys/windows/rwlock.rs @@ -5,6 +5,8 @@ pub struct RWLock { inner: UnsafeCell, } +pub type MovableRWLock = RWLock; + unsafe impl Send for RWLock {} unsafe impl Sync for RWLock {} diff --git a/library/std/src/sys_common/rwlock.rs b/library/std/src/sys_common/rwlock.rs index 3705d641a1be..07ec20f4dc61 100644 --- a/library/std/src/sys_common/rwlock.rs +++ b/library/std/src/sys_common/rwlock.rs @@ -1,63 +1,112 @@ use crate::sys::rwlock as imp; -/// An OS-based reader-writer lock. +/// An OS-based reader-writer lock, meant for use in static variables. /// -/// This structure is entirely unsafe and serves as the lowest layer of a -/// cross-platform binding of system rwlocks. It is recommended to use the -/// safer types at the top level of this crate instead of this type. -pub struct RWLock(imp::RWLock); +/// This rwlock does not implement poisoning. +/// +/// This rwlock has a const constructor ([`StaticRWLock::new`]), does not +/// implement `Drop` to cleanup resources. +pub struct StaticRWLock(imp::RWLock); -impl RWLock { - /// Creates a new reader-writer lock for use. - /// - /// Behavior is undefined if the reader-writer lock is moved after it is - /// first used with any of the functions below. - pub const fn new() -> RWLock { - RWLock(imp::RWLock::new()) +impl StaticRWLock { + /// Creates a new rwlock for use. + pub const fn new() -> Self { + Self(imp::RWLock::new()) } /// Acquires shared access to the underlying lock, blocking the current /// thread to do so. /// - /// Behavior is undefined if the rwlock has been moved between this and any - /// previous method call. + /// The lock is automatically unlocked when the returned guard is dropped. #[inline] - pub unsafe fn read(&self) { - self.0.read() + pub fn read(&'static self) -> StaticRWLockReadGuard { + unsafe { self.0.read() }; + StaticRWLockReadGuard(&self.0) + } + + /// Acquires write access to the underlying lock, blocking the current thread + /// to do so. + /// + /// The lock is automatically unlocked when the returned guard is dropped. + #[inline] + pub fn write(&'static self) -> StaticRWLockWriteGuard { + unsafe { self.0.write() }; + StaticRWLockWriteGuard(&self.0) + } +} + +#[must_use] +pub struct StaticRWLockReadGuard(&'static imp::RWLock); + +impl Drop for StaticRWLockReadGuard { + #[inline] + fn drop(&mut self) { + unsafe { + self.0.read_unlock(); + } + } +} + +#[must_use] +pub struct StaticRWLockWriteGuard(&'static imp::RWLock); + +impl Drop for StaticRWLockWriteGuard { + #[inline] + fn drop(&mut self) { + unsafe { + self.0.write_unlock(); + } + } +} + +/// An OS-based reader-writer lock. +/// +/// This rwlock does *not* have a const constructor, cleans up its resources in +/// its `Drop` implementation and may safely be moved (when not borrowed). +/// +/// This rwlock does not implement poisoning. +/// +/// This is either a wrapper around `Box` or `imp::RWLock`, +/// depending on the platform. It is boxed on platforms where `imp::RWLock` may +/// not be moved. +pub struct MovableRWLock(imp::MovableRWLock); + +impl MovableRWLock { + /// Creates a new reader-writer lock for use. + pub fn new() -> Self { + Self(imp::MovableRWLock::from(imp::RWLock::new())) + } + + /// Acquires shared access to the underlying lock, blocking the current + /// thread to do so. + #[inline] + pub fn read(&self) { + unsafe { self.0.read() } } /// Attempts to acquire shared access to this lock, returning whether it /// succeeded or not. /// /// This function does not block the current thread. - /// - /// Behavior is undefined if the rwlock has been moved between this and any - /// previous method call. #[inline] - pub unsafe fn try_read(&self) -> bool { - self.0.try_read() + pub fn try_read(&self) -> bool { + unsafe { self.0.try_read() } } /// Acquires write access to the underlying lock, blocking the current thread /// to do so. - /// - /// Behavior is undefined if the rwlock has been moved between this and any - /// previous method call. #[inline] - pub unsafe fn write(&self) { - self.0.write() + pub fn write(&self) { + unsafe { self.0.write() } } /// Attempts to acquire exclusive access to this lock, returning whether it /// succeeded or not. /// /// This function does not block the current thread. - /// - /// Behavior is undefined if the rwlock has been moved between this and any - /// previous method call. #[inline] - pub unsafe fn try_write(&self) -> bool { - self.0.try_write() + pub fn try_write(&self) -> bool { + unsafe { self.0.try_write() } } /// Unlocks previously acquired shared access to this lock. @@ -76,13 +125,10 @@ impl RWLock { pub unsafe fn write_unlock(&self) { self.0.write_unlock() } +} - /// Destroys OS-related resources with this RWLock. - /// - /// Behavior is undefined if there are any currently active users of this - /// lock. - #[inline] - pub unsafe fn destroy(&self) { - self.0.destroy() +impl Drop for MovableRWLock { + fn drop(&mut self) { + unsafe { self.0.destroy() }; } } From c5233b7d4bf3c35e5c5809f4b7adbf6220e263ce Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Tue, 1 Jun 2021 13:16:52 +0200 Subject: [PATCH 165/441] Fix typo in internal documentation for `TrustedRandomAccess` `next_back` is a method of DoubleEndedIterator, not Iterator. --- library/core/src/iter/adapters/zip.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/iter/adapters/zip.rs b/library/core/src/iter/adapters/zip.rs index 2f8f504d8fca..c95324c80ba6 100644 --- a/library/core/src/iter/adapters/zip.rs +++ b/library/core/src/iter/adapters/zip.rs @@ -434,7 +434,7 @@ impl ZipFmt Date: Tue, 1 Jun 2021 17:00:54 +0200 Subject: [PATCH 166/441] Fix test --- .../expected_show_coverage.generics.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.generics.txt b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.generics.txt index 7b38ffb87cba..be0dbf71607f 100644 --- a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.generics.txt +++ b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.generics.txt @@ -11,15 +11,15 @@ 11| 3| self.strength = new_strength; 12| 3| } ------------------ - | >::set_strength: - | 10| 2| fn set_strength(&mut self, new_strength: T) { - | 11| 2| self.strength = new_strength; - | 12| 2| } - ------------------ | >::set_strength: | 10| 1| fn set_strength(&mut self, new_strength: T) { | 11| 1| self.strength = new_strength; | 12| 1| } + ------------------ + | >::set_strength: + | 10| 2| fn set_strength(&mut self, new_strength: T) { + | 11| 2| self.strength = new_strength; + | 12| 2| } ------------------ 13| |} 14| | From c63cb014a045642efbbf1363666a4eda247163a3 Mon Sep 17 00:00:00 2001 From: klensy Date: Tue, 1 Jun 2021 18:25:36 +0300 Subject: [PATCH 167/441] updated shlex for jsondocck --- Cargo.lock | 10 ++-------- src/tools/jsondocck/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df7d84419414..6e674d7257f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1747,7 +1747,7 @@ dependencies = [ "regex", "serde", "serde_json", - "shlex 0.1.1", + "shlex", ] [[package]] @@ -2128,7 +2128,7 @@ dependencies = [ "serde", "serde_derive", "serde_json", - "shlex 1.0.0", + "shlex", "tempfile", "toml", ] @@ -4794,12 +4794,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45bb67a18fa91266cc7807181f62f9178a6873bfad7dc788c42e6430db40184f" -[[package]] -name = "shlex" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" - [[package]] name = "shlex" version = "1.0.0" diff --git a/src/tools/jsondocck/Cargo.toml b/src/tools/jsondocck/Cargo.toml index a6efc4c9a6b5..eb1c422ef729 100644 --- a/src/tools/jsondocck/Cargo.toml +++ b/src/tools/jsondocck/Cargo.toml @@ -9,7 +9,7 @@ jsonpath_lib = "0.2" getopts = "0.2" regex = "1.4" lazy_static = "1.4" -shlex = "0.1" +shlex = "1.0" serde = "1.0" serde_json = "1.0" fs-err = "2.5.0" From 1213d9262f31873dfa396bd57290c2ced63670ff Mon Sep 17 00:00:00 2001 From: Frank Steffahn Date: Tue, 1 Jun 2021 18:26:42 +0200 Subject: [PATCH 168/441] Update unsound label for triagebot --- triagebot.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/triagebot.toml b/triagebot.toml index 8b6157cd4aae..c97f63f1cfd9 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -79,7 +79,7 @@ trigger_labels = [ "regression-from-stable-to-stable", "regression-from-stable-to-beta", "regression-from-stable-to-nightly", - "I-unsound 💥", + "I-unsound", ] exclude_labels = [ "P-*", From 5afc594e6294cee451ded335397cade6a9098bd1 Mon Sep 17 00:00:00 2001 From: klensy Date: Tue, 1 Jun 2021 19:44:10 +0300 Subject: [PATCH 169/441] replace lazy_static with once_cell, drop direct dependency on serde --- Cargo.lock | 3 +-- src/tools/jsondocck/Cargo.toml | 3 +-- src/tools/jsondocck/src/main.rs | 12 ++++++------ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e674d7257f9..7badb93bce55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1743,9 +1743,8 @@ dependencies = [ "fs-err", "getopts", "jsonpath_lib", - "lazy_static", + "once_cell", "regex", - "serde", "serde_json", "shlex", ] diff --git a/src/tools/jsondocck/Cargo.toml b/src/tools/jsondocck/Cargo.toml index eb1c422ef729..b5f1554dbe4d 100644 --- a/src/tools/jsondocck/Cargo.toml +++ b/src/tools/jsondocck/Cargo.toml @@ -8,8 +8,7 @@ edition = "2018" jsonpath_lib = "0.2" getopts = "0.2" regex = "1.4" -lazy_static = "1.4" shlex = "1.0" -serde = "1.0" serde_json = "1.0" fs-err = "2.5.0" +once_cell = "1.0" diff --git a/src/tools/jsondocck/src/main.rs b/src/tools/jsondocck/src/main.rs index 216890d59ad6..b8ea10f3d227 100644 --- a/src/tools/jsondocck/src/main.rs +++ b/src/tools/jsondocck/src/main.rs @@ -1,5 +1,5 @@ use jsonpath_lib::select; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use regex::{Regex, RegexBuilder}; use serde_json::Value; use std::borrow::Cow; @@ -94,19 +94,19 @@ impl fmt::Display for CommandKind { } } -lazy_static! { - static ref LINE_PATTERN: Regex = RegexBuilder::new( +static LINE_PATTERN: Lazy = Lazy::new(|| { + RegexBuilder::new( r#" \s(?P!?)@(?P!?) (?P[A-Za-z]+(?:-[A-Za-z]+)*) (?P.*)$ - "# + "#, ) .ignore_whitespace(true) .unicode(true) .build() - .unwrap(); -} + .unwrap() +}); fn print_err(msg: &str, lineno: usize) { eprintln!("Invalid command: {} on line {}", msg, lineno) From ba680aa5f25e1584ef6eb54ed45b35ea6d58f9a7 Mon Sep 17 00:00:00 2001 From: Ellen Date: Tue, 1 Jun 2021 17:44:49 +0100 Subject: [PATCH 170/441] Add test for forward declared const param defaults --- compiler/rustc_resolve/src/diagnostics.rs | 2 +- compiler/rustc_resolve/src/lib.rs | 4 +-- .../defaults/forward-declared.rs | 15 +++++++++++ .../defaults/forward-declared.stderr | 27 +++++++++++++++++++ 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/const-generics/defaults/forward-declared.rs create mode 100644 src/test/ui/const-generics/defaults/forward-declared.stderr diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index a1eafd65d643..03d94f43897b 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -450,7 +450,7 @@ impl<'a> Resolver<'a> { err.span_label(shadowed_binding_span, msg); err } - ResolutionError::ForwardDeclaredTyParam => { + ResolutionError::ForwardDeclaredGenericParam => { let mut err = struct_span_err!( self.session, span, diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 5e009d148322..dd80b0045967 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -242,7 +242,7 @@ enum ResolutionError<'a> { shadowed_binding_span: Span, }, /// Error E0128: generic parameters with a default cannot use forward-declared identifiers. - ForwardDeclaredTyParam, // FIXME(const_generics_defaults) + ForwardDeclaredGenericParam, /// ERROR E0770: the type of const parameters must not depend on other generic parameters. ParamInTyOfConstParam(Symbol), /// generic parameters must not be used inside const evaluations. @@ -2617,7 +2617,7 @@ impl<'a> Resolver<'a> { let res_error = if rib_ident.name == kw::SelfUpper { ResolutionError::SelfInTyParamDefault } else { - ResolutionError::ForwardDeclaredTyParam + ResolutionError::ForwardDeclaredGenericParam }; self.report_error(span, res_error); } diff --git a/src/test/ui/const-generics/defaults/forward-declared.rs b/src/test/ui/const-generics/defaults/forward-declared.rs new file mode 100644 index 000000000000..09fc105320e4 --- /dev/null +++ b/src/test/ui/const-generics/defaults/forward-declared.rs @@ -0,0 +1,15 @@ +#![feature(const_generics_defaults)] + +struct Foo; +//~^ ERROR generic parameters with a default cannot use forward declared identifiers + +enum Bar {} +//~^ ERROR generic parameters with a default cannot use forward declared identifiers + +struct Foo2; +//~^ ERROR generic parameters with a default cannot use forward declared identifiers + +enum Bar2 {} +//~^ ERROR generic parameters with a default cannot use forward declared identifiers + +fn main() {} diff --git a/src/test/ui/const-generics/defaults/forward-declared.stderr b/src/test/ui/const-generics/defaults/forward-declared.stderr new file mode 100644 index 000000000000..a6c4a7ae4ef2 --- /dev/null +++ b/src/test/ui/const-generics/defaults/forward-declared.stderr @@ -0,0 +1,27 @@ +error[E0128]: generic parameters with a default cannot use forward declared identifiers + --> $DIR/forward-declared.rs:3:29 + | +LL | struct Foo; + | ^ defaulted generic parameters cannot be forward declared + +error[E0128]: generic parameters with a default cannot use forward declared identifiers + --> $DIR/forward-declared.rs:6:27 + | +LL | enum Bar {} + | ^ defaulted generic parameters cannot be forward declared + +error[E0128]: generic parameters with a default cannot use forward declared identifiers + --> $DIR/forward-declared.rs:9:30 + | +LL | struct Foo2; + | ^ defaulted generic parameters cannot be forward declared + +error[E0128]: generic parameters with a default cannot use forward declared identifiers + --> $DIR/forward-declared.rs:12:28 + | +LL | enum Bar2 {} + | ^ defaulted generic parameters cannot be forward declared + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0128`. From 4675690ac4022a937f6817570e06f987c2efbc61 Mon Sep 17 00:00:00 2001 From: Ryan Levick Date: Tue, 1 Jun 2021 18:01:13 +0200 Subject: [PATCH 171/441] Fix issues and add test --- compiler/rustc_lint/src/levels.rs | 2 +- compiler/rustc_middle/src/lint.rs | 1 - src/test/ui/lint/force-warn/force-allowed-group.rs | 2 +- src/test/ui/lint/force-warn/force-warn-group.rs | 13 +++++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/lint/force-warn/force-warn-group.rs diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 482ec58fd1af..4f3d98304e7a 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -147,7 +147,7 @@ impl<'s> LintLevelsBuilder<'s> { LintLevelSource::Default => false, LintLevelSource::Node(symbol, _, _) => self.store.is_lint_group(symbol), LintLevelSource::CommandLine(symbol, _) => self.store.is_lint_group(symbol), - LintLevelSource::ForceWarn(symbol) => { + LintLevelSource::ForceWarn(_symbol) => { bug!("forced warn lint returned a forbid lint level") } }; diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index af9bc5ebe707..f3088326db80 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -1,7 +1,6 @@ use std::cmp; use crate::ich::StableHashingContext; -use chalk_ir::Substitution; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_errors::{DiagnosticBuilder, DiagnosticId}; diff --git a/src/test/ui/lint/force-warn/force-allowed-group.rs b/src/test/ui/lint/force-warn/force-allowed-group.rs index fe8b106a0860..b68b979ca11c 100644 --- a/src/test/ui/lint/force-warn/force-allowed-group.rs +++ b/src/test/ui/lint/force-warn/force-allowed-group.rs @@ -1,7 +1,7 @@ // compile-flags: --force-warns bare_trait_objects // check-pass -#![allow(rust_2018_compatibility)] +#![allow(rust_2018_idioms)] pub trait SomeTrait {} diff --git a/src/test/ui/lint/force-warn/force-warn-group.rs b/src/test/ui/lint/force-warn/force-warn-group.rs new file mode 100644 index 000000000000..3206d75e940c --- /dev/null +++ b/src/test/ui/lint/force-warn/force-warn-group.rs @@ -0,0 +1,13 @@ +// ignore-test +// compile-flags: --force-warns rust_2018_idioms +// check-pass + +#![allow(rust_2018_idioms)] + +pub trait SomeTrait {} + +pub fn function(_x: Box) {} +//~^ WARN trait objects without an explicit `dyn` are deprecated +//~| WARN this was previously accepted by the compiler + +fn main() {} From a2c4affe860ec53647b902f257e7e575f0350854 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Tue, 1 Jun 2021 19:12:55 +0200 Subject: [PATCH 172/441] Remove unused functions and arguments from rustc_serialize --- compiler/rustc_errors/src/json.rs | 4 +- compiler/rustc_macros/src/serialize.rs | 18 +- .../src/dep_graph/serialized.rs | 12 +- .../rustc_serialize/src/collection_impls.rs | 48 ++--- compiler/rustc_serialize/src/json.rs | 171 +++--------------- compiler/rustc_serialize/src/serialize.rs | 161 ++++------------- compiler/rustc_span/src/def_id.rs | 12 +- compiler/rustc_span/src/lib.rs | 68 +++---- 8 files changed, 144 insertions(+), 350 deletions(-) diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index 5d175a3ade9a..72395bd31eca 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -216,7 +216,7 @@ macro_rules! encode_fields { $( $enc.emit_struct_field( stringify!($name), - idx, + idx == 0, |enc| $name.encode(enc), )?; idx += 1; @@ -229,7 +229,7 @@ macro_rules! encode_fields { // Special-case encoder to skip tool_metadata if not set impl Encodable for Diagnostic { fn encode(&self, s: &mut E) -> Result<(), E::Error> { - s.emit_struct("diagnostic", 7, |s| { + s.emit_struct(false, |s| { let mut idx = 0; idx = encode_fields!( diff --git a/compiler/rustc_macros/src/serialize.rs b/compiler/rustc_macros/src/serialize.rs index 72bd4804e98c..7bc669f2b005 100644 --- a/compiler/rustc_macros/src/serialize.rs +++ b/compiler/rustc_macros/src/serialize.rs @@ -43,12 +43,9 @@ fn decodable_body( let decode_body = match s.variants() { [vi] => { let construct = vi.construct(|field, index| decode_field(field, index, true)); - let n_fields = vi.ast().fields.len(); quote! { ::rustc_serialize::Decoder::read_struct( __decoder, - #ty_name, - #n_fields, |__decoder| { ::std::result::Result::Ok(#construct) }, ) } @@ -77,7 +74,6 @@ fn decodable_body( quote! { ::rustc_serialize::Decoder::read_enum( __decoder, - #ty_name, |__decoder| { ::rustc_serialize::Decoder::read_enum_variant( __decoder, @@ -128,7 +124,7 @@ fn decode_field(field: &syn::Field, index: usize, is_struct: bool) -> proc_macro quote! { match ::rustc_serialize::Decoder::#decode_method( - __decoder, #opt_field_name #index, #decode_inner_method) { + __decoder, #opt_field_name #decode_inner_method) { ::std::result::Result::Ok(__res) => __res, ::std::result::Result::Err(__err) => return ::std::result::Result::Err(__err), } @@ -183,7 +179,6 @@ fn encodable_body( } }); - let ty_name = s.ast().ident.to_string(); let encode_body = match s.variants() { [_] => { let mut field_idx = 0usize; @@ -197,11 +192,12 @@ fn encodable_body( .ident .as_ref() .map_or_else(|| field_idx.to_string(), |i| i.to_string()); + let first = field_idx == 0; let result = quote! { match ::rustc_serialize::Encoder::emit_struct_field( __encoder, #field_name, - #field_idx, + #first, |__encoder| ::rustc_serialize::Encodable::<#encoder_ty>::encode(#bind_ident, __encoder), ) { @@ -215,8 +211,9 @@ fn encodable_body( }) .collect::() }); + let no_fields = field_idx == 0; quote! { - ::rustc_serialize::Encoder::emit_struct(__encoder, #ty_name, #field_idx, |__encoder| { + ::rustc_serialize::Encoder::emit_struct(__encoder, #no_fields, |__encoder| { ::std::result::Result::Ok(match *self { #encode_inner }) }) } @@ -232,10 +229,11 @@ fn encodable_body( .iter() .map(|binding| { let bind_ident = &binding.binding; + let first = field_idx == 0; let result = quote! { match ::rustc_serialize::Encoder::emit_enum_variant_arg( __encoder, - #field_idx, + #first, |__encoder| ::rustc_serialize::Encodable::<#encoder_ty>::encode(#bind_ident, __encoder), ) { @@ -260,7 +258,7 @@ fn encodable_body( result }); quote! { - ::rustc_serialize::Encoder::emit_enum(__encoder, #ty_name, |__encoder| { + ::rustc_serialize::Encoder::emit_enum(__encoder, |__encoder| { match *self { #encode_inner } diff --git a/compiler/rustc_query_system/src/dep_graph/serialized.rs b/compiler/rustc_query_system/src/dep_graph/serialized.rs index 6a84a28be665..73c00fc49ba3 100644 --- a/compiler/rustc_query_system/src/dep_graph/serialized.rs +++ b/compiler/rustc_query_system/src/dep_graph/serialized.rs @@ -122,21 +122,21 @@ impl<'a, K: DepKind + Decodable>> Decodable = d.read_struct_field("node", 0, Decodable::decode)?; + d.read_struct(|d| { + let dep_node: DepNode = d.read_struct_field("node", Decodable::decode)?; let _i: SerializedDepNodeIndex = nodes.push(dep_node); debug_assert_eq!(_i.index(), _index); let fingerprint: Fingerprint = - d.read_struct_field("fingerprint", 1, Decodable::decode)?; + d.read_struct_field("fingerprint", Decodable::decode)?; let _i: SerializedDepNodeIndex = fingerprints.push(fingerprint); debug_assert_eq!(_i.index(), _index); - d.read_struct_field("edges", 2, |d| { + d.read_struct_field("edges", |d| { d.read_seq(|d, len| { let start = edge_list_data.len().try_into().unwrap(); - for e in 0..len { - let edge = d.read_seq_elt(e, Decodable::decode)?; + for _ in 0..len { + let edge = d.read_seq_elt(Decodable::decode)?; edge_list_data.push(edge); } let end = edge_list_data.len().try_into().unwrap(); diff --git a/compiler/rustc_serialize/src/collection_impls.rs b/compiler/rustc_serialize/src/collection_impls.rs index ae6d27e037b2..80a7f6501888 100644 --- a/compiler/rustc_serialize/src/collection_impls.rs +++ b/compiler/rustc_serialize/src/collection_impls.rs @@ -21,8 +21,8 @@ impl>> Decodable for SmallVec { d.read_seq(|d, len| { let mut vec = SmallVec::with_capacity(len); // FIXME(#48994) - could just be collected into a Result - for i in 0..len { - vec.push(d.read_seq_elt(i, |d| Decodable::decode(d))?); + for _ in 0..len { + vec.push(d.read_seq_elt(|d| Decodable::decode(d))?); } Ok(vec) }) @@ -44,8 +44,8 @@ impl> Decodable for LinkedList { fn decode(d: &mut D) -> Result, D::Error> { d.read_seq(|d, len| { let mut list = LinkedList::new(); - for i in 0..len { - list.push_back(d.read_seq_elt(i, |d| Decodable::decode(d))?); + for _ in 0..len { + list.push_back(d.read_seq_elt(|d| Decodable::decode(d))?); } Ok(list) }) @@ -67,8 +67,8 @@ impl> Decodable for VecDeque { fn decode(d: &mut D) -> Result, D::Error> { d.read_seq(|d, len| { let mut deque: VecDeque = VecDeque::with_capacity(len); - for i in 0..len { - deque.push_back(d.read_seq_elt(i, |d| Decodable::decode(d))?); + for _ in 0..len { + deque.push_back(d.read_seq_elt(|d| Decodable::decode(d))?); } Ok(deque) }) @@ -84,7 +84,7 @@ where e.emit_map(self.len(), |e| { for (i, (key, val)) in self.iter().enumerate() { e.emit_map_elt_key(i, |e| key.encode(e))?; - e.emit_map_elt_val(i, |e| val.encode(e))?; + e.emit_map_elt_val(|e| val.encode(e))?; } Ok(()) }) @@ -99,9 +99,9 @@ where fn decode(d: &mut D) -> Result, D::Error> { d.read_map(|d, len| { let mut map = BTreeMap::new(); - for i in 0..len { - let key = d.read_map_elt_key(i, |d| Decodable::decode(d))?; - let val = d.read_map_elt_val(i, |d| Decodable::decode(d))?; + for _ in 0..len { + let key = d.read_map_elt_key(|d| Decodable::decode(d))?; + let val = d.read_map_elt_val(|d| Decodable::decode(d))?; map.insert(key, val); } Ok(map) @@ -130,8 +130,8 @@ where fn decode(d: &mut D) -> Result, D::Error> { d.read_seq(|d, len| { let mut set = BTreeSet::new(); - for i in 0..len { - set.insert(d.read_seq_elt(i, |d| Decodable::decode(d))?); + for _ in 0..len { + set.insert(d.read_seq_elt(|d| Decodable::decode(d))?); } Ok(set) }) @@ -148,7 +148,7 @@ where e.emit_map(self.len(), |e| { for (i, (key, val)) in self.iter().enumerate() { e.emit_map_elt_key(i, |e| key.encode(e))?; - e.emit_map_elt_val(i, |e| val.encode(e))?; + e.emit_map_elt_val(|e| val.encode(e))?; } Ok(()) }) @@ -165,9 +165,9 @@ where d.read_map(|d, len| { let state = Default::default(); let mut map = HashMap::with_capacity_and_hasher(len, state); - for i in 0..len { - let key = d.read_map_elt_key(i, |d| Decodable::decode(d))?; - let val = d.read_map_elt_val(i, |d| Decodable::decode(d))?; + for _ in 0..len { + let key = d.read_map_elt_key(|d| Decodable::decode(d))?; + let val = d.read_map_elt_val(|d| Decodable::decode(d))?; map.insert(key, val); } Ok(map) @@ -209,8 +209,8 @@ where d.read_seq(|d, len| { let state = Default::default(); let mut set = HashSet::with_capacity_and_hasher(len, state); - for i in 0..len { - set.insert(d.read_seq_elt(i, |d| Decodable::decode(d))?); + for _ in 0..len { + set.insert(d.read_seq_elt(|d| Decodable::decode(d))?); } Ok(set) }) @@ -227,7 +227,7 @@ where e.emit_map(self.len(), |e| { for (i, (key, val)) in self.iter().enumerate() { e.emit_map_elt_key(i, |e| key.encode(e))?; - e.emit_map_elt_val(i, |e| val.encode(e))?; + e.emit_map_elt_val(|e| val.encode(e))?; } Ok(()) }) @@ -244,9 +244,9 @@ where d.read_map(|d, len| { let state = Default::default(); let mut map = indexmap::IndexMap::with_capacity_and_hasher(len, state); - for i in 0..len { - let key = d.read_map_elt_key(i, |d| Decodable::decode(d))?; - let val = d.read_map_elt_val(i, |d| Decodable::decode(d))?; + for _ in 0..len { + let key = d.read_map_elt_key(|d| Decodable::decode(d))?; + let val = d.read_map_elt_val(|d| Decodable::decode(d))?; map.insert(key, val); } Ok(map) @@ -278,8 +278,8 @@ where d.read_seq(|d, len| { let state = Default::default(); let mut set = indexmap::IndexSet::with_capacity_and_hasher(len, state); - for i in 0..len { - set.insert(d.read_seq_elt(i, |d| Decodable::decode(d))?); + for _ in 0..len { + set.insert(d.read_seq_elt(|d| Decodable::decode(d))?); } Ok(set) }) diff --git a/compiler/rustc_serialize/src/json.rs b/compiler/rustc_serialize/src/json.rs index 78a102c5c233..b79adb6f7bcd 100644 --- a/compiler/rustc_serialize/src/json.rs +++ b/compiler/rustc_serialize/src/json.rs @@ -560,7 +560,7 @@ impl<'a> crate::Encoder for Encoder<'a> { Ok(()) } - fn emit_enum(&mut self, _name: &str, f: F) -> EncodeResult + fn emit_enum(&mut self, f: F) -> EncodeResult where F: FnOnce(&mut Encoder<'a>) -> EncodeResult, { @@ -589,46 +589,20 @@ impl<'a> crate::Encoder for Encoder<'a> { } } - fn emit_enum_variant_arg(&mut self, idx: usize, f: F) -> EncodeResult + fn emit_enum_variant_arg(&mut self, first: bool, f: F) -> EncodeResult where F: FnOnce(&mut Encoder<'a>) -> EncodeResult, { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if idx != 0 { + if !first { write!(self.writer, ",")?; } f(self) } - fn emit_enum_struct_variant( - &mut self, - name: &str, - id: usize, - cnt: usize, - f: F, - ) -> EncodeResult - where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult, - { - if self.is_emitting_map_key { - return Err(EncoderError::BadHashmapKey); - } - self.emit_enum_variant(name, id, cnt, f) - } - - fn emit_enum_struct_variant_field(&mut self, _: &str, idx: usize, f: F) -> EncodeResult - where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult, - { - if self.is_emitting_map_key { - return Err(EncoderError::BadHashmapKey); - } - self.emit_enum_variant_arg(idx, f) - } - - fn emit_struct(&mut self, _: &str, _: usize, f: F) -> EncodeResult + fn emit_struct(&mut self, _: bool, f: F) -> EncodeResult where F: FnOnce(&mut Encoder<'a>) -> EncodeResult, { @@ -641,14 +615,14 @@ impl<'a> crate::Encoder for Encoder<'a> { Ok(()) } - fn emit_struct_field(&mut self, name: &str, idx: usize, f: F) -> EncodeResult + fn emit_struct_field(&mut self, name: &str, first: bool, f: F) -> EncodeResult where F: FnOnce(&mut Encoder<'a>) -> EncodeResult, { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if idx != 0 { + if !first { write!(self.writer, ",")?; } escape_str(self.writer, name)?; @@ -675,25 +649,6 @@ impl<'a> crate::Encoder for Encoder<'a> { self.emit_seq_elt(idx, f) } - fn emit_tuple_struct(&mut self, _name: &str, len: usize, f: F) -> EncodeResult - where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult, - { - if self.is_emitting_map_key { - return Err(EncoderError::BadHashmapKey); - } - self.emit_seq(len, f) - } - fn emit_tuple_struct_arg(&mut self, idx: usize, f: F) -> EncodeResult - where - F: FnOnce(&mut Encoder<'a>) -> EncodeResult, - { - if self.is_emitting_map_key { - return Err(EncoderError::BadHashmapKey); - } - self.emit_seq_elt(idx, f) - } - fn emit_option(&mut self, f: F) -> EncodeResult where F: FnOnce(&mut Encoder<'a>) -> EncodeResult, @@ -774,7 +729,7 @@ impl<'a> crate::Encoder for Encoder<'a> { Ok(()) } - fn emit_map_elt_val(&mut self, _idx: usize, f: F) -> EncodeResult + fn emit_map_elt_val(&mut self, f: F) -> EncodeResult where F: FnOnce(&mut Encoder<'a>) -> EncodeResult, { @@ -892,7 +847,7 @@ impl<'a> crate::Encoder for PrettyEncoder<'a> { Ok(()) } - fn emit_enum(&mut self, _name: &str, f: F) -> EncodeResult + fn emit_enum(&mut self, f: F) -> EncodeResult where F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, { @@ -930,54 +885,28 @@ impl<'a> crate::Encoder for PrettyEncoder<'a> { } } - fn emit_enum_variant_arg(&mut self, idx: usize, f: F) -> EncodeResult + fn emit_enum_variant_arg(&mut self, first: bool, f: F) -> EncodeResult where F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if idx != 0 { + if !first { writeln!(self.writer, ",")?; } spaces(self.writer, self.curr_indent)?; f(self) } - fn emit_enum_struct_variant( - &mut self, - name: &str, - id: usize, - cnt: usize, - f: F, - ) -> EncodeResult + fn emit_struct(&mut self, no_fields: bool, f: F) -> EncodeResult where F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - self.emit_enum_variant(name, id, cnt, f) - } - - fn emit_enum_struct_variant_field(&mut self, _: &str, idx: usize, f: F) -> EncodeResult - where - F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, - { - if self.is_emitting_map_key { - return Err(EncoderError::BadHashmapKey); - } - self.emit_enum_variant_arg(idx, f) - } - - fn emit_struct(&mut self, _: &str, len: usize, f: F) -> EncodeResult - where - F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, - { - if self.is_emitting_map_key { - return Err(EncoderError::BadHashmapKey); - } - if len == 0 { + if no_fields { write!(self.writer, "{{}}")?; } else { write!(self.writer, "{{")?; @@ -991,14 +920,14 @@ impl<'a> crate::Encoder for PrettyEncoder<'a> { Ok(()) } - fn emit_struct_field(&mut self, name: &str, idx: usize, f: F) -> EncodeResult + fn emit_struct_field(&mut self, name: &str, first: bool, f: F) -> EncodeResult where F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, { if self.is_emitting_map_key { return Err(EncoderError::BadHashmapKey); } - if idx == 0 { + if first { writeln!(self.writer)?; } else { writeln!(self.writer, ",")?; @@ -1028,25 +957,6 @@ impl<'a> crate::Encoder for PrettyEncoder<'a> { self.emit_seq_elt(idx, f) } - fn emit_tuple_struct(&mut self, _: &str, len: usize, f: F) -> EncodeResult - where - F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, - { - if self.is_emitting_map_key { - return Err(EncoderError::BadHashmapKey); - } - self.emit_seq(len, f) - } - fn emit_tuple_struct_arg(&mut self, idx: usize, f: F) -> EncodeResult - where - F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, - { - if self.is_emitting_map_key { - return Err(EncoderError::BadHashmapKey); - } - self.emit_seq_elt(idx, f) - } - fn emit_option(&mut self, f: F) -> EncodeResult where F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, @@ -1149,7 +1059,7 @@ impl<'a> crate::Encoder for PrettyEncoder<'a> { Ok(()) } - fn emit_map_elt_val(&mut self, _idx: usize, f: F) -> EncodeResult + fn emit_map_elt_val(&mut self, f: F) -> EncodeResult where F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult, { @@ -2373,7 +2283,7 @@ impl crate::Decoder for Decoder { Ok(()) } - fn read_enum(&mut self, _name: &str, f: F) -> DecodeResult + fn read_enum(&mut self, f: F) -> DecodeResult where F: FnOnce(&mut Decoder) -> DecodeResult, { @@ -2410,33 +2320,14 @@ impl crate::Decoder for Decoder { f(self, idx) } - fn read_enum_variant_arg(&mut self, _idx: usize, f: F) -> DecodeResult + fn read_enum_variant_arg(&mut self, f: F) -> DecodeResult where F: FnOnce(&mut Decoder) -> DecodeResult, { f(self) } - fn read_enum_struct_variant(&mut self, names: &[&str], f: F) -> DecodeResult - where - F: FnMut(&mut Decoder, usize) -> DecodeResult, - { - self.read_enum_variant(names, f) - } - - fn read_enum_struct_variant_field( - &mut self, - _name: &str, - idx: usize, - f: F, - ) -> DecodeResult - where - F: FnOnce(&mut Decoder) -> DecodeResult, - { - self.read_enum_variant_arg(idx, f) - } - - fn read_struct(&mut self, _name: &str, _len: usize, f: F) -> DecodeResult + fn read_struct(&mut self, f: F) -> DecodeResult where F: FnOnce(&mut Decoder) -> DecodeResult, { @@ -2445,7 +2336,7 @@ impl crate::Decoder for Decoder { Ok(value) } - fn read_struct_field(&mut self, name: &str, _idx: usize, f: F) -> DecodeResult + fn read_struct_field(&mut self, name: &str, f: F) -> DecodeResult where F: FnOnce(&mut Decoder) -> DecodeResult, { @@ -2483,25 +2374,11 @@ impl crate::Decoder for Decoder { }) } - fn read_tuple_arg(&mut self, idx: usize, f: F) -> DecodeResult + fn read_tuple_arg(&mut self, f: F) -> DecodeResult where F: FnOnce(&mut Decoder) -> DecodeResult, { - self.read_seq_elt(idx, f) - } - - fn read_tuple_struct(&mut self, _name: &str, len: usize, f: F) -> DecodeResult - where - F: FnOnce(&mut Decoder) -> DecodeResult, - { - self.read_tuple(len, f) - } - - fn read_tuple_struct_arg(&mut self, idx: usize, f: F) -> DecodeResult - where - F: FnOnce(&mut Decoder) -> DecodeResult, - { - self.read_tuple_arg(idx, f) + self.read_seq_elt(f) } fn read_option(&mut self, mut f: F) -> DecodeResult @@ -2527,7 +2404,7 @@ impl crate::Decoder for Decoder { f(self, len) } - fn read_seq_elt(&mut self, _idx: usize, f: F) -> DecodeResult + fn read_seq_elt(&mut self, f: F) -> DecodeResult where F: FnOnce(&mut Decoder) -> DecodeResult, { @@ -2547,14 +2424,14 @@ impl crate::Decoder for Decoder { f(self, len) } - fn read_map_elt_key(&mut self, _idx: usize, f: F) -> DecodeResult + fn read_map_elt_key(&mut self, f: F) -> DecodeResult where F: FnOnce(&mut Decoder) -> DecodeResult, { f(self) } - fn read_map_elt_val(&mut self, _idx: usize, f: F) -> DecodeResult + fn read_map_elt_val(&mut self, f: F) -> DecodeResult where F: FnOnce(&mut Decoder) -> DecodeResult, { diff --git a/compiler/rustc_serialize/src/serialize.rs b/compiler/rustc_serialize/src/serialize.rs index d3e5f306970c..bb3c537ef194 100644 --- a/compiler/rustc_serialize/src/serialize.rs +++ b/compiler/rustc_serialize/src/serialize.rs @@ -37,7 +37,7 @@ pub trait Encoder { // Compound types: #[inline] - fn emit_enum(&mut self, _name: &str, f: F) -> Result<(), Self::Error> + fn emit_enum(&mut self, f: F) -> Result<(), Self::Error> where F: FnOnce(&mut Self) -> Result<(), Self::Error>, { @@ -59,40 +59,7 @@ pub trait Encoder { } #[inline] - fn emit_enum_variant_arg(&mut self, _a_idx: usize, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - f(self) - } - - fn emit_enum_struct_variant( - &mut self, - v_name: &str, - v_id: usize, - len: usize, - f: F, - ) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - self.emit_enum_variant(v_name, v_id, len, f) - } - - fn emit_enum_struct_variant_field( - &mut self, - _f_name: &str, - f_idx: usize, - f: F, - ) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - self.emit_enum_variant_arg(f_idx, f) - } - - #[inline] - fn emit_struct(&mut self, _name: &str, _len: usize, f: F) -> Result<(), Self::Error> + fn emit_enum_variant_arg(&mut self, _first: bool, f: F) -> Result<(), Self::Error> where F: FnOnce(&mut Self) -> Result<(), Self::Error>, { @@ -100,12 +67,15 @@ pub trait Encoder { } #[inline] - fn emit_struct_field( - &mut self, - _f_name: &str, - _f_idx: usize, - f: F, - ) -> Result<(), Self::Error> + fn emit_struct(&mut self, _no_fields: bool, f: F) -> Result<(), Self::Error> + where + F: FnOnce(&mut Self) -> Result<(), Self::Error>, + { + f(self) + } + + #[inline] + fn emit_struct_field(&mut self, _f_name: &str, _first: bool, f: F) -> Result<(), Self::Error> where F: FnOnce(&mut Self) -> Result<(), Self::Error>, { @@ -128,26 +98,12 @@ pub trait Encoder { f(self) } - fn emit_tuple_struct(&mut self, _name: &str, len: usize, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - self.emit_tuple(len, f) - } - - fn emit_tuple_struct_arg(&mut self, f_idx: usize, f: F) -> Result<(), Self::Error> - where - F: FnOnce(&mut Self) -> Result<(), Self::Error>, - { - self.emit_tuple_arg(f_idx, f) - } - // Specialized types: fn emit_option(&mut self, f: F) -> Result<(), Self::Error> where F: FnOnce(&mut Self) -> Result<(), Self::Error>, { - self.emit_enum("Option", f) + self.emit_enum(f) } #[inline] @@ -195,7 +151,7 @@ pub trait Encoder { } #[inline] - fn emit_map_elt_val(&mut self, _idx: usize, f: F) -> Result<(), Self::Error> + fn emit_map_elt_val(&mut self, f: F) -> Result<(), Self::Error> where F: FnOnce(&mut Self) -> Result<(), Self::Error>, { @@ -229,7 +185,7 @@ pub trait Decoder { // Compound types: #[inline] - fn read_enum(&mut self, _name: &str, f: F) -> Result + fn read_enum(&mut self, f: F) -> Result where F: FnOnce(&mut Self) -> Result, { @@ -246,34 +202,7 @@ pub trait Decoder { } #[inline] - fn read_enum_variant_arg(&mut self, _a_idx: usize, f: F) -> Result - where - F: FnOnce(&mut Self) -> Result, - { - f(self) - } - - fn read_enum_struct_variant(&mut self, names: &[&str], f: F) -> Result - where - F: FnMut(&mut Self, usize) -> Result, - { - self.read_enum_variant(names, f) - } - - fn read_enum_struct_variant_field( - &mut self, - _f_name: &str, - f_idx: usize, - f: F, - ) -> Result - where - F: FnOnce(&mut Self) -> Result, - { - self.read_enum_variant_arg(f_idx, f) - } - - #[inline] - fn read_struct(&mut self, _s_name: &str, _len: usize, f: F) -> Result + fn read_enum_variant_arg(&mut self, f: F) -> Result where F: FnOnce(&mut Self) -> Result, { @@ -281,12 +210,15 @@ pub trait Decoder { } #[inline] - fn read_struct_field( - &mut self, - _f_name: &str, - _f_idx: usize, - f: F, - ) -> Result + fn read_struct(&mut self, f: F) -> Result + where + F: FnOnce(&mut Self) -> Result, + { + f(self) + } + + #[inline] + fn read_struct_field(&mut self, _f_name: &str, f: F) -> Result where F: FnOnce(&mut Self) -> Result, { @@ -302,33 +234,19 @@ pub trait Decoder { } #[inline] - fn read_tuple_arg(&mut self, _a_idx: usize, f: F) -> Result + fn read_tuple_arg(&mut self, f: F) -> Result where F: FnOnce(&mut Self) -> Result, { f(self) } - fn read_tuple_struct(&mut self, _s_name: &str, len: usize, f: F) -> Result - where - F: FnOnce(&mut Self) -> Result, - { - self.read_tuple(len, f) - } - - fn read_tuple_struct_arg(&mut self, a_idx: usize, f: F) -> Result - where - F: FnOnce(&mut Self) -> Result, - { - self.read_tuple_arg(a_idx, f) - } - // Specialized types: fn read_option(&mut self, mut f: F) -> Result where F: FnMut(&mut Self, bool) -> Result, { - self.read_enum("Option", move |this| { + self.read_enum(move |this| { this.read_enum_variant(&["None", "Some"], move |this, idx| match idx { 0 => f(this, false), 1 => f(this, true), @@ -346,7 +264,7 @@ pub trait Decoder { } #[inline] - fn read_seq_elt(&mut self, _idx: usize, f: F) -> Result + fn read_seq_elt(&mut self, f: F) -> Result where F: FnOnce(&mut Self) -> Result, { @@ -362,7 +280,7 @@ pub trait Decoder { } #[inline] - fn read_map_elt_key(&mut self, _idx: usize, f: F) -> Result + fn read_map_elt_key(&mut self, f: F) -> Result where F: FnOnce(&mut Self) -> Result, { @@ -370,7 +288,7 @@ pub trait Decoder { } #[inline] - fn read_map_elt_val(&mut self, _idx: usize, f: F) -> Result + fn read_map_elt_val(&mut self, f: F) -> Result where F: FnOnce(&mut Self) -> Result, { @@ -550,8 +468,8 @@ impl> Decodable for Vec { default fn decode(d: &mut D) -> Result, D::Error> { d.read_seq(|d, len| { let mut v = Vec::with_capacity(len); - for i in 0..len { - v.push(d.read_seq_elt(i, |d| Decodable::decode(d))?); + for _ in 0..len { + v.push(d.read_seq_elt(|d| Decodable::decode(d))?); } Ok(v) }) @@ -571,7 +489,7 @@ impl Decodable for [u8; N] { assert!(len == N); let mut v = [0u8; N]; for i in 0..len { - v[i] = d.read_seq_elt(i, |d| Decodable::decode(d))?; + v[i] = d.read_seq_elt(|d| Decodable::decode(d))?; } Ok(v) }) @@ -615,12 +533,12 @@ impl> Decodable for Option { impl, T2: Encodable> Encodable for Result { fn encode(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_enum("Result", |s| match *self { + s.emit_enum(|s| match *self { Ok(ref v) => { - s.emit_enum_variant("Ok", 0, 1, |s| s.emit_enum_variant_arg(0, |s| v.encode(s))) + s.emit_enum_variant("Ok", 0, 1, |s| s.emit_enum_variant_arg(true, |s| v.encode(s))) } Err(ref v) => { - s.emit_enum_variant("Err", 1, 1, |s| s.emit_enum_variant_arg(0, |s| v.encode(s))) + s.emit_enum_variant("Err", 1, 1, |s| s.emit_enum_variant_arg(true, |s| v.encode(s))) } }) } @@ -628,10 +546,10 @@ impl, T2: Encodable> Encodable for Result, T2: Decodable> Decodable for Result { fn decode(d: &mut D) -> Result, D::Error> { - d.read_enum("Result", |d| { + d.read_enum(|d| { d.read_enum_variant(&["Ok", "Err"], |d, disr| match disr { - 0 => Ok(Ok(d.read_enum_variant_arg(0, |d| T1::decode(d))?)), - 1 => Ok(Err(d.read_enum_variant_arg(0, |d| T2::decode(d))?)), + 0 => Ok(Ok(d.read_enum_variant_arg(|d| T1::decode(d))?)), + 1 => Ok(Err(d.read_enum_variant_arg(|d| T2::decode(d))?)), _ => { panic!( "Encountered invalid discriminant while \ @@ -668,8 +586,7 @@ macro_rules! tuple { fn decode(d: &mut D) -> Result<($($name,)+), D::Error> { let len: usize = count!($($name)+); d.read_tuple(len, |d| { - let mut i = 0; - let ret = ($(d.read_tuple_arg({ i+=1; i-1 }, |d| -> Result<$name, D::Error> { + let ret = ($(d.read_tuple_arg(|d| -> Result<$name, D::Error> { Decodable::decode(d) })?,)+); Ok(ret) diff --git a/compiler/rustc_span/src/def_id.rs b/compiler/rustc_span/src/def_id.rs index aeb3234315f7..02b20d03a574 100644 --- a/compiler/rustc_span/src/def_id.rs +++ b/compiler/rustc_span/src/def_id.rs @@ -295,20 +295,20 @@ impl DefId { impl Encodable for DefId { default fn encode(&self, s: &mut E) -> Result<(), E::Error> { - s.emit_struct("DefId", 2, |s| { - s.emit_struct_field("krate", 0, |s| self.krate.encode(s))?; + s.emit_struct(false, |s| { + s.emit_struct_field("krate", true, |s| self.krate.encode(s))?; - s.emit_struct_field("index", 1, |s| self.index.encode(s)) + s.emit_struct_field("index", false, |s| self.index.encode(s)) }) } } impl Decodable for DefId { default fn decode(d: &mut D) -> Result { - d.read_struct("DefId", 2, |d| { + d.read_struct(|d| { Ok(DefId { - krate: d.read_struct_field("krate", 0, Decodable::decode)?, - index: d.read_struct_field("index", 1, Decodable::decode)?, + krate: d.read_struct_field("krate", Decodable::decode)?, + index: d.read_struct_field("index", Decodable::decode)?, }) }) } diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index dc15c531d1e5..74a5eded650f 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -146,11 +146,12 @@ impl Hash for RealFileName { // an added assert statement impl Encodable for RealFileName { fn encode(&self, encoder: &mut S) -> Result<(), S::Error> { - encoder.emit_enum("RealFileName", |encoder| match *self { + encoder.emit_enum(|encoder| match *self { RealFileName::LocalPath(ref local_path) => { encoder.emit_enum_variant("LocalPath", 0, 1, |encoder| { Ok({ - encoder.emit_enum_variant_arg(0, |encoder| local_path.encode(encoder))?; + encoder + .emit_enum_variant_arg(true, |encoder| local_path.encode(encoder))?; }) }) } @@ -161,8 +162,10 @@ impl Encodable for RealFileName { // if they have been remapped by --remap-path-prefix assert!(local_path.is_none()); Ok({ - encoder.emit_enum_variant_arg(0, |encoder| local_path.encode(encoder))?; - encoder.emit_enum_variant_arg(1, |encoder| virtual_name.encode(encoder))?; + encoder + .emit_enum_variant_arg(true, |encoder| local_path.encode(encoder))?; + encoder + .emit_enum_variant_arg(false, |encoder| virtual_name.encode(encoder))?; }) }), }) @@ -827,17 +830,17 @@ impl Default for Span { impl Encodable for Span { default fn encode(&self, s: &mut E) -> Result<(), E::Error> { let span = self.data(); - s.emit_struct("Span", 2, |s| { - s.emit_struct_field("lo", 0, |s| span.lo.encode(s))?; - s.emit_struct_field("hi", 1, |s| span.hi.encode(s)) + s.emit_struct(false, |s| { + s.emit_struct_field("lo", true, |s| span.lo.encode(s))?; + s.emit_struct_field("hi", false, |s| span.hi.encode(s)) }) } } impl Decodable for Span { default fn decode(s: &mut D) -> Result { - s.read_struct("Span", 2, |d| { - let lo = d.read_struct_field("lo", 0, Decodable::decode)?; - let hi = d.read_struct_field("hi", 1, Decodable::decode)?; + s.read_struct(|d| { + let lo = d.read_struct_field("lo", Decodable::decode)?; + let hi = d.read_struct_field("hi", Decodable::decode)?; Ok(Span::new(lo, hi, SyntaxContext::root())) }) @@ -1234,12 +1237,12 @@ pub struct SourceFile { impl Encodable for SourceFile { fn encode(&self, s: &mut S) -> Result<(), S::Error> { - s.emit_struct("SourceFile", 8, |s| { - s.emit_struct_field("name", 0, |s| self.name.encode(s))?; - s.emit_struct_field("src_hash", 2, |s| self.src_hash.encode(s))?; - s.emit_struct_field("start_pos", 3, |s| self.start_pos.encode(s))?; - s.emit_struct_field("end_pos", 4, |s| self.end_pos.encode(s))?; - s.emit_struct_field("lines", 5, |s| { + s.emit_struct(false, |s| { + s.emit_struct_field("name", true, |s| self.name.encode(s))?; + s.emit_struct_field("src_hash", false, |s| self.src_hash.encode(s))?; + s.emit_struct_field("start_pos", false, |s| self.start_pos.encode(s))?; + s.emit_struct_field("end_pos", false, |s| self.end_pos.encode(s))?; + s.emit_struct_field("lines", false, |s| { let lines = &self.lines[..]; // Store the length. s.emit_u32(lines.len() as u32)?; @@ -1297,25 +1300,24 @@ impl Encodable for SourceFile { Ok(()) })?; - s.emit_struct_field("multibyte_chars", 6, |s| self.multibyte_chars.encode(s))?; - s.emit_struct_field("non_narrow_chars", 7, |s| self.non_narrow_chars.encode(s))?; - s.emit_struct_field("name_hash", 8, |s| self.name_hash.encode(s))?; - s.emit_struct_field("normalized_pos", 9, |s| self.normalized_pos.encode(s))?; - s.emit_struct_field("cnum", 10, |s| self.cnum.encode(s)) + s.emit_struct_field("multibyte_chars", false, |s| self.multibyte_chars.encode(s))?; + s.emit_struct_field("non_narrow_chars", false, |s| self.non_narrow_chars.encode(s))?; + s.emit_struct_field("name_hash", false, |s| self.name_hash.encode(s))?; + s.emit_struct_field("normalized_pos", false, |s| self.normalized_pos.encode(s))?; + s.emit_struct_field("cnum", false, |s| self.cnum.encode(s)) }) } } impl Decodable for SourceFile { fn decode(d: &mut D) -> Result { - d.read_struct("SourceFile", 8, |d| { - let name: FileName = d.read_struct_field("name", 0, |d| Decodable::decode(d))?; + d.read_struct(|d| { + let name: FileName = d.read_struct_field("name", |d| Decodable::decode(d))?; let src_hash: SourceFileHash = - d.read_struct_field("src_hash", 2, |d| Decodable::decode(d))?; - let start_pos: BytePos = - d.read_struct_field("start_pos", 3, |d| Decodable::decode(d))?; - let end_pos: BytePos = d.read_struct_field("end_pos", 4, |d| Decodable::decode(d))?; - let lines: Vec = d.read_struct_field("lines", 5, |d| { + d.read_struct_field("src_hash", |d| Decodable::decode(d))?; + let start_pos: BytePos = d.read_struct_field("start_pos", |d| Decodable::decode(d))?; + let end_pos: BytePos = d.read_struct_field("end_pos", |d| Decodable::decode(d))?; + let lines: Vec = d.read_struct_field("lines", |d| { let num_lines: u32 = Decodable::decode(d)?; let mut lines = Vec::with_capacity(num_lines as usize); @@ -1344,13 +1346,13 @@ impl Decodable for SourceFile { Ok(lines) })?; let multibyte_chars: Vec = - d.read_struct_field("multibyte_chars", 6, |d| Decodable::decode(d))?; + d.read_struct_field("multibyte_chars", |d| Decodable::decode(d))?; let non_narrow_chars: Vec = - d.read_struct_field("non_narrow_chars", 7, |d| Decodable::decode(d))?; - let name_hash: u128 = d.read_struct_field("name_hash", 8, |d| Decodable::decode(d))?; + d.read_struct_field("non_narrow_chars", |d| Decodable::decode(d))?; + let name_hash: u128 = d.read_struct_field("name_hash", |d| Decodable::decode(d))?; let normalized_pos: Vec = - d.read_struct_field("normalized_pos", 9, |d| Decodable::decode(d))?; - let cnum: CrateNum = d.read_struct_field("cnum", 10, |d| Decodable::decode(d))?; + d.read_struct_field("normalized_pos", |d| Decodable::decode(d))?; + let cnum: CrateNum = d.read_struct_field("cnum", |d| Decodable::decode(d))?; Ok(SourceFile { name, start_pos, From e291be3649c3088735936a6258317e69d3ad88f0 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sun, 4 Apr 2021 14:24:27 +0200 Subject: [PATCH 173/441] Only compute the trait_map once. --- compiler/rustc_ast_lowering/src/lib.rs | 20 ++++++++++---------- compiler/rustc_hir/src/hir.rs | 8 ++++++-- compiler/rustc_middle/src/query/mod.rs | 1 - compiler/rustc_middle/src/ty/context.rs | 13 +------------ compiler/rustc_resolve/src/lib.rs | 4 ++-- 5 files changed, 19 insertions(+), 27 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 6f1772ff8188..7202774292f5 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -43,7 +43,8 @@ use rustc_ast::walk_list; use rustc_ast::{self as ast, *}; use rustc_ast_pretty::pprust; use rustc_data_structures::captures::Captures; -use rustc_data_structures::fx::FxHashSet; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::stable_hasher::StableVec; use rustc_data_structures::sync::Lrc; use rustc_errors::{struct_span_err, Applicability}; use rustc_hir as hir; @@ -198,7 +199,7 @@ pub trait ResolverAstLowering { fn next_node_id(&mut self) -> NodeId; - fn trait_map(&self) -> &NodeMap>; + fn trait_map(&mut self) -> NodeMap>; fn opt_local_def_id(&self, node: NodeId) -> Option; @@ -501,14 +502,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { let proc_macros = c.proc_macros.iter().map(|id| self.node_id_to_hir_id[*id].unwrap()).collect(); - let trait_map = self - .resolver - .trait_map() - .iter() - .filter_map(|(&k, v)| { - self.node_id_to_hir_id.get(k).and_then(|id| id.as_ref()).map(|id| (*id, v.clone())) - }) - .collect(); + let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default(); + for (k, v) in self.resolver.trait_map().into_iter() { + if let Some(Some(hir_id)) = self.node_id_to_hir_id.get(k) { + let map = trait_map.entry(hir_id.owner).or_default(); + map.insert(hir_id.local_id, StableVec::new(v.to_vec())); + } + } let mut def_id_to_hir_id = IndexVec::default(); diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 91fd97a0d402..8600276f05d2 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -1,7 +1,7 @@ // ignore-tidy-filelength use crate::def::{CtorKind, DefKind, Res}; use crate::def_id::DefId; -crate use crate::hir_id::HirId; +crate use crate::hir_id::{HirId, ItemLocalId}; use crate::{itemlikevisit, LangItem}; use rustc_ast::util::parser::ExprPrecedence; @@ -10,6 +10,8 @@ use rustc_ast::{Attribute, FloatTy, IntTy, Label, LitKind, StrStyle, TraitObject pub use rustc_ast::{BorrowKind, ImplPolarity, IsAuto}; pub use rustc_ast::{CaptureBy, Movability, Mutability}; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; +use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::stable_hasher::StableVec; use rustc_data_structures::sync::{par_for_each_in, Send, Sync}; use rustc_macros::HashStable_Generic; use rustc_span::source_map::Spanned; @@ -658,7 +660,9 @@ pub struct Crate<'hir> { /// they are declared in the static array generated by proc_macro_harness. pub proc_macros: Vec, - pub trait_map: BTreeMap>, + /// Map indicating what traits are in scope for places where this + /// is relevant; generated by resolve. + pub trait_map: FxHashMap>>, /// Collected attributes from HIR nodes. pub attrs: BTreeMap, diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 9974f2bb8cac..90be88e19367 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -1128,7 +1128,6 @@ rustc_queries! { } query in_scope_traits_map(_: LocalDefId) -> Option<&'tcx FxHashMap>> { - eval_always desc { "traits in scope at a block" } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index a2b17e97c29d..19a768689b88 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -966,10 +966,6 @@ pub struct GlobalCtxt<'tcx> { /// Resolutions of `extern crate` items produced by resolver. extern_crate_map: FxHashMap, - /// Map indicating what traits are in scope for places where this - /// is relevant; generated by resolve. - trait_map: FxHashMap>>, - /// Export map produced by name resolution. export_map: ExportMap, @@ -1150,12 +1146,6 @@ impl<'tcx> TyCtxt<'tcx> { let common_consts = CommonConsts::new(&interners, &common_types); let cstore = resolutions.cstore; - let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default(); - for (hir_id, v) in krate.trait_map.iter() { - let map = trait_map.entry(hir_id.owner).or_default(); - map.insert(hir_id.local_id, StableVec::new(v.to_vec())); - } - GlobalCtxt { sess: s, lint_store, @@ -1169,7 +1159,6 @@ impl<'tcx> TyCtxt<'tcx> { consts: common_consts, visibilities: resolutions.visibilities, extern_crate_map: resolutions.extern_crate_map, - trait_map, export_map: resolutions.export_map, maybe_unused_trait_imports: resolutions.maybe_unused_trait_imports, maybe_unused_extern_crates: resolutions.maybe_unused_extern_crates, @@ -2793,7 +2782,7 @@ fn ptr_eq(t: *const T, u: *const U) -> bool { } pub fn provide(providers: &mut ty::query::Providers) { - providers.in_scope_traits_map = |tcx, id| tcx.gcx.trait_map.get(&id); + providers.in_scope_traits_map = |tcx, id| tcx.hir_crate(()).trait_map.get(&id); providers.module_exports = |tcx, id| tcx.gcx.export_map.get(&id).map(|v| &v[..]); providers.crate_name = |tcx, id| { assert_eq!(id, LOCAL_CRATE); diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 29d4271c475d..7f97be9434ce 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1138,8 +1138,8 @@ impl ResolverAstLowering for Resolver<'_> { self.next_node_id() } - fn trait_map(&self) -> &NodeMap> { - &self.trait_map + fn trait_map(&mut self) -> NodeMap> { + std::mem::take(&mut self.trait_map) } fn opt_local_def_id(&self, node: NodeId) -> Option { From 86562b4fdb39e2810e84c2107297a682cdec8042 Mon Sep 17 00:00:00 2001 From: LingMan Date: Tue, 1 Jun 2021 20:50:08 +0200 Subject: [PATCH 174/441] Use `Iterator::find` instead of open-coding it --- compiler/rustc_lint/src/types.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 9c94bab04e98..e0f19ad5ec84 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -680,16 +680,11 @@ pub fn transparent_newtype_field<'a, 'tcx>( variant: &'a ty::VariantDef, ) -> Option<&'a ty::FieldDef> { let param_env = tcx.param_env(variant.def_id); - for field in &variant.fields { + variant.fields.iter().find(|field| { let field_ty = tcx.type_of(field.did); let is_zst = tcx.layout_of(param_env.and(field_ty)).map_or(false, |layout| layout.is_zst()); - - if !is_zst { - return Some(field); - } - } - - None + !is_zst + }) } /// Is type known to be non-null? From 273778086c08dff938af758ae4a1b00974480c5d Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Tue, 11 May 2021 10:38:54 +0200 Subject: [PATCH 175/441] Remove StableVec. --- compiler/rustc_ast_lowering/src/lib.rs | 3 +- .../src/stable_hasher.rs | 32 ------------------- compiler/rustc_hir/src/hir.rs | 3 +- compiler/rustc_middle/src/query/mod.rs | 2 +- compiler/rustc_middle/src/ty/context.rs | 8 +++-- compiler/rustc_middle/src/ty/query/mod.rs | 1 - 6 files changed, 8 insertions(+), 41 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 7202774292f5..a9950b82928b 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -44,7 +44,6 @@ use rustc_ast::{self as ast, *}; use rustc_ast_pretty::pprust; use rustc_data_structures::captures::Captures; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_data_structures::stable_hasher::StableVec; use rustc_data_structures::sync::Lrc; use rustc_errors::{struct_span_err, Applicability}; use rustc_hir as hir; @@ -506,7 +505,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { for (k, v) in self.resolver.trait_map().into_iter() { if let Some(Some(hir_id)) = self.node_id_to_hir_id.get(k) { let map = trait_map.entry(hir_id.owner).or_default(); - map.insert(hir_id.local_id, StableVec::new(v.to_vec())); + map.insert(hir_id.local_id, v.into_boxed_slice()); } } diff --git a/compiler/rustc_data_structures/src/stable_hasher.rs b/compiler/rustc_data_structures/src/stable_hasher.rs index ff28784a1dc4..18b352cf3b0b 100644 --- a/compiler/rustc_data_structures/src/stable_hasher.rs +++ b/compiler/rustc_data_structures/src/stable_hasher.rs @@ -550,35 +550,3 @@ pub fn hash_stable_hashmap( entries.sort_unstable_by(|&(ref sk1, _), &(ref sk2, _)| sk1.cmp(sk2)); entries.hash_stable(hcx, hasher); } - -/// A vector container that makes sure that its items are hashed in a stable -/// order. -#[derive(Debug)] -pub struct StableVec(Vec); - -impl StableVec { - pub fn new(v: Vec) -> Self { - StableVec(v) - } -} - -impl ::std::ops::Deref for StableVec { - type Target = Vec; - - fn deref(&self) -> &Vec { - &self.0 - } -} - -impl HashStable for StableVec -where - T: HashStable + ToStableHashKey, -{ - fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher) { - let StableVec(ref v) = *self; - - let mut sorted: Vec<_> = v.iter().map(|x| x.to_stable_hash_key(hcx)).collect(); - sorted.sort_unstable(); - sorted.hash_stable(hcx, hasher); - } -} diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 8600276f05d2..e9055c954108 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -11,7 +11,6 @@ pub use rustc_ast::{BorrowKind, ImplPolarity, IsAuto}; pub use rustc_ast::{CaptureBy, Movability, Mutability}; use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece}; use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::stable_hasher::StableVec; use rustc_data_structures::sync::{par_for_each_in, Send, Sync}; use rustc_macros::HashStable_Generic; use rustc_span::source_map::Spanned; @@ -662,7 +661,7 @@ pub struct Crate<'hir> { /// Map indicating what traits are in scope for places where this /// is relevant; generated by resolve. - pub trait_map: FxHashMap>>, + pub trait_map: FxHashMap>>, /// Collected attributes from HIR nodes. pub attrs: BTreeMap, diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 90be88e19367..3cc8fc3fe318 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -1127,7 +1127,7 @@ rustc_queries! { desc { "computing whether impls specialize one another" } } query in_scope_traits_map(_: LocalDefId) - -> Option<&'tcx FxHashMap>> { + -> Option<&'tcx FxHashMap>> { desc { "traits in scope at a block" } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 19a768689b88..ef93f4f64d8b 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -31,7 +31,7 @@ use rustc_attr as attr; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::profiling::SelfProfilerRef; use rustc_data_structures::sharded::{IntoPointer, ShardedHashMap}; -use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableVec}; +use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::steal::Steal; use rustc_data_structures::sync::{self, Lock, Lrc, WorkerLocal}; use rustc_errors::ErrorReported; @@ -2651,8 +2651,10 @@ impl<'tcx> TyCtxt<'tcx> { struct_lint_level(self.sess, lint, level, src, None, decorate); } - pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx StableVec> { - self.in_scope_traits_map(id.owner).and_then(|map| map.get(&id.local_id)) + pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate]> { + let map = self.in_scope_traits_map(id.owner)?; + let candidates = map.get(&id.local_id)?; + Some(&*candidates) } pub fn named_region(self, id: HirId) -> Option { diff --git a/compiler/rustc_middle/src/ty/query/mod.rs b/compiler/rustc_middle/src/ty/query/mod.rs index bec13da017ea..a5b540dcb70c 100644 --- a/compiler/rustc_middle/src/ty/query/mod.rs +++ b/compiler/rustc_middle/src/ty/query/mod.rs @@ -34,7 +34,6 @@ use crate::ty::subst::{GenericArg, SubstsRef}; use crate::ty::util::AlwaysRequiresDrop; use crate::ty::{self, AdtSizedConstraint, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt}; use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap}; -use rustc_data_structures::stable_hasher::StableVec; use rustc_data_structures::steal::Steal; use rustc_data_structures::svh::Svh; use rustc_data_structures::sync::Lrc; From c11691b46041fa08b76d556277d17f3e531a4025 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 29 May 2021 22:56:23 +0200 Subject: [PATCH 176/441] Check that trait_map is not moved twice. --- compiler/rustc_resolve/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 7f97be9434ce..e181b30f0e3d 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -910,6 +910,8 @@ pub struct Resolver<'a> { extern_crate_map: FxHashMap, export_map: ExportMap, trait_map: NodeMap>, + #[cfg(debug_assertions)] + took_trait_map: bool, /// A map from nodes to anonymous modules. /// Anonymous modules are pseudo-modules that are implicitly created around items @@ -1139,6 +1141,11 @@ impl ResolverAstLowering for Resolver<'_> { } fn trait_map(&mut self) -> NodeMap> { + #[cfg(debug_assertions)] + { + debug_assert!(!self.took_trait_map); + self.took_trait_map = true; + } std::mem::take(&mut self.trait_map) } @@ -1287,6 +1294,8 @@ impl<'a> Resolver<'a> { extern_crate_map: Default::default(), export_map: FxHashMap::default(), trait_map: Default::default(), + #[cfg(debug_assertions)] + took_trait_map: false, underscore_disambiguator: 0, empty_module, module_map, From 0839cd5e9ae41acf3694c01fd2a831c9019206ea Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 29 May 2021 23:10:04 +0200 Subject: [PATCH 177/441] Rename take_trait_map. --- compiler/rustc_ast_lowering/src/lib.rs | 4 ++-- compiler/rustc_resolve/src/lib.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index a9950b82928b..0ff1efd8165e 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -198,7 +198,7 @@ pub trait ResolverAstLowering { fn next_node_id(&mut self) -> NodeId; - fn trait_map(&mut self) -> NodeMap>; + fn take_trait_map(&mut self) -> NodeMap>; fn opt_local_def_id(&self, node: NodeId) -> Option; @@ -502,7 +502,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { c.proc_macros.iter().map(|id| self.node_id_to_hir_id[*id].unwrap()).collect(); let mut trait_map: FxHashMap<_, FxHashMap<_, _>> = FxHashMap::default(); - for (k, v) in self.resolver.trait_map().into_iter() { + for (k, v) in self.resolver.take_trait_map().into_iter() { if let Some(Some(hir_id)) = self.node_id_to_hir_id.get(k) { let map = trait_map.entry(hir_id.owner).or_default(); map.insert(hir_id.local_id, v.into_boxed_slice()); diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index e181b30f0e3d..5e009d148322 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1140,7 +1140,7 @@ impl ResolverAstLowering for Resolver<'_> { self.next_node_id() } - fn trait_map(&mut self) -> NodeMap> { + fn take_trait_map(&mut self) -> NodeMap> { #[cfg(debug_assertions)] { debug_assert!(!self.took_trait_map); From 28afaeec17058b632219027f2bbb83e6655409e6 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Tue, 11 May 2021 22:06:07 +0200 Subject: [PATCH 178/441] Make is_private_dep a query. --- compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 9 +++++---- compiler/rustc_middle/src/dep_graph/dep_node.rs | 2 +- compiler/rustc_middle/src/middle/cstore.rs | 1 - compiler/rustc_middle/src/query/mod.rs | 6 ++++++ compiler/rustc_middle/src/ty/context.rs | 6 ------ 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 02d1cf9aec79..3c05efd6a5eb 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -155,6 +155,7 @@ provide! { <'tcx> tcx, def_id, other, cdata, is_ctfe_mir_available => { cdata.is_ctfe_mir_available(def_id.index) } dylib_dependency_formats => { cdata.get_dylib_dependency_formats(tcx) } + is_private_dep => { cdata.private_dep } is_panic_runtime => { cdata.root.panic_runtime } is_compiler_builtins => { cdata.root.compiler_builtins } has_global_allocator => { cdata.root.has_global_allocator } @@ -250,6 +251,10 @@ pub fn provide(providers: &mut Providers) { is_statically_included_foreign_item: |tcx, id| { matches!(tcx.native_library_kind(id), Some(NativeLibKind::Static { .. })) }, + is_private_dep: |_tcx, cnum| { + assert_eq!(cnum, LOCAL_CRATE); + false + }, native_library_kind: |tcx, id| { tcx.native_libraries(id.krate) .iter() @@ -477,10 +482,6 @@ impl CrateStore for CStore { self.get_crate_data(cnum).root.name } - fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool { - self.get_crate_data(cnum).private_dep - } - fn stable_crate_id_untracked(&self, cnum: CrateNum) -> StableCrateId { self.get_crate_data(cnum).root.stable_crate_id } diff --git a/compiler/rustc_middle/src/dep_graph/dep_node.rs b/compiler/rustc_middle/src/dep_graph/dep_node.rs index aa54d1ae7b9d..8476929eaece 100644 --- a/compiler/rustc_middle/src/dep_graph/dep_node.rs +++ b/compiler/rustc_middle/src/dep_graph/dep_node.rs @@ -285,7 +285,7 @@ pub type DepNode = rustc_query_system::dep_graph::DepNode; // required that their size stay the same, but we don't want to change // it inadvertently. This assert just ensures we're aware of any change. #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -static_assert_size!(DepNode, 17); +static_assert_size!(DepNode, 18); #[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))] static_assert_size!(DepNode, 24); diff --git a/compiler/rustc_middle/src/middle/cstore.rs b/compiler/rustc_middle/src/middle/cstore.rs index e88b96bde887..dd3b0a40d694 100644 --- a/compiler/rustc_middle/src/middle/cstore.rs +++ b/compiler/rustc_middle/src/middle/cstore.rs @@ -199,7 +199,6 @@ pub trait CrateStore { // "queries" used in resolve that aren't tracked for incremental compilation fn crate_name_untracked(&self, cnum: CrateNum) -> Symbol; - fn crate_is_private_dep_untracked(&self, cnum: CrateNum) -> bool; fn stable_crate_id_untracked(&self, cnum: CrateNum) -> StableCrateId; fn crate_hash_untracked(&self, cnum: CrateNum) -> Svh; diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 9974f2bb8cac..cad0dc683ecb 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -1415,6 +1415,12 @@ rustc_queries! { eval_always desc { "generating a postorder list of CrateNums" } } + /// Returns whether or not the crate with CrateNum 'cnum' + /// is marked as a private dependency + query is_private_dep(c: CrateNum) -> bool { + eval_always + desc { "check whether crate {} is a private dependency", c } + } query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap> { desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index a2b17e97c29d..aa414c49e9b7 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1275,12 +1275,6 @@ impl<'tcx> TyCtxt<'tcx> { } } - /// Returns whether or not the crate with CrateNum 'cnum' - /// is marked as a private dependency - pub fn is_private_dep(self, cnum: CrateNum) -> bool { - if cnum == LOCAL_CRATE { false } else { self.cstore.crate_is_private_dep_untracked(cnum) } - } - #[inline] pub fn def_path_hash(self, def_id: DefId) -> rustc_hir::definitions::DefPathHash { if let Some(def_id) = def_id.as_local() { From 0933fbd05a96d5685a6b47e5feeeb128d7daa2bf Mon Sep 17 00:00:00 2001 From: LingMan Date: Tue, 1 Jun 2021 21:07:07 +0200 Subject: [PATCH 179/441] Use `Iterator::any` and `filter_map` instead of open-coding them --- compiler/rustc_lint/src/types.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs index 9c94bab04e98..8e7706758b68 100644 --- a/compiler/rustc_lint/src/types.rs +++ b/compiler/rustc_lint/src/types.rs @@ -712,15 +712,10 @@ fn ty_is_known_nonnull<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, mode: CItemKi return false; } - for variant in &def.variants { - if let Some(field) = transparent_newtype_field(cx.tcx, variant) { - if ty_is_known_nonnull(cx, field.ty(tcx, substs), mode) { - return true; - } - } - } - - false + def.variants + .iter() + .filter_map(|variant| transparent_newtype_field(cx.tcx, variant)) + .any(|field| ty_is_known_nonnull(cx, field.ty(tcx, substs), mode)) } _ => false, } From 202d39a96bb2ec64c0e1f1fc4229a473ed810a5f Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 29 May 2021 22:49:59 +0200 Subject: [PATCH 180/441] Drop metadata_encoding_version. --- Cargo.lock | 1 + compiler/rustc_codegen_cranelift/src/lib.rs | 1 + compiler/rustc_codegen_cranelift/src/metadata.rs | 2 +- compiler/rustc_codegen_llvm/Cargo.toml | 1 + compiler/rustc_codegen_llvm/src/base.rs | 2 +- compiler/rustc_metadata/src/lib.rs | 2 ++ compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 6 +----- compiler/rustc_metadata/src/rmeta/mod.rs | 2 +- compiler/rustc_middle/src/middle/cstore.rs | 1 - compiler/rustc_middle/src/ty/context.rs | 4 ---- 10 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df7d84419414..1d3b539c682c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3677,6 +3677,7 @@ dependencies = [ "rustc_incremental", "rustc_index", "rustc_llvm", + "rustc_metadata", "rustc_middle", "rustc_serialize", "rustc_session", diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index 4ee887cd5afa..637e91f5117d 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -14,6 +14,7 @@ extern crate rustc_fs_util; extern crate rustc_hir; extern crate rustc_incremental; extern crate rustc_index; +extern crate rustc_metadata; extern crate rustc_session; extern crate rustc_span; extern crate rustc_target; diff --git a/compiler/rustc_codegen_cranelift/src/metadata.rs b/compiler/rustc_codegen_cranelift/src/metadata.rs index ab238244d68d..db24bf65eb5a 100644 --- a/compiler/rustc_codegen_cranelift/src/metadata.rs +++ b/compiler/rustc_codegen_cranelift/src/metadata.rs @@ -10,7 +10,7 @@ pub(crate) fn write_metadata(tcx: TyCtxt<'_>, object: &mut O) use std::io::Write; let metadata = tcx.encode_metadata(); - let mut compressed = tcx.metadata_encoding_version(); + let mut compressed = rustc_metadata::METADATA_HEADER.to_vec(); FrameEncoder::new(&mut compressed).write_all(&metadata.raw_data).unwrap(); object.add_rustc_section( diff --git a/compiler/rustc_codegen_llvm/Cargo.toml b/compiler/rustc_codegen_llvm/Cargo.toml index 4999cb3c7ab4..d0eb6913accd 100644 --- a/compiler/rustc_codegen_llvm/Cargo.toml +++ b/compiler/rustc_codegen_llvm/Cargo.toml @@ -27,6 +27,7 @@ rustc_hir = { path = "../rustc_hir" } rustc_incremental = { path = "../rustc_incremental" } rustc_index = { path = "../rustc_index" } rustc_llvm = { path = "../rustc_llvm" } +rustc_metadata = { path = "../rustc_metadata" } rustc_session = { path = "../rustc_session" } rustc_serialize = { path = "../rustc_serialize" } rustc_target = { path = "../rustc_target" } diff --git a/compiler/rustc_codegen_llvm/src/base.rs b/compiler/rustc_codegen_llvm/src/base.rs index 893c909b2041..cc3cbea4def5 100644 --- a/compiler/rustc_codegen_llvm/src/base.rs +++ b/compiler/rustc_codegen_llvm/src/base.rs @@ -63,7 +63,7 @@ pub fn write_compressed_metadata<'tcx>( let section_name = if tcx.sess.target.is_like_osx { "__DATA,.rustc" } else { ".rustc" }; let (metadata_llcx, metadata_llmod) = (&*llvm_module.llcx, llvm_module.llmod()); - let mut compressed = tcx.metadata_encoding_version(); + let mut compressed = rustc_metadata::METADATA_HEADER.to_vec(); FrameEncoder::new(&mut compressed).write_all(&metadata.raw_data).unwrap(); let llmeta = common::bytes_in_context(metadata_llcx, &compressed); diff --git a/compiler/rustc_metadata/src/lib.rs b/compiler/rustc_metadata/src/lib.rs index 15c9eda9902c..c5bbb96f777e 100644 --- a/compiler/rustc_metadata/src/lib.rs +++ b/compiler/rustc_metadata/src/lib.rs @@ -31,3 +31,5 @@ mod rmeta; pub mod creader; pub mod dynamic_lib; pub mod locator; + +pub use rmeta::METADATA_HEADER; diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 02d1cf9aec79..818376b20def 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -1,7 +1,7 @@ use crate::creader::{CStore, LoadedMacro}; use crate::foreign_modules; use crate::native_libs; -use crate::rmeta::{self, encoder}; +use crate::rmeta::encoder; use rustc_ast as ast; use rustc_ast::expand::allocator::AllocatorKind; @@ -528,10 +528,6 @@ impl CrateStore for CStore { encoder::encode_metadata(tcx) } - fn metadata_encoding_version(&self) -> &[u8] { - rmeta::METADATA_HEADER - } - fn allocator_kind(&self) -> Option { self.allocator_kind() } diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index 9a3a6284c361..a1819a19097c 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -51,7 +51,7 @@ const METADATA_VERSION: u8 = 5; /// This header is followed by the position of the `CrateRoot`, /// which is encoded as a 32-bit big-endian unsigned integer, /// and further followed by the rustc version string. -crate const METADATA_HEADER: &[u8; 8] = &[b'r', b'u', b's', b't', 0, 0, 0, METADATA_VERSION]; +pub const METADATA_HEADER: &[u8; 8] = &[b'r', b'u', b's', b't', 0, 0, 0, METADATA_VERSION]; /// Additional metadata for a `Lazy` where `T` may not be `Sized`, /// e.g. for `Lazy<[T]>`, this is the length (count of `T` values). diff --git a/compiler/rustc_middle/src/middle/cstore.rs b/compiler/rustc_middle/src/middle/cstore.rs index e88b96bde887..965de117e75b 100644 --- a/compiler/rustc_middle/src/middle/cstore.rs +++ b/compiler/rustc_middle/src/middle/cstore.rs @@ -209,7 +209,6 @@ pub trait CrateStore { // utility functions fn encode_metadata(&self, tcx: TyCtxt<'_>) -> EncodedMetadata; - fn metadata_encoding_version(&self) -> &[u8]; fn allocator_kind(&self) -> Option; } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index a2b17e97c29d..175908143224 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1314,10 +1314,6 @@ impl<'tcx> TyCtxt<'tcx> { ) } - pub fn metadata_encoding_version(self) -> Vec { - self.cstore.metadata_encoding_version().to_vec() - } - pub fn encode_metadata(self) -> EncodedMetadata { let _prof_timer = self.prof.verbose_generic_activity("generate_crate_metadata"); self.cstore.encode_metadata(self) From 7414d28e0bb9342c159b5e0e0db43bde11ef8c09 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 23 Apr 2021 17:10:23 +0200 Subject: [PATCH 181/441] Replace empty href with "#" --- src/librustdoc/html/render/print_item.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 42d7e9c8c93d..925bf2272bda 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -75,7 +75,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer, ); } } - write!(buf, "{}", item.type_(), item.name.as_ref().unwrap()); + write!(buf, "{}", item.type_(), item.name.as_ref().unwrap()); write!( buf, " + \ \ Date: Thu, 3 Jun 2021 20:16:47 +0200 Subject: [PATCH 315/441] Fix invalid ID value in all.html file --- src/librustdoc/html/render/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 10f5184e39a6..4b6faefc2fb0 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -322,7 +322,13 @@ impl AllTypes { if !e.is_empty() { let mut e: Vec<&ItemEntry> = e.iter().collect(); e.sort(); - write!(f, "

{}