Skip to content

Commit 0576ac1

Browse files
committed
Auto merge of #59397 - kennytm:rollup, r=kennytm
Rollup of 7 pull requests Successful merges: - #59213 (Track changes to robots.txt) - #59239 (Remove inline assembly from hint::spin_loop) - #59251 (Use a valid name for graphviz graphs) - #59296 (Do not encode gensymed imports in metadata) - #59328 (Implement specialized nth_back() for Box and Windows.) - #59355 (Fix ICE with const generic param in struct) - #59377 (Correct minimum system LLVM version in tests)
2 parents c7b5f4d + 00478a0 commit 0576ac1

37 files changed

+233
-74
lines changed

src/doc/robots.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# NB: This file is not automatically deployed. After changes, it needs to be uploaded manually to doc.rust-lang.org
2+
User-agent: *
3+
Disallow: /0.3/
4+
Disallow: /0.4/
5+
Disallow: /0.5/
6+
Disallow: /0.6/
7+
Disallow: /0.7/
8+
Disallow: /0.8/
9+
Disallow: /0.9/
10+
Disallow: /0.10/
11+
Disallow: /0.11.0/
12+
Disallow: /0.12.0/
13+
Disallow: /1.0.0-alpha/
14+
Disallow: /1.0.0-alpha.2/
15+
Disallow: /1.0.0-beta/
16+
Disallow: /1.0.0-beta.2/
17+
Disallow: /1.0.0-beta.3/
18+
Disallow: /1.0.0-beta.4/
19+
Disallow: /1.0.0-beta.5/

src/liballoc/boxed.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,9 @@ impl<I: DoubleEndedIterator + ?Sized> DoubleEndedIterator for Box<I> {
677677
fn next_back(&mut self) -> Option<I::Item> {
678678
(**self).next_back()
679679
}
680+
fn nth_back(&mut self, n: usize) -> Option<I::Item> {
681+
(**self).nth_back(n)
682+
}
680683
}
681684
#[stable(feature = "rust1", since = "1.0.0")]
682685
impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {

src/liballoc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
#![feature(maybe_uninit, maybe_uninit_slice, maybe_uninit_array)]
116116
#![feature(alloc_layout_extra)]
117117
#![feature(try_trait)]
118+
#![feature(iter_nth_back)]
118119

119120
// Allow testing this library
120121

src/libcore/hint.rs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,32 @@ pub unsafe fn unreachable_unchecked() -> ! {
6262
#[inline]
6363
#[unstable(feature = "renamed_spin_loop", issue = "55002")]
6464
pub fn spin_loop() {
65-
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
66-
unsafe {
67-
asm!("pause" ::: "memory" : "volatile");
65+
#[cfg(
66+
all(
67+
any(target_arch = "x86", target_arch = "x86_64"),
68+
target_feature = "sse2"
69+
)
70+
)] {
71+
#[cfg(target_arch = "x86")] {
72+
unsafe { crate::arch::x86::_mm_pause() };
73+
}
74+
75+
#[cfg(target_arch = "x86_64")] {
76+
unsafe { crate::arch::x86_64::_mm_pause() };
77+
}
6878
}
6979

70-
#[cfg(target_arch = "aarch64")]
71-
unsafe {
72-
asm!("yield" ::: "memory" : "volatile");
80+
#[cfg(
81+
any(
82+
target_arch = "aarch64",
83+
all(target_arch = "arm", target_feature = "v6")
84+
)
85+
)] {
86+
#[cfg(target_arch = "aarch64")] {
87+
unsafe { crate::arch::aarch64::__yield() };
88+
}
89+
#[cfg(target_arch = "arm")] {
90+
unsafe { crate::arch::arm::__yield() };
91+
}
7392
}
7493
}

src/libcore/slice/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3867,6 +3867,19 @@ impl<'a, T> DoubleEndedIterator for Windows<'a, T> {
38673867
ret
38683868
}
38693869
}
3870+
3871+
#[inline]
3872+
fn nth_back(&mut self, n: usize) -> Option<Self::Item> {
3873+
let (end, overflow) = self.v.len().overflowing_sub(n);
3874+
if end < self.size || overflow {
3875+
self.v = &[];
3876+
None
3877+
} else {
3878+
let ret = &self.v[end-self.size..end];
3879+
self.v = &self.v[..end-1];
3880+
Some(ret)
3881+
}
3882+
}
38703883
}
38713884

38723885
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/tests/slice.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,19 @@ fn test_windows_nth() {
578578
assert_eq!(c2.next(), None);
579579
}
580580

581+
#[test]
582+
fn test_windows_nth_back() {
583+
let v: &[i32] = &[0, 1, 2, 3, 4, 5];
584+
let mut c = v.windows(2);
585+
assert_eq!(c.nth_back(2).unwrap()[0], 2);
586+
assert_eq!(c.next_back().unwrap()[1], 2);
587+
588+
let v2: &[i32] = &[0, 1, 2, 3, 4];
589+
let mut c2 = v2.windows(4);
590+
assert_eq!(c2.nth_back(1).unwrap()[1], 1);
591+
assert_eq!(c2.next_back(), None);
592+
}
593+
581594
#[test]
582595
fn test_windows_last() {
583596
let v: &[i32] = &[0, 1, 2, 3, 4, 5];

src/librustc_codegen_llvm/debuginfo/metadata.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,12 +1156,14 @@ fn prepare_union_metadata(
11561156
// Enums
11571157
//=-----------------------------------------------------------------------------
11581158

1159-
// DWARF variant support is only available starting in LLVM 7.
1159+
// DWARF variant support is only available starting in LLVM 8.
11601160
// Although the earlier enum debug info output did not work properly
11611161
// in all situations, it is better for the time being to continue to
11621162
// sometimes emit the old style rather than emit something completely
1163-
// useless when rust is compiled against LLVM 6 or older. This
1164-
// function decides which representation will be emitted.
1163+
// useless when rust is compiled against LLVM 6 or older. LLVM 7
1164+
// contains an early version of the DWARF variant support, and will
1165+
// crash when handling the new debug info format. This function
1166+
// decides which representation will be emitted.
11651167
fn use_enum_fallback(cx: &CodegenCx<'_, '_>) -> bool {
11661168
// On MSVC we have to use the fallback mode, because LLVM doesn't
11671169
// lower variant parts to PDB.

src/librustc_driver/pretty.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,10 +633,20 @@ fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
633633
let body = tcx.hir().body(body_id);
634634
let cfg = cfg::CFG::new(tcx, &body);
635635
let labelled_edges = mode != PpFlowGraphMode::UnlabelledEdges;
636+
let hir_id = code.id();
637+
// We have to disassemble the hir_id because name must be ASCII
638+
// alphanumeric. This does not appear in the rendered graph, so it does not
639+
// have to be user friendly.
640+
let name = format!(
641+
"hir_id_{}_{}_{}",
642+
hir_id.owner.address_space().index(),
643+
hir_id.owner.as_array_index(),
644+
hir_id.local_id.index(),
645+
);
636646
let lcfg = LabelledCFG {
637647
tcx,
638648
cfg: &cfg,
639-
name: format!("node_{}", code.id()),
649+
name,
640650
labelled_edges,
641651
};
642652

src/librustc_mir/borrow_check/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
156156
let mut flow_inits = FlowAtLocation::new(do_dataflow(
157157
tcx,
158158
mir,
159-
id,
159+
def_id,
160160
&attributes,
161161
&dead_unwinds,
162162
MaybeInitializedPlaces::new(tcx, mir, &mdpe),
@@ -191,7 +191,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
191191
let flow_borrows = FlowAtLocation::new(do_dataflow(
192192
tcx,
193193
mir,
194-
id,
194+
def_id,
195195
&attributes,
196196
&dead_unwinds,
197197
Borrows::new(tcx, mir, regioncx.clone(), &borrow_set),
@@ -200,7 +200,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
200200
let flow_uninits = FlowAtLocation::new(do_dataflow(
201201
tcx,
202202
mir,
203-
id,
203+
def_id,
204204
&attributes,
205205
&dead_unwinds,
206206
MaybeUninitializedPlaces::new(tcx, mir, &mdpe),
@@ -209,7 +209,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
209209
let flow_ever_inits = FlowAtLocation::new(do_dataflow(
210210
tcx,
211211
mir,
212-
id,
212+
def_id,
213213
&attributes,
214214
&dead_unwinds,
215215
EverInitializedPlaces::new(tcx, mir, &mdpe),

src/librustc_mir/dataflow/graphviz.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
//! Hook into libgraphviz for rendering dataflow graphs for MIR.
22
3-
use rustc::hir::HirId;
3+
use rustc::hir::def_id::DefId;
44
use rustc::mir::{BasicBlock, Mir};
55

66
use std::fs;
77
use std::io;
88
use std::marker::PhantomData;
99
use std::path::Path;
1010

11+
use crate::util::graphviz_safe_def_name;
12+
1113
use super::{BitDenotation, DataflowState};
1214
use super::DataflowBuilder;
1315
use super::DebugFormatted;
1416

1517
pub trait MirWithFlowState<'tcx> {
1618
type BD: BitDenotation<'tcx>;
17-
fn hir_id(&self) -> HirId;
19+
fn def_id(&self) -> DefId;
1820
fn mir(&self) -> &Mir<'tcx>;
1921
fn flow_state(&self) -> &DataflowState<'tcx, Self::BD>;
2022
}
@@ -23,7 +25,7 @@ impl<'a, 'tcx, BD> MirWithFlowState<'tcx> for DataflowBuilder<'a, 'tcx, BD>
2325
where BD: BitDenotation<'tcx>
2426
{
2527
type BD = BD;
26-
fn hir_id(&self) -> HirId { self.hir_id }
28+
fn def_id(&self) -> DefId { self.def_id }
2729
fn mir(&self) -> &Mir<'tcx> { self.flow_state.mir() }
2830
fn flow_state(&self) -> &DataflowState<'tcx, Self::BD> { &self.flow_state.flow_state }
2931
}
@@ -47,8 +49,8 @@ pub(crate) fn print_borrowck_graph_to<'a, 'tcx, BD, P>(
4749
let g = Graph { mbcx, phantom: PhantomData, render_idx };
4850
let mut v = Vec::new();
4951
dot::render(&g, &mut v)?;
50-
debug!("print_borrowck_graph_to path: {} hir_id: {}",
51-
path.display(), mbcx.hir_id);
52+
debug!("print_borrowck_graph_to path: {} def_id: {:?}",
53+
path.display(), mbcx.def_id);
5254
fs::write(path, v)
5355
}
5456

@@ -69,9 +71,8 @@ impl<'a, 'tcx, MWF, P> dot::Labeller<'a> for Graph<'a, 'tcx, MWF, P>
6971
type Node = Node;
7072
type Edge = Edge;
7173
fn graph_id(&self) -> dot::Id<'_> {
72-
dot::Id::new(format!("graph_for_node_{}",
73-
self.mbcx.hir_id()))
74-
.unwrap()
74+
let name = graphviz_safe_def_name(self.mbcx.def_id());
75+
dot::Id::new(format!("graph_for_def_id_{}", name)).unwrap()
7576
}
7677

7778
fn node_id(&self, n: &Node) -> dot::Id<'_> {

0 commit comments

Comments
 (0)