From da18df285910446d5b4c212b96379e694f47533f Mon Sep 17 00:00:00 2001 From: Trevor Spiteri Date: Sun, 3 May 2020 15:17:45 +0200 Subject: [PATCH 01/10] doc: make impl block collapsible if it has an associated constant Fixes #71822. --- src/librustdoc/html/static/main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 22c9426db2036..5b8c4890e8374 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2366,7 +2366,9 @@ function defocusSearchBar() { if (!next) { return; } - if (next.getElementsByClassName("method").length > 0 && hasClass(e, "impl")) { + if (hasClass(e, "impl") && + (next.getElementsByClassName("method").length > 0 || + next.getElementsByClassName("associatedconstant").length > 0)) { insertAfter(toggle.cloneNode(true), e.childNodes[e.childNodes.length - 1]); } }; From e508db28405dddbee45c6727b0d59586b522fe80 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Fri, 5 Jun 2020 03:05:12 +0200 Subject: [PATCH 02/10] Update RELEASES.md make catch_unwind line more readable --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 8d6535b20c2eb..ef28679a438bf 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -25,7 +25,7 @@ Compiler -------- - [Rustc now respects the `-C codegen-units` flag in incremental mode.][70156] Additionally when in incremental mode rustc defaults to 256 codegen units. -- [Refactored `catch_unwind`, to have zero-cost unless unwinding is enabled and +- [Refactored `catch_unwind` to have zero-cost, unless unwinding is enabled AND a panic is thrown.][67502] - [Added tier 3\* support for the `aarch64-unknown-none` and `aarch64-unknown-none-softfloat` targets.][68334] From 9d6ed2960c302e87f7b01c75efb59fc0353da05a Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Fri, 5 Jun 2020 03:41:21 +0200 Subject: [PATCH 03/10] address review comment --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index ef28679a438bf..46641e825620e 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -25,7 +25,7 @@ Compiler -------- - [Rustc now respects the `-C codegen-units` flag in incremental mode.][70156] Additionally when in incremental mode rustc defaults to 256 codegen units. -- [Refactored `catch_unwind` to have zero-cost, unless unwinding is enabled AND +- [Refactored `catch_unwind` to have zero-cost, unless unwinding is enabled and a panic is thrown.][67502] - [Added tier 3\* support for the `aarch64-unknown-none` and `aarch64-unknown-none-softfloat` targets.][68334] From e8fb46090e938d52f2637c973e1e13886289ee3d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 2 Jun 2020 14:13:03 +0200 Subject: [PATCH 04/10] Create new error code E0758 for unterminated multi-line comments --- src/librustc_error_codes/error_codes.rs | 1 + src/librustc_error_codes/error_codes/E0758.md | 20 +++++++++++++++++++ src/librustc_parse/lexer/mod.rs | 10 +++++++++- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 src/librustc_error_codes/error_codes/E0758.md diff --git a/src/librustc_error_codes/error_codes.rs b/src/librustc_error_codes/error_codes.rs index 7abe75a375a0b..760b4d7ba00a3 100644 --- a/src/librustc_error_codes/error_codes.rs +++ b/src/librustc_error_codes/error_codes.rs @@ -437,6 +437,7 @@ E0751: include_str!("./error_codes/E0751.md"), E0752: include_str!("./error_codes/E0752.md"), E0753: include_str!("./error_codes/E0753.md"), E0754: include_str!("./error_codes/E0754.md"), +E0758: include_str!("./error_codes/E0758.md"), E0760: include_str!("./error_codes/E0760.md"), ; // E0006, // merged with E0005 diff --git a/src/librustc_error_codes/error_codes/E0758.md b/src/librustc_error_codes/error_codes/E0758.md new file mode 100644 index 0000000000000..ddca4b3d75f77 --- /dev/null +++ b/src/librustc_error_codes/error_codes/E0758.md @@ -0,0 +1,20 @@ +A multi-line (doc-)comment is unterminated. + +Erroneous code example: + +```compile_fail,E0758 +/* I am not terminated! +``` + +The same goes for doc comments: + +```compile_fail,E0758 +/*! I am not terminated! +``` + +You need to end your multi-line comment with `*/` in order to fix this error: + +``` +/* I am terminated! */ +/*! I am also terminated! */ +``` diff --git a/src/librustc_parse/lexer/mod.rs b/src/librustc_parse/lexer/mod.rs index 7e59f06e44ae3..9bc6a50acad04 100644 --- a/src/librustc_parse/lexer/mod.rs +++ b/src/librustc_parse/lexer/mod.rs @@ -191,7 +191,15 @@ impl<'a> StringReader<'a> { "unterminated block comment" }; let last_bpos = self.pos; - self.fatal_span_(start, last_bpos, msg).raise(); + self.sess + .span_diagnostic + .struct_span_fatal_with_code( + self.mk_sp(start, last_bpos), + msg, + error_code!(E0758), + ) + .emit(); + FatalError.raise(); } if is_doc_comment { From fbf7d27791c524c60637ff2b7e738494e6dfaef5 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 2 Jun 2020 14:16:46 +0200 Subject: [PATCH 05/10] Add tests for E0758 --- src/test/ui/unterminated-comment.rs | 1 + src/test/ui/unterminated-comment.stderr | 9 +++++++++ src/test/ui/unterminated-doc-comment.rs | 1 + src/test/ui/unterminated-doc-comment.stderr | 9 +++++++++ 4 files changed, 20 insertions(+) create mode 100644 src/test/ui/unterminated-comment.rs create mode 100644 src/test/ui/unterminated-comment.stderr create mode 100644 src/test/ui/unterminated-doc-comment.rs create mode 100644 src/test/ui/unterminated-doc-comment.stderr diff --git a/src/test/ui/unterminated-comment.rs b/src/test/ui/unterminated-comment.rs new file mode 100644 index 0000000000000..1cfdfb1fb4575 --- /dev/null +++ b/src/test/ui/unterminated-comment.rs @@ -0,0 +1 @@ +/* //~ ERROR E0758 diff --git a/src/test/ui/unterminated-comment.stderr b/src/test/ui/unterminated-comment.stderr new file mode 100644 index 0000000000000..c513fafeeb35c --- /dev/null +++ b/src/test/ui/unterminated-comment.stderr @@ -0,0 +1,9 @@ +error[E0758]: unterminated block comment + --> $DIR/unterminated-comment.rs:1:1 + | +LL | /* + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0758`. diff --git a/src/test/ui/unterminated-doc-comment.rs b/src/test/ui/unterminated-doc-comment.rs new file mode 100644 index 0000000000000..82546fe73da4f --- /dev/null +++ b/src/test/ui/unterminated-doc-comment.rs @@ -0,0 +1 @@ +/*! //~ ERROR E0758 diff --git a/src/test/ui/unterminated-doc-comment.stderr b/src/test/ui/unterminated-doc-comment.stderr new file mode 100644 index 0000000000000..2d5e537973ea8 --- /dev/null +++ b/src/test/ui/unterminated-doc-comment.stderr @@ -0,0 +1,9 @@ +error[E0758]: unterminated block doc-comment + --> $DIR/unterminated-doc-comment.rs:1:1 + | +LL | /*! + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0758`. From e75922246152e3d9a353e41a643025fc7ffb0f67 Mon Sep 17 00:00:00 2001 From: marmeladema Date: Sun, 7 Jun 2020 11:14:47 +0100 Subject: [PATCH 06/10] Use `LocalDefId` directly in `Resolver::export_map` and `module_exports` query This is to avoid the final conversion from `NodeId` to `HirId` during call to `Resolver::(clone|into)_outputs`. --- src/librustc_metadata/rmeta/encoder.rs | 13 ++++++++++-- src/librustc_middle/hir/exports.rs | 5 +++-- src/librustc_middle/query/mod.rs | 4 ++-- src/librustc_middle/ty/context.rs | 4 ++-- src/librustc_middle/ty/mod.rs | 2 +- src/librustc_resolve/imports.rs | 8 +++++--- src/librustc_resolve/lib.rs | 28 +++----------------------- 7 files changed, 27 insertions(+), 37 deletions(-) diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index 9964c9c94c951..64ccd46a744f5 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -693,16 +693,25 @@ impl EncodeContext<'tcx> { vis: &hir::Visibility<'_>, ) { let tcx = self.tcx; - let def_id = tcx.hir().local_def_id(id).to_def_id(); + let def_id = tcx.hir().local_def_id(id); debug!("EncodeContext::encode_info_for_mod({:?})", def_id); let data = ModData { reexports: match tcx.module_exports(def_id) { - Some(exports) => self.lazy(exports), + Some(exports) => { + let hir_map = self.tcx.hir(); + self.lazy( + exports + .iter() + .map(|export| export.map_id(|id| hir_map.as_local_hir_id(id))), + ) + } _ => Lazy::empty(), }, }; + let def_id = def_id.to_def_id(); + record!(self.tables.kind[def_id] <- EntryKind::Mod(self.lazy(data))); record!(self.tables.visibility[def_id] <- ty::Visibility::from_hir(vis, id, self.tcx)); record!(self.tables.span[def_id] <- self.tcx.def_span(def_id)); diff --git a/src/librustc_middle/hir/exports.rs b/src/librustc_middle/hir/exports.rs index 83baf6cc43345..af48c9e94ff82 100644 --- a/src/librustc_middle/hir/exports.rs +++ b/src/librustc_middle/hir/exports.rs @@ -1,7 +1,8 @@ use crate::ty; +use rustc_data_structures::fx::FxHashMap; use rustc_hir::def::Res; -use rustc_hir::def_id::DefIdMap; +use rustc_hir::def_id::LocalDefId; use rustc_macros::HashStable; use rustc_span::symbol::Ident; use rustc_span::Span; @@ -10,7 +11,7 @@ use std::fmt::Debug; /// This is the replacement export map. It maps a module to all of the exports /// within. -pub type ExportMap = DefIdMap>>; +pub type ExportMap = FxHashMap>>; #[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable, HashStable)] pub struct Export { diff --git a/src/librustc_middle/query/mod.rs b/src/librustc_middle/query/mod.rs index 5a3ab205fc238..16ed9aff8f2a6 100644 --- a/src/librustc_middle/query/mod.rs +++ b/src/librustc_middle/query/mod.rs @@ -865,8 +865,8 @@ rustc_queries! { } Other { - query module_exports(def_id: DefId) -> Option<&'tcx [Export]> { - desc { |tcx| "looking up items exported by `{}`", tcx.def_path_str(def_id) } + query module_exports(def_id: LocalDefId) -> Option<&'tcx [Export]> { + desc { |tcx| "looking up items exported by `{}`", tcx.def_path_str(def_id.to_def_id()) } eval_always } } diff --git a/src/librustc_middle/ty/context.rs b/src/librustc_middle/ty/context.rs index 089a1613e7d3b..d5be3508d2d80 100644 --- a/src/librustc_middle/ty/context.rs +++ b/src/librustc_middle/ty/context.rs @@ -2,7 +2,7 @@ use crate::arena::Arena; use crate::dep_graph::{self, DepConstructor, DepGraph}; -use crate::hir::exports::Export; +use crate::hir::exports::ExportMap; use crate::ich::{NodeIdHashingMode, StableHashingContext}; use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos}; use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintSource}; @@ -919,7 +919,7 @@ pub struct GlobalCtxt<'tcx> { trait_map: FxHashMap>>, /// Export map produced by name resolution. - export_map: FxHashMap>>, + export_map: ExportMap, pub(crate) untracked_crate: &'tcx hir::Crate<'tcx>, pub(crate) definitions: &'tcx Definitions, diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 00c00a63b6b5d..ffbe3a40297c1 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -124,7 +124,7 @@ pub struct ResolverOutputs { pub trait_map: FxHashMap>>, pub maybe_unused_trait_imports: FxHashSet, pub maybe_unused_extern_crates: Vec<(LocalDefId, Span)>, - pub export_map: ExportMap, + pub export_map: ExportMap, pub glob_map: FxHashMap>, /// Extern prelude entries. The value is `true` if the entry was introduced /// via `extern crate` item and not `--extern` option or compiler built-in. diff --git a/src/librustc_resolve/imports.rs b/src/librustc_resolve/imports.rs index a1e05d21b58d5..74a8b7e2f556d 100644 --- a/src/librustc_resolve/imports.rs +++ b/src/librustc_resolve/imports.rs @@ -1393,8 +1393,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> { let is_good_import = binding.is_import() && !binding.is_ambiguity() && !ident.span.from_expansion(); if is_good_import || binding.is_macro_def() { - let res = binding.res(); - if res != Res::Err { + let res = binding.res().map_id(|id| this.definitions.local_def_id(id)); + if res != def::Res::Err { reexports.push(Export { ident, res, span: binding.span, vis: binding.vis }); } } @@ -1467,7 +1467,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> { if !reexports.is_empty() { if let Some(def_id) = module.def_id() { - self.r.export_map.insert(def_id, reexports); + // Call to `expect_local` should be fine because current + // code is only called for local modules. + self.r.export_map.insert(def_id.expect_local(), reexports); } } } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 00a5d08d6a955..6bd73877fab75 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -878,7 +878,7 @@ pub struct Resolver<'a> { /// `CrateNum` resolutions of `extern crate` items. extern_crate_map: FxHashMap, - export_map: ExportMap, + export_map: ExportMap, trait_map: TraitMap, /// A map from nodes to anonymous modules. @@ -1281,18 +1281,7 @@ impl<'a> Resolver<'a> { pub fn into_outputs(self) -> ResolverOutputs { let definitions = self.definitions; let extern_crate_map = self.extern_crate_map; - let export_map = self - .export_map - .into_iter() - .map(|(k, v)| { - ( - k, - v.into_iter() - .map(|e| e.map_id(|id| definitions.node_id_to_hir_id(id))) - .collect(), - ) - }) - .collect(); + let export_map = self.export_map; let trait_map = self .trait_map .into_iter() @@ -1330,18 +1319,7 @@ impl<'a> Resolver<'a> { definitions: self.definitions.clone(), cstore: Box::new(self.cstore().clone()), extern_crate_map: self.extern_crate_map.clone(), - export_map: self - .export_map - .iter() - .map(|(&k, v)| { - ( - k, - v.iter() - .map(|e| e.map_id(|id| self.definitions.node_id_to_hir_id(id))) - .collect(), - ) - }) - .collect(), + export_map: self.export_map.clone(), trait_map: self .trait_map .iter() From 7b0906b2e96fee11544c55ee56228bab782f1401 Mon Sep 17 00:00:00 2001 From: alamb Date: Mon, 8 Jun 2020 06:04:34 -0400 Subject: [PATCH 07/10] Fix small typo in docs for std::mem::drop --- src/libcore/mem/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/mem/mod.rs b/src/libcore/mem/mod.rs index 010f2958e36b9..d1f5cb44913db 100644 --- a/src/libcore/mem/mod.rs +++ b/src/libcore/mem/mod.rs @@ -808,7 +808,7 @@ pub fn replace(dest: &mut T, mut src: T) -> T { /// Disposes of a value. /// -/// This does call the argument's implementation of [`Drop`][drop]. +/// This does so by calling the argument's implementation of [`Drop`][drop]. /// /// This effectively does nothing for types which implement `Copy`, e.g. /// integers. Such values are copied and _then_ moved into the function, so the From b7f25d512ca96b70f0476eaef3824b467dede3ad Mon Sep 17 00:00:00 2001 From: Ayush Kumar Mishra Date: Mon, 8 Jun 2020 17:15:48 +0530 Subject: [PATCH 08/10] Removed lifetime parameters from Explanation of E0207 #62144 --- src/librustc_error_codes/error_codes/E0207.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0207.md b/src/librustc_error_codes/error_codes/E0207.md index 21e7e461c753b..cb4f5d5157d9b 100644 --- a/src/librustc_error_codes/error_codes/E0207.md +++ b/src/librustc_error_codes/error_codes/E0207.md @@ -1,4 +1,4 @@ -A type or lifetime parameter that is specified for `impl` is not constrained. +A type parameter that is specified for `impl` is not constrained. Erroneous code example: @@ -14,7 +14,7 @@ impl Foo { } ``` -Any type parameter or lifetime parameter of an `impl` must meet at least one of +Any type parameter parameter of an `impl` must meet at least one of the following criteria: - it appears in the _implementing type_ of the impl, e.g. `impl Foo` From 8cf85bc0dcabcf99775f2b9a7fa2191caea7f164 Mon Sep 17 00:00:00 2001 From: Alan Egerton Date: Mon, 8 Jun 2020 17:24:21 +0100 Subject: [PATCH 09/10] Use shorthand linker strip arguments in order to support MacOS --- src/librustc_codegen_ssa/back/linker.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs index d9fed998c92fb..b17c367820748 100644 --- a/src/librustc_codegen_ssa/back/linker.rs +++ b/src/librustc_codegen_ssa/back/linker.rs @@ -481,10 +481,12 @@ impl<'a> Linker for GccLinker<'a> { match strip { Strip::None => {} Strip::Debuginfo => { - self.linker_arg("--strip-debug"); + // MacOS linker does not support longhand argument --strip-debug + self.linker_arg("-S"); } Strip::Symbols => { - self.linker_arg("--strip-all"); + // MacOS linker does not support longhand argument --strip-all + self.linker_arg("-s"); } } } From ef4c4a570fe0b9416dc106a7f66255905afe1b4c Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 8 Jun 2020 12:01:01 -0700 Subject: [PATCH 10/10] Update books --- src/doc/book | 2 +- src/doc/edition-guide | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/book b/src/doc/book index e8a4714a9d8a6..30cd9dfe71c44 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit e8a4714a9d8a6136a59b8e63544e149683876e36 +Subproject commit 30cd9dfe71c446de63826bb4472627af45acc9db diff --git a/src/doc/edition-guide b/src/doc/edition-guide index 0a8ab50468297..82bec5877c77c 160000 --- a/src/doc/edition-guide +++ b/src/doc/edition-guide @@ -1 +1 @@ -Subproject commit 0a8ab5046829733eb03df0738c4fafaa9b36b348 +Subproject commit 82bec5877c77cfad530ca11095db4456d757f668 diff --git a/src/doc/nomicon b/src/doc/nomicon index d1517d4e3f292..bfe1ab96d717d 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit d1517d4e3f29264c5c67bce2658516bb5202c800 +Subproject commit bfe1ab96d717d1dda50e499b360f2e2f57e1750a diff --git a/src/doc/reference b/src/doc/reference index becdca9477c9e..5d40ba5c2515c 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit becdca9477c9eafa96a4eea5156fe7a2730d9dd2 +Subproject commit 5d40ba5c2515caffa7790cda621239dc21ef5a72