Skip to content

Rollup of 14 pull requests #53049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8642412
Update libc and activate align feature
faern Jul 17, 2018
2b5fc66
Make Ipv{4,6}Addr::new const fns
faern Jul 19, 2018
0d2f96e
Move IPs to assoc consts
faern Jul 20, 2018
798680a
Add Ipv4Addr BROADCAST assoc const
faern Jul 29, 2018
312cdb4
Simplify is_broadcast
faern Jul 29, 2018
0da7da8
Align 6-week cycle check with beta promotion instead of stable release.
kennytm Aug 1, 2018
66a4718
rustbuild: fix local_rebuild
Keruspe Aug 2, 2018
0217459
Update LLVM submodule to 7.0
alexcrichton Aug 2, 2018
f3733a2
make `everybody_loops` keep item declarations
QuietMisdreavus Aug 2, 2018
3a93e91
Remove unnecessary local in await! macro
cramertj Aug 2, 2018
8df498b
more fixes for everybody_loops
QuietMisdreavus Aug 2, 2018
d6a7a3c
add rustdoc test for `everybody_loops` fix
QuietMisdreavus Aug 2, 2018
dda85ab
Stabilize --color and --error-format options in rustdoc
GuillaumeGomez Aug 2, 2018
23bdc82
RELEASES.md: fix the `hash_map::Entry::or_default` link
cuviper Aug 2, 2018
4471537
make TinyList more readable and optimize remove(_)
llogiq Aug 2, 2018
7e77d19
preserve order if blocks are between items
QuietMisdreavus Aug 2, 2018
71460d4
volatile operations docs: clarify that this does not help wrt. concur…
RalfJung Aug 3, 2018
94de821
Specify reentrancy gurantees of `Once::call_once`
matklad Aug 3, 2018
a2f9aaf
Fix trailnig WS
matklad Aug 3, 2018
d4beeca
Move validate_crate_name to rustc_metadata
Mark-Simulacrum Jul 31, 2018
cc1a6b9
Delete dummy crate store
Mark-Simulacrum Jul 31, 2018
eb0bc64
Visibility is now a query
Mark-Simulacrum Jul 31, 2018
5aec365
Store concrete crate stores where possible
Mark-Simulacrum Jul 31, 2018
6fdd6f6
Move unused trait functions to inherent functions
Mark-Simulacrum Jul 31, 2018
e2cda7d
Fix invalid code css rule
GuillaumeGomez Aug 3, 2018
903851f
Highlight closure spans for borrow and initialization errors
matthewjasper Aug 1, 2018
5639e21
Tests for closure spans
matthewjasper Aug 1, 2018
12af36a
Update tests for new spans for nll errors involving closures
matthewjasper Aug 1, 2018
a233ec8
Rollup merge of #52872 - faern:use-modern-alignment-libc, r=TimNN
cramertj Aug 3, 2018
4043448
Rollup merge of #52927 - Mark-Simulacrum:cratestore-cleanup, r=alexcr…
cramertj Aug 3, 2018
44a668b
Rollup merge of #52940 - kennytm:move-checktool-protection-week, r=al…
cramertj Aug 3, 2018
1923e0b
Rollup merge of #52959 - matthewjasper:closure-spans, r=pnkfelix
cramertj Aug 3, 2018
1c35e52
Rollup merge of #52969 - Keruspe:local_rebuild, r=alexcrichton
cramertj Aug 3, 2018
a635638
Rollup merge of #52983 - alexcrichton:update-llvm, r=kennytm
cramertj Aug 3, 2018
e44c046
Rollup merge of #52995 - cramertj:smaller-await, r=withoutboats
cramertj Aug 3, 2018
65e39b8
Rollup merge of #52996 - cuviper:1.28-or_default, r=Mark-Simulacrum
cramertj Aug 3, 2018
e492215
Rollup merge of #52997 - llogiq:tiny-list-opt, r=varkor
cramertj Aug 3, 2018
e764022
Rollup merge of #53002 - QuietMisdreavus:brother-may-i-have-some-loop…
cramertj Aug 3, 2018
6df26f4
Rollup merge of #53003 - GuillaumeGomez:stabilize-rustdoc-options, r=…
cramertj Aug 3, 2018
5ffeaa8
Rollup merge of #53022 - RalfJung:volatile, r=alexcrichton
cramertj Aug 3, 2018
0fbfdf6
Rollup merge of #53024 - matklad:patch-1, r=alexcrichton
cramertj Aug 3, 2018
290f9e9
Rollup merge of #53041 - GuillaumeGomez:fix-code-css-rule, r=QuietMis…
cramertj Aug 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#![feature(box_syntax)]
#![cfg_attr(unix, feature(libc))]
#![feature(option_replace)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(slice_sort_by_cached_key)]
Expand Down
102 changes: 78 additions & 24 deletions src/librustc_driver/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use syntax::fold::{self, Folder};
use syntax::print::{pprust};
use syntax::print::pprust::PrintState;
use syntax::ptr::P;
use syntax::util::ThinVec;
use syntax::util::small_vector::SmallVector;
use syntax_pos::{self, FileName};

Expand Down Expand Up @@ -650,18 +651,25 @@ impl UserIdentifiedItem {
// [#34511]: https://github.com/rust-lang/rust/issues/34511#issuecomment-322340401
pub struct ReplaceBodyWithLoop<'a> {
within_static_or_const: bool,
nested_blocks: Option<Vec<ast::Block>>,
sess: &'a Session,
}

impl<'a> ReplaceBodyWithLoop<'a> {
pub fn new(sess: &'a Session) -> ReplaceBodyWithLoop<'a> {
ReplaceBodyWithLoop { within_static_or_const: false, sess }
ReplaceBodyWithLoop {
within_static_or_const: false,
nested_blocks: None,
sess
}
}

fn run<R, F: FnOnce(&mut Self) -> R>(&mut self, is_const: bool, action: F) -> R {
let old_const = mem::replace(&mut self.within_static_or_const, is_const);
let old_blocks = self.nested_blocks.take();
let ret = action(self);
self.within_static_or_const = old_const;
self.nested_blocks = old_blocks;
ret
}

Expand Down Expand Up @@ -739,42 +747,88 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
self.run(is_const, |s| fold::noop_fold_impl_item(i, s))
}

fn fold_anon_const(&mut self, c: ast::AnonConst) -> ast::AnonConst {
self.run(true, |s| fold::noop_fold_anon_const(c, s))
}

fn fold_block(&mut self, b: P<ast::Block>) -> P<ast::Block> {
fn expr_to_block(rules: ast::BlockCheckMode,
fn stmt_to_block(rules: ast::BlockCheckMode,
recovered: bool,
e: Option<P<ast::Expr>>,
sess: &Session) -> P<ast::Block> {
P(ast::Block {
stmts: e.map(|e| {
ast::Stmt {
id: sess.next_node_id(),
span: e.span,
node: ast::StmtKind::Expr(e),
}
})
.into_iter()
.collect(),
s: Option<ast::Stmt>,
sess: &Session) -> ast::Block {
ast::Block {
stmts: s.into_iter().collect(),
rules,
id: sess.next_node_id(),
span: syntax_pos::DUMMY_SP,
recovered,
})
}
}

if !self.within_static_or_const {

let empty_block = expr_to_block(BlockCheckMode::Default, false, None, self.sess);
let loop_expr = P(ast::Expr {
node: ast::ExprKind::Loop(empty_block, None),
id: self.sess.next_node_id(),
fn block_to_stmt(b: ast::Block, sess: &Session) -> ast::Stmt {
let expr = P(ast::Expr {
id: sess.next_node_id(),
node: ast::ExprKind::Block(P(b), None),
span: syntax_pos::DUMMY_SP,
attrs: ast::ThinVec::new(),
attrs: ThinVec::new(),
});

expr_to_block(b.rules, b.recovered, Some(loop_expr), self.sess)
ast::Stmt {
id: sess.next_node_id(),
node: ast::StmtKind::Expr(expr),
span: syntax_pos::DUMMY_SP,
}
}

} else {
let empty_block = stmt_to_block(BlockCheckMode::Default, false, None, self.sess);
let loop_expr = P(ast::Expr {
node: ast::ExprKind::Loop(P(empty_block), None),
id: self.sess.next_node_id(),
span: syntax_pos::DUMMY_SP,
attrs: ast::ThinVec::new(),
});

let loop_stmt = ast::Stmt {
id: self.sess.next_node_id(),
span: syntax_pos::DUMMY_SP,
node: ast::StmtKind::Expr(loop_expr),
};

if self.within_static_or_const {
fold::noop_fold_block(b, self)
} else {
b.map(|b| {
let mut stmts = vec![];
for s in b.stmts {
let old_blocks = self.nested_blocks.replace(vec![]);

stmts.extend(self.fold_stmt(s).into_iter().filter(|s| s.is_item()));

// we put a Some in there earlier with that replace(), so this is valid
let new_blocks = self.nested_blocks.take().unwrap();
self.nested_blocks = old_blocks;
stmts.extend(new_blocks.into_iter().map(|b| block_to_stmt(b, &self.sess)));
}

let mut new_block = ast::Block {
stmts,
..b
};

if let Some(old_blocks) = self.nested_blocks.as_mut() {
//push our fresh block onto the cache and yield an empty block with `loop {}`
if !new_block.stmts.is_empty() {
old_blocks.push(new_block);
}

stmt_to_block(b.rules, b.recovered, Some(loop_stmt), self.sess)
} else {
//push `loop {}` onto the end of our fresh block and yield that
new_block.stmts.push(loop_stmt);

new_block
}
})
}
}

Expand Down
29 changes: 29 additions & 0 deletions src/test/rustdoc/traits-in-bodies.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//prior to fixing `everybody_loops` to preserve items, rustdoc would crash on this file, as it
//didn't see that `SomeStruct` implemented `Clone`

//FIXME(misdreavus): whenever rustdoc shows traits impl'd inside bodies, make sure this test
//reflects that

pub struct Bounded<T: Clone>(T);

pub struct SomeStruct;

fn asdf() -> Bounded<SomeStruct> {
impl Clone for SomeStruct {
fn clone(&self) -> SomeStruct {
SomeStruct
}
}

Bounded(SomeStruct)
}