Skip to content

Commit d022dd4

Browse files
committed
Auto merge of #51023 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests Successful merges: - #50864 (Add NetBSD/arm target specs) - #50956 (rust-gdb: work around the re-used -d argument in cgdb) - #50964 (Make sure that queries have predictable symbol names.) - #50965 (Update LLVM to pull in another wasm fix) - #50972 (Add -Z no-parallel-llvm flag) - #50979 (Fix span for type-only arguments) - #50981 (Shrink `LiveNode`.) - #50995 (move type out of unsafe block) - #51011 ( rustdoc: hide macro export statements from docs) Failed merges:
2 parents a76bff8 + 98606cf commit d022dd4

File tree

17 files changed

+137
-45
lines changed

17 files changed

+137
-45
lines changed

src/bootstrap/native.rs

+2
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,10 @@ impl Step for Openssl {
596596
"arm-linux-androideabi" => "android",
597597
"arm-unknown-linux-gnueabi" => "linux-armv4",
598598
"arm-unknown-linux-gnueabihf" => "linux-armv4",
599+
"armv6-unknown-netbsd-eabihf" => "BSD-generic32",
599600
"armv7-linux-androideabi" => "android-armv7",
600601
"armv7-unknown-linux-gnueabihf" => "linux-armv4",
602+
"armv7-unknown-netbsd-eabihf" => "BSD-generic32",
601603
"i586-unknown-linux-gnu" => "linux-elf",
602604
"i586-unknown-linux-musl" => "linux-elf",
603605
"i686-apple-darwin" => "darwin-i386-cc",

src/etc/rust-gdb

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ GDB_PYTHON_MODULE_DIRECTORY="$RUSTC_SYSROOT/lib/rustlib/etc"
2121
# different/specific command (defaults to `gdb`).
2222
RUST_GDB="${RUST_GDB:-gdb}"
2323
PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" ${RUST_GDB} \
24-
-d "$GDB_PYTHON_MODULE_DIRECTORY" \
24+
--directory="$GDB_PYTHON_MODULE_DIRECTORY" \
2525
-iex "add-auto-load-safe-path $GDB_PYTHON_MODULE_DIRECTORY" \
2626
"$@"

src/libcore/str/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -2246,13 +2246,11 @@ impl str {
22462246
#[inline(always)]
22472247
#[rustc_const_unstable(feature="const_str_as_bytes")]
22482248
pub const fn as_bytes(&self) -> &[u8] {
2249-
unsafe {
2250-
union Slices<'a> {
2251-
str: &'a str,
2252-
slice: &'a [u8],
2253-
}
2254-
Slices { str: self }.slice
2249+
union Slices<'a> {
2250+
str: &'a str,
2251+
slice: &'a [u8],
22552252
}
2253+
unsafe { Slices { str: self }.slice }
22562254
}
22572255

22582256
/// Converts a mutable string slice to a mutable byte slice. To convert the

src/libpanic_unwind/gcc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const UNWIND_DATA_REG: (i32, i32) = (24, 25); // I0, I1
143143
// The personality routine for most of our targets, except ARM, which has a slightly different ABI
144144
// (however, iOS goes here as it uses SjLj unwinding). Also, the 64-bit Windows implementation
145145
// lives in seh64_gnu.rs
146-
#[cfg(all(any(target_os = "ios", not(target_arch = "arm"))))]
146+
#[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm"))))]
147147
#[lang = "eh_personality"]
148148
#[no_mangle]
149149
#[allow(unused)]
@@ -184,7 +184,7 @@ unsafe extern "C" fn rust_eh_personality(version: c_int,
184184

185185
// ARM EHABI personality routine.
186186
// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf
187-
#[cfg(all(target_arch = "arm", not(target_os = "ios")))]
187+
#[cfg(all(target_arch = "arm", not(target_os = "ios"), not(target_os = "netbsd")))]
188188
#[lang = "eh_personality"]
189189
#[no_mangle]
190190
unsafe extern "C" fn rust_eh_personality(state: uw::_Unwind_State,

src/librustc/middle/liveness.rs

+14-20
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
//! enclosing function. On the way down the tree, it identifies those AST
5252
//! nodes and variable IDs that will be needed for the liveness analysis
5353
//! and assigns them contiguous IDs. The liveness id for an AST node is
54-
//! called a `live_node` (it's a newtype'd usize) and the id for a variable
55-
//! is called a `variable` (another newtype'd usize).
54+
//! called a `live_node` (it's a newtype'd u32) and the id for a variable
55+
//! is called a `variable` (another newtype'd u32).
5656
//!
5757
//! On the way back up the tree, as we are about to exit from a function
5858
//! declaration we allocate a `liveness` instance. Now that we know
@@ -112,7 +112,7 @@ use lint;
112112
use util::nodemap::{NodeMap, NodeSet};
113113

114114
use std::collections::VecDeque;
115-
use std::{fmt, usize};
115+
use std::{fmt, u32};
116116
use std::io::prelude::*;
117117
use std::io;
118118
use std::rc::Rc;
@@ -134,23 +134,17 @@ enum LoopKind<'a> {
134134
}
135135

136136
#[derive(Copy, Clone, PartialEq)]
137-
struct Variable(usize);
137+
struct Variable(u32);
138138

139-
#[derive(Copy, PartialEq)]
140-
struct LiveNode(usize);
139+
#[derive(Copy, Clone, PartialEq)]
140+
struct LiveNode(u32);
141141

142142
impl Variable {
143-
fn get(&self) -> usize { let Variable(v) = *self; v }
143+
fn get(&self) -> usize { self.0 as usize }
144144
}
145145

146146
impl LiveNode {
147-
fn get(&self) -> usize { let LiveNode(v) = *self; v }
148-
}
149-
150-
impl Clone for LiveNode {
151-
fn clone(&self) -> LiveNode {
152-
LiveNode(self.get())
153-
}
147+
fn get(&self) -> usize { self.0 as usize }
154148
}
155149

156150
#[derive(Copy, Clone, PartialEq, Debug)]
@@ -233,11 +227,11 @@ impl fmt::Debug for Variable {
233227

234228
impl LiveNode {
235229
fn is_valid(&self) -> bool {
236-
self.get() != usize::MAX
230+
self.0 != u32::MAX
237231
}
238232
}
239233

240-
fn invalid_node() -> LiveNode { LiveNode(usize::MAX) }
234+
fn invalid_node() -> LiveNode { LiveNode(u32::MAX) }
241235

242236
struct CaptureInfo {
243237
ln: LiveNode,
@@ -285,7 +279,7 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
285279
}
286280

287281
fn add_live_node(&mut self, lnk: LiveNodeKind) -> LiveNode {
288-
let ln = LiveNode(self.num_live_nodes);
282+
let ln = LiveNode(self.num_live_nodes as u32);
289283
self.lnks.push(lnk);
290284
self.num_live_nodes += 1;
291285

@@ -303,7 +297,7 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> {
303297
}
304298

305299
fn add_variable(&mut self, vk: VarKind) -> Variable {
306-
let v = Variable(self.num_vars);
300+
let v = Variable(self.num_vars as u32);
307301
self.var_kinds.push(vk);
308302
self.num_vars += 1;
309303

@@ -708,7 +702,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
708702
for var_idx in 0..self.ir.num_vars {
709703
let idx = node_base_idx + var_idx;
710704
if test(idx).is_valid() {
711-
write!(wr, " {:?}", Variable(var_idx))?;
705+
write!(wr, " {:?}", Variable(var_idx as u32))?;
712706
}
713707
}
714708
Ok(())
@@ -848,7 +842,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
848842
debug!("^^ liveness computation results for body {} (entry={:?})",
849843
{
850844
for ln_idx in 0..self.ir.num_live_nodes {
851-
debug!("{:?}", self.ln_str(LiveNode(ln_idx)));
845+
debug!("{:?}", self.ln_str(LiveNode(ln_idx as u32)));
852846
}
853847
body.id
854848
},

src/librustc/session/config.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
13371337
"enable the experimental Chalk-based trait solving engine"),
13381338
cross_lang_lto: CrossLangLto = (CrossLangLto::Disabled, parse_cross_lang_lto, [TRACKED],
13391339
"generate build artifacts that are compatible with linker-based LTO."),
1340+
no_parallel_llvm: bool = (false, parse_bool, [UNTRACKED],
1341+
"don't run LLVM in parallel (while keeping codegen-units and ThinLTO)"),
13401342
}
13411343

13421344
pub fn default_lib_output() -> CrateType {

src/librustc/ty/maps/plumbing.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,16 @@ macro_rules! define_maps {
701701
})*
702702
}
703703

704+
// This module and the functions in it exist only to provide a
705+
// predictable symbol name prefix for query providers. This is helpful
706+
// for analyzing queries in profilers.
707+
pub(super) mod __query_compute {
708+
$(#[inline(never)]
709+
pub fn $name<F: FnOnce() -> R, R>(f: F) -> R {
710+
f()
711+
})*
712+
}
713+
704714
$(impl<$tcx> QueryConfig<$tcx> for queries::$name<$tcx> {
705715
type Key = $K;
706716
type Value = $V;
@@ -722,9 +732,12 @@ macro_rules! define_maps {
722732
DepNode::new(tcx, $node(*key))
723733
}
724734

735+
#[inline]
725736
fn compute(tcx: TyCtxt<'_, 'tcx, '_>, key: Self::Key) -> Self::Value {
726-
let provider = tcx.maps.providers[key.map_crate()].$name;
727-
provider(tcx.global_tcx(), key)
737+
__query_compute::$name(move || {
738+
let provider = tcx.maps.providers[key.map_crate()].$name;
739+
provider(tcx.global_tcx(), key)
740+
})
728741
}
729742

730743
fn handle_cycle_error(tcx: TyCtxt<'_, 'tcx, '_>) -> Self::Value {

src/librustc_codegen_llvm/back/write.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1738,7 +1738,9 @@ fn start_executing_work(tcx: TyCtxt,
17381738
.binary_search_by_key(&cost, |&(_, cost)| cost)
17391739
.unwrap_or_else(|e| e);
17401740
work_items.insert(insertion_index, (work, cost));
1741-
helper.request_token();
1741+
if !cgcx.opts.debugging_opts.no_parallel_llvm {
1742+
helper.request_token();
1743+
}
17421744
}
17431745
}
17441746

@@ -1842,7 +1844,9 @@ fn start_executing_work(tcx: TyCtxt,
18421844
};
18431845
work_items.insert(insertion_index, (llvm_work_item, cost));
18441846

1845-
helper.request_token();
1847+
if !cgcx.opts.debugging_opts.no_parallel_llvm {
1848+
helper.request_token();
1849+
}
18461850
assert_eq!(main_thread_worker_state,
18471851
MainThreadWorkerState::Codegenning);
18481852
main_thread_worker_state = MainThreadWorkerState::Idle;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
12+
13+
pub fn target() -> TargetResult {
14+
let mut base = super::netbsd_base::opts();
15+
base.max_atomic_width = Some(64);
16+
Ok(Target {
17+
llvm_target: "armv6-unknown-netbsdelf-eabihf".to_string(),
18+
target_endian: "little".to_string(),
19+
target_pointer_width: "32".to_string(),
20+
target_c_int_width: "32".to_string(),
21+
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
22+
arch: "arm".to_string(),
23+
target_os: "netbsd".to_string(),
24+
target_env: "eabihf".to_string(),
25+
target_vendor: "unknown".to_string(),
26+
linker_flavor: LinkerFlavor::Gcc,
27+
28+
options: TargetOptions {
29+
features: "+v6,+vfp2".to_string(),
30+
abi_blacklist: super::arm_base::abi_blacklist(),
31+
.. base
32+
}
33+
})
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
12+
13+
pub fn target() -> TargetResult {
14+
let base = super::netbsd_base::opts();
15+
Ok(Target {
16+
llvm_target: "armv7-unknown-netbsdelf-eabihf".to_string(),
17+
target_endian: "little".to_string(),
18+
target_pointer_width: "32".to_string(),
19+
target_c_int_width: "32".to_string(),
20+
data_layout: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64".to_string(),
21+
arch: "arm".to_string(),
22+
target_os: "netbsd".to_string(),
23+
target_env: "eabihf".to_string(),
24+
target_vendor: "unknown".to_string(),
25+
linker_flavor: LinkerFlavor::Gcc,
26+
27+
options: TargetOptions {
28+
features: "+v7,+vfp3,+d16,+thumb2,-neon".to_string(),
29+
cpu: "generic".to_string(),
30+
max_atomic_width: Some(64),
31+
abi_blacklist: super::arm_base::abi_blacklist(),
32+
.. base
33+
}
34+
})
35+
}

src/librustc_target/spec/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ supported_targets! {
317317
("i686-unknown-openbsd", i686_unknown_openbsd),
318318
("x86_64-unknown-openbsd", x86_64_unknown_openbsd),
319319

320+
("armv6-unknown-netbsd-eabihf", armv6_unknown_netbsd_eabihf),
321+
("armv7-unknown-netbsd-eabihf", armv7_unknown_netbsd_eabihf),
320322
("i686-unknown-netbsd", i686_unknown_netbsd),
321323
("powerpc-unknown-netbsd", powerpc_unknown_netbsd),
322324
("sparc64-unknown-netbsd", sparc64_unknown_netbsd),

src/librustdoc/clean/inline.rs

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ pub fn try_inline(cx: &DocContext, def: Def, name: ast::Name, visited: &mut FxHa
9797
record_extern_fqn(cx, did, clean::TypeKind::Const);
9898
clean::ConstantItem(build_const(cx, did))
9999
}
100+
// Macros are eagerly inlined back in visit_ast, don't show their export statements
101+
// FIXME(50647): the eager inline does not take doc(hidden)/doc(no_inline) into account
102+
Def::Macro(..) => return Some(Vec::new()),
100103
_ => return None,
101104
};
102105
cx.renderinfo.borrow_mut().inlined.insert(did);

src/librustdoc/visit_ast.rs

+4
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
219219
if let Some(exports) = self.cx.tcx.module_exports(def_id) {
220220
for export in exports.iter().filter(|e| e.vis == Visibility::Public) {
221221
if let Def::Macro(def_id, ..) = export.def {
222+
// FIXME(50647): this eager macro inlining does not take
223+
// doc(hidden)/doc(no_inline) into account
222224
if def_id.krate == LOCAL_CRATE {
223225
continue // These are `krate.exported_macros`, handled in `self.visit()`.
224226
}
@@ -237,6 +239,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
237239
unreachable!()
238240
};
239241

242+
debug!("inlining macro {}", def.ident.name);
240243
om.macros.push(Macro {
241244
def_id,
242245
attrs: def.attrs.clone().into(),
@@ -561,6 +564,7 @@ impl<'a, 'tcx, 'rcx> RustdocVisitor<'a, 'tcx, 'rcx> {
561564

562565
// convert each exported_macro into a doc item
563566
fn visit_local_macro(&self, def: &hir::MacroDef) -> Macro {
567+
debug!("visit_local_macro: {}", def.name);
564568
let tts = def.body.trees().collect::<Vec<_>>();
565569
// Extract the spans of all matchers. They represent the "interface" of the macro.
566570
let matchers = tts.chunks(4).map(|arm| arm[0].span()).collect();

src/libsyntax/parse/parser.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1772,27 +1772,27 @@ impl<'a> Parser<'a> {
17721772
pub fn parse_arg_general(&mut self, require_name: bool) -> PResult<'a, Arg> {
17731773
maybe_whole!(self, NtArg, |x| x);
17741774

1775-
let pat = if require_name || self.is_named_argument() {
1775+
let (pat, ty) = if require_name || self.is_named_argument() {
17761776
debug!("parse_arg_general parse_pat (require_name:{})",
17771777
require_name);
17781778
let pat = self.parse_pat()?;
17791779

17801780
self.expect(&token::Colon)?;
1781-
pat
1781+
(pat, self.parse_ty()?)
17821782
} else {
17831783
debug!("parse_arg_general ident_to_pat");
17841784
let ident = Ident::new(keywords::Invalid.name(), self.prev_span);
1785-
P(Pat {
1785+
let ty = self.parse_ty()?;
1786+
let pat = P(Pat {
17861787
id: ast::DUMMY_NODE_ID,
17871788
node: PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None),
1788-
span: ident.span,
1789-
})
1789+
span: ty.span,
1790+
});
1791+
(pat, ty)
17901792
};
17911793

1792-
let t = self.parse_ty()?;
1793-
17941794
Ok(Arg {
1795-
ty: t,
1795+
ty,
17961796
pat,
17971797
id: ast::DUMMY_NODE_ID,
17981798
})

src/libunwind/libunwind.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ extern "C" {
9393
}
9494

9595
cfg_if! {
96-
if #[cfg(all(any(target_os = "ios", not(target_arch = "arm"))))] {
96+
if #[cfg(all(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm"))))] {
9797
// Not ARM EHABI
9898
#[repr(C)]
9999
#[derive(Copy, Clone, PartialEq)]

src/test/rustdoc/pub-use-extern-macros.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
extern crate macros;
1616

1717
// @has pub_use_extern_macros/macro.bar.html
18+
// @!has pub_use_extern_macros/index.html '//code' 'pub use macros::bar;'
1819
pub use macros::bar;
1920

2021
// @has pub_use_extern_macros/macro.baz.html
21-
// @!has pub_use_extern_macros/index.html 'pub use macros::baz;'
22+
// @!has pub_use_extern_macros/index.html '//code' 'pub use macros::baz;'
2223
#[doc(inline)]
2324
pub use macros::baz;
2425

2526
// @has pub_use_extern_macros/macro.quux.html
26-
// @!has pub_use_extern_macros/index.html 'pub use macros::quux;'
27+
// @!has pub_use_extern_macros/index.html '//code' 'pub use macros::quux;'
2728
#[doc(hidden)]
2829
pub use macros::quux;

0 commit comments

Comments
 (0)