From 6ac2080670ce05ad950613c1809d675e15802886 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sat, 3 Apr 2021 21:39:25 +0300 Subject: [PATCH 01/14] rustc_target: Remove compiler-rt linking hack on Android --- compiler/rustc_target/src/spec/android_base.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/compiler/rustc_target/src/spec/android_base.rs b/compiler/rustc_target/src/spec/android_base.rs index aaf81648c51b3..20fb4848c30d1 100644 --- a/compiler/rustc_target/src/spec/android_base.rs +++ b/compiler/rustc_target/src/spec/android_base.rs @@ -1,14 +1,8 @@ -use crate::spec::{LinkerFlavor, TargetOptions}; +use crate::spec::TargetOptions; pub fn opts() -> TargetOptions { let mut base = super::linux_gnu_base::opts(); base.os = "android".to_string(); - // Many of the symbols defined in compiler-rt are also defined in libgcc. - // Android's linker doesn't like that by default. - base.pre_link_args - .entry(LinkerFlavor::Gcc) - .or_default() - .push("-Wl,--allow-multiple-definition".to_string()); base.dwarf_version = Some(2); base.position_independent_executables = true; base.has_elf_tls = false; From 6e4ef54d79fa87701d4a11712f900994846b811e Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 5 Apr 2021 04:50:01 -0400 Subject: [PATCH 02/14] Rename path_str -> ori_link in anchor_failure ori_link contains anchors, path_str does not. It's important that anchor_failure be passed a link with the anchors still present. --- src/librustdoc/passes/collect_intra_doc_links.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 545fbf2618121..40a93855cf289 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -2005,16 +2005,16 @@ fn resolution_failure( fn anchor_failure( cx: &DocContext<'_>, item: &Item, - path_str: &str, + ori_link: &str, dox: &str, link_range: Range, failure: AnchorFailure, ) { let msg = match failure { - AnchorFailure::MultipleAnchors => format!("`{}` contains multiple anchors", path_str), + AnchorFailure::MultipleAnchors => format!("`{}` contains multiple anchors", ori_link), AnchorFailure::RustdocAnchorConflict(res) => format!( "`{}` contains an anchor, but links to {kind}s are already anchored", - path_str, + ori_link, kind = res.descr(), ), }; From d4011e12708bc760f02ed27d6226e27317ed8629 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 5 Apr 2021 04:56:47 -0400 Subject: [PATCH 03/14] Use DiagnosticInfo for anchor failure This gets rid of a lot of parameters, as well as fixing a diagnostic bug. --- .../passes/collect_intra_doc_links.rs | 62 +++++-------------- src/test/rustdoc-ui/intra-doc/anchors.rs | 4 ++ src/test/rustdoc-ui/intra-doc/anchors.stderr | 16 +++-- 3 files changed, 30 insertions(+), 52 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 40a93855cf289..09823d4b05948 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -251,6 +251,7 @@ struct ResolutionInfo { extra_fragment: Option, } +#[derive(Clone)] struct DiagnosticInfo<'a> { item: &'a Item, dox: &'a str, @@ -949,19 +950,19 @@ impl LinkCollector<'_, '_> { return None; } + let diag_info = DiagnosticInfo { + item, + dox, + ori_link: &ori_link.link, + link_range: ori_link.range.clone(), + }; + let link = ori_link.link.replace("`", ""); let no_backticks_range = range_between_backticks(&ori_link); let parts = link.split('#').collect::>(); let (link, extra_fragment) = if parts.len() > 2 { // A valid link can't have multiple #'s - anchor_failure( - self.cx, - &item, - &link, - dox, - ori_link.range, - AnchorFailure::MultipleAnchors, - ); + anchor_failure(self.cx, diag_info, AnchorFailure::MultipleAnchors); return None; } else if parts.len() == 2 { if parts[0].trim().is_empty() { @@ -1092,12 +1093,6 @@ impl LinkCollector<'_, '_> { return None; } - let diag_info = DiagnosticInfo { - item, - dox, - ori_link: &ori_link.link, - link_range: ori_link.range.clone(), - }; let (mut res, mut fragment) = self.resolve_with_disambiguator_cached( ResolutionInfo { module_id, @@ -1105,7 +1100,7 @@ impl LinkCollector<'_, '_> { path_str: path_str.to_owned(), extra_fragment, }, - diag_info, + diag_info.clone(), // this struct should really be Copy, but Range is not :( matches!(ori_link.kind, LinkType::Reference | LinkType::Shortcut), )?; @@ -1123,10 +1118,7 @@ impl LinkCollector<'_, '_> { if fragment.is_some() { anchor_failure( self.cx, - &item, - path_str, - dox, - ori_link.range, + diag_info, AnchorFailure::RustdocAnchorConflict(prim), ); return None; @@ -1360,14 +1352,7 @@ impl LinkCollector<'_, '_> { None } Err(ErrorKind::AnchorFailure(msg)) => { - anchor_failure( - self.cx, - diag.item, - diag.ori_link, - diag.dox, - diag.link_range, - msg, - ); + anchor_failure(self.cx, diag, msg); None } } @@ -1384,14 +1369,7 @@ impl LinkCollector<'_, '_> { Ok(res) } Err(ErrorKind::AnchorFailure(msg)) => { - anchor_failure( - self.cx, - diag.item, - diag.ori_link, - diag.dox, - diag.link_range, - msg, - ); + anchor_failure(self.cx, diag, msg); return None; } Err(ErrorKind::Resolve(box kind)) => Err(kind), @@ -1399,14 +1377,7 @@ impl LinkCollector<'_, '_> { value_ns: match self.resolve(path_str, ValueNS, base_node, extra_fragment) { Ok(res) => Ok(res), Err(ErrorKind::AnchorFailure(msg)) => { - anchor_failure( - self.cx, - diag.item, - diag.ori_link, - diag.dox, - diag.link_range, - msg, - ); + anchor_failure(self.cx, diag, msg); return None; } Err(ErrorKind::Resolve(box kind)) => Err(kind), @@ -2004,10 +1975,7 @@ fn resolution_failure( /// Report an anchor failure. fn anchor_failure( cx: &DocContext<'_>, - item: &Item, - ori_link: &str, - dox: &str, - link_range: Range, + DiagnosticInfo { item, ori_link, dox, link_range }: DiagnosticInfo<'_>, failure: AnchorFailure, ) { let msg = match failure { diff --git a/src/test/rustdoc-ui/intra-doc/anchors.rs b/src/test/rustdoc-ui/intra-doc/anchors.rs index 009b291be1f08..6785cb7abeaee 100644 --- a/src/test/rustdoc-ui/intra-doc/anchors.rs +++ b/src/test/rustdoc-ui/intra-doc/anchors.rs @@ -43,3 +43,7 @@ pub fn enum_link() {} /// [u32#hello] //~^ ERROR `u32#hello` contains an anchor pub fn x() {} + +/// [prim@usize#x] +//~^ ERROR `prim@usize#x` contains an anchor +pub mod usize {} diff --git a/src/test/rustdoc-ui/intra-doc/anchors.stderr b/src/test/rustdoc-ui/intra-doc/anchors.stderr index 97b0cea0c1e4d..787a68ed969ef 100644 --- a/src/test/rustdoc-ui/intra-doc/anchors.stderr +++ b/src/test/rustdoc-ui/intra-doc/anchors.stderr @@ -1,8 +1,8 @@ -error: `Foo::f#hola` contains an anchor, but links to fields are already anchored - --> $DIR/anchors.rs:25:15 +error: `prim@usize#x` contains an anchor, but links to builtin types are already anchored + --> $DIR/anchors.rs:47:6 | -LL | /// Or maybe [Foo::f#hola]. - | ^^^^^^^^^^^ contains invalid anchor +LL | /// [prim@usize#x] + | ^^^^^^^^^^^^ contains invalid anchor | note: the lint level is defined here --> $DIR/anchors.rs:1:9 @@ -10,6 +10,12 @@ note: the lint level is defined here LL | #![deny(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: `Foo::f#hola` contains an anchor, but links to fields are already anchored + --> $DIR/anchors.rs:25:15 + | +LL | /// Or maybe [Foo::f#hola]. + | ^^^^^^^^^^^ contains invalid anchor + error: `hello#people#!` contains multiple anchors --> $DIR/anchors.rs:31:28 | @@ -28,5 +34,5 @@ error: `u32#hello` contains an anchor, but links to builtin types are already an LL | /// [u32#hello] | ^^^^^^^^^ contains invalid anchor -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors From 8ed7d936f8780a857a981676899ab24660529e7b Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 5 Apr 2021 05:01:15 -0400 Subject: [PATCH 04/14] Take `DiagnosticInfo` in `resolution_failure` --- .../passes/collect_intra_doc_links.rs | 36 ++++--------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 09823d4b05948..496c2f57c3fc2 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1023,11 +1023,9 @@ impl LinkCollector<'_, '_> { debug!("attempting to resolve item without parent module: {}", path_str); resolution_failure( self, - &item, + diag_info, path_str, disambiguator, - dox, - ori_link.range, smallvec![ResolutionFailure::NoParentItem], ); return None; @@ -1073,11 +1071,9 @@ impl LinkCollector<'_, '_> { debug!("link has malformed generics: {}", path_str); resolution_failure( self, - &item, + diag_info, path_str, disambiguator, - dox, - ori_link.range, smallvec![err_kind], ); return None; @@ -1337,15 +1333,7 @@ impl LinkCollector<'_, '_> { } } } - resolution_failure( - self, - diag.item, - path_str, - disambiguator, - diag.dox, - diag.link_range, - smallvec![kind], - ); + resolution_failure(self, diag, path_str, disambiguator, smallvec![kind]); // This could just be a normal link or a broken link // we could potentially check if something is // "intra-doc-link-like" and warn in that case. @@ -1406,11 +1394,9 @@ impl LinkCollector<'_, '_> { if len == 0 { resolution_failure( self, - diag.item, + diag, path_str, disambiguator, - diag.dox, - diag.link_range, candidates.into_iter().filter_map(|res| res.err()).collect(), ); // this could just be a normal link @@ -1452,15 +1438,7 @@ impl LinkCollector<'_, '_> { break; } } - resolution_failure( - self, - diag.item, - path_str, - disambiguator, - diag.dox, - diag.link_range, - smallvec![kind], - ); + resolution_failure(self, diag, path_str, disambiguator, smallvec![kind]); None } } @@ -1750,11 +1728,9 @@ fn report_diagnostic( /// `std::io::Error::x`, this will resolve `std::io::Error`. fn resolution_failure( collector: &mut LinkCollector<'_, '_>, - item: &Item, + DiagnosticInfo { item, ori_link: _, dox, link_range }: DiagnosticInfo<'_>, path_str: &str, disambiguator: Option, - dox: &str, - link_range: Range, kinds: SmallVec<[ResolutionFailure<'_>; 3]>, ) { let tcx = collector.cx.tcx; From 2ab1b7d8c3076510863e969ecc907c983a42a4ed Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 5 Apr 2021 05:04:46 -0400 Subject: [PATCH 05/14] Rename link_range -> disambiguator_range in disambiguator_error It's not the range of the full link, it's only a partial range. --- src/librustdoc/passes/collect_intra_doc_links.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 496c2f57c3fc2..3efde35fd8b1a 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1975,10 +1975,10 @@ fn disambiguator_error( cx: &DocContext<'_>, item: &Item, dox: &str, - link_range: Range, + disambiguator_range: Range, msg: &str, ) { - report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, item, dox, &link_range, |_diag, _sp| {}); + report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, item, dox, &disambiguator_range, |_diag, _sp| {}); } /// Report an ambiguity error, where there were multiple possible resolutions. From 58f9c5b74a77eb339d747dfead08cbafad823923 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 5 Apr 2021 05:06:50 -0400 Subject: [PATCH 06/14] Take DiagnosticInfo in disambiguator_error --- src/librustdoc/passes/collect_intra_doc_links.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 3efde35fd8b1a..e8f0c09dca4dd 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -984,7 +984,7 @@ impl LinkCollector<'_, '_> { // See issue #83859. let disambiguator_range = (no_backticks_range.start + relative_range.start) ..(no_backticks_range.start + relative_range.end); - disambiguator_error(self.cx, &item, dox, disambiguator_range, &err_msg); + disambiguator_error(self.cx, diag_info, disambiguator_range, &err_msg); } return None; } @@ -1973,8 +1973,7 @@ fn anchor_failure( /// Report an error in the link disambiguator. fn disambiguator_error( cx: &DocContext<'_>, - item: &Item, - dox: &str, + DiagnosticInfo { item, ori_link: _, dox, link_range: _ }: DiagnosticInfo<'_>, disambiguator_range: Range, msg: &str, ) { From f4c87c58a83406207a232d8f9f00f604a6d657b7 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 5 Apr 2021 05:09:37 -0400 Subject: [PATCH 07/14] Take `DiagnosticInfo` in `ambiguity_error` --- src/librustdoc/passes/collect_intra_doc_links.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index e8f0c09dca4dd..d0ece91f01462 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1124,7 +1124,7 @@ impl LinkCollector<'_, '_> { } else { // `[char]` when a `char` module is in scope let candidates = vec![res, prim]; - ambiguity_error(self.cx, &item, path_str, dox, ori_link.range, candidates); + ambiguity_error(self.cx, diag_info, path_str, candidates); return None; } } @@ -1413,14 +1413,7 @@ impl LinkCollector<'_, '_> { } // If we're reporting an ambiguity, don't mention the namespaces that failed let candidates = candidates.map(|candidate| candidate.ok().map(|(res, _)| res)); - ambiguity_error( - self.cx, - diag.item, - path_str, - diag.dox, - diag.link_range, - candidates.present_items().collect(), - ); + ambiguity_error(self.cx, diag, path_str, candidates.present_items().collect()); None } } @@ -1983,10 +1976,8 @@ fn disambiguator_error( /// Report an ambiguity error, where there were multiple possible resolutions. fn ambiguity_error( cx: &DocContext<'_>, - item: &Item, + DiagnosticInfo { item, ori_link: _, dox, link_range }: DiagnosticInfo<'_>, path_str: &str, - dox: &str, - link_range: Range, candidates: Vec, ) { let mut msg = format!("`{}` is ", path_str); From 661acbc8bc9f9f0669e27c8af37faf4effff7c53 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 5 Apr 2021 05:15:57 -0400 Subject: [PATCH 08/14] Take DiagnosticInfo in privacy_error --- src/librustdoc/passes/collect_intra_doc_links.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index d0ece91f01462..59981a2f85265 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1192,7 +1192,7 @@ impl LinkCollector<'_, '_> { if self.cx.tcx.privacy_access_levels(LOCAL_CRATE).is_exported(hir_src) && !self.cx.tcx.privacy_access_levels(LOCAL_CRATE).is_exported(hir_dst) { - privacy_error(self.cx, &item, &path_str, dox, &ori_link); + privacy_error(self.cx, diag_info, &path_str); } } @@ -2045,7 +2045,11 @@ fn suggest_disambiguator( } /// Report a link from a public item to a private one. -fn privacy_error(cx: &DocContext<'_>, item: &Item, path_str: &str, dox: &str, link: &MarkdownLink) { +fn privacy_error( + cx: &DocContext<'_>, + DiagnosticInfo { item, ori_link: _, dox, link_range }: DiagnosticInfo<'_>, + path_str: &str, +) { let sym; let item_name = match item.name { Some(name) => { @@ -2057,7 +2061,7 @@ fn privacy_error(cx: &DocContext<'_>, item: &Item, path_str: &str, dox: &str, li let msg = format!("public documentation for `{}` links to private item `{}`", item_name, path_str); - report_diagnostic(cx.tcx, PRIVATE_INTRA_DOC_LINKS, &msg, item, dox, &link.range, |diag, sp| { + report_diagnostic(cx.tcx, PRIVATE_INTRA_DOC_LINKS, &msg, item, dox, &link_range, |diag, sp| { if let Some(sp) = sp { diag.span_label(sp, "this item is private"); } From a86a740defc4be4c89c28310b144af4559a4c9de Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 5 Apr 2021 05:28:29 -0400 Subject: [PATCH 09/14] Use DiagnosticInfo for `report_diagnostic` --- .../passes/collect_intra_doc_links.rs | 68 ++++++++----------- 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 59981a2f85265..8ce30dfddc6e2 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1144,15 +1144,7 @@ impl LinkCollector<'_, '_> { diag.note(¬e); suggest_disambiguator(resolved, diag, path_str, dox, sp, &ori_link.range); }; - report_diagnostic( - self.cx.tcx, - BROKEN_INTRA_DOC_LINKS, - &msg, - &item, - dox, - &ori_link.range, - callback, - ); + report_diagnostic(self.cx.tcx, BROKEN_INTRA_DOC_LINKS, &msg, &diag_info, callback); }; let verify = |kind: DefKind, id: DefId| { @@ -1192,7 +1184,7 @@ impl LinkCollector<'_, '_> { if self.cx.tcx.privacy_access_levels(LOCAL_CRATE).is_exported(hir_src) && !self.cx.tcx.privacy_access_levels(LOCAL_CRATE).is_exported(hir_dst) { - privacy_error(self.cx, diag_info, &path_str); + privacy_error(self.cx, &diag_info, &path_str); } } @@ -1665,9 +1657,7 @@ fn report_diagnostic( tcx: TyCtxt<'_>, lint: &'static Lint, msg: &str, - item: &Item, - dox: &str, - link_range: &Range, + DiagnosticInfo { item, ori_link: _, dox, link_range }: &DiagnosticInfo<'_>, decorate: impl FnOnce(&mut DiagnosticBuilder<'_>, Option), ) { let hir_id = match DocContext::as_local_hir_id(tcx, item.def_id) { @@ -1721,7 +1711,7 @@ fn report_diagnostic( /// `std::io::Error::x`, this will resolve `std::io::Error`. fn resolution_failure( collector: &mut LinkCollector<'_, '_>, - DiagnosticInfo { item, ori_link: _, dox, link_range }: DiagnosticInfo<'_>, + diag_info: DiagnosticInfo<'_>, path_str: &str, disambiguator: Option, kinds: SmallVec<[ResolutionFailure<'_>; 3]>, @@ -1731,9 +1721,7 @@ fn resolution_failure( tcx, BROKEN_INTRA_DOC_LINKS, &format!("unresolved link to `{}`", path_str), - item, - dox, - &link_range, + &diag_info, |diag, sp| { let item = |res: Res| format!("the {} `{}`", res.descr(), res.name(tcx),); let assoc_item_not_allowed = |res: Res| { @@ -1893,9 +1881,9 @@ fn resolution_failure( disambiguator, diag, path_str, - dox, + diag_info.dox, sp, - &link_range, + &diag_info.link_range, ) } @@ -1942,21 +1930,19 @@ fn resolution_failure( } /// Report an anchor failure. -fn anchor_failure( - cx: &DocContext<'_>, - DiagnosticInfo { item, ori_link, dox, link_range }: DiagnosticInfo<'_>, - failure: AnchorFailure, -) { +fn anchor_failure(cx: &DocContext<'_>, diag_info: DiagnosticInfo<'_>, failure: AnchorFailure) { let msg = match failure { - AnchorFailure::MultipleAnchors => format!("`{}` contains multiple anchors", ori_link), + AnchorFailure::MultipleAnchors => { + format!("`{}` contains multiple anchors", diag_info.ori_link) + } AnchorFailure::RustdocAnchorConflict(res) => format!( "`{}` contains an anchor, but links to {kind}s are already anchored", - ori_link, + diag_info.ori_link, kind = res.descr(), ), }; - report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, &msg, item, dox, &link_range, |diag, sp| { + report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, &msg, &diag_info, |diag, sp| { if let Some(sp) = sp { diag.span_label(sp, "contains invalid anchor"); } @@ -1966,17 +1952,18 @@ fn anchor_failure( /// Report an error in the link disambiguator. fn disambiguator_error( cx: &DocContext<'_>, - DiagnosticInfo { item, ori_link: _, dox, link_range: _ }: DiagnosticInfo<'_>, + mut diag_info: DiagnosticInfo<'_>, disambiguator_range: Range, msg: &str, ) { - report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, item, dox, &disambiguator_range, |_diag, _sp| {}); + diag_info.link_range = disambiguator_range; + report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, msg, &diag_info, |_diag, _sp| {}); } /// Report an ambiguity error, where there were multiple possible resolutions. fn ambiguity_error( cx: &DocContext<'_>, - DiagnosticInfo { item, ori_link: _, dox, link_range }: DiagnosticInfo<'_>, + diag_info: DiagnosticInfo<'_>, path_str: &str, candidates: Vec, ) { @@ -2004,7 +1991,7 @@ fn ambiguity_error( } } - report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, &msg, item, dox, &link_range, |diag, sp| { + report_diagnostic(cx.tcx, BROKEN_INTRA_DOC_LINKS, &msg, &diag_info, |diag, sp| { if let Some(sp) = sp { diag.span_label(sp, "ambiguous link"); } else { @@ -2013,7 +2000,14 @@ fn ambiguity_error( for res in candidates { let disambiguator = Disambiguator::from_res(res); - suggest_disambiguator(disambiguator, diag, path_str, dox, sp, &link_range); + suggest_disambiguator( + disambiguator, + diag, + path_str, + diag_info.dox, + sp, + &diag_info.link_range, + ); } }); } @@ -2045,13 +2039,9 @@ fn suggest_disambiguator( } /// Report a link from a public item to a private one. -fn privacy_error( - cx: &DocContext<'_>, - DiagnosticInfo { item, ori_link: _, dox, link_range }: DiagnosticInfo<'_>, - path_str: &str, -) { +fn privacy_error(cx: &DocContext<'_>, diag_info: &DiagnosticInfo<'_>, path_str: &str) { let sym; - let item_name = match item.name { + let item_name = match diag_info.item.name { Some(name) => { sym = name.as_str(); &*sym @@ -2061,7 +2051,7 @@ fn privacy_error( let msg = format!("public documentation for `{}` links to private item `{}`", item_name, path_str); - report_diagnostic(cx.tcx, PRIVATE_INTRA_DOC_LINKS, &msg, item, dox, &link_range, |diag, sp| { + report_diagnostic(cx.tcx, PRIVATE_INTRA_DOC_LINKS, &msg, diag_info, |diag, sp| { if let Some(sp) = sp { diag.span_label(sp, "this item is private"); } From e7e485cf51ada6052938efc41ea2fa3dc9d74fad Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 4 Apr 2021 00:31:28 +0300 Subject: [PATCH 10/14] rustc_target: Rely on defaults more in target specs --- compiler/rustc_target/src/spec/apple_base.rs | 4 +--- .../rustc_target/src/spec/armv7_unknown_linux_gnueabi.rs | 1 - .../rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs | 1 - .../rustc_target/src/spec/armv7_unknown_linux_musleabi.rs | 1 - .../src/spec/armv7_unknown_linux_musleabihf.rs | 1 - .../rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs | 1 - compiler/rustc_target/src/spec/armv7_wrs_vxworks_eabihf.rs | 1 - compiler/rustc_target/src/spec/avr_gnu_base.rs | 3 --- compiler/rustc_target/src/spec/fuchsia_base.rs | 2 -- compiler/rustc_target/src/spec/haiku_base.rs | 1 - compiler/rustc_target/src/spec/hermit_base.rs | 5 +---- compiler/rustc_target/src/spec/hermit_kernel_base.rs | 5 +---- .../rustc_target/src/spec/hexagon_unknown_linux_musl.rs | 6 +----- compiler/rustc_target/src/spec/l4re_base.rs | 7 +------ .../rustc_target/src/spec/riscv32i_unknown_none_elf.rs | 1 - .../rustc_target/src/spec/riscv32imac_unknown_none_elf.rs | 1 - .../rustc_target/src/spec/riscv64gc_unknown_none_elf.rs | 1 - .../rustc_target/src/spec/riscv64imac_unknown_none_elf.rs | 1 - compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs | 3 --- compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs | 1 - .../rustc_target/src/spec/thumbv7a_uwp_windows_msvc.rs | 1 - .../src/spec/thumbv7neon_unknown_linux_gnueabihf.rs | 1 - .../src/spec/thumbv7neon_unknown_linux_musleabihf.rs | 1 - compiler/rustc_target/src/spec/vxworks_base.rs | 1 - compiler/rustc_target/src/spec/wasm_base.rs | 1 - compiler/rustc_target/src/spec/windows_gnu_base.rs | 2 -- .../rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs | 4 +--- 27 files changed, 6 insertions(+), 52 deletions(-) diff --git a/compiler/rustc_target/src/spec/apple_base.rs b/compiler/rustc_target/src/spec/apple_base.rs index 23f1357af163f..6fa0b34545097 100644 --- a/compiler/rustc_target/src/spec/apple_base.rs +++ b/compiler/rustc_target/src/spec/apple_base.rs @@ -1,6 +1,6 @@ use std::env; -use crate::spec::{LinkArgs, SplitDebuginfo, TargetOptions}; +use crate::spec::{SplitDebuginfo, TargetOptions}; pub fn opts(os: &str) -> TargetOptions { // ELF TLS is only available in macOS 10.7+. If you try to compile for 10.6 @@ -27,10 +27,8 @@ pub fn opts(os: &str) -> TargetOptions { is_like_osx: true, dwarf_version: Some(2), has_rpath: true, - dll_prefix: "lib".to_string(), dll_suffix: ".dylib".to_string(), archive_format: "darwin".to_string(), - pre_link_args: LinkArgs::new(), has_elf_tls: version >= (10, 7), abi_return_struct_as_int: true, emit_debug_gdb_scripts: false, diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabi.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabi.rs index ae6b8286f085f..f6fe88de37cf6 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabi.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabi.rs @@ -13,7 +13,6 @@ pub fn target() -> Target { options: TargetOptions { features: "+v7,+thumb2,+soft-float,-neon".to_string(), - cpu: "generic".to_string(), max_atomic_width: Some(64), unsupported_abis: super::arm_base::unsupported_abis(), mcount: "\u{1}__gnu_mcount_nc".to_string(), diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs index 48c16b620fd69..5f0f47dd39776 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_linux_gnueabihf.rs @@ -14,7 +14,6 @@ pub fn target() -> Target { options: TargetOptions { // Info about features at https://wiki.debian.org/ArmHardFloatPort features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), - cpu: "generic".to_string(), max_atomic_width: Some(64), unsupported_abis: super::arm_base::unsupported_abis(), mcount: "\u{1}__gnu_mcount_nc".to_string(), diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabi.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabi.rs index 9f9f1bd79b0c1..c888fc2d4a389 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabi.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabi.rs @@ -18,7 +18,6 @@ pub fn target() -> Target { options: TargetOptions { features: "+v7,+thumb2,+soft-float,-neon".to_string(), - cpu: "generic".to_string(), max_atomic_width: Some(64), unsupported_abis: super::arm_base::unsupported_abis(), mcount: "\u{1}mcount".to_string(), diff --git a/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabihf.rs index 59deee30ef260..2432ea519a8ec 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabihf.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_linux_musleabihf.rs @@ -17,7 +17,6 @@ pub fn target() -> Target { // target. options: TargetOptions { features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), - cpu: "generic".to_string(), max_atomic_width: Some(64), unsupported_abis: super::arm_base::unsupported_abis(), mcount: "\u{1}mcount".to_string(), diff --git a/compiler/rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs b/compiler/rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs index 660525704c1b0..4fae3a8d0bf45 100644 --- a/compiler/rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs +++ b/compiler/rustc_target/src/spec/armv7_unknown_netbsd_eabihf.rs @@ -11,7 +11,6 @@ pub fn target() -> Target { options: TargetOptions { env: "eabihf".to_string(), features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), - cpu: "generic".to_string(), max_atomic_width: Some(64), unsupported_abis: super::arm_base::unsupported_abis(), mcount: "__mcount".to_string(), diff --git a/compiler/rustc_target/src/spec/armv7_wrs_vxworks_eabihf.rs b/compiler/rustc_target/src/spec/armv7_wrs_vxworks_eabihf.rs index 6a43054067fe5..9fe7098a85f00 100644 --- a/compiler/rustc_target/src/spec/armv7_wrs_vxworks_eabihf.rs +++ b/compiler/rustc_target/src/spec/armv7_wrs_vxworks_eabihf.rs @@ -10,7 +10,6 @@ pub fn target() -> Target { options: TargetOptions { // Info about features at https://wiki.debian.org/ArmHardFloatPort features: "+v7,+vfp3,-d32,+thumb2,-neon".to_string(), - cpu: "generic".to_string(), max_atomic_width: Some(64), unsupported_abis: super::arm_base::unsupported_abis(), ..base diff --git a/compiler/rustc_target/src/spec/avr_gnu_base.rs b/compiler/rustc_target/src/spec/avr_gnu_base.rs index df4389b8165a8..69ccce875ab0c 100644 --- a/compiler/rustc_target/src/spec/avr_gnu_base.rs +++ b/compiler/rustc_target/src/spec/avr_gnu_base.rs @@ -15,11 +15,8 @@ pub fn target(target_cpu: String) -> Target { exe_suffix: ".elf".to_string(), linker: Some("avr-gcc".to_owned()), - dynamic_linking: false, executables: true, linker_is_gnu: true, - has_rpath: false, - position_independent_executables: false, eh_frame_header: false, pre_link_args: vec![(LinkerFlavor::Gcc, vec![format!("-mmcu={}", target_cpu)])] .into_iter() diff --git a/compiler/rustc_target/src/spec/fuchsia_base.rs b/compiler/rustc_target/src/spec/fuchsia_base.rs index 5c39773cbe381..2b925f8b946c4 100644 --- a/compiler/rustc_target/src/spec/fuchsia_base.rs +++ b/compiler/rustc_target/src/spec/fuchsia_base.rs @@ -23,13 +23,11 @@ pub fn opts() -> TargetOptions { os: "fuchsia".to_string(), linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), linker: Some("rust-lld".to_owned()), - lld_flavor: LldFlavor::Ld, dynamic_linking: true, executables: true, os_family: Some("unix".to_string()), is_like_fuchsia: true, linker_is_gnu: true, - has_rpath: false, pre_link_args, pre_link_objects: crt_objects::new(&[ (LinkOutputKind::DynamicNoPicExe, &["Scrt1.o"]), diff --git a/compiler/rustc_target/src/spec/haiku_base.rs b/compiler/rustc_target/src/spec/haiku_base.rs index ec87645c4faaa..956e4ed4bf9c8 100644 --- a/compiler/rustc_target/src/spec/haiku_base.rs +++ b/compiler/rustc_target/src/spec/haiku_base.rs @@ -5,7 +5,6 @@ pub fn opts() -> TargetOptions { os: "haiku".to_string(), dynamic_linking: true, executables: true, - has_rpath: false, os_family: Some("unix".to_string()), relro_level: RelroLevel::Full, linker_is_gnu: true, diff --git a/compiler/rustc_target/src/spec/hermit_base.rs b/compiler/rustc_target/src/spec/hermit_base.rs index a75158a0ea0cb..ad013047e6a13 100644 --- a/compiler/rustc_target/src/spec/hermit_base.rs +++ b/compiler/rustc_target/src/spec/hermit_base.rs @@ -1,5 +1,4 @@ -use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy}; -use crate::spec::{RelocModel, TargetOptions, TlsModel}; +use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, TargetOptions, TlsModel}; pub fn opts() -> TargetOptions { let mut pre_link_args = LinkArgs::new(); @@ -19,8 +18,6 @@ pub fn opts() -> TargetOptions { panic_strategy: PanicStrategy::Abort, position_independent_executables: true, static_position_independent_executables: true, - relocation_model: RelocModel::Pic, - os_family: None, tls_model: TlsModel::InitialExec, ..Default::default() } diff --git a/compiler/rustc_target/src/spec/hermit_kernel_base.rs b/compiler/rustc_target/src/spec/hermit_kernel_base.rs index 622f0d9a47198..6d18a14d6aec0 100644 --- a/compiler/rustc_target/src/spec/hermit_kernel_base.rs +++ b/compiler/rustc_target/src/spec/hermit_kernel_base.rs @@ -1,5 +1,4 @@ -use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy}; -use crate::spec::{RelocModel, TargetOptions, TlsModel}; +use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, TargetOptions, TlsModel}; pub fn opts() -> TargetOptions { let mut pre_link_args = LinkArgs::new(); @@ -20,8 +19,6 @@ pub fn opts() -> TargetOptions { panic_strategy: PanicStrategy::Abort, position_independent_executables: true, static_position_independent_executables: true, - relocation_model: RelocModel::Pic, - os_family: None, tls_model: TlsModel::InitialExec, ..Default::default() } diff --git a/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs index 73d5e2057f955..e0097ee220a46 100644 --- a/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/hexagon_unknown_linux_musl.rs @@ -1,4 +1,4 @@ -use crate::spec::{LinkArgs, Target}; +use crate::spec::Target; pub fn target() -> Target { let mut base = super::linux_musl_base::opts(); @@ -8,15 +8,11 @@ pub fn target() -> Target { base.features = "-small-data,+hvx-length128b".to_string(); base.crt_static_default = false; - base.atomic_cas = true; base.has_rpath = true; base.linker_is_gnu = false; base.dynamic_linking = true; base.executables = true; - base.pre_link_args = LinkArgs::new(); - base.post_link_args = LinkArgs::new(); - Target { llvm_target: "hexagon-unknown-linux-musl".to_string(), pointer_width: 32, diff --git a/compiler/rustc_target/src/spec/l4re_base.rs b/compiler/rustc_target/src/spec/l4re_base.rs index 660fae5f5c7cd..db6b74eff6dbd 100644 --- a/compiler/rustc_target/src/spec/l4re_base.rs +++ b/compiler/rustc_target/src/spec/l4re_base.rs @@ -1,4 +1,4 @@ -use crate::spec::{LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions}; +use crate::spec::{LinkerFlavor, PanicStrategy, TargetOptions}; //use std::process::Command; // Use GCC to locate code for crt* libraries from the host, not from L4Re. Note @@ -13,18 +13,13 @@ use crate::spec::{LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions}; //} pub fn opts() -> TargetOptions { - let mut args = LinkArgs::new(); - args.insert(LinkerFlavor::Gcc, vec![]); - TargetOptions { os: "l4re".to_string(), env: "uclibc".to_string(), linker_flavor: LinkerFlavor::Ld, executables: true, - has_elf_tls: false, panic_strategy: PanicStrategy::Abort, linker: Some("ld".to_string()), - pre_link_args: args, os_family: Some("unix".to_string()), ..Default::default() } diff --git a/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs index a31a08a8cf93d..88a22f25ff47b 100644 --- a/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs @@ -14,7 +14,6 @@ pub fn target() -> Target { cpu: "generic-rv32".to_string(), max_atomic_width: Some(0), atomic_cas: false, - features: String::new(), executables: true, panic_strategy: PanicStrategy::Abort, relocation_model: RelocModel::Static, diff --git a/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs index 2ee53fdc4016d..b406eec1e7502 100644 --- a/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/riscv32imac_unknown_none_elf.rs @@ -13,7 +13,6 @@ pub fn target() -> Target { linker: Some("rust-lld".to_string()), cpu: "generic-rv32".to_string(), max_atomic_width: Some(32), - atomic_cas: true, features: "+m,+a,+c".to_string(), executables: true, panic_strategy: PanicStrategy::Abort, diff --git a/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs index aa823b13fddf2..481bce05a08e5 100644 --- a/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/riscv64gc_unknown_none_elf.rs @@ -14,7 +14,6 @@ pub fn target() -> Target { llvm_abiname: "lp64d".to_string(), cpu: "generic-rv64".to_string(), max_atomic_width: Some(64), - atomic_cas: true, features: "+m,+a,+f,+d,+c".to_string(), executables: true, panic_strategy: PanicStrategy::Abort, diff --git a/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs b/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs index 908367ee2006e..3e4afd446dda9 100644 --- a/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs +++ b/compiler/rustc_target/src/spec/riscv64imac_unknown_none_elf.rs @@ -13,7 +13,6 @@ pub fn target() -> Target { linker: Some("rust-lld".to_string()), cpu: "generic-rv64".to_string(), max_atomic_width: Some(64), - atomic_cas: true, features: "+m,+a,+c".to_string(), executables: true, panic_strategy: PanicStrategy::Abort, diff --git a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs index d87c06d49cbc2..ef58824f38108 100644 --- a/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs +++ b/compiler/rustc_target/src/spec/thumbv4t_none_eabi.rs @@ -45,9 +45,6 @@ pub fn target() -> Target { main_needs_argc_argv: false, - // No thread-local storage (just use a static Cell) - has_elf_tls: false, - // don't have atomic compare-and-swap atomic_cas: false, has_thumb_interworking: true, diff --git a/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs b/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs index 975fd81d9c3d8..1232daa577f23 100644 --- a/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/thumbv7a_pc_windows_msvc.rs @@ -29,7 +29,6 @@ pub fn target() -> Target { options: TargetOptions { features: "+vfp3,+neon".to_string(), - cpu: "generic".to_string(), max_atomic_width: Some(64), unsupported_abis: super::arm_base::unsupported_abis(), ..base diff --git a/compiler/rustc_target/src/spec/thumbv7a_uwp_windows_msvc.rs b/compiler/rustc_target/src/spec/thumbv7a_uwp_windows_msvc.rs index a2c1b6bb90c97..e6a59f015c993 100644 --- a/compiler/rustc_target/src/spec/thumbv7a_uwp_windows_msvc.rs +++ b/compiler/rustc_target/src/spec/thumbv7a_uwp_windows_msvc.rs @@ -16,7 +16,6 @@ pub fn target() -> Target { arch: "arm".to_string(), options: TargetOptions { features: "+vfp3,+neon".to_string(), - cpu: "generic".to_string(), unsupported_abis: super::arm_base::unsupported_abis(), ..base }, diff --git a/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_gnueabihf.rs b/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_gnueabihf.rs index 352d246874308..12d816d095b68 100644 --- a/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_gnueabihf.rs +++ b/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_gnueabihf.rs @@ -17,7 +17,6 @@ pub fn target() -> Target { options: TargetOptions { // Info about features at https://wiki.debian.org/ArmHardFloatPort features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".to_string(), - cpu: "generic".to_string(), max_atomic_width: Some(64), unsupported_abis: super::arm_base::unsupported_abis(), ..base diff --git a/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_musleabihf.rs index a788167aede07..020de87147cb6 100644 --- a/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_musleabihf.rs +++ b/compiler/rustc_target/src/spec/thumbv7neon_unknown_linux_musleabihf.rs @@ -21,7 +21,6 @@ pub fn target() -> Target { // target. options: TargetOptions { features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".to_string(), - cpu: "generic".to_string(), max_atomic_width: Some(64), unsupported_abis: super::arm_base::unsupported_abis(), mcount: "\u{1}mcount".to_string(), diff --git a/compiler/rustc_target/src/spec/vxworks_base.rs b/compiler/rustc_target/src/spec/vxworks_base.rs index 8396d0463d931..41c4d7625af2a 100644 --- a/compiler/rustc_target/src/spec/vxworks_base.rs +++ b/compiler/rustc_target/src/spec/vxworks_base.rs @@ -12,7 +12,6 @@ pub fn opts() -> TargetOptions { os_family: Some("unix".to_string()), linker_is_gnu: true, has_rpath: true, - position_independent_executables: false, has_elf_tls: true, crt_static_default: true, crt_static_respected: true, diff --git a/compiler/rustc_target/src/spec/wasm_base.rs b/compiler/rustc_target/src/spec/wasm_base.rs index c93ad24225a5e..b208eb92f8ff9 100644 --- a/compiler/rustc_target/src/spec/wasm_base.rs +++ b/compiler/rustc_target/src/spec/wasm_base.rs @@ -75,7 +75,6 @@ pub fn options() -> TargetOptions { exe_suffix: ".wasm".to_string(), dll_prefix: String::new(), dll_suffix: ".wasm".to_string(), - linker_is_gnu: false, eh_frame_header: false, max_atomic_width: Some(64), diff --git a/compiler/rustc_target/src/spec/windows_gnu_base.rs b/compiler/rustc_target/src/spec/windows_gnu_base.rs index 7036f338150c2..478c567a93b25 100644 --- a/compiler/rustc_target/src/spec/windows_gnu_base.rs +++ b/compiler/rustc_target/src/spec/windows_gnu_base.rs @@ -71,8 +71,6 @@ pub fn opts() -> TargetOptions { dll_prefix: String::new(), dll_suffix: ".dll".to_string(), exe_suffix: ".exe".to_string(), - staticlib_prefix: "lib".to_string(), - staticlib_suffix: ".a".to_string(), os_family: Some("windows".to_string()), is_like_windows: true, allows_weak_linkage: false, diff --git a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs index 6365e5650e471..90705c526f4b2 100644 --- a/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs +++ b/compiler/rustc_target/src/spec/x86_64_fortanix_unknown_sgx.rs @@ -1,6 +1,6 @@ use std::iter; -use super::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions}; +use super::{LinkerFlavor, LldFlavor, Target, TargetOptions}; pub fn target() -> Target { const PRE_LINK_ARGS: &[&str] = &[ @@ -56,12 +56,10 @@ pub fn target() -> Target { env: "sgx".into(), vendor: "fortanix".into(), linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld), - dynamic_linking: false, executables: true, linker_is_gnu: true, linker: Some("rust-lld".to_owned()), max_atomic_width: Some(64), - panic_strategy: PanicStrategy::Unwind, cpu: "x86-64".into(), features: "+rdrnd,+rdseed,+lvi-cfi,+lvi-load-hardening".into(), llvm_args: vec!["--x86-experimental-lvi-inline-asm-hardening".into()], From 6c0b98724c9745e53d08610799ef91f2715af707 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 5 Apr 2021 13:50:49 -0700 Subject: [PATCH 11/14] Update LLVM to support more wasm simd ops Adds a commit with support for i64 simd comparisons for the wasm target --- src/llvm-project | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm-project b/src/llvm-project index 0abbcc04d8375..171991e309666 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 0abbcc04d8375661a0637896b9ae5dc37a99dc70 +Subproject commit 171991e30966695fd118c90ebbb2eeec5098ccce From f4a19ca851c16215a3eaf0d38048bf114ee1aa1e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 Apr 2021 22:58:07 +0200 Subject: [PATCH 12/14] Fix typo in TokenStream documentation --- compiler/rustc_ast/src/tokenstream.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 06d49c7524a58..1c26668779f6f 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -178,7 +178,7 @@ impl HashStable for LazyTokenStream { /// The goal is for procedural macros to work with `TokenStream`s and `TokenTree`s /// instead of a representation of the abstract syntax tree. /// Today's `TokenTree`s can still contain AST via `token::Interpolated` for -/// backwards compatability. +/// backwards compatibility. #[derive(Clone, Debug, Default, Encodable, Decodable)] pub struct TokenStream(pub(crate) Lrc>); From 48c2cde39eed290b2b4a10b991d2bfd24b2eadba Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 5 Apr 2021 17:10:04 -0700 Subject: [PATCH 13/14] Update cargo --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index 3c44c3c4b7900..65d57e6f384c2 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 3c44c3c4b7900b8b13c85ead25ccaa8abb7d8989 +Subproject commit 65d57e6f384c2317f76626eac116f683e2b63665 From 525646a380f2e0730468bcdcc8ee2021fa9e243d Mon Sep 17 00:00:00 2001 From: Camelid Date: Fri, 2 Apr 2021 12:08:28 -0700 Subject: [PATCH 14/14] Move `SharedContext` to `context.rs` It is tightly connected to `Context` and is primarily used as a field in `Context`. Thus, it should be next to `Context`. --- src/librustdoc/html/render/context.rs | 79 +++++++++++++++++++++++--- src/librustdoc/html/render/mod.rs | 81 ++------------------------- 2 files changed, 77 insertions(+), 83 deletions(-) diff --git a/src/librustdoc/html/render/context.rs b/src/librustdoc/html/render/context.rs index 1a993f360a166..df5ff6e106d7c 100644 --- a/src/librustdoc/html/render/context.rs +++ b/src/librustdoc/html/render/context.rs @@ -1,11 +1,11 @@ use std::cell::RefCell; use std::collections::BTreeMap; use std::io; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::rc::Rc; -use std::sync::mpsc::channel; +use std::sync::mpsc::{channel, Receiver}; -use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def_id::{DefId, LOCAL_CRATE}; use rustc_middle::ty::TyCtxt; use rustc_session::Session; @@ -16,10 +16,7 @@ use rustc_span::{symbol::sym, Symbol}; use super::cache::{build_index, ExternalLocation}; use super::print_item::{full_path, item_path, print_item}; use super::write_shared::write_shared; -use super::{ - print_sidebar, settings, AllTypes, NameDoc, SharedContext, StylePath, BASIC_KEYWORDS, - CURRENT_DEPTH, -}; +use super::{print_sidebar, settings, AllTypes, NameDoc, StylePath, BASIC_KEYWORDS, CURRENT_DEPTH}; use crate::clean::{self, AttributesExt}; use crate::config::RenderOptions; @@ -78,6 +75,74 @@ crate struct Context<'tcx> { #[cfg(target_arch = "x86_64")] rustc_data_structures::static_assert_size!(Context<'_>, 152); +/// Shared mutable state used in [`Context`] and elsewhere. +crate struct SharedContext<'tcx> { + crate tcx: TyCtxt<'tcx>, + /// The path to the crate root source minus the file name. + /// Used for simplifying paths to the highlighted source code files. + crate src_root: PathBuf, + /// This describes the layout of each page, and is not modified after + /// creation of the context (contains info like the favicon and added html). + crate layout: layout::Layout, + /// This flag indicates whether `[src]` links should be generated or not. If + /// the source files are present in the html rendering, then this will be + /// `true`. + crate include_sources: bool, + /// The local file sources we've emitted and their respective url-paths. + crate local_sources: FxHashMap, + /// Whether the collapsed pass ran + collapsed: bool, + /// The base-URL of the issue tracker for when an item has been tagged with + /// an issue number. + pub(super) issue_tracker_base_url: Option, + /// The directories that have already been created in this doc run. Used to reduce the number + /// of spurious `create_dir_all` calls. + created_dirs: RefCell>, + /// This flag indicates whether listings of modules (in the side bar and documentation itself) + /// should be ordered alphabetically or in order of appearance (in the source code). + pub(super) sort_modules_alphabetically: bool, + /// Additional CSS files to be added to the generated docs. + crate style_files: Vec, + /// Suffix to be added on resource files (if suffix is "-v2" then "light.css" becomes + /// "light-v2.css"). + crate resource_suffix: String, + /// Optional path string to be used to load static files on output pages. If not set, uses + /// combinations of `../` to reach the documentation root. + crate static_root_path: Option, + /// The fs handle we are working with. + crate fs: DocFS, + /// The default edition used to parse doctests. + crate edition: Edition, + pub(super) codes: ErrorCodes, + pub(super) playground: Option, + all: RefCell, + /// Storage for the errors produced while generating documentation so they + /// can be printed together at the end. + errors: Receiver, + /// `None` by default, depends on the `generate-redirect-map` option flag. If this field is set + /// to `Some(...)`, it'll store redirections and then generate a JSON file at the top level of + /// the crate. + redirections: Option>>, +} + +impl SharedContext<'_> { + crate fn ensure_dir(&self, dst: &Path) -> Result<(), Error> { + let mut dirs = self.created_dirs.borrow_mut(); + if !dirs.contains(dst) { + try_err!(self.fs.create_dir_all(dst), dst); + dirs.insert(dst.to_path_buf()); + } + + Ok(()) + } + + /// Based on whether the `collapse-docs` pass was run, return either the `doc_value` or the + /// `collapsed_doc_value` of the given item. + crate fn maybe_collapsed_doc_value<'a>(&self, item: &'a clean::Item) -> Option { + if self.collapsed { item.collapsed_doc_value() } else { item.doc_value() } + } +} + impl<'tcx> Context<'tcx> { pub(super) fn tcx(&self) -> TyCtxt<'tcx> { self.shared.tcx diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 7b656baa1b4bf..909b88ac25a31 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -35,32 +35,30 @@ mod write_shared; crate use context::*; crate use write_shared::FILES_UNVERSIONED; -use std::cell::{Cell, RefCell}; +use std::cell::Cell; use std::collections::VecDeque; use std::default::Default; use std::fmt; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use std::str; use std::string::ToString; -use std::sync::mpsc::Receiver; use itertools::Itertools; use rustc_ast_pretty::pprust; use rustc_attr::{Deprecation, StabilityLevel}; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_data_structures::fx::FxHashSet; use rustc_hir as hir; use rustc_hir::def::CtorKind; use rustc_hir::def_id::DefId; use rustc_hir::Mutability; use rustc_middle::middle::stability; use rustc_middle::ty::TyCtxt; -use rustc_span::edition::Edition; use rustc_span::symbol::{kw, sym, Symbol}; use serde::ser::SerializeSeq; use serde::{Serialize, Serializer}; use crate::clean::{self, GetDefId, RenderedLink, SelfTy, TypeKind}; -use crate::docfs::{DocFS, PathError}; +use crate::docfs::PathError; use crate::error::Error; use crate::formats::cache::Cache; use crate::formats::item_type::ItemType; @@ -70,8 +68,7 @@ use crate::html::format::{ href, print_abi_with_space, print_default_space, print_generic_bounds, print_where_clause, Buffer, PrintWithSpace, }; -use crate::html::layout; -use crate::html::markdown::{self, ErrorCodes, Markdown, MarkdownHtml, MarkdownSummaryLine}; +use crate::html::markdown::{Markdown, MarkdownHtml, MarkdownSummaryLine}; /// A pair of name and its optional document. crate type NameDoc = (String, Option); @@ -82,74 +79,6 @@ crate fn ensure_trailing_slash(v: &str) -> impl fmt::Display + '_ { }) } -/// Shared mutable state used in [`Context`] and elsewhere. -crate struct SharedContext<'tcx> { - crate tcx: TyCtxt<'tcx>, - /// The path to the crate root source minus the file name. - /// Used for simplifying paths to the highlighted source code files. - crate src_root: PathBuf, - /// This describes the layout of each page, and is not modified after - /// creation of the context (contains info like the favicon and added html). - crate layout: layout::Layout, - /// This flag indicates whether `[src]` links should be generated or not. If - /// the source files are present in the html rendering, then this will be - /// `true`. - crate include_sources: bool, - /// The local file sources we've emitted and their respective url-paths. - crate local_sources: FxHashMap, - /// Whether the collapsed pass ran - collapsed: bool, - /// The base-URL of the issue tracker for when an item has been tagged with - /// an issue number. - issue_tracker_base_url: Option, - /// The directories that have already been created in this doc run. Used to reduce the number - /// of spurious `create_dir_all` calls. - created_dirs: RefCell>, - /// This flag indicates whether listings of modules (in the side bar and documentation itself) - /// should be ordered alphabetically or in order of appearance (in the source code). - sort_modules_alphabetically: bool, - /// Additional CSS files to be added to the generated docs. - crate style_files: Vec, - /// Suffix to be added on resource files (if suffix is "-v2" then "light.css" becomes - /// "light-v2.css"). - crate resource_suffix: String, - /// Optional path string to be used to load static files on output pages. If not set, uses - /// combinations of `../` to reach the documentation root. - crate static_root_path: Option, - /// The fs handle we are working with. - crate fs: DocFS, - /// The default edition used to parse doctests. - crate edition: Edition, - codes: ErrorCodes, - playground: Option, - all: RefCell, - /// Storage for the errors produced while generating documentation so they - /// can be printed together at the end. - errors: Receiver, - /// `None` by default, depends on the `generate-redirect-map` option flag. If this field is set - /// to `Some(...)`, it'll store redirections and then generate a JSON file at the top level of - /// the crate. - redirections: Option>>, -} - -impl SharedContext<'_> { - crate fn ensure_dir(&self, dst: &Path) -> Result<(), Error> { - let mut dirs = self.created_dirs.borrow_mut(); - if !dirs.contains(dst) { - try_err!(self.fs.create_dir_all(dst), dst); - dirs.insert(dst.to_path_buf()); - } - - Ok(()) - } - - /// Based on whether the `collapse-docs` pass was run, return either the `doc_value` or the - /// `collapsed_doc_value` of the given item. - crate fn maybe_collapsed_doc_value<'a>(&self, item: &'a clean::Item) -> Option { - if self.collapsed { item.collapsed_doc_value() } else { item.doc_value() } - } -} - // Helper structs for rendering items/sidebars and carrying along contextual // information