Skip to content

Commit eff3de0

Browse files
committed
Auto merge of #46904 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 5 pull requests - Successful merges: #46827, #46853, #46860, #46861, #46887 - Failed merges:
2 parents de38f49 + bdd3f5b commit eff3de0

File tree

16 files changed

+248
-99
lines changed

16 files changed

+248
-99
lines changed

src/librustc_mir/dataflow/impls/borrows.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
361361
}
362362
}
363363

364-
mir::StatementKind::Assign(_, ref rhs) => {
364+
mir::StatementKind::Assign(ref lhs, ref rhs) => {
365365
// NOTE: if/when the Assign case is revised to inspect
366366
// the assigned_place here, make sure to also
367367
// re-consider the current implementations of the
@@ -382,6 +382,22 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> {
382382
panic!("could not find BorrowIndexs for region {:?}", region);
383383
}).contains(&index));
384384
sets.gen(&ReserveOrActivateIndex::reserved(*index));
385+
386+
if is_activations {
387+
// Issue #46746: Two-phase borrows handles
388+
// stmts of form `Tmp = &mut Borrow` ...
389+
match lhs {
390+
Place::Local(..) => {} // okay
391+
Place::Static(..) => unreachable!(), // (filtered by is_unsafe_place)
392+
Place::Projection(..) => {
393+
// ... can assign into projections,
394+
// e.g. `box (&mut _)`. Current
395+
// conservative solution: force
396+
// immediate activation here.
397+
sets.gen(&ReserveOrActivateIndex::active(*index));
398+
}
399+
}
400+
}
385401
}
386402
}
387403

src/librustc_typeck/check/method/suggest.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
122122
impl_ty);
123123
if let Some(note_span) = note_span {
124124
// We have a span pointing to the method. Show note with snippet.
125-
err.span_note(note_span, &note_str);
125+
err.span_note(self.tcx.sess.codemap().def_span(note_span), &note_str);
126126
} else {
127127
err.note(&note_str);
128128
}
@@ -131,7 +131,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
131131
let item = self
132132
.associated_item(trait_did, item_name, Namespace::Value)
133133
.unwrap();
134-
let item_span = self.tcx.def_span(item.def_id);
134+
let item_span = self.tcx.sess.codemap()
135+
.def_span(self.tcx.def_span(item.def_id));
135136
span_note!(err,
136137
item_span,
137138
"candidate #{} is defined in the trait `{}`",

src/librustdoc/html/static/main.js

+17-9
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,32 @@
109109
function showSidebar() {
110110
var elems = document.getElementsByClassName("sidebar-elems")[0];
111111
if (elems) {
112-
elems.style.display = "block";
112+
addClass(elems, "show-it");
113113
}
114114
var sidebar = document.getElementsByClassName('sidebar')[0];
115-
sidebar.style.position = 'fixed';
116-
sidebar.style.width = '100%';
117-
sidebar.style.marginLeft = '0';
115+
if (sidebar) {
116+
addClass(sidebar, 'mobile');
117+
var filler = document.getElementById("sidebar-filler");
118+
if (!filler) {
119+
var div = document.createElement("div");
120+
div.id = "sidebar-filler";
121+
sidebar.appendChild(div);
122+
}
123+
}
118124
document.getElementsByTagName("body")[0].style.marginTop = '45px';
119125
}
120126

121127
function hideSidebar() {
122128
var elems = document.getElementsByClassName("sidebar-elems")[0];
123129
if (elems) {
124-
elems.style.display = "";
130+
removeClass(elems, "show-it");
125131
}
126132
var sidebar = document.getElementsByClassName('sidebar')[0];
127-
sidebar.style.position = '';
128-
sidebar.style.width = '';
129-
sidebar.style.marginLeft = '';
133+
removeClass(sidebar, 'mobile');
134+
var filler = document.getElementById("sidebar-filler");
135+
if (filler) {
136+
filler.remove();
137+
}
130138
document.getElementsByTagName("body")[0].style.marginTop = '';
131139
}
132140

@@ -1859,7 +1867,7 @@
18591867
if (sidebar_menu) {
18601868
sidebar_menu.onclick = function() {
18611869
var sidebar = document.getElementsByClassName('sidebar')[0];
1862-
if (sidebar.style.position === "fixed") {
1870+
if (hasClass(sidebar, "mobile") === true) {
18631871
hideSidebar();
18641872
} else {
18651873
showSidebar();

src/librustdoc/html/static/rustdoc.css

+27
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,33 @@ h4 > .important-traits {
10201020
#titles {
10211021
height: 50px;
10221022
}
1023+
1024+
.sidebar.mobile {
1025+
position: fixed;
1026+
width: 100%;
1027+
margin-left: 0;
1028+
background-color: rgba(0,0,0,0);
1029+
height: 100%;
1030+
}
1031+
1032+
.show-it {
1033+
display: block;
1034+
}
1035+
1036+
/* Because of ios, we need to actually have a full height sidebar title so the
1037+
* actual sidebar can show up. But then we need to make it transparent so we don't
1038+
* hide content. The filler just allows to create the background for the sidebar
1039+
* title. But because of the absolute position, I had to lower the z-index.
1040+
*/
1041+
#sidebar-filler {
1042+
position: fixed;
1043+
left: 45px;
1044+
width: calc(100% - 45px);
1045+
top: 0;
1046+
height: 45px;
1047+
z-index: -1;
1048+
border-bottom: 1px solid;
1049+
}
10231050
}
10241051

10251052

src/librustdoc/html/static/styles/main.css

+6-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ a.test-arrow {
191191

192192
#help > div {
193193
background: #e9e9e9;
194-
border-color: #bfbfbf;;
194+
border-color: #bfbfbf;
195195
}
196196

197197
#help dt {
@@ -342,4 +342,9 @@ pre.ignore:hover, .information:hover + pre.ignore {
342342
background-color: #F1F1F1;
343343
border-right-color: #000;
344344
}
345+
346+
#sidebar-filler {
347+
background-color: #F1F1F1;
348+
border-bottom-color: #e0e0e0;
349+
}
345350
}

src/libstd/io/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
441441
/// # }
442442
/// ```
443443
///
444-
/// Read from `&str` because [`&[u8]`] implements `Read`:
444+
/// Read from [`&str`] because [`&[u8]`][slice] implements `Read`:
445445
///
446446
/// ```
447447
/// # use std::io;
@@ -464,7 +464,8 @@ fn read_to_end<R: Read + ?Sized>(r: &mut R, buf: &mut Vec<u8>) -> Result<usize>
464464
/// [`File`]: ../fs/struct.File.html
465465
/// [`BufRead`]: trait.BufRead.html
466466
/// [`BufReader`]: struct.BufReader.html
467-
/// [`&[u8]`]: primitive.slice.html
467+
/// [`&str`]: ../../std/primitive.str.html
468+
/// [slice]: ../../std/primitive.slice.html
468469
#[stable(feature = "rust1", since = "1.0.0")]
469470
#[doc(spotlight)]
470471
pub trait Read {

src/libsyntax/ast.rs

+25-56
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use syntax_pos::{Span, DUMMY_SP};
2020
use codemap::{respan, Spanned};
2121
use abi::Abi;
2222
use ext::hygiene::{Mark, SyntaxContext};
23-
use parse::parser::{RecoverQPath, PathStyle};
2423
use print::pprust;
2524
use ptr::P;
2625
use rustc_data_structures::indexed_vec;
@@ -485,6 +484,30 @@ impl fmt::Debug for Pat {
485484
}
486485

487486
impl Pat {
487+
pub(super) fn to_ty(&self) -> Option<P<Ty>> {
488+
let node = match &self.node {
489+
PatKind::Wild => TyKind::Infer,
490+
PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None) =>
491+
TyKind::Path(None, Path::from_ident(ident.span, ident.node)),
492+
PatKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
493+
PatKind::Mac(mac) => TyKind::Mac(mac.clone()),
494+
PatKind::Ref(pat, mutbl) =>
495+
pat.to_ty().map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))?,
496+
PatKind::Slice(pats, None, _) if pats.len() == 1 =>
497+
pats[0].to_ty().map(TyKind::Slice)?,
498+
PatKind::Tuple(pats, None) => {
499+
let mut tys = Vec::new();
500+
for pat in pats {
501+
tys.push(pat.to_ty()?);
502+
}
503+
TyKind::Tup(tys)
504+
}
505+
_ => return None,
506+
};
507+
508+
Some(P(Ty { node, id: self.id, span: self.span }))
509+
}
510+
488511
pub fn walk<F>(&self, it: &mut F) -> bool
489512
where F: FnMut(&Pat) -> bool
490513
{
@@ -520,38 +543,6 @@ impl Pat {
520543
}
521544
}
522545

523-
impl RecoverQPath for Pat {
524-
fn to_ty(&self) -> Option<P<Ty>> {
525-
let node = match &self.node {
526-
PatKind::Wild => TyKind::Infer,
527-
PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None) =>
528-
TyKind::Path(None, Path::from_ident(ident.span, ident.node)),
529-
PatKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
530-
PatKind::Mac(mac) => TyKind::Mac(mac.clone()),
531-
PatKind::Ref(pat, mutbl) =>
532-
pat.to_ty().map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))?,
533-
PatKind::Slice(pats, None, _) if pats.len() == 1 =>
534-
pats[0].to_ty().map(TyKind::Slice)?,
535-
PatKind::Tuple(pats, None) => {
536-
let mut tys = Vec::new();
537-
for pat in pats {
538-
tys.push(pat.to_ty()?);
539-
}
540-
TyKind::Tup(tys)
541-
}
542-
_ => return None,
543-
};
544-
545-
Some(P(Ty { node, id: self.id, span: self.span }))
546-
}
547-
fn to_recovered(&self, qself: Option<QSelf>, path: Path) -> Self {
548-
Self { span: path.span, node: PatKind::Path(qself, path), id: self.id }
549-
}
550-
fn to_string(&self) -> String {
551-
pprust::pat_to_string(self)
552-
}
553-
}
554-
555546
/// A single field in a struct pattern
556547
///
557548
/// Patterns like the fields of Foo `{ x, ref y, ref mut z }`
@@ -919,10 +910,8 @@ impl Expr {
919910
_ => None,
920911
}
921912
}
922-
}
923913

924-
impl RecoverQPath for Expr {
925-
fn to_ty(&self) -> Option<P<Ty>> {
914+
pub(super) fn to_ty(&self) -> Option<P<Ty>> {
926915
let node = match &self.node {
927916
ExprKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
928917
ExprKind::Mac(mac) => TyKind::Mac(mac.clone()),
@@ -951,13 +940,6 @@ impl RecoverQPath for Expr {
951940

952941
Some(P(Ty { node, id: self.id, span: self.span }))
953942
}
954-
fn to_recovered(&self, qself: Option<QSelf>, path: Path) -> Self {
955-
Self { span: path.span, node: ExprKind::Path(qself, path),
956-
id: self.id, attrs: self.attrs.clone() }
957-
}
958-
fn to_string(&self) -> String {
959-
pprust::expr_to_string(self)
960-
}
961943
}
962944

963945
impl fmt::Debug for Expr {
@@ -1469,19 +1451,6 @@ pub struct Ty {
14691451
pub span: Span,
14701452
}
14711453

1472-
impl RecoverQPath for Ty {
1473-
fn to_ty(&self) -> Option<P<Ty>> {
1474-
Some(P(self.clone()))
1475-
}
1476-
fn to_recovered(&self, qself: Option<QSelf>, path: Path) -> Self {
1477-
Self { span: path.span, node: TyKind::Path(qself, path), id: self.id }
1478-
}
1479-
fn to_string(&self) -> String {
1480-
pprust::ty_to_string(self)
1481-
}
1482-
const PATH_STYLE: PathStyle = PathStyle::Type;
1483-
}
1484-
14851454
impl fmt::Debug for Ty {
14861455
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
14871456
write!(f, "type({})", pprust::ty_to_string(self))

0 commit comments

Comments
 (0)