From e836b1b9d082d904533c2c7fc510a17fec030182 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 24 Oct 2019 00:37:14 +0200 Subject: [PATCH 01/26] Prevent help popup to disappear when clicking on it --- src/librustdoc/html/static/main.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index f0104c9156ded..5171190d0ddc5 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -380,8 +380,11 @@ function getSearchElement() { set_fragment(cur_id); } } else if (hasClass(document.getElementById("help"), "hidden") === false) { - addClass(document.getElementById("help"), "hidden"); - removeClass(document.body, "blur"); + var is_inside_help_popup = document.getElementById("help").contains(ev.target); + if (is_inside_help_popup === false) { + addClass(document.getElementById("help"), "hidden"); + removeClass(document.body, "blur"); + } } else { // Making a collapsed element visible on onhashchange seems // too late From 863796be7debb97e79d46aacc6501f1d4a6424ae Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 25 Oct 2019 13:43:25 +0200 Subject: [PATCH 02/26] Improve help popup detection --- src/librustdoc/html/static/main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 5171190d0ddc5..b95042247798d 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -379,10 +379,11 @@ function getSearchElement() { set_fragment(cur_id); } - } else if (hasClass(document.getElementById("help"), "hidden") === false) { - var is_inside_help_popup = document.getElementById("help").contains(ev.target); + } else if (hasClass(getHelpElement(), "hidden") === false) { + var help = getHelpElement(); + var is_inside_help_popup = ev.target !== help && help.contains(ev.target); if (is_inside_help_popup === false) { - addClass(document.getElementById("help"), "hidden"); + addClass(help, "hidden"); removeClass(document.body, "blur"); } } else { From 62c3443e9659be2bf0ae53df1421c846ceaca904 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Fri, 18 Oct 2019 14:47:54 -0700 Subject: [PATCH 03/26] Re-enable Emscripten's exception handling support Passes LLVM codegen and Emscripten link-time flags for exception handling if and only if the panic strategy is `unwind`. Sets the default panic strategy for Emscripten targets to `unwind`. Re-enables tests that depend on unwinding support for Emscripten, including `should_panic` tests. --- src/bootstrap/native.rs | 4 ++++ src/librustc_codegen_llvm/llvm_util.rs | 6 +++++- src/librustc_codegen_ssa/back/symbol_export.rs | 5 +++-- src/librustc_target/spec/wasm32_unknown_emscripten.rs | 11 ++--------- src/libtest/lib.rs | 4 ++-- src/test/codegen/c-variadic.rs | 2 +- src/test/codegen/drop.rs | 2 +- src/test/codegen/personality_lifetimes.rs | 2 +- src/test/codegen/unwind-extern-exports.rs | 2 +- src/test/codegen/unwind-extern-imports.rs | 2 +- src/test/incremental/change_crate_dep_kind.rs | 2 +- src/test/mir-opt/box_expr.rs | 2 +- src/test/mir-opt/generator-storage-dead-unwind.rs | 2 +- src/test/mir-opt/issue-41110.rs | 2 +- src/test/mir-opt/issue-62289.rs | 2 +- src/test/mir-opt/no-spurious-drop-after-call.rs | 2 +- src/test/mir-opt/packed-struct-drop-aligned.rs | 2 +- src/test/mir-opt/remove_fake_borrows.rs | 2 +- src/test/mir-opt/retag.rs | 2 +- src/test/ui/abi/statics/static-mut-foreign.rs | 4 ---- .../binding/fn-arg-incomplete-pattern-drop-order.rs | 2 +- src/test/ui/builtin-clone-unwind.rs | 2 +- src/test/ui/catch-unwind-bang.rs | 2 +- src/test/ui/drop/dynamic-drop-async.rs | 2 +- src/test/ui/drop/dynamic-drop.rs | 2 +- .../feature-gates/feature-gate-unwind-attributes.rs | 2 +- src/test/ui/generator/panic-drops.rs | 2 +- src/test/ui/generator/panic-safe.rs | 2 +- src/test/ui/generator/resume-after-return.rs | 2 +- src/test/ui/issues/issue-14875.rs | 2 +- src/test/ui/issues/issue-29948.rs | 2 +- src/test/ui/issues/issue-43853.rs | 2 +- src/test/ui/issues/issue-46519.rs | 2 +- src/test/ui/iterators/iter-count-overflow-debug.rs | 2 +- src/test/ui/iterators/iter-position-overflow-debug.rs | 2 +- src/test/ui/iterators/iter-step-overflow-debug.rs | 2 +- src/test/ui/iterators/iter-sum-overflow-debug.rs | 2 +- .../ui/iterators/iter-sum-overflow-overflow-checks.rs | 2 +- src/test/ui/macros/macro-comma-behavior-rpass.rs | 2 +- src/test/ui/mir/mir_calls_to_shims.rs | 2 +- src/test/ui/mir/mir_drop_order.rs | 2 +- src/test/ui/never_type/panic-uninitialized-zeroed.rs | 2 +- .../next-power-of-two-overflow-debug.rs | 2 +- src/test/ui/panic-runtime/transitive-link-a-bunch.rs | 2 +- src/test/ui/panic-runtime/want-unwind-got-abort.rs | 2 +- src/test/ui/panic-runtime/want-unwind-got-abort2.rs | 2 +- src/test/ui/proc-macro/expand-with-a-macro.rs | 2 +- src/test/ui/reachable-unnameable-items.rs | 2 +- .../termination-trait-in-test.rs | 2 +- src/test/ui/rfcs/rfc1857-drop-order.rs | 2 +- src/test/ui/test-attrs/test-allow-fail-attr.rs | 2 +- .../ui/test-attrs/test-should-fail-good-message.rs | 2 +- src/tools/compiletest/src/header.rs | 4 ---- 53 files changed, 62 insertions(+), 68 deletions(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 97cdd25680162..e76604e45bdeb 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -534,6 +534,10 @@ impl Step for TestHelpers { builder.info("Building test helpers"); t!(fs::create_dir_all(&dst)); let mut cfg = cc::Build::new(); + // FIXME: Workaround for https://github.com/emscripten-core/emscripten/issues/9013 + if target.contains("emscripten") { + cfg.pic(false); + } // We may have found various cross-compilers a little differently due to our // extra configuration, so inform gcc of these compilers. Note, though, that diff --git a/src/librustc_codegen_llvm/llvm_util.rs b/src/librustc_codegen_llvm/llvm_util.rs index 2dce9b04c9e9e..a56d015a1b2b1 100644 --- a/src/librustc_codegen_llvm/llvm_util.rs +++ b/src/librustc_codegen_llvm/llvm_util.rs @@ -3,7 +3,7 @@ use crate::llvm; use syntax_pos::symbol::Symbol; use rustc::session::Session; use rustc::session::config::PrintRequest; -use rustc_target::spec::MergeFunctions; +use rustc_target::spec::{MergeFunctions, PanicStrategy}; use libc::c_int; use std::ffi::CString; use syntax::feature_gate::UnstableFeatures; @@ -73,6 +73,10 @@ unsafe fn configure_llvm(sess: &Session) { } } + if sess.target.target.target_os == "emscripten" && sess.panic_strategy() == PanicStrategy::Unwind { + add("-enable-emscripten-cxx-exceptions"); + } + // HACK(eddyb) LLVM inserts `llvm.assume` calls to preserve align attributes // during inlining. Unfortunately these may block other optimizations. add("-preserve-alignment-assumptions-during-inlining=false"); diff --git a/src/librustc_codegen_ssa/back/symbol_export.rs b/src/librustc_codegen_ssa/back/symbol_export.rs index d866a10f06935..333af4cd1d75e 100644 --- a/src/librustc_codegen_ssa/back/symbol_export.rs +++ b/src/librustc_codegen_ssa/back/symbol_export.rs @@ -364,8 +364,9 @@ fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL); if is_extern && !std_internal { - // Emscripten cannot export statics, so reduce their export level here - if tcx.sess.target.target.options.is_like_emscripten { + let target = &tcx.sess.target.target.llvm_target; + // WebAssembly cannot export data symbols, so reduce their export level + if target.contains("wasm32") || target.contains("emscripten") { if let Some(Node::Item(&hir::Item { kind: hir::ItemKind::Static(..), .. diff --git a/src/librustc_target/spec/wasm32_unknown_emscripten.rs b/src/librustc_target/spec/wasm32_unknown_emscripten.rs index 6a2c8c495372f..906c704c804f3 100644 --- a/src/librustc_target/spec/wasm32_unknown_emscripten.rs +++ b/src/librustc_target/spec/wasm32_unknown_emscripten.rs @@ -9,12 +9,8 @@ pub fn target() -> Result { "-s".to_string(), "ASSERTIONS=1".to_string(), "-s".to_string(), - "DISABLE_EXCEPTION_CATCHING=1".to_string(), - "-s".to_string(), "ABORTING_MALLOC=0".to_string(), - // FIXME(tlively): Enable this linker option once libc type errors - // are resolved. See https://github.com/rust-lang/libc/pull/1478. - // "-Wl,--fatal-warnings".to_string(), + "-Wl,--fatal-warnings".to_string(), ]); let opts = TargetOptions { @@ -24,10 +20,7 @@ pub fn target() -> Result { linker: None, linker_is_gnu: true, is_like_emscripten: true, - // FIXME(tlively): Emscripten supports unwinding, but we would have to pass - // -enable-emscripten-cxx-exceptions to LLVM at codegen time and merge - // https://reviews.llvm.org/rG5c3cdef84b82464756bb571c13c31cf7773860c3to use it. - panic_strategy: PanicStrategy::Abort, + panic_strategy: PanicStrategy::Unwind, post_link_args, target_family: Some("unix".to_string()), .. wasm32_base::options() diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 8c1e9f1722a26..341a2e18db5fc 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -441,9 +441,9 @@ pub fn run_test( ) { let TestDescAndFn { desc, testfn } = test; - // FIXME: Re-enable emscripten once it can catch panics again + // Emscripten can catch panics but other wasm targets cannot let ignore_because_no_process_support = desc.should_panic != ShouldPanic::No - && (cfg!(target_arch = "wasm32") || cfg!(target_os = "emscripten")); + && cfg!(target_arch = "wasm32") && !cfg!(target_os = "emscripten"); if force_ignore || desc.ignore || ignore_because_no_process_support { let message = CompletedTest::new(desc, TrIgnored, None, Vec::new()); diff --git a/src/test/codegen/c-variadic.rs b/src/test/codegen/c-variadic.rs index 7fa61d15f77c4..971f4e3e12ea8 100644 --- a/src/test/codegen/c-variadic.rs +++ b/src/test/codegen/c-variadic.rs @@ -1,4 +1,4 @@ -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C no-prepopulate-passes // ignore-tidy-linelength diff --git a/src/test/codegen/drop.rs b/src/test/codegen/drop.rs index 49e40d5f243f1..959929fbafbf1 100644 --- a/src/test/codegen/drop.rs +++ b/src/test/codegen/drop.rs @@ -1,4 +1,4 @@ -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/src/test/codegen/personality_lifetimes.rs b/src/test/codegen/personality_lifetimes.rs index c82ae476b1b2c..9f07488a9a8a6 100644 --- a/src/test/codegen/personality_lifetimes.rs +++ b/src/test/codegen/personality_lifetimes.rs @@ -1,5 +1,5 @@ // ignore-msvc -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -O -C no-prepopulate-passes diff --git a/src/test/codegen/unwind-extern-exports.rs b/src/test/codegen/unwind-extern-exports.rs index d924a3b75dde3..e5a2936b92497 100644 --- a/src/test/codegen/unwind-extern-exports.rs +++ b/src/test/codegen/unwind-extern-exports.rs @@ -1,5 +1,5 @@ // compile-flags: -C opt-level=0 -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![crate_type = "lib"] #![feature(unwind_attributes)] diff --git a/src/test/codegen/unwind-extern-imports.rs b/src/test/codegen/unwind-extern-imports.rs index d88a498775642..8403e1e9da9fa 100644 --- a/src/test/codegen/unwind-extern-imports.rs +++ b/src/test/codegen/unwind-extern-imports.rs @@ -1,5 +1,5 @@ // compile-flags: -C no-prepopulate-passes -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![crate_type = "lib"] #![feature(unwind_attributes)] diff --git a/src/test/incremental/change_crate_dep_kind.rs b/src/test/incremental/change_crate_dep_kind.rs index 2bcb06d6eb8b7..8c35f6ca0000d 100644 --- a/src/test/incremental/change_crate_dep_kind.rs +++ b/src/test/incremental/change_crate_dep_kind.rs @@ -1,7 +1,7 @@ // Test that we detect changes to the `dep_kind` query. If the change is not // detected then -Zincremental-verify-ich will trigger an assertion. -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // revisions:cfail1 cfail2 // compile-flags: -Z query-dep-graph -Cpanic=unwind // build-pass (FIXME(62277): could be check-pass?) diff --git a/src/test/mir-opt/box_expr.rs b/src/test/mir-opt/box_expr.rs index 4b66c07b0934b..8dc6b73edf6d4 100644 --- a/src/test/mir-opt/box_expr.rs +++ b/src/test/mir-opt/box_expr.rs @@ -1,4 +1,4 @@ -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![feature(box_syntax)] diff --git a/src/test/mir-opt/generator-storage-dead-unwind.rs b/src/test/mir-opt/generator-storage-dead-unwind.rs index b595c100039d6..109304d6d22cc 100644 --- a/src/test/mir-opt/generator-storage-dead-unwind.rs +++ b/src/test/mir-opt/generator-storage-dead-unwind.rs @@ -1,4 +1,4 @@ -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // Test that we generate StorageDead on unwind paths for generators. // diff --git a/src/test/mir-opt/issue-41110.rs b/src/test/mir-opt/issue-41110.rs index 8824496fdb07c..e73390f52b5d5 100644 --- a/src/test/mir-opt/issue-41110.rs +++ b/src/test/mir-opt/issue-41110.rs @@ -1,4 +1,4 @@ -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // check that we don't emit multiple drop flags when they are not needed. diff --git a/src/test/mir-opt/issue-62289.rs b/src/test/mir-opt/issue-62289.rs index 93250fd48d82d..a3b517e9bca87 100644 --- a/src/test/mir-opt/issue-62289.rs +++ b/src/test/mir-opt/issue-62289.rs @@ -1,7 +1,7 @@ // check that we don't forget to drop the Box if we early return before // initializing it // ignore-tidy-linelength -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![feature(box_syntax)] diff --git a/src/test/mir-opt/no-spurious-drop-after-call.rs b/src/test/mir-opt/no-spurious-drop-after-call.rs index 370cd593b02bb..782bc31186ca5 100644 --- a/src/test/mir-opt/no-spurious-drop-after-call.rs +++ b/src/test/mir-opt/no-spurious-drop-after-call.rs @@ -1,4 +1,4 @@ -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // Test that after the call to `std::mem::drop` we do not generate a // MIR drop of the argument. (We used to have a `DROP(_2)` in the code diff --git a/src/test/mir-opt/packed-struct-drop-aligned.rs b/src/test/mir-opt/packed-struct-drop-aligned.rs index eaa1fbd69ecc6..da73cc96348f0 100644 --- a/src/test/mir-opt/packed-struct-drop-aligned.rs +++ b/src/test/mir-opt/packed-struct-drop-aligned.rs @@ -1,4 +1,4 @@ -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default fn main() { let mut x = Packed(Aligned(Droppy(0))); diff --git a/src/test/mir-opt/remove_fake_borrows.rs b/src/test/mir-opt/remove_fake_borrows.rs index 71beaa736639d..965897ad541e7 100644 --- a/src/test/mir-opt/remove_fake_borrows.rs +++ b/src/test/mir-opt/remove_fake_borrows.rs @@ -1,6 +1,6 @@ // Test that the fake borrows for matches are removed after borrow checking. -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default fn match_guard(x: Option<&&i32>, c: bool) -> i32 { match x { diff --git a/src/test/mir-opt/retag.rs b/src/test/mir-opt/retag.rs index a0bdfb3ab8ba9..db36a1fab5f21 100644 --- a/src/test/mir-opt/retag.rs +++ b/src/test/mir-opt/retag.rs @@ -1,4 +1,4 @@ -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // ignore-tidy-linelength // compile-flags: -Z mir-emit-retag -Z mir-opt-level=0 -Z span_free_formats diff --git a/src/test/ui/abi/statics/static-mut-foreign.rs b/src/test/ui/abi/statics/static-mut-foreign.rs index b30e8f00e4035..5d6fa416b9895 100644 --- a/src/test/ui/abi/statics/static-mut-foreign.rs +++ b/src/test/ui/abi/statics/static-mut-foreign.rs @@ -5,10 +5,6 @@ // ignore-wasm32-bare no libc to test ffi with -// FIXME: This will work on emscripten once libc is updated to include -// rust-lang/libc/#1478 -// ignore-emscripten libc type mismatch - #![feature(rustc_private)] extern crate libc; diff --git a/src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs b/src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs index 4e0a238c5d48d..ea4a9e5afa501 100644 --- a/src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs +++ b/src/test/ui/binding/fn-arg-incomplete-pattern-drop-order.rs @@ -2,7 +2,7 @@ // Check that partially moved from function parameters are dropped after the // named bindings that move from them. -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default use std::{panic, cell::RefCell}; diff --git a/src/test/ui/builtin-clone-unwind.rs b/src/test/ui/builtin-clone-unwind.rs index 1fd91440a7884..339bcfa1060a4 100644 --- a/src/test/ui/builtin-clone-unwind.rs +++ b/src/test/ui/builtin-clone-unwind.rs @@ -2,7 +2,7 @@ #![allow(unused_variables)] #![allow(unused_imports)] -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // Test that builtin implementations of `Clone` cleanup everything // in case of unwinding. diff --git a/src/test/ui/catch-unwind-bang.rs b/src/test/ui/catch-unwind-bang.rs index c2c21bca7ef71..f181991713b2c 100644 --- a/src/test/ui/catch-unwind-bang.rs +++ b/src/test/ui/catch-unwind-bang.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default fn worker() -> ! { panic!() diff --git a/src/test/ui/drop/dynamic-drop-async.rs b/src/test/ui/drop/dynamic-drop-async.rs index bec86d6465ae9..91063edf0f6c4 100644 --- a/src/test/ui/drop/dynamic-drop-async.rs +++ b/src/test/ui/drop/dynamic-drop-async.rs @@ -5,7 +5,7 @@ // run-pass // edition:2018 -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![feature(slice_patterns)] #![allow(unused)] diff --git a/src/test/ui/drop/dynamic-drop.rs b/src/test/ui/drop/dynamic-drop.rs index 5a7568fe2cd50..29dcbfe9609a0 100644 --- a/src/test/ui/drop/dynamic-drop.rs +++ b/src/test/ui/drop/dynamic-drop.rs @@ -2,7 +2,7 @@ #![allow(unused_assignments)] #![allow(unused_variables)] -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![feature(generators, generator_trait, untagged_unions)] #![feature(slice_patterns)] diff --git a/src/test/ui/feature-gates/feature-gate-unwind-attributes.rs b/src/test/ui/feature-gates/feature-gate-unwind-attributes.rs index 759fb170f90dd..20c443b63d175 100644 --- a/src/test/ui/feature-gates/feature-gate-unwind-attributes.rs +++ b/src/test/ui/feature-gates/feature-gate-unwind-attributes.rs @@ -1,4 +1,4 @@ -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C no-prepopulate-passes -Cpasses=name-anon-globals #![crate_type = "lib"] diff --git a/src/test/ui/generator/panic-drops.rs b/src/test/ui/generator/panic-drops.rs index b1a5cc67e86b3..f88687858fd11 100644 --- a/src/test/ui/generator/panic-drops.rs +++ b/src/test/ui/generator/panic-drops.rs @@ -1,6 +1,6 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![feature(generators, generator_trait)] diff --git a/src/test/ui/generator/panic-safe.rs b/src/test/ui/generator/panic-safe.rs index 06c026180190a..5f6778674dce1 100644 --- a/src/test/ui/generator/panic-safe.rs +++ b/src/test/ui/generator/panic-safe.rs @@ -1,6 +1,6 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![feature(generators, generator_trait)] diff --git a/src/test/ui/generator/resume-after-return.rs b/src/test/ui/generator/resume-after-return.rs index ab18be58155df..71a68ff684af3 100644 --- a/src/test/ui/generator/resume-after-return.rs +++ b/src/test/ui/generator/resume-after-return.rs @@ -1,6 +1,6 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![feature(generators, generator_trait)] diff --git a/src/test/ui/issues/issue-14875.rs b/src/test/ui/issues/issue-14875.rs index 29e974ad83d1e..0d95d168b3db3 100644 --- a/src/test/ui/issues/issue-14875.rs +++ b/src/test/ui/issues/issue-14875.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // Check that values are not leaked when a dtor panics (#14875) diff --git a/src/test/ui/issues/issue-29948.rs b/src/test/ui/issues/issue-29948.rs index 5237a2f67bdd7..8ede8143ea657 100644 --- a/src/test/ui/issues/issue-29948.rs +++ b/src/test/ui/issues/issue-29948.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default use std::panic; diff --git a/src/test/ui/issues/issue-43853.rs b/src/test/ui/issues/issue-43853.rs index 2a932db05af26..47c3ab59aa2eb 100644 --- a/src/test/ui/issues/issue-43853.rs +++ b/src/test/ui/issues/issue-43853.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default use std::panic; diff --git a/src/test/ui/issues/issue-46519.rs b/src/test/ui/issues/issue-46519.rs index 40c3117f01ce9..cca0995d4ca10 100644 --- a/src/test/ui/issues/issue-46519.rs +++ b/src/test/ui/issues/issue-46519.rs @@ -1,7 +1,7 @@ // run-pass // compile-flags:--test -O -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #[test] #[should_panic(expected = "creating inhabited type")] diff --git a/src/test/ui/iterators/iter-count-overflow-debug.rs b/src/test/ui/iterators/iter-count-overflow-debug.rs index fdd285dcad2a1..d661203575083 100644 --- a/src/test/ui/iterators/iter-count-overflow-debug.rs +++ b/src/test/ui/iterators/iter-count-overflow-debug.rs @@ -1,6 +1,6 @@ // run-pass // only-32bit too impatient for 2⁶⁴ items -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C debug_assertions=yes -C opt-level=3 use std::panic; diff --git a/src/test/ui/iterators/iter-position-overflow-debug.rs b/src/test/ui/iterators/iter-position-overflow-debug.rs index b578999af8e94..f1eded31702c4 100644 --- a/src/test/ui/iterators/iter-position-overflow-debug.rs +++ b/src/test/ui/iterators/iter-position-overflow-debug.rs @@ -1,6 +1,6 @@ // run-pass // only-32bit too impatient for 2⁶⁴ items -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C debug_assertions=yes -C opt-level=3 use std::panic; diff --git a/src/test/ui/iterators/iter-step-overflow-debug.rs b/src/test/ui/iterators/iter-step-overflow-debug.rs index 3872a03b68259..5d67c7cbb4256 100644 --- a/src/test/ui/iterators/iter-step-overflow-debug.rs +++ b/src/test/ui/iterators/iter-step-overflow-debug.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C debug_assertions=yes use std::panic; diff --git a/src/test/ui/iterators/iter-sum-overflow-debug.rs b/src/test/ui/iterators/iter-sum-overflow-debug.rs index 4a9e8cdb72e70..ee4ab4d24c6ab 100644 --- a/src/test/ui/iterators/iter-sum-overflow-debug.rs +++ b/src/test/ui/iterators/iter-sum-overflow-debug.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C debug_assertions=yes use std::panic; diff --git a/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs b/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs index 6bd1425e32465..429f8e0bc9648 100644 --- a/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs +++ b/src/test/ui/iterators/iter-sum-overflow-overflow-checks.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -C overflow-checks use std::panic; diff --git a/src/test/ui/macros/macro-comma-behavior-rpass.rs b/src/test/ui/macros/macro-comma-behavior-rpass.rs index 1c791bb1ca3d6..32cf59294e760 100644 --- a/src/test/ui/macros/macro-comma-behavior-rpass.rs +++ b/src/test/ui/macros/macro-comma-behavior-rpass.rs @@ -13,7 +13,7 @@ // compile-flags: --test -C debug_assertions=yes // revisions: std core -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![cfg_attr(core, no_std)] diff --git a/src/test/ui/mir/mir_calls_to_shims.rs b/src/test/ui/mir/mir_calls_to_shims.rs index de8d958af45e3..6f13d5612ce51 100644 --- a/src/test/ui/mir/mir_calls_to_shims.rs +++ b/src/test/ui/mir/mir_calls_to_shims.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![feature(fn_traits)] #![feature(never_type)] diff --git a/src/test/ui/mir/mir_drop_order.rs b/src/test/ui/mir/mir_drop_order.rs index 2bc5cf1c97637..2949437b1e4b6 100644 --- a/src/test/ui/mir/mir_drop_order.rs +++ b/src/test/ui/mir/mir_drop_order.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default use std::cell::RefCell; use std::panic; diff --git a/src/test/ui/never_type/panic-uninitialized-zeroed.rs b/src/test/ui/never_type/panic-uninitialized-zeroed.rs index 72b844d8b4886..e0c30160b9e94 100644 --- a/src/test/ui/never_type/panic-uninitialized-zeroed.rs +++ b/src/test/ui/never_type/panic-uninitialized-zeroed.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // This test checks that instantiating an uninhabited type via `mem::{uninitialized,zeroed}` results // in a runtime panic. diff --git a/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs b/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs index c1959866e5c25..e9927304f23f8 100644 --- a/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs +++ b/src/test/ui/numbers-arithmetic/next-power-of-two-overflow-debug.rs @@ -1,6 +1,6 @@ // run-pass // compile-flags: -C debug_assertions=yes -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // ignore-emscripten dies with an LLVM error use std::panic; diff --git a/src/test/ui/panic-runtime/transitive-link-a-bunch.rs b/src/test/ui/panic-runtime/transitive-link-a-bunch.rs index 6dcb852a3669f..5d72771c2dcff 100644 --- a/src/test/ui/panic-runtime/transitive-link-a-bunch.rs +++ b/src/test/ui/panic-runtime/transitive-link-a-bunch.rs @@ -4,7 +4,7 @@ // aux-build:wants-panic-runtime-abort.rs // aux-build:panic-runtime-lang-items.rs // error-pattern: is not compiled with this crate's panic strategy `unwind` -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![no_std] #![no_main] diff --git a/src/test/ui/panic-runtime/want-unwind-got-abort.rs b/src/test/ui/panic-runtime/want-unwind-got-abort.rs index e7811d40b5b9a..4c25c09d6438f 100644 --- a/src/test/ui/panic-runtime/want-unwind-got-abort.rs +++ b/src/test/ui/panic-runtime/want-unwind-got-abort.rs @@ -1,7 +1,7 @@ // error-pattern:is incompatible with this crate's strategy of `unwind` // aux-build:panic-runtime-abort.rs // aux-build:panic-runtime-lang-items.rs -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![no_std] #![no_main] diff --git a/src/test/ui/panic-runtime/want-unwind-got-abort2.rs b/src/test/ui/panic-runtime/want-unwind-got-abort2.rs index 44671796c01a3..478af451e7f65 100644 --- a/src/test/ui/panic-runtime/want-unwind-got-abort2.rs +++ b/src/test/ui/panic-runtime/want-unwind-got-abort2.rs @@ -2,7 +2,7 @@ // aux-build:panic-runtime-abort.rs // aux-build:wants-panic-runtime-abort.rs // aux-build:panic-runtime-lang-items.rs -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![no_std] #![no_main] diff --git a/src/test/ui/proc-macro/expand-with-a-macro.rs b/src/test/ui/proc-macro/expand-with-a-macro.rs index 690a76ef3e0af..418178d0f0ead 100644 --- a/src/test/ui/proc-macro/expand-with-a-macro.rs +++ b/src/test/ui/proc-macro/expand-with-a-macro.rs @@ -1,7 +1,7 @@ // run-pass // aux-build:expand-with-a-macro.rs -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![deny(warnings)] diff --git a/src/test/ui/reachable-unnameable-items.rs b/src/test/ui/reachable-unnameable-items.rs index 26c51efea1e1c..f1e53a0d8b426 100644 --- a/src/test/ui/reachable-unnameable-items.rs +++ b/src/test/ui/reachable-unnameable-items.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // aux-build:reachable-unnameable-items.rs extern crate reachable_unnameable_items; diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-in-test.rs b/src/test/ui/rfc-1937-termination-trait/termination-trait-in-test.rs index c8e8b9dcfc6a7..0bd7bf3d51a78 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-in-test.rs +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-in-test.rs @@ -1,7 +1,7 @@ // compile-flags: --test // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![feature(test)] diff --git a/src/test/ui/rfcs/rfc1857-drop-order.rs b/src/test/ui/rfcs/rfc1857-drop-order.rs index b10b6ec11b53a..7923aa7c0e22f 100644 --- a/src/test/ui/rfcs/rfc1857-drop-order.rs +++ b/src/test/ui/rfcs/rfc1857-drop-order.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default #![allow(dead_code, unreachable_code)] diff --git a/src/test/ui/test-attrs/test-allow-fail-attr.rs b/src/test/ui/test-attrs/test-allow-fail-attr.rs index 55b743ab7c7ea..1a478460efc6c 100644 --- a/src/test/ui/test-attrs/test-allow-fail-attr.rs +++ b/src/test/ui/test-attrs/test-allow-fail-attr.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: --test #![feature(allow_fail)] diff --git a/src/test/ui/test-attrs/test-should-fail-good-message.rs b/src/test/ui/test-attrs/test-should-fail-good-message.rs index 2284953fbbe94..9fa759f9eb483 100644 --- a/src/test/ui/test-attrs/test-should-fail-good-message.rs +++ b/src/test/ui/test-attrs/test-should-fail-good-message.rs @@ -1,5 +1,5 @@ // run-pass -// ignore-emscripten compiled with panic=abort by default +// ignore-wasm32-bare compiled with panic=abort by default // compile-flags: --test #[test] #[should_panic(expected = "foo")] diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 0309488506584..d750595e272cf 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -141,10 +141,6 @@ impl EarlyProps { if config.target == "wasm32-unknown-unknown" && config.parse_check_run_results(ln) { props.ignore = Ignore::Ignore; } - // FIXME: Re-enable run-fail once panics are handled correctly - if config.target.contains("emscripten") && config.mode == common::RunFail { - props.ignore = Ignore::Ignore; - } } if (config.mode == common::DebugInfoGdb || config.mode == common::DebugInfoGdbLldb) && From 29d6aaae32df46f0f8101be6aafd9594ece8ad64 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Fri, 25 Oct 2019 14:47:05 -0700 Subject: [PATCH 04/26] Temporarily enable asmjs and wasm32 CI on PRs --- src/ci/azure-pipelines/pr.yml | 4 ++++ src/ci/docker/{disabled => }/asmjs/Dockerfile | 0 2 files changed, 4 insertions(+) rename src/ci/docker/{disabled => }/asmjs/Dockerfile (100%) diff --git a/src/ci/azure-pipelines/pr.yml b/src/ci/azure-pipelines/pr.yml index 62e23efe1ef16..3730fd0f09784 100644 --- a/src/ci/azure-pipelines/pr.yml +++ b/src/ci/azure-pipelines/pr.yml @@ -22,6 +22,10 @@ jobs: IMAGE: x86_64-gnu-llvm-6.0 mingw-check: IMAGE: mingw-check + wasm32: + IMAGE: wasm32 + wasmjs: + IMAGE: asmjs - job: LinuxTools timeoutInMinutes: 600 diff --git a/src/ci/docker/disabled/asmjs/Dockerfile b/src/ci/docker/asmjs/Dockerfile similarity index 100% rename from src/ci/docker/disabled/asmjs/Dockerfile rename to src/ci/docker/asmjs/Dockerfile From f8ed98503e5987b5bc440b46fa7072e080262552 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Fri, 25 Oct 2019 16:10:17 -0700 Subject: [PATCH 05/26] Formatting --- src/librustc_codegen_llvm/llvm_util.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_codegen_llvm/llvm_util.rs b/src/librustc_codegen_llvm/llvm_util.rs index a56d015a1b2b1..85e0b6d465ab0 100644 --- a/src/librustc_codegen_llvm/llvm_util.rs +++ b/src/librustc_codegen_llvm/llvm_util.rs @@ -73,7 +73,8 @@ unsafe fn configure_llvm(sess: &Session) { } } - if sess.target.target.target_os == "emscripten" && sess.panic_strategy() == PanicStrategy::Unwind { + if sess.target.target.target_os == "emscripten" && + sess.panic_strategy() == PanicStrategy::Unwind { add("-enable-emscripten-cxx-exceptions"); } From 23b382755dab5d6bd8fd6e9bdda53912fec750b7 Mon Sep 17 00:00:00 2001 From: Wang Xuerui Date: Sun, 28 Jul 2019 11:50:14 +0800 Subject: [PATCH 06/26] ci: add support for MIPS64 musl targets --- src/bootstrap/configure.py | 4 ++++ src/ci/docker/dist-various-1/Dockerfile | 16 ++++++++++++++++ src/tools/build-manifest/src/main.rs | 2 ++ 3 files changed, 22 insertions(+) diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 76509134f7ccd..bb6041d7f3196 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -133,6 +133,10 @@ def v(*args): "mips-unknown-linux-musl install directory") v("musl-root-mipsel", "target.mipsel-unknown-linux-musl.musl-root", "mipsel-unknown-linux-musl install directory") +v("musl-root-mips64", "target.mips64-unknown-linux-muslabi64.musl-root", + "mips64-unknown-linux-muslabi64 install directory") +v("musl-root-mips64el", "target.mips64el-unknown-linux-muslabi64.musl-root", + "mips64el-unknown-linux-muslabi64 install directory") v("qemu-armhf-rootfs", "target.arm-unknown-linux-gnueabihf.qemu-rootfs", "rootfs in qemu testing, you probably don't want to use this") v("qemu-aarch64-rootfs", "target.aarch64-unknown-linux-gnu.qemu-rootfs", diff --git a/src/ci/docker/dist-various-1/Dockerfile b/src/ci/docker/dist-various-1/Dockerfile index fab3824a20ae3..816bdb34a7bfe 100644 --- a/src/ci/docker/dist-various-1/Dockerfile +++ b/src/ci/docker/dist-various-1/Dockerfile @@ -15,6 +15,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ g++-arm-linux-gnueabi \ g++-arm-linux-gnueabihf \ g++-aarch64-linux-gnu \ + g++-mips64-linux-gnuabi64 \ + g++-mips64el-linux-gnuabi64 \ gcc-sparc64-linux-gnu \ libc6-dev-sparc64-cross \ bzip2 \ @@ -77,6 +79,14 @@ RUN env \ CC=mipsel-openwrt-linux-gcc \ CXX=mipsel-openwrt-linux-g++ \ bash musl.sh mipsel && \ + env \ + CC=mips64-linux-gnuabi64-gcc \ + CXX=mips64-linux-gnuabi64-g++ \ + bash musl.sh mips64 && \ + env \ + CC=mips64el-linux-gnuabi64-gcc \ + CXX=mips64el-linux-gnuabi64-g++ \ + bash musl.sh mips64el && \ rm -rf /build/* # FIXME(mozilla/sccache#235) this shouldn't be necessary but is currently @@ -97,6 +107,8 @@ ENV TARGETS=$TARGETS,wasm32-unknown-emscripten ENV TARGETS=$TARGETS,x86_64-rumprun-netbsd ENV TARGETS=$TARGETS,mips-unknown-linux-musl ENV TARGETS=$TARGETS,mipsel-unknown-linux-musl +ENV TARGETS=$TARGETS,mips64-unknown-linux-muslabi64 +ENV TARGETS=$TARGETS,mips64el-unknown-linux-muslabi64 ENV TARGETS=$TARGETS,arm-unknown-linux-musleabi ENV TARGETS=$TARGETS,arm-unknown-linux-musleabihf ENV TARGETS=$TARGETS,armv5te-unknown-linux-gnueabi @@ -125,6 +137,8 @@ ENV TARGETS=$TARGETS,thumbv7neon-unknown-linux-gnueabihf ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \ CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc \ + CC_mips64el_unknown_linux_muslabi64=mips64el-linux-gnuabi64-gcc \ + CC_mips64_unknown_linux_muslabi64=mips64-linux-gnuabi64-gcc \ CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \ CC_x86_64_unknown_redox=x86_64-unknown-redox-gcc \ CC_thumbv7neon_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \ @@ -139,6 +153,8 @@ ENV RUST_CONFIGURE_ARGS \ --musl-root-aarch64=/musl-aarch64 \ --musl-root-mips=/musl-mips \ --musl-root-mipsel=/musl-mipsel \ + --musl-root-mips64=/musl-mips64 \ + --musl-root-mips64el=/musl-mips64el \ --disable-docs ENV SCRIPT \ diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index c0d2deab2f8ba..9a9335538c5fa 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -90,7 +90,9 @@ static TARGETS: &[&str] = &[ "mips-unknown-linux-gnu", "mips-unknown-linux-musl", "mips64-unknown-linux-gnuabi64", + "mips64-unknown-linux-muslabi64", "mips64el-unknown-linux-gnuabi64", + "mips64el-unknown-linux-muslabi64", "mipsisa32r6-unknown-linux-gnu", "mipsisa32r6el-unknown-linux-gnu", "mipsisa64r6-unknown-linux-gnuabi64", From de9413bd3403f1b95c717a839b7612e3cfe83b03 Mon Sep 17 00:00:00 2001 From: Quentin Boyer Date: Mon, 28 Oct 2019 00:57:25 +0100 Subject: [PATCH 07/26] changing non-empty glob must import something to a lint --- src/librustc_resolve/resolve_imports.rs | 5 +++-- src/test/ui/imports/reexports.rs | 9 ++++++-- src/test/ui/imports/reexports.stderr | 28 +++++++++++++++---------- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 360343169bc3d..daee4d4e9b268 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -972,8 +972,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> { if !is_prelude && max_vis.get() != ty::Visibility::Invisible && // Allow empty globs. !max_vis.get().is_at_least(directive.vis.get(), &*self) { - let msg = "A non-empty glob must import something with the glob's visibility"; - self.r.session.span_err(directive.span, msg); + let msg = + "glob import doesn't reexport anything because no candidate is public enough"; + self.r.session.buffer_lint(UNUSED_IMPORTS, directive.id, directive.span, msg); } return None; } diff --git a/src/test/ui/imports/reexports.rs b/src/test/ui/imports/reexports.rs index b0a591b08ac89..d76cc41be4e55 100644 --- a/src/test/ui/imports/reexports.rs +++ b/src/test/ui/imports/reexports.rs @@ -1,16 +1,21 @@ +#![warn(unused_imports)] + mod a { fn foo() {} mod foo {} mod a { pub use super::foo; //~ ERROR cannot be re-exported - pub use super::*; //~ ERROR must import something with the glob's visibility + pub use super::*; + //~^ WARNING glob import doesn't reexport anything because no candidate is public enough } } mod b { pub fn foo() {} - mod foo { pub struct S; } + mod foo { + pub struct S; + } pub mod a { pub use super::foo; // This is OK since the value `foo` is visible enough. diff --git a/src/test/ui/imports/reexports.stderr b/src/test/ui/imports/reexports.stderr index af2c97e77b9d7..382b181f45b7b 100644 --- a/src/test/ui/imports/reexports.stderr +++ b/src/test/ui/imports/reexports.stderr @@ -1,34 +1,40 @@ error[E0364]: `foo` is private, and cannot be re-exported - --> $DIR/reexports.rs:6:17 + --> $DIR/reexports.rs:10:17 | LL | pub use super::foo; | ^^^^^^^^^^ | note: consider marking `foo` as `pub` in the imported module - --> $DIR/reexports.rs:6:17 + --> $DIR/reexports.rs:10:17 | LL | pub use super::foo; | ^^^^^^^^^^ -error: A non-empty glob must import something with the glob's visibility - --> $DIR/reexports.rs:7:17 - | -LL | pub use super::*; - | ^^^^^^^^ - error[E0603]: module `foo` is private - --> $DIR/reexports.rs:28:15 + --> $DIR/reexports.rs:35:15 | LL | use b::a::foo::S; | ^^^ error[E0603]: module `foo` is private - --> $DIR/reexports.rs:29:15 + --> $DIR/reexports.rs:36:15 | LL | use b::b::foo::S as T; | ^^^ -error: aborting due to 4 previous errors +warning: this glob doesn't reexport anything because no canditate is public enough + --> $DIR/reexports.rs:11:17 + | +LL | pub use super::*; + | ^^^^^^^^ + | +note: lint level defined here + --> $DIR/reexports.rs:1:9 + | +LL | #![warn(unused_imports)] + | ^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors Some errors have detailed explanations: E0364, E0603. For more information about an error, try `rustc --explain E0364`. From 652b1bd45dfd81435b431cfe84c0f18f79c3ee7a Mon Sep 17 00:00:00 2001 From: Quentin Boyer Date: Mon, 28 Oct 2019 11:22:26 +0100 Subject: [PATCH 08/26] fix tidy --- src/librustc_resolve/resolve_imports.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index daee4d4e9b268..c387adebbf7f1 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -973,7 +973,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> { max_vis.get() != ty::Visibility::Invisible && // Allow empty globs. !max_vis.get().is_at_least(directive.vis.get(), &*self) { let msg = - "glob import doesn't reexport anything because no candidate is public enough"; + "glob import doesn't reexport anything because no candidate is public enough"; self.r.session.buffer_lint(UNUSED_IMPORTS, directive.id, directive.span, msg); } return None; From 7cecfab386279ff626da7ee62fc6127b4093b69b Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 28 Oct 2019 09:54:24 -0400 Subject: [PATCH 09/26] add basic HermitCore support within libtest --- src/libtest/helpers/concurrency.rs | 6 ++++++ src/libtest/helpers/isatty.rs | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libtest/helpers/concurrency.rs b/src/libtest/helpers/concurrency.rs index 61651a927c5f7..4fec01d752502 100644 --- a/src/libtest/helpers/concurrency.rs +++ b/src/libtest/helpers/concurrency.rs @@ -54,6 +54,12 @@ pub fn get_concurrency() -> usize { 1 } + #[cfg(target_os = "hermit")] + fn num_cpus() -> usize { + // FIXME: Implement num_cpus on HermitCore + 1 + } + #[cfg(any( all(target_arch = "wasm32", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx") diff --git a/src/libtest/helpers/isatty.rs b/src/libtest/helpers/isatty.rs index 6e4954778e605..4955e1fc88862 100644 --- a/src/libtest/helpers/isatty.rs +++ b/src/libtest/helpers/isatty.rs @@ -2,7 +2,7 @@ //! if stdout is a tty. #[cfg(any( - target_os = "cloudabi", + target_os = "cloudabi", target_os = "hermit", all(target_arch = "wasm32", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx") ))] From b3f64946f9d89833c1f05bd010c464f54c3fb6b5 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Mon, 28 Oct 2019 19:55:25 +0200 Subject: [PATCH 10/26] proc_macro: remove now-unnecessary ICE workarounds from bridge::client. --- src/libproc_macro/bridge/client.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/libproc_macro/bridge/client.rs b/src/libproc_macro/bridge/client.rs index 5c543165bc2b1..cd33c4bc67e76 100644 --- a/src/libproc_macro/bridge/client.rs +++ b/src/libproc_macro/bridge/client.rs @@ -15,8 +15,9 @@ macro_rules! define_handles { } impl HandleCounters { - // FIXME(#53451) public to work around `Cannot create local mono-item` ICE. - pub extern "C" fn get() -> &'static Self { + // FIXME(eddyb) use a reference to the `static COUNTERS`, intead of + // a wrapper `fn` pointer, once `const fn` can reference `static`s. + extern "C" fn get() -> &'static Self { static COUNTERS: HandleCounters = HandleCounters { $($oty: AtomicUsize::new(1),)* $($ity: AtomicUsize::new(1),)* @@ -333,14 +334,14 @@ impl Bridge<'_> { #[repr(C)] #[derive(Copy, Clone)] pub struct Client { + // FIXME(eddyb) use a reference to the `static COUNTERS`, intead of + // a wrapper `fn` pointer, once `const fn` can reference `static`s. pub(super) get_handle_counters: extern "C" fn() -> &'static HandleCounters, pub(super) run: extern "C" fn(Bridge<'_>, F) -> Buffer, pub(super) f: F, } -// FIXME(#53451) public to work around `Cannot create local mono-item` ICE, -// affecting not only the function itself, but also the `BridgeState` `thread_local!`. -pub extern "C" fn __run_expand1( +extern "C" fn run_expand1( mut bridge: Bridge<'_>, f: fn(crate::TokenStream) -> crate::TokenStream, ) -> Buffer { @@ -385,15 +386,13 @@ impl Client crate::TokenStream> { pub const fn expand1(f: fn(crate::TokenStream) -> crate::TokenStream) -> Self { Client { get_handle_counters: HandleCounters::get, - run: __run_expand1, + run: run_expand1, f, } } } -// FIXME(#53451) public to work around `Cannot create local mono-item` ICE, -// affecting not only the function itself, but also the `BridgeState` `thread_local!`. -pub extern "C" fn __run_expand2( +extern "C" fn run_expand2( mut bridge: Bridge<'_>, f: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream, ) -> Buffer { @@ -441,7 +440,7 @@ impl Client crate::TokenStream> { ) -> Self { Client { get_handle_counters: HandleCounters::get, - run: __run_expand2, + run: run_expand2, f, } } From cf65200e5c78c04a7d9f05c4d8131218624a7924 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 28 Oct 2019 14:03:53 -0400 Subject: [PATCH 11/26] removing trailing whitespaces --- src/libtest/helpers/concurrency.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libtest/helpers/concurrency.rs b/src/libtest/helpers/concurrency.rs index 4fec01d752502..6b0c8a8af32b4 100644 --- a/src/libtest/helpers/concurrency.rs +++ b/src/libtest/helpers/concurrency.rs @@ -57,7 +57,7 @@ pub fn get_concurrency() -> usize { #[cfg(target_os = "hermit")] fn num_cpus() -> usize { // FIXME: Implement num_cpus on HermitCore - 1 + 1 } #[cfg(any( From da5965f3a6bbc984d97027896fad9c4f551426fd Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Mon, 28 Oct 2019 20:21:12 +0200 Subject: [PATCH 12/26] proc_macro: consolidate bridge::client::run_expand{1,2} into one helper. --- src/libproc_macro/bridge/client.rs | 71 ++++++++++-------------------- 1 file changed, 23 insertions(+), 48 deletions(-) diff --git a/src/libproc_macro/bridge/client.rs b/src/libproc_macro/bridge/client.rs index cd33c4bc67e76..b17359a4c8cf7 100644 --- a/src/libproc_macro/bridge/client.rs +++ b/src/libproc_macro/bridge/client.rs @@ -341,9 +341,12 @@ pub struct Client { pub(super) f: F, } -extern "C" fn run_expand1( +/// Client-side helper for handling client panics, entering the bridge, +/// deserializing input and serializing output. +// FIXME(eddyb) maybe replace `Bridge::enter` with this? +fn run_client DecodeMut<'a, 's, ()>, R: Encode<()>>( mut bridge: Bridge<'_>, - f: fn(crate::TokenStream) -> crate::TokenStream, + f: impl FnOnce(A) -> R, ) -> Buffer { // The initial `cached_buffer` contains the input. let mut b = bridge.cached_buffer.take(); @@ -351,12 +354,12 @@ extern "C" fn run_expand1( panic::catch_unwind(panic::AssertUnwindSafe(|| { bridge.enter(|| { let reader = &mut &b[..]; - let input = TokenStream::decode(reader, &mut ()); + let input = A::decode(reader, &mut ()); // Put the `cached_buffer` back in the `Bridge`, for requests. Bridge::with(|bridge| bridge.cached_buffer = b.take()); - let output = f(crate::TokenStream(input)).0; + let output = f(input); // Take the `cached_buffer` back out, for the output value. b = Bridge::with(|bridge| bridge.cached_buffer.take()); @@ -384,63 +387,35 @@ extern "C" fn run_expand1( impl Client crate::TokenStream> { pub const fn expand1(f: fn(crate::TokenStream) -> crate::TokenStream) -> Self { + extern "C" fn run( + bridge: Bridge<'_>, + f: fn(crate::TokenStream) -> crate::TokenStream, + ) -> Buffer { + run_client(bridge, |input| f(crate::TokenStream(input)).0) + } Client { get_handle_counters: HandleCounters::get, - run: run_expand1, + run, f, } } } -extern "C" fn run_expand2( - mut bridge: Bridge<'_>, - f: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream, -) -> Buffer { - // The initial `cached_buffer` contains the input. - let mut b = bridge.cached_buffer.take(); - - panic::catch_unwind(panic::AssertUnwindSafe(|| { - bridge.enter(|| { - let reader = &mut &b[..]; - let input = TokenStream::decode(reader, &mut ()); - let input2 = TokenStream::decode(reader, &mut ()); - - // Put the `cached_buffer` back in the `Bridge`, for requests. - Bridge::with(|bridge| bridge.cached_buffer = b.take()); - - let output = f(crate::TokenStream(input), crate::TokenStream(input2)).0; - - // Take the `cached_buffer` back out, for the output value. - b = Bridge::with(|bridge| bridge.cached_buffer.take()); - - // HACK(eddyb) Separate encoding a success value (`Ok(output)`) - // from encoding a panic (`Err(e: PanicMessage)`) to avoid - // having handles outside the `bridge.enter(|| ...)` scope, and - // to catch panics that could happen while encoding the success. - // - // Note that panics should be impossible beyond this point, but - // this is defensively trying to avoid any accidental panicking - // reaching the `extern "C"` (which should `abort` but may not - // at the moment, so this is also potentially preventing UB). - b.clear(); - Ok::<_, ()>(output).encode(&mut b, &mut ()); - }) - })) - .map_err(PanicMessage::from) - .unwrap_or_else(|e| { - b.clear(); - Err::<(), _>(e).encode(&mut b, &mut ()); - }); - b -} - impl Client crate::TokenStream> { pub const fn expand2( f: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream ) -> Self { + extern "C" fn run( + bridge: Bridge<'_>, + f: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream, + ) -> Buffer { + run_client(bridge, |(input, input2)| { + f(crate::TokenStream(input), crate::TokenStream(input2)).0 + }) + } Client { get_handle_counters: HandleCounters::get, - run: run_expand2, + run, f, } } From b58634454f2a6def88f3197261a458e208f77f49 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Mon, 28 Oct 2019 20:34:59 +0200 Subject: [PATCH 13/26] proc_macro: don't use Rust ABI fn pointers in a C ABI fn signature. --- src/libproc_macro/bridge/client.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libproc_macro/bridge/client.rs b/src/libproc_macro/bridge/client.rs index b17359a4c8cf7..9643dba997aa4 100644 --- a/src/libproc_macro/bridge/client.rs +++ b/src/libproc_macro/bridge/client.rs @@ -389,7 +389,7 @@ impl Client crate::TokenStream> { pub const fn expand1(f: fn(crate::TokenStream) -> crate::TokenStream) -> Self { extern "C" fn run( bridge: Bridge<'_>, - f: fn(crate::TokenStream) -> crate::TokenStream, + f: impl FnOnce(crate::TokenStream) -> crate::TokenStream, ) -> Buffer { run_client(bridge, |input| f(crate::TokenStream(input)).0) } @@ -407,7 +407,7 @@ impl Client crate::TokenStream> { ) -> Self { extern "C" fn run( bridge: Bridge<'_>, - f: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream, + f: impl FnOnce(crate::TokenStream, crate::TokenStream) -> crate::TokenStream, ) -> Buffer { run_client(bridge, |(input, input2)| { f(crate::TokenStream(input), crate::TokenStream(input2)).0 From 92c049be583a559430f17f3364c616fc92c059a1 Mon Sep 17 00:00:00 2001 From: Thomas Lively Date: Mon, 28 Oct 2019 12:30:08 -0700 Subject: [PATCH 14/26] Revert "Temporarily enable asmjs and wasm32 CI on PRs" This reverts commit 29d6aaae32df46f0f8101be6aafd9594ece8ad64. --- src/ci/azure-pipelines/pr.yml | 4 ---- src/ci/docker/{ => disabled}/asmjs/Dockerfile | 0 2 files changed, 4 deletions(-) rename src/ci/docker/{ => disabled}/asmjs/Dockerfile (100%) diff --git a/src/ci/azure-pipelines/pr.yml b/src/ci/azure-pipelines/pr.yml index 3730fd0f09784..62e23efe1ef16 100644 --- a/src/ci/azure-pipelines/pr.yml +++ b/src/ci/azure-pipelines/pr.yml @@ -22,10 +22,6 @@ jobs: IMAGE: x86_64-gnu-llvm-6.0 mingw-check: IMAGE: mingw-check - wasm32: - IMAGE: wasm32 - wasmjs: - IMAGE: asmjs - job: LinuxTools timeoutInMinutes: 600 diff --git a/src/ci/docker/asmjs/Dockerfile b/src/ci/docker/disabled/asmjs/Dockerfile similarity index 100% rename from src/ci/docker/asmjs/Dockerfile rename to src/ci/docker/disabled/asmjs/Dockerfile From 3bd16c291e6899d0867b6ff9a2714be8d3b2a2f6 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 28 Oct 2019 16:21:53 -0400 Subject: [PATCH 15/26] Update mdbook to 0.3.3 --- Cargo.lock | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4b264ef3f9faf..f490814854f10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,16 +27,16 @@ dependencies = [ [[package]] name = "ammonia" -version = "2.1.2" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384d704f242a0a9faf793fff775a0be6ab9aa27edabffa097331d73779142520" +checksum = "9e266e1f4be5ffa05309f650e2586fe1d3ae6034eb24025a7ae1dfecc330823a" dependencies = [ "html5ever", "lazy_static 1.3.0", "maplit", "matches", "tendril", - "url 1.7.2", + "url 2.1.0", ] [[package]] @@ -1363,16 +1363,16 @@ dependencies = [ [[package]] name = "html5ever" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce65ac8028cf5a287a7dbf6c4e0a6cf2dcf022ed5b167a81bae66ebf599a8b7" +checksum = "025483b0a1e4577bb28578318c886ee5f817dda6eb62473269349044406644cb" dependencies = [ "log", "mac", "markup5ever", - "proc-macro2 0.4.30", - "quote 0.6.12", - "syn 0.15.35", + "proc-macro2 1.0.3", + "quote 1.0.2", + "syn 1.0.5", ] [[package]] @@ -1902,9 +1902,9 @@ checksum = "08cbb6b4fef96b6d77bfc40ec491b1690c779e77b05cd9f07f787ed376fd4c43" [[package]] name = "markup5ever" -version = "0.8.1" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1af46a727284117e09780d05038b1ce6fc9c76cc6df183c3dae5a8955a25e21" +checksum = "65381d9d47506b8592b97c4efd936afcf673b09b059f2bef39c7211ee78b9d03" dependencies = [ "log", "phf", @@ -1925,9 +1925,9 @@ checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" [[package]] name = "mdbook" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "949bb2acb2cff9fa5c375cf9c43e70b3dba0a974d9fe01c31285d7a84d2a0fa2" +checksum = "9a070268274c566082efb6b2ace7743e43ba91a70d5c6982981e96d3c05ac81c" dependencies = [ "ammonia", "chrono", From ed8585ffb5a6d82cb12eff263cd0466ef3f79e36 Mon Sep 17 00:00:00 2001 From: Quentin Boyer Date: Tue, 29 Oct 2019 00:20:28 +0100 Subject: [PATCH 16/26] forgot to add the changed stderr --- src/test/ui/imports/reexports.stderr | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/ui/imports/reexports.stderr b/src/test/ui/imports/reexports.stderr index 382b181f45b7b..4388e2c276b8e 100644 --- a/src/test/ui/imports/reexports.stderr +++ b/src/test/ui/imports/reexports.stderr @@ -1,29 +1,29 @@ error[E0364]: `foo` is private, and cannot be re-exported - --> $DIR/reexports.rs:10:17 + --> $DIR/reexports.rs:8:17 | LL | pub use super::foo; | ^^^^^^^^^^ | note: consider marking `foo` as `pub` in the imported module - --> $DIR/reexports.rs:10:17 + --> $DIR/reexports.rs:8:17 | LL | pub use super::foo; | ^^^^^^^^^^ error[E0603]: module `foo` is private - --> $DIR/reexports.rs:35:15 + --> $DIR/reexports.rs:33:15 | LL | use b::a::foo::S; | ^^^ error[E0603]: module `foo` is private - --> $DIR/reexports.rs:36:15 + --> $DIR/reexports.rs:34:15 | LL | use b::b::foo::S as T; | ^^^ -warning: this glob doesn't reexport anything because no canditate is public enough - --> $DIR/reexports.rs:11:17 +warning: glob import doesn't reexport anything because no candidate is public enough + --> $DIR/reexports.rs:9:17 | LL | pub use super::*; | ^^^^^^^^ From c648ad587c7b133b2e95cc370b8b5e813c352fb1 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Sun, 6 Oct 2019 17:30:11 -0500 Subject: [PATCH 17/26] Use rustc-workspace-hack for rustbook As rustbook now depends transitively on openssl, it needs access to the rustc-workspace-hack/all-static feature to pick up openssl-sys/vendored. This fixes the rust build with `all-static = true` on systems where openssl is not installed (e.g. when cross-compiling). --- Cargo.lock | 1 + src/bootstrap/tool.rs | 1 + src/tools/rustbook/Cargo.toml | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 4b264ef3f9faf..89be17972cc2b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3103,6 +3103,7 @@ dependencies = [ "failure", "mdbook", "mdbook-linkcheck", + "rustc-workspace-hack", ] [[package]] diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index f1baeafe26afb..815498047fd5d 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -244,6 +244,7 @@ pub fn prepare_tool_cargo( path.ends_with("rls") || path.ends_with("clippy") || path.ends_with("miri") || + path.ends_with("rustbook") || path.ends_with("rustfmt") { cargo.env("LIBZ_SYS_STATIC", "1"); diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml index a7188f0d11eac..89bbde4d5a9e3 100644 --- a/src/tools/rustbook/Cargo.toml +++ b/src/tools/rustbook/Cargo.toml @@ -13,6 +13,11 @@ clap = "2.25.0" failure = "0.1" mdbook-linkcheck = { version = "0.3.0", optional = true } +# A noop dependency that changes in the Rust repository, it's a bit of a hack. +# See the `src/tools/rustc-workspace-hack/README.md` file in `rust-lang/rust` +# for more information. +rustc-workspace-hack = "1.0.0" + [dependencies.mdbook] version = "0.3.0" default-features = false From 53be2724157ca6fe9412e52dea56d4b29759ac11 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 23 Oct 2019 15:56:21 +0200 Subject: [PATCH 18/26] ci: enable "run when submodule changes" with environment variables We have a job in our CI (PR's x86_64-gnu-tools) that's supposed to run only when a submodule is changed in the PR, and it works by having a task at the start of the build that skips all the following tasks if the condition isn't met. Before this commit that task was gated with template parameters, which is a unique feature of Azure Pipelines. To make our CI more generic this commit switches the gate to use a simple environment variable plus a condition, which should be supported on more CI providers. --- src/ci/azure-pipelines/pr.yml | 14 +++----------- src/ci/azure-pipelines/steps/run.yml | 29 ++++++++++++---------------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/ci/azure-pipelines/pr.yml b/src/ci/azure-pipelines/pr.yml index 62e23efe1ef16..566e654fdb3f0 100644 --- a/src/ci/azure-pipelines/pr.yml +++ b/src/ci/azure-pipelines/pr.yml @@ -22,14 +22,6 @@ jobs: IMAGE: x86_64-gnu-llvm-6.0 mingw-check: IMAGE: mingw-check - -- job: LinuxTools - timeoutInMinutes: 600 - pool: - vmImage: ubuntu-16.04 - steps: - - template: steps/run.yml - parameters: - only_on_updated_submodules: 'yes' - variables: - IMAGE: x86_64-gnu-tools + x86_64-gnu-tools: + IMAGE: x86_64-gnu-tools + CI_ONLY_WHEN_SUBMODULES_CHANGED: 1 diff --git a/src/ci/azure-pipelines/steps/run.yml b/src/ci/azure-pipelines/steps/run.yml index 01858cca50b1c..f3339808567e7 100644 --- a/src/ci/azure-pipelines/steps/run.yml +++ b/src/ci/azure-pipelines/steps/run.yml @@ -6,11 +6,6 @@ # # Check travis config for `gdb --batch` command to print all crash logs -parameters: - # When this parameter is set to anything other than an empty string the tests - # will only be executed when the commit updates submodules - only_on_updated_submodules: '' - steps: # Disable automatic line ending conversion, which is enabled by default on @@ -29,18 +24,18 @@ steps: # Set the SKIP_JOB environment variable if this job is supposed to only run # when submodules are updated and they were not. The following time consuming # tasks will be skipped when the environment variable is present. -- ${{ if parameters.only_on_updated_submodules }}: - - bash: | - set -e - # Submodules pseudo-files inside git have the 160000 permissions, so when - # those files are present in the diff a submodule was updated. - if git diff HEAD^ | grep "^index .* 160000" >/dev/null 2>&1; then - echo "Executing the job since submodules are updated" - else - echo "Not executing this job since no submodules were updated" - echo "##vso[task.setvariable variable=SKIP_JOB;]1" - fi - displayName: Decide whether to run this job +- bash: | + set -e + # Submodules pseudo-files inside git have the 160000 permissions, so when + # those files are present in the diff a submodule was updated. + if git diff HEAD^ | grep "^index .* 160000" >/dev/null 2>&1; then + echo "Executing the job since submodules are updated" + else + echo "Not executing this job since no submodules were updated" + echo "##vso[task.setvariable variable=SKIP_JOB;]1" + fi + displayName: Decide whether to run this job + condition: and(succeeded(), variables.CI_ONLY_WHEN_SUBMODULES_CHANGED) # Spawn a background process to collect CPU usage statistics which we'll upload # at the end of the build. See the comments in the script here for more From 4fb8a9a73cb5c42543e02ce1d797a6d028f6068f Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Wed, 23 Oct 2019 16:07:13 +0200 Subject: [PATCH 19/26] ci: extract job skipping logic into a script --- src/ci/azure-pipelines/steps/run.yml | 15 +-------------- src/ci/scripts/should-skip-this.sh | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 14 deletions(-) create mode 100755 src/ci/scripts/should-skip-this.sh diff --git a/src/ci/azure-pipelines/steps/run.yml b/src/ci/azure-pipelines/steps/run.yml index f3339808567e7..b8e32cf2cdfe3 100644 --- a/src/ci/azure-pipelines/steps/run.yml +++ b/src/ci/azure-pipelines/steps/run.yml @@ -21,21 +21,8 @@ steps: - checkout: self fetchDepth: 2 -# Set the SKIP_JOB environment variable if this job is supposed to only run -# when submodules are updated and they were not. The following time consuming -# tasks will be skipped when the environment variable is present. -- bash: | - set -e - # Submodules pseudo-files inside git have the 160000 permissions, so when - # those files are present in the diff a submodule was updated. - if git diff HEAD^ | grep "^index .* 160000" >/dev/null 2>&1; then - echo "Executing the job since submodules are updated" - else - echo "Not executing this job since no submodules were updated" - echo "##vso[task.setvariable variable=SKIP_JOB;]1" - fi +- bash: src/ci/scripts/should-skip-this.sh displayName: Decide whether to run this job - condition: and(succeeded(), variables.CI_ONLY_WHEN_SUBMODULES_CHANGED) # Spawn a background process to collect CPU usage statistics which we'll upload # at the end of the build. See the comments in the script here for more diff --git a/src/ci/scripts/should-skip-this.sh b/src/ci/scripts/should-skip-this.sh new file mode 100755 index 0000000000000..a38099a2db7ff --- /dev/null +++ b/src/ci/scripts/should-skip-this.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# Set the SKIP_JOB environment variable if this job is supposed to only run +# when submodules are updated and they were not. The following time consuming +# tasks will be skipped when the environment variable is present. + +set -euo pipefail +IFS=$'\n\t' + +source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" + +if [[ -z "${CI_ONLY_WHEN_SUBMODULES_CHANGED+x}" ]]; then + echo "Executing the job since there is no skip rule in effect" +elif git diff HEAD^ | grep "^index .* 160000" >/dev/null 2>&1; then + # Submodules pseudo-files inside git have the 160000 permissions, so when + # those files are present in the diff a submodule was updated. + echo "Executing the job since submodules are updated" +else + echo "Not executing this job since no submodules were updated" + ciCommandSetEnv SKIP_JOB 1 +fi From 95ad6c33c7744da263c6cf05840cbfdfd790bb89 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Tue, 29 Oct 2019 10:32:51 +0100 Subject: [PATCH 20/26] Apply suggestions from lzutao Co-Authored-By: lzutao --- src/ci/scripts/should-skip-this.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/scripts/should-skip-this.sh b/src/ci/scripts/should-skip-this.sh index a38099a2db7ff..f945db0ada27d 100755 --- a/src/ci/scripts/should-skip-this.sh +++ b/src/ci/scripts/should-skip-this.sh @@ -10,7 +10,7 @@ source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" if [[ -z "${CI_ONLY_WHEN_SUBMODULES_CHANGED+x}" ]]; then echo "Executing the job since there is no skip rule in effect" -elif git diff HEAD^ | grep "^index .* 160000" >/dev/null 2>&1; then +elif git diff HEAD^ | grep --quiet "^index .* 160000"; then # Submodules pseudo-files inside git have the 160000 permissions, so when # those files are present in the diff a submodule was updated. echo "Executing the job since submodules are updated" From c8420db21d6d64ed9ce8c7937ad7ceda0eee8d20 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 14 Oct 2019 13:13:38 +0200 Subject: [PATCH 21/26] Create new error code E0740 for visibility restrictions to ancestor module issues --- src/librustc_resolve/build_reduced_graph.rs | 6 +++--- src/librustc_resolve/error_codes.rs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index c18bdfad22cf0..3564aefba73ae 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -256,9 +256,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { if self.r.is_accessible_from(vis, parent_scope.module) { vis } else { - let msg = - "visibilities can only be restricted to ancestor modules"; - self.r.session.span_err(path.span, msg); + struct_span_err!(self.r.session, path.span, E0741, + "visibilities can only be restricted to ancestor modules") + .emit(); ty::Visibility::Public } } diff --git a/src/librustc_resolve/error_codes.rs b/src/librustc_resolve/error_codes.rs index 9515c87ce4bb5..b76373703d1ea 100644 --- a/src/librustc_resolve/error_codes.rs +++ b/src/librustc_resolve/error_codes.rs @@ -1953,4 +1953,5 @@ struct Foo> { // E0470, removed E0577, E0578, + E0740, } From 208af201ec8a2fc563d58005b1609e02fce9ab5e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 14 Oct 2019 14:06:54 +0200 Subject: [PATCH 22/26] Add long error explanation for E0740 --- src/librustc_resolve/error_codes.rs | 39 ++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/librustc_resolve/error_codes.rs b/src/librustc_resolve/error_codes.rs index b76373703d1ea..32e5eb50a76da 100644 --- a/src/librustc_resolve/error_codes.rs +++ b/src/librustc_resolve/error_codes.rs @@ -1933,6 +1933,44 @@ struct Foo> { ``` "##, +E0741: r##" +Visibility is restricted to a module which isn't an ancestor of the current +item. + +Erroneous code example: + +```compile_fail,E0741,edition2018 +pub mod Sea {} + +pub (in crate::Sea) struct Shark; // error! + +fn main() {} +``` + +To fix this error, we need to move the `Shark` struct inside the `Sea` module: + +```edition2018 +pub mod Sea { + pub (in crate::Sea) struct Shark; // ok! +} + +fn main() {} +``` + +Of course, you can do it as long as the module you're referring to is an +ancestor: + +```edition2018 +pub mod Earth { + pub mod Sea { + pub (in crate::Earth) struct Shark; // ok! + } +} + +fn main() {} +``` +"##, + ; // E0153, unused error code // E0157, unused error code @@ -1953,5 +1991,4 @@ struct Foo> { // E0470, removed E0577, E0578, - E0740, } From 6c7fe5a94ee1c6c22ec6c2c6e986ea68f8b3e7f6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 14 Oct 2019 14:07:05 +0200 Subject: [PATCH 23/26] Update ui tests --- src/test/ui/privacy/restricted/relative-2018.stderr | 3 ++- src/test/ui/privacy/restricted/test.stderr | 4 ++-- src/test/ui/proc-macro/issue-50493.stderr | 5 +++-- src/test/ui/pub/pub-restricted.stderr | 5 +++-- src/test/ui/resolve/resolve-bad-visibility.stderr | 5 +++-- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/test/ui/privacy/restricted/relative-2018.stderr b/src/test/ui/privacy/restricted/relative-2018.stderr index 61effc463e98f..2205d6e518cf3 100644 --- a/src/test/ui/privacy/restricted/relative-2018.stderr +++ b/src/test/ui/privacy/restricted/relative-2018.stderr @@ -1,4 +1,4 @@ -error: visibilities can only be restricted to ancestor modules +error[E0741]: visibilities can only be restricted to ancestor modules --> $DIR/relative-2018.rs:7:12 | LL | pub(in ::core) struct S4; @@ -14,3 +14,4 @@ LL | pub(in a::b) struct S5; error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0741`. diff --git a/src/test/ui/privacy/restricted/test.stderr b/src/test/ui/privacy/restricted/test.stderr index a23973d0853f1..b39a42ef3ce3b 100644 --- a/src/test/ui/privacy/restricted/test.stderr +++ b/src/test/ui/privacy/restricted/test.stderr @@ -4,7 +4,7 @@ error[E0433]: failed to resolve: maybe a missing crate `bad`? LL | pub(in bad::path) mod m1 {} | ^^^ maybe a missing crate `bad`? -error: visibilities can only be restricted to ancestor modules +error[E0741]: visibilities can only be restricted to ancestor modules --> $DIR/test.rs:51:12 | LL | pub(in foo) mod m2 {} @@ -78,5 +78,5 @@ LL | u.h(); error: aborting due to 12 previous errors -Some errors have detailed explanations: E0364, E0433, E0603, E0616, E0624. +Some errors have detailed explanations: E0364, E0433, E0603, E0616, E0624, E0741. For more information about an error, try `rustc --explain E0364`. diff --git a/src/test/ui/proc-macro/issue-50493.stderr b/src/test/ui/proc-macro/issue-50493.stderr index 28c61a2f52fed..25035106f25c9 100644 --- a/src/test/ui/proc-macro/issue-50493.stderr +++ b/src/test/ui/proc-macro/issue-50493.stderr @@ -1,4 +1,4 @@ -error: visibilities can only be restricted to ancestor modules +error[E0741]: visibilities can only be restricted to ancestor modules --> $DIR/issue-50493.rs:8:12 | LL | pub(in restricted) field: usize, @@ -12,4 +12,5 @@ LL | #[derive(Derive)] error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0616`. +Some errors have detailed explanations: E0616, E0741. +For more information about an error, try `rustc --explain E0616`. diff --git a/src/test/ui/pub/pub-restricted.stderr b/src/test/ui/pub/pub-restricted.stderr index 596264ba16b42..3ec4e1143feba 100644 --- a/src/test/ui/pub/pub-restricted.stderr +++ b/src/test/ui/pub/pub-restricted.stderr @@ -53,7 +53,7 @@ LL | pub (xyz) fn xyz() {} `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path -error: visibilities can only be restricted to ancestor modules +error[E0741]: visibilities can only be restricted to ancestor modules --> $DIR/pub-restricted.rs:25:17 | LL | pub (in x) non_parent_invalid: usize, @@ -61,4 +61,5 @@ LL | pub (in x) non_parent_invalid: usize, error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0704`. +Some errors have detailed explanations: E0704, E0741. +For more information about an error, try `rustc --explain E0704`. diff --git a/src/test/ui/resolve/resolve-bad-visibility.stderr b/src/test/ui/resolve/resolve-bad-visibility.stderr index d2fb7c7a9e69d..b077bb81872a8 100644 --- a/src/test/ui/resolve/resolve-bad-visibility.stderr +++ b/src/test/ui/resolve/resolve-bad-visibility.stderr @@ -10,7 +10,7 @@ error[E0577]: expected module, found trait `Tr` LL | pub(in Tr) struct Z; | ^^ not a module -error: visibilities can only be restricted to ancestor modules +error[E0741]: visibilities can only be restricted to ancestor modules --> $DIR/resolve-bad-visibility.rs:6:8 | LL | pub(in std::vec) struct F; @@ -30,4 +30,5 @@ LL | pub(in too_soon) struct H; error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0433`. +Some errors have detailed explanations: E0433, E0741. +For more information about an error, try `rustc --explain E0433`. From 9869e5b969553699af4f50433170827d4e440e60 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 29 Oct 2019 13:59:22 +0100 Subject: [PATCH 24/26] Change E0741 into E0742 --- src/librustc_resolve/build_reduced_graph.rs | 2 +- src/librustc_resolve/error_codes.rs | 5 +++-- src/test/ui/privacy/restricted/relative-2018.stderr | 4 ++-- src/test/ui/privacy/restricted/test.stderr | 4 ++-- src/test/ui/proc-macro/issue-50493.stderr | 4 ++-- src/test/ui/pub/pub-restricted.stderr | 4 ++-- src/test/ui/resolve/resolve-bad-visibility.stderr | 4 ++-- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 3564aefba73ae..648c5104b1af7 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -256,7 +256,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { if self.r.is_accessible_from(vis, parent_scope.module) { vis } else { - struct_span_err!(self.r.session, path.span, E0741, + struct_span_err!(self.r.session, path.span, E0742, "visibilities can only be restricted to ancestor modules") .emit(); ty::Visibility::Public diff --git a/src/librustc_resolve/error_codes.rs b/src/librustc_resolve/error_codes.rs index 32e5eb50a76da..9937f27931fb7 100644 --- a/src/librustc_resolve/error_codes.rs +++ b/src/librustc_resolve/error_codes.rs @@ -1910,6 +1910,7 @@ E0671: r##" Const parameters cannot depend on type parameters. The following is therefore invalid: + ```compile_fail,E0741 #![feature(const_generics)] @@ -1933,13 +1934,13 @@ struct Foo> { ``` "##, -E0741: r##" +E0742: r##" Visibility is restricted to a module which isn't an ancestor of the current item. Erroneous code example: -```compile_fail,E0741,edition2018 +```compile_fail,E0742,edition2018 pub mod Sea {} pub (in crate::Sea) struct Shark; // error! diff --git a/src/test/ui/privacy/restricted/relative-2018.stderr b/src/test/ui/privacy/restricted/relative-2018.stderr index 2205d6e518cf3..54fee085ee943 100644 --- a/src/test/ui/privacy/restricted/relative-2018.stderr +++ b/src/test/ui/privacy/restricted/relative-2018.stderr @@ -1,4 +1,4 @@ -error[E0741]: visibilities can only be restricted to ancestor modules +error[E0742]: visibilities can only be restricted to ancestor modules --> $DIR/relative-2018.rs:7:12 | LL | pub(in ::core) struct S4; @@ -14,4 +14,4 @@ LL | pub(in a::b) struct S5; error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0741`. +For more information about this error, try `rustc --explain E0742`. diff --git a/src/test/ui/privacy/restricted/test.stderr b/src/test/ui/privacy/restricted/test.stderr index b39a42ef3ce3b..e6a61fbefb0d8 100644 --- a/src/test/ui/privacy/restricted/test.stderr +++ b/src/test/ui/privacy/restricted/test.stderr @@ -4,7 +4,7 @@ error[E0433]: failed to resolve: maybe a missing crate `bad`? LL | pub(in bad::path) mod m1 {} | ^^^ maybe a missing crate `bad`? -error[E0741]: visibilities can only be restricted to ancestor modules +error[E0742]: visibilities can only be restricted to ancestor modules --> $DIR/test.rs:51:12 | LL | pub(in foo) mod m2 {} @@ -78,5 +78,5 @@ LL | u.h(); error: aborting due to 12 previous errors -Some errors have detailed explanations: E0364, E0433, E0603, E0616, E0624, E0741. +Some errors have detailed explanations: E0364, E0433, E0603, E0616, E0624, E0742. For more information about an error, try `rustc --explain E0364`. diff --git a/src/test/ui/proc-macro/issue-50493.stderr b/src/test/ui/proc-macro/issue-50493.stderr index 25035106f25c9..6b8724457a6a3 100644 --- a/src/test/ui/proc-macro/issue-50493.stderr +++ b/src/test/ui/proc-macro/issue-50493.stderr @@ -1,4 +1,4 @@ -error[E0741]: visibilities can only be restricted to ancestor modules +error[E0742]: visibilities can only be restricted to ancestor modules --> $DIR/issue-50493.rs:8:12 | LL | pub(in restricted) field: usize, @@ -12,5 +12,5 @@ LL | #[derive(Derive)] error: aborting due to 2 previous errors -Some errors have detailed explanations: E0616, E0741. +Some errors have detailed explanations: E0616, E0742. For more information about an error, try `rustc --explain E0616`. diff --git a/src/test/ui/pub/pub-restricted.stderr b/src/test/ui/pub/pub-restricted.stderr index 3ec4e1143feba..56ff104b4fed9 100644 --- a/src/test/ui/pub/pub-restricted.stderr +++ b/src/test/ui/pub/pub-restricted.stderr @@ -53,7 +53,7 @@ LL | pub (xyz) fn xyz() {} `pub(super)`: visible only in the current module's parent `pub(in path::to::module)`: visible only on the specified path -error[E0741]: visibilities can only be restricted to ancestor modules +error[E0742]: visibilities can only be restricted to ancestor modules --> $DIR/pub-restricted.rs:25:17 | LL | pub (in x) non_parent_invalid: usize, @@ -61,5 +61,5 @@ LL | pub (in x) non_parent_invalid: usize, error: aborting due to 6 previous errors -Some errors have detailed explanations: E0704, E0741. +Some errors have detailed explanations: E0704, E0742. For more information about an error, try `rustc --explain E0704`. diff --git a/src/test/ui/resolve/resolve-bad-visibility.stderr b/src/test/ui/resolve/resolve-bad-visibility.stderr index b077bb81872a8..43af38cf491e3 100644 --- a/src/test/ui/resolve/resolve-bad-visibility.stderr +++ b/src/test/ui/resolve/resolve-bad-visibility.stderr @@ -10,7 +10,7 @@ error[E0577]: expected module, found trait `Tr` LL | pub(in Tr) struct Z; | ^^ not a module -error[E0741]: visibilities can only be restricted to ancestor modules +error[E0742]: visibilities can only be restricted to ancestor modules --> $DIR/resolve-bad-visibility.rs:6:8 | LL | pub(in std::vec) struct F; @@ -30,5 +30,5 @@ LL | pub(in too_soon) struct H; error: aborting due to 5 previous errors -Some errors have detailed explanations: E0433, E0741. +Some errors have detailed explanations: E0433, E0742. For more information about an error, try `rustc --explain E0433`. From bc98c86a8b966fdd83756309ddb0e5b53dfccf37 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Tue, 29 Oct 2019 13:01:54 +0000 Subject: [PATCH 25/26] doc: use new feature gate for c_void type --- src/libcore/ffi.rs | 7 ++++++- src/libstd/ffi/mod.rs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/libcore/ffi.rs b/src/libcore/ffi.rs index 0ea4187ccd482..569c667ac0a54 100644 --- a/src/libcore/ffi.rs +++ b/src/libcore/ffi.rs @@ -18,8 +18,13 @@ use crate::ops::{Deref, DerefMut}; /// stabilized, it is recommended to use a newtype wrapper around an empty /// byte array. See the [Nomicon] for details. /// +/// One could use `std::os::raw::c_void` if they want to support old Rust +/// compiler down to 1.1.0. After Rust 1.30.0, it was re-exported by +/// this definition. For more information, please read [RFC 2521]. +/// /// [pointer]: ../../std/primitive.pointer.html /// [Nomicon]: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs +/// [RFC 2521]: https://github.com/rust-lang/rfcs/blob/master/text/2521-c_void-reunification.md // N.B., for LLVM to recognize the void pointer type and by extension // functions like malloc(), we need to have it represented as i8* in // LLVM bitcode. The enum used here ensures this and prevents misuse @@ -29,7 +34,7 @@ use crate::ops::{Deref, DerefMut}; // would be uninhabited and at least dereferencing such pointers would // be UB. #[repr(u8)] -#[stable(feature = "raw_os", since = "1.1.0")] +#[stable(feature = "core_c_void", since = "1.30.0")] pub enum c_void { #[unstable(feature = "c_void_variant", reason = "temporary implementation detail", issue = "0")] diff --git a/src/libstd/ffi/mod.rs b/src/libstd/ffi/mod.rs index 69fcfa8b39ca5..28d9906eb93b5 100644 --- a/src/libstd/ffi/mod.rs +++ b/src/libstd/ffi/mod.rs @@ -163,7 +163,7 @@ pub use self::c_str::{FromBytesWithNulError}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::os_str::{OsString, OsStr}; -#[stable(feature = "raw_os", since = "1.1.0")] +#[stable(feature = "core_c_void", since = "1.30.0")] pub use core::ffi::c_void; #[unstable(feature = "c_variadic", From e755963cbdbdfb97994eb861360f1aa0de1888c2 Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Tue, 29 Oct 2019 16:19:16 +0100 Subject: [PATCH 26/26] save-analysis: Account for async desugaring in async fn return types --- src/librustc_save_analysis/dump_visitor.rs | 27 ++++++++++++++++++---- src/test/ui/save-analysis/issue-65590.rs | 21 +++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/save-analysis/issue-65590.rs diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index e282936b5d9e7..a372106d3795b 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -300,7 +300,16 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { } if let ast::FunctionRetTy::Ty(ref ret_ty) = sig.decl.output { - v.visit_ty(ret_ty); + // In async functions, return types are desugared and redefined + // as an `impl Trait` existential type. Because of this, to match + // the definition paths when resolving nested types we need to + // start walking from the newly-created definition. + match sig.header.asyncness.node { + ast::IsAsync::Async { return_impl_trait_id, .. } => { + v.nest_tables(return_impl_trait_id, |v| v.visit_ty(ret_ty)) + } + _ => v.visit_ty(ret_ty) + } } // walk the fn body @@ -369,6 +378,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { &mut self, item: &'l ast::Item, decl: &'l ast::FnDecl, + header: &'l ast::FnHeader, ty_params: &'l ast::Generics, body: &'l ast::Block, ) { @@ -391,7 +401,16 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> { // FIXME: Opaque type desugaring prevents us from easily // processing trait bounds. See `visit_ty` for more details. } else { - v.visit_ty(&ret_ty); + // In async functions, return types are desugared and redefined + // as an `impl Trait` existential type. Because of this, to match + // the definition paths when resolving nested types we need to + // start walking from the newly-created definition. + match header.asyncness.node { + ast::IsAsync::Async { return_impl_trait_id, .. } => { + v.nest_tables(return_impl_trait_id, |v| v.visit_ty(ret_ty)) + } + _ => v.visit_ty(ret_ty) + } } } @@ -1315,8 +1334,8 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> { ); } } - Fn(ref decl, .., ref ty_params, ref body) => { - self.process_fn(item, &decl, ty_params, &body) + Fn(ref decl, ref header, ref ty_params, ref body) => { + self.process_fn(item, &decl, &header, ty_params, &body) } Static(ref typ, _, ref expr) => self.process_static_or_const_item(item, typ, expr), Const(ref typ, ref expr) => self.process_static_or_const_item(item, &typ, &expr), diff --git a/src/test/ui/save-analysis/issue-65590.rs b/src/test/ui/save-analysis/issue-65590.rs new file mode 100644 index 0000000000000..27874f8655e56 --- /dev/null +++ b/src/test/ui/save-analysis/issue-65590.rs @@ -0,0 +1,21 @@ +// check-pass +// compile-flags: -Zsave-analysis +// edition:2018 + +// Async desugaring for return types in (associated) functions introduces a +// separate definition internally, which we need to take into account +// (or else we ICE). +trait Trait { type Assoc; } +struct Struct; + +async fn foobar() -> T::Assoc { + unimplemented!() +} + +impl Struct { + async fn foo(&self) -> T::Assoc { + unimplemented!() + } +} + +fn main() {}