From 4cd8cae1fdbacd3b51e38277d371e5ca4a082e7b Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 16 Feb 2021 19:17:01 -0800 Subject: [PATCH 1/9] rustdoc: treat edition 2021 as unstable (cherry picked from commit ee0e841a2e949cba1dcf3a2fb04e9a673681e4fd) --- compiler/rustc_session/src/config.rs | 2 +- src/librustdoc/config.rs | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 9d73c3b4424cb..a6d4dcb34c1a8 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1290,7 +1290,7 @@ pub fn parse_error_format( error_format } -fn parse_crate_edition(matches: &getopts::Matches) -> Edition { +pub fn parse_crate_edition(matches: &getopts::Matches) -> Edition { let edition = match matches.opt_str("edition") { Some(arg) => Edition::from_str(&arg).unwrap_or_else(|_| { early_error( diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 63a25e5dbfbbb..1478437cefaa3 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -16,7 +16,7 @@ use rustc_session::config::{CodegenOptions, DebuggingOptions, ErrorOutputType, E use rustc_session::getopts; use rustc_session::lint::Level; use rustc_session::search_paths::SearchPath; -use rustc_span::edition::{Edition, DEFAULT_EDITION}; +use rustc_span::edition::Edition; use rustc_target::spec::TargetTriple; use crate::core::new_handler; @@ -469,17 +469,7 @@ impl Options { } } - let edition = if let Some(e) = matches.opt_str("edition") { - match e.parse() { - Ok(e) => e, - Err(_) => { - diag.struct_err("could not parse edition").emit(); - return Err(1); - } - } - } else { - DEFAULT_EDITION - }; + let edition = config::parse_crate_edition(&matches); let mut id_map = html::markdown::IdMap::new(); id_map.populate(&html::render::INITIAL_IDS); From c10902e6197cbd8530a0ec7c0cd526663164bb43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Sinan=20A=C4=9Facan?= Date: Thu, 18 Feb 2021 17:53:09 +0300 Subject: [PATCH 2/9] Fix popping singleton paths in when generating E0433 Fixes #82156 (cherry picked from commit 9889e44470cbc6ae3c8e2fcfb6016ed15ed8cf51) --- compiler/rustc_resolve/src/late.rs | 11 +++++------ src/test/ui/resolve/issue-82156.rs | 3 +++ src/test/ui/resolve/issue-82156.stderr | 9 +++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/resolve/issue-82156.rs create mode 100644 src/test/ui/resolve/issue-82156.stderr diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index 9b5b793363b5b..e5d6aebe97a0d 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -1801,7 +1801,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { crate_lint: CrateLint, ) -> PartialRes { tracing::debug!( - "smart_resolve_path_fragment(id={:?},qself={:?},path={:?}", + "smart_resolve_path_fragment(id={:?}, qself={:?}, path={:?})", id, qself, path @@ -1841,11 +1841,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { // Before we start looking for candidates, we have to get our hands // on the type user is trying to perform invocation on; basically: - // we're transforming `HashMap::new` into just `HashMap` - let path = if let Some((_, path)) = path.split_last() { - path - } else { - return Some(parent_err); + // we're transforming `HashMap::new` into just `HashMap`. + let path = match path.split_last() { + Some((_, path)) if !path.is_empty() => path, + _ => return Some(parent_err), }; let (mut err, candidates) = diff --git a/src/test/ui/resolve/issue-82156.rs b/src/test/ui/resolve/issue-82156.rs new file mode 100644 index 0000000000000..6215259e48657 --- /dev/null +++ b/src/test/ui/resolve/issue-82156.rs @@ -0,0 +1,3 @@ +fn main() { + super(); //~ ERROR failed to resolve: there are too many leading `super` keywords +} diff --git a/src/test/ui/resolve/issue-82156.stderr b/src/test/ui/resolve/issue-82156.stderr new file mode 100644 index 0000000000000..d53599dcce61b --- /dev/null +++ b/src/test/ui/resolve/issue-82156.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve: there are too many leading `super` keywords + --> $DIR/issue-82156.rs:2:5 + | +LL | super(); + | ^^^^^ there are too many leading `super` keywords + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. From 03fe394e93883f71b1acc4a2ea418f1fa7ac8a64 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 18 Feb 2021 12:41:08 -0800 Subject: [PATCH 3/9] libtest: Fix unwrap panic on duplicate TestDesc. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is possible for different tests to collide to the same TestDesc when macros are involved. That is a bug, but it didn’t cause a panic until #81367. For now, change the code to ignore this problem. Fixes #81852. Signed-off-by: Anders Kaseorg (cherry picked from commit 1605af015c493c4800be9b56d7eb8d759f9a7d3c) --- library/test/src/lib.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index 3ff79eaea49ab..2d37fdd135eee 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -353,12 +353,13 @@ where } let mut completed_test = res.unwrap(); - let running_test = running_tests.remove(&completed_test.desc).unwrap(); - if let Some(join_handle) = running_test.join_handle { - if let Err(_) = join_handle.join() { - if let TrOk = completed_test.result { - completed_test.result = - TrFailedMsg("panicked after reporting success".to_string()); + if let Some(running_test) = running_tests.remove(&completed_test.desc) { + if let Some(join_handle) = running_test.join_handle { + if let Err(_) = join_handle.join() { + if let TrOk = completed_test.result { + completed_test.result = + TrFailedMsg("panicked after reporting success".to_string()); + } } } } From 93586af7a5ecaa9323030974be61cb9c80af5e34 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Fri, 19 Feb 2021 10:18:10 -0500 Subject: [PATCH 4/9] [intra-doc links] Don't check feature gates of items re-exported across crates It should be never break another crate to re-export a public item. Note that this doesn't check the feature gate at *all* for other crates: - Feature-gates aren't currently serialized, so the only way to check the gate is with ad-hoc attribute checking. - Checking the feature gate twice (once when documenting the original crate and one when documenting the current crate) seems not great. This should still catch using the feature most of the time though, since people tend to document their own crates. (cherry picked from commit fdb32e997bef725f538f66dcfd96b1c1e51d2c56) --- src/librustdoc/passes/collect_intra_doc_links.rs | 3 +++ .../intra-doc/auxiliary/pointer-reexports-allowed.rs | 4 ++++ src/test/rustdoc-ui/intra-doc/pointer-reexports-allowed.rs | 4 ++++ 3 files changed, 11 insertions(+) create mode 100644 src/test/rustdoc-ui/intra-doc/auxiliary/pointer-reexports-allowed.rs create mode 100644 src/test/rustdoc-ui/intra-doc/pointer-reexports-allowed.rs diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 532a0cf932904..f0c254ede650a 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1206,7 +1206,10 @@ impl LinkCollector<'_, '_> { // for discussion on the matter. verify(kind, id)?; + // FIXME: it would be nice to check that the feature gate was enabled in the original crate, not just ignore it altogether. + // However I'm not sure how to check that across crates. if prim == PrimitiveType::RawPointer + && item.def_id.is_local() && !self.cx.tcx.features().intra_doc_pointers { let span = super::source_span_for_markdown_range( diff --git a/src/test/rustdoc-ui/intra-doc/auxiliary/pointer-reexports-allowed.rs b/src/test/rustdoc-ui/intra-doc/auxiliary/pointer-reexports-allowed.rs new file mode 100644 index 0000000000000..0a3dc57f10241 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/auxiliary/pointer-reexports-allowed.rs @@ -0,0 +1,4 @@ +#![feature(intra_doc_pointers)] +#![crate_name = "inner"] +/// Link to [some pointer](*const::to_raw_parts) +pub fn foo() {} diff --git a/src/test/rustdoc-ui/intra-doc/pointer-reexports-allowed.rs b/src/test/rustdoc-ui/intra-doc/pointer-reexports-allowed.rs new file mode 100644 index 0000000000000..8654a8e1bd2b4 --- /dev/null +++ b/src/test/rustdoc-ui/intra-doc/pointer-reexports-allowed.rs @@ -0,0 +1,4 @@ +// aux-build:pointer-reexports-allowed.rs +// check-pass +extern crate inner; +pub use inner::foo; From 0e214cab6654a09b88545768476604fa7906df80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Wed, 24 Feb 2021 17:44:37 +0100 Subject: [PATCH 5/9] Remove duplicate string (cherry picked from commit 3be69b100f6678c42eff36e18505c2ba9419647a) --- src/librustdoc/html/render/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 6909ab870db61..b38fb09a1c589 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -1344,7 +1344,6 @@ impl AllTypes { \ - List of all items\ ", ); // Note: print_entries does not escape the title, because we know the current set of titles From 3ad36d242a868855b8b66ac404e387d5787e4680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Wed, 24 Feb 2021 18:14:31 +0100 Subject: [PATCH 6/9] Add test (cherry picked from commit d3f75ebf609eed01b39fb7528745f2fce88e33e6) --- src/librustdoc/html/render/tests.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/librustdoc/html/render/tests.rs b/src/librustdoc/html/render/tests.rs index abf5f05fe58ab..224c794fb3b4a 100644 --- a/src/librustdoc/html/render/tests.rs +++ b/src/librustdoc/html/render/tests.rs @@ -38,3 +38,14 @@ fn test_name_sorting() { sorted.sort_by(|&l, r| compare_names(l, r)); assert_eq!(names, sorted); } + +#[test] +fn test_all_types_prints_header_once() { + // Regression test for #82477 + let all_types = AllTypes::new(); + + let mut buffer = Buffer::new(); + all_types.print(&mut buffer); + + assert_eq!(1, buffer.into_inner().matches("List of all items").count()); +} From 3fee12f83f5caa16dc98fb8df0427b64cb245608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 24 Feb 2021 12:21:18 -0800 Subject: [PATCH 7/9] Substitute erased lifetimes on bad placeholder type Fix #82455. (cherry picked from commit 5ad60888275852136adea38aebc7fcce69b52474) --- compiler/rustc_typeck/src/collect.rs | 12 ++++++++++ .../ui/typeck/typeck_type_placeholder_item.rs | 12 ++++++++++ .../typeck_type_placeholder_item.stderr | 22 +++++++++++++++++-- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index b1d98d75196d5..c6cc54d71211a 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -331,6 +331,11 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> { span: Span, ) -> &'tcx Const<'tcx> { bad_placeholder_type(self.tcx(), vec![span]).emit(); + // Typeck doesn't expect erased regions to be returned from `type_of`. + let ty = self.tcx.fold_regions(ty, &mut false, |r, _| match r { + ty::ReErased => self.tcx.lifetimes.re_static, + _ => r, + }); self.tcx().const_error(ty) } @@ -1536,6 +1541,12 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { match get_infer_ret_ty(&sig.decl.output) { Some(ty) => { let fn_sig = tcx.typeck(def_id).liberated_fn_sigs()[hir_id]; + // Typeck doesn't expect erased regions to be returned from `type_of`. + let fn_sig = tcx.fold_regions(fn_sig, &mut false, |r, _| match r { + ty::ReErased => tcx.lifetimes.re_static, + _ => r, + }); + let mut visitor = PlaceholderHirTyCollector::default(); visitor.visit_ty(ty); let mut diag = bad_placeholder_type(tcx, visitor.0); @@ -1564,6 +1575,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { } } diag.emit(); + ty::Binder::bind(fn_sig) } None => AstConv::ty_of_fn( diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.rs b/src/test/ui/typeck/typeck_type_placeholder_item.rs index 2c8b1e76b1b82..2523362fdc4b6 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item.rs +++ b/src/test/ui/typeck/typeck_type_placeholder_item.rs @@ -208,3 +208,15 @@ impl Qux for Struct { const D: _ = 42; //~^ ERROR the type placeholder `_` is not allowed within types on item signatures } + +fn map(_: fn() -> Option<&'static T>) -> Option { + None +} + +fn value() -> Option<&'static _> { +//~^ ERROR the type placeholder `_` is not allowed within types on item signatures + Option::<&'static u8>::None +} + +const _: Option<_> = map(value); +//~^ ERROR the type placeholder `_` is not allowed within types on item signatures diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.stderr b/src/test/ui/typeck/typeck_type_placeholder_item.stderr index 684f451b7c3f6..1034402bfb08d 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item.stderr +++ b/src/test/ui/typeck/typeck_type_placeholder_item.stderr @@ -158,7 +158,7 @@ LL | fn test11(x: &usize) -> &_ { | -^ | || | |not allowed in type signatures - | help: replace with the correct return type: `&&usize` + | help: replace with the correct return type: `&'static &'static usize` error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:52:52 @@ -410,6 +410,24 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa LL | type Y = impl Trait<_>; | ^ not allowed in type signatures +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item.rs:216:31 + | +LL | fn value() -> Option<&'static _> { + | ----------------^- + | | | + | | not allowed in type signatures + | help: replace with the correct return type: `Option<&'static u8>` + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item.rs:221:10 + | +LL | const _: Option<_> = map(value); + | ^^^^^^^^^ + | | + | not allowed in type signatures + | help: replace `_` with the correct type: `Option` + error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:140:31 | @@ -614,7 +632,7 @@ LL | const D: _ = 42; | not allowed in type signatures | help: replace `_` with the correct type: `i32` -error: aborting due to 67 previous errors +error: aborting due to 69 previous errors Some errors have detailed explanations: E0121, E0282, E0403. For more information about an error, try `rustc --explain E0121`. From 5317d2fc77ce6ec70bf8e6d922b52d550e6850ff Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Sat, 27 Feb 2021 11:09:00 -0800 Subject: [PATCH 8/9] Revert LLVM D81803 because it broke Windows 7 This submodule update reverts . While that change is meant to fix a real bug, [LLVM PR42623], it caused new permission errors on Windows 7 that make it unable to build any archives. This is probably the same root cause as [LLVM PR48378]. Fixes #81051. We'll file a new Rust issue to track the LLVM resolution. [LLVM PR42623]: https://bugs.llvm.org/show_bug.cgi?id=42623 [LLVM PR48378]: https://bugs.llvm.org/show_bug.cgi?id=48378 (cherry picked from commit 31814c41aa8df26450bb3aa2dac0883d95394bca) --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 70d09f218d1c8..96ae8953e4938 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 70d09f218d1c84fedabdb74881e214dacd5b0c3d +Subproject commit 96ae8953e4938d39c4173dd189f268459fff8c02 From ee7176150cc1ae95c9f3f150a9615123090cbfa1 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 10 Mar 2021 15:55:14 -0800 Subject: [PATCH 9/9] Fix s390x stack-split args --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 96ae8953e4938..c6f9d6db7b0c4 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 96ae8953e4938d39c4173dd189f268459fff8c02 +Subproject commit c6f9d6db7b0c4677d1aae8977505fe6340a3aae2