Skip to content
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

Rollup of 12 pull requests #60296

Merged
merged 34 commits into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b2c0fd0
Remove redundant code in copy_clone_conditions
tmandry Apr 21, 2019
d676386
Fix index-page generation
GuillaumeGomez Apr 20, 2019
64f7ced
Derive Default instead of new in applicable lint
sd234678 Apr 24, 2019
ef37f38
Derive Default for EllipsisInclusiveRangePatterns
sd234678 Apr 24, 2019
a0e0849
Add Pin::{into_inner,into_inner_unchecked}
Nemo157 Apr 21, 2019
8ed2292
Set test flag when rustdoc is running with --test option
GuillaumeGomez Apr 13, 2019
459d677
Add test for rustdoc cfg(test) feature
GuillaumeGomez Apr 24, 2019
feb5a53
Prevent failure in case no space left on device in rustdoc
GuillaumeGomez Apr 5, 2019
f199627
Remove useless code and update index page test
GuillaumeGomez Apr 24, 2019
c75e089
chalkify: Add Copy/Clone builtins
tmandry Apr 22, 2019
56ab3e7
Add builtin impls for int and float inference vars in chalk
tmandry Apr 24, 2019
4bd36ab
Introduce hir::ExprKind::Use and employ in for loop desugaring.
Centril Apr 24, 2019
6aa5a5d
Improvement comment explanations
GuillaumeGomez Apr 25, 2019
72cda98
Implement Debug for Place using Place::iterate
spastorino Apr 24, 2019
d37f3fc
Add feature-gate for f16c target feature
gnzlbg Apr 25, 2019
976b3d1
Prevent const parameters having type parameters as types
varkor Apr 25, 2019
102f7a8
Make sure const params with type params don't cause errors without a …
varkor Apr 25, 2019
908a639
Add a test for const parameters with type parameters as types
varkor Apr 25, 2019
6b190d6
Do not ICE when checking types against foreign fn
estebank Apr 25, 2019
0a26789
Make `-Z allow-features` work for stdlib features
tmandry Apr 25, 2019
8f78736
Fix error code description
varkor Apr 25, 2019
6d7c794
Add comment explaining restriction
varkor Apr 25, 2019
294e89d
Rollup merge of #59734 - GuillaumeGomez:improve-rustdoc-failure, r=ol…
Centril Apr 26, 2019
09a7051
Rollup merge of #59940 - GuillaumeGomez:rustdoc-test, r=ollie27
Centril Apr 26, 2019
878a7d6
Rollup merge of #60134 - GuillaumeGomez:fix-index-page, r=Manishearth
Centril Apr 26, 2019
8bdb91d
Rollup merge of #60165 - Nemo157:pin-into-inner, r=cramertj
Centril Apr 26, 2019
77c5f55
Rollup merge of #60183 - tmandry:chalk-builtin-copy-clone, r=scalexm
Centril Apr 26, 2019
7560c15
Rollup merge of #60225 - Centril:hir-exprkind-use-in-for-loops, r=oli…
Centril Apr 26, 2019
4d9d849
Rollup merge of #60247 - spastorino:place2_3, r=oli-obk
Centril Apr 26, 2019
1738273
Rollup merge of #60259 - sd234678:60181-derive-default-lints, r=Centril
Centril Apr 26, 2019
4387f99
Rollup merge of #60267 - gnzlbg:f16c_target_feature, r=alexcrichton
Centril Apr 26, 2019
3a907ce
Rollup merge of #60284 - varkor:const-param-of-type-param, r=cramertj
Centril Apr 26, 2019
6664534
Rollup merge of #60285 - estebank:icent, r=varkor
Centril Apr 26, 2019
a133caa
Rollup merge of #60289 - tmandry:allow-features-include-std, r=cramertj
Centril Apr 26, 2019
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
6 changes: 3 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "minifier"
version = "0.0.29"
version = "0.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"macro-utils 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -3038,7 +3038,7 @@ dependencies = [
name = "rustdoc"
version = "0.0.0"
dependencies = [
"minifier 0.0.29 (registry+https://github.com/rust-lang/crates.io-index)",
"minifier 0.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pulldown-cmark 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down Expand Up @@ -4170,7 +4170,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39"
"checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff"
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
"checksum minifier 0.0.29 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4950cb2617b1933e2da0446e864dfe0d6a22c22ff72297996c46e6a63b210b"
"checksum minifier 0.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "4c909e78edf61f3aa0dd2086da168cdf304329044bbf248768ca3d20253ec8c0"
"checksum miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0300eafb20369952951699b68243ab4334f4b10a88f411c221d444b36c40e649"
"checksum miniz_oxide 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5ad30a47319c16cde58d0314f5d98202a80c9083b5f61178457403dfb14e509c"
"checksum miniz_oxide_c_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "28edaef377517fd9fe3e085c37d892ce7acd1fbeab9239c5a36eec352d8a8b7e"
Expand Down
34 changes: 34 additions & 0 deletions src/libcore/pin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,18 @@ where
// around pinning.
unsafe { Pin::new_unchecked(pointer) }
}

/// Unwraps this `Pin<P>` returning the underlying pointer.
///
/// This requires that the data inside this `Pin` is [`Unpin`] so that we
/// can ignore the pinning invariants when unwrapping it.
///
/// [`Unpin`]: ../../std/marker/trait.Unpin.html
#[unstable(feature = "pin_into_inner", issue = "60245")]
#[inline(always)]
pub fn into_inner(pin: Pin<P>) -> P {
pin.pointer
}
}

impl<P: Deref> Pin<P> {
Expand Down Expand Up @@ -434,6 +446,28 @@ impl<P: Deref> Pin<P> {
pub fn as_ref(self: &Pin<P>) -> Pin<&P::Target> {
unsafe { Pin::new_unchecked(&*self.pointer) }
}

/// Unwraps this `Pin<P>` returning the underlying pointer.
///
/// # Safety
///
/// This function is unsafe. You must guarantee that you will continue to
/// treat the pointer `P` as pinned after you call this function, so that
/// the invariants on the `Pin` type can be upheld. If the code using the
/// resulting `P` does not continue to maintain the pinning invariants that
/// is a violation of the API contract and may lead to undefined behavior in
/// later (safe) operations.
///
/// If the underlying data is [`Unpin`], [`Pin::into_inner`] should be used
/// instead.
///
/// [`Unpin`]: ../../std/marker/trait.Unpin.html
/// [`Pin::into_inner`]: #method.into_inner
#[unstable(feature = "pin_into_inner", issue = "60245")]
#[inline(always)]
pub unsafe fn into_inner_unchecked(pin: Pin<P>) -> P {
pin.pointer
}
}

impl<P: DerefMut> Pin<P> {
Expand Down
1 change: 1 addition & 0 deletions src/librustc/cfg/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
hir::ExprKind::AddrOf(_, ref e) |
hir::ExprKind::Cast(ref e, _) |
hir::ExprKind::Type(ref e, _) |
hir::ExprKind::Use(ref e) |
hir::ExprKind::Unary(_, ref e) |
hir::ExprKind::Field(ref e, _) |
hir::ExprKind::Yield(ref e) |
Expand Down
3 changes: 3 additions & 0 deletions src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,9 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
visitor.visit_expr(subexpression);
visitor.visit_ty(typ)
}
ExprKind::Use(ref subexpression) => {
visitor.visit_expr(subexpression);
}
ExprKind::If(ref head_expression, ref if_block, ref optional_else) => {
visitor.visit_expr(head_expression);
visitor.visit_expr(if_block);
Expand Down
45 changes: 16 additions & 29 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4738,16 +4738,11 @@ impl<'a> LoweringContext<'a> {
hir::MatchSource::ForLoopDesugar,
));

// `{ let _result = ...; _result }`
// Underscore prevents an `unused_variables` lint if the head diverges.
let result_ident = self.str_to_ident("_result");
let (let_stmt, let_stmt_binding) =
self.stmt_let(e.span, false, result_ident, match_expr);

let result = P(self.expr_ident(e.span, result_ident, let_stmt_binding));
let block = P(self.block_all(e.span, hir_vec![let_stmt], Some(result)));
// Add the attributes to the outer returned expr node.
return self.expr_block(block, e.attrs.clone());
// This is effectively `{ let _result = ...; _result }`.
// The construct was introduced in #21984.
// FIXME(60253): Is this still necessary?
// Also, add the attributes to the outer returned expr node.
return self.expr_use(head_sp, match_expr, e.attrs.clone())
}

// Desugar `ExprKind::Try`
Expand Down Expand Up @@ -5117,6 +5112,17 @@ impl<'a> LoweringContext<'a> {
)
}

/// Wrap the given `expr` in `hir::ExprKind::Use`.
///
/// In terms of drop order, it has the same effect as
/// wrapping `expr` in `{ let _t = $expr; _t }` but
/// should provide better compile-time performance.
///
/// The drop order can be important in e.g. `if expr { .. }`.
fn expr_use(&mut self, span: Span, expr: P<hir::Expr>, attrs: ThinVec<Attribute>) -> hir::Expr {
self.expr(span, hir::ExprKind::Use(expr), attrs)
}

fn expr_match(
&mut self,
span: Span,
Expand Down Expand Up @@ -5172,25 +5178,6 @@ impl<'a> LoweringContext<'a> {
}
}

fn stmt_let(
&mut self,
sp: Span,
mutbl: bool,
ident: Ident,
ex: P<hir::Expr>,
) -> (hir::Stmt, hir::HirId) {
let (pat, pat_hid) = if mutbl {
self.pat_ident_binding_mode(sp, ident, hir::BindingAnnotation::Mutable)
} else {
self.pat_ident(sp, ident)
};

(
self.stmt_let_pat(sp, Some(ex), pat, hir::LocalSource::Normal),
pat_hid,
)
}

fn block_expr(&mut self, expr: P<hir::Expr>) -> hir::Block {
self.block_all(expr.span, hir::HirVec::new(), Some(expr))
}
Expand Down
6 changes: 6 additions & 0 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,7 @@ impl Expr {
ExprKind::Unary(..) => ExprPrecedence::Unary,
ExprKind::Lit(_) => ExprPrecedence::Lit,
ExprKind::Type(..) | ExprKind::Cast(..) => ExprPrecedence::Cast,
ExprKind::Use(ref expr, ..) => expr.precedence(),
ExprKind::If(..) => ExprPrecedence::If,
ExprKind::While(..) => ExprPrecedence::While,
ExprKind::Loop(..) => ExprPrecedence::Loop,
Expand Down Expand Up @@ -1437,6 +1438,7 @@ impl Expr {
ExprKind::Binary(..) |
ExprKind::Yield(..) |
ExprKind::Cast(..) |
ExprKind::Use(..) |
ExprKind::Err => {
false
}
Expand Down Expand Up @@ -1486,6 +1488,10 @@ pub enum ExprKind {
Cast(P<Expr>, P<Ty>),
/// A type reference (e.g., `Foo`).
Type(P<Expr>, P<Ty>),
/// Semantically equivalent to `{ let _t = expr; _t }`.
/// Maps directly to `hair::ExprKind::Use`.
/// Only exists to tweak the drop order in HIR.
Use(P<Expr>),
/// An `if` block, with an optional else block.
///
/// I.e., `if <expr> { <expr> } else { <expr> }`.
Expand Down
53 changes: 40 additions & 13 deletions src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -995,23 +995,32 @@ impl<'a> State<'a> {
self.ann.post(self, AnnNode::SubItem(ii.hir_id))
}

pub fn print_local(
&mut self,
init: Option<&hir::Expr>,
decl: impl Fn(&mut Self) -> io::Result<()>
) -> io::Result<()> {
self.space_if_not_bol()?;
self.ibox(indent_unit)?;
self.word_nbsp("let")?;

self.ibox(indent_unit)?;
decl(self)?;
self.end()?;

if let Some(ref init) = init {
self.nbsp()?;
self.word_space("=")?;
self.print_expr(&init)?;
}
self.end()
}

pub fn print_stmt(&mut self, st: &hir::Stmt) -> io::Result<()> {
self.maybe_print_comment(st.span.lo())?;
match st.node {
hir::StmtKind::Local(ref loc) => {
self.space_if_not_bol()?;
self.ibox(indent_unit)?;
self.word_nbsp("let")?;

self.ibox(indent_unit)?;
self.print_local_decl(&loc)?;
self.end()?;
if let Some(ref init) = loc.init {
self.nbsp()?;
self.word_space("=")?;
self.print_expr(&init)?;
}
self.end()?
self.print_local(loc.init.deref(), |this| this.print_local_decl(&loc))?;
}
hir::StmtKind::Item(item) => {
self.ann.nested(self, Nested::Item(item))?
Expand Down Expand Up @@ -1379,6 +1388,24 @@ impl<'a> State<'a> {
self.word_space(":")?;
self.print_type(&ty)?;
}
hir::ExprKind::Use(ref init) => {
// Print `{`:
self.cbox(indent_unit)?;
self.ibox(0)?;
self.bopen()?;

// Print `let _t = $init;`:
let temp = ast::Ident::from_str("_t");
self.print_local(Some(init), |this| this.print_ident(temp))?;
self.s.word(";")?;

// Print `_t`:
self.space_if_not_bol()?;
self.print_ident(temp)?;

// Print `}`:
self.bclose_maybe_open(expr.span, indent_unit, true)?;
}
hir::ExprKind::If(ref test, ref blk, ref elseopt) => {
self.print_if(&test, &blk, elseopt.as_ref().map(|e| &**e))?;
}
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#![feature(box_syntax)]
#![feature(core_intrinsics)]
#![feature(drain_filter)]
#![feature(inner_deref)]
#![cfg_attr(windows, feature(libc))]
#![feature(never_type)]
#![feature(exhaustive_patterns)]
Expand Down
4 changes: 4 additions & 0 deletions src/librustc/middle/expr_use_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,10 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> {
self.consume_expr(&base);
}

hir::ExprKind::Use(ref expr) => {
self.consume_expr(&expr);
}

hir::ExprKind::AssignOp(_, ref lhs, ref rhs) => {
if self.mc.tables.is_method_call(expr) {
self.consume_expr(lhs);
Expand Down
8 changes: 5 additions & 3 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ fn visit_expr<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, expr: &'tcx Expr) {
hir::ExprKind::Binary(..) |
hir::ExprKind::AddrOf(..) |
hir::ExprKind::Cast(..) |
hir::ExprKind::Use(..) |
hir::ExprKind::Unary(..) |
hir::ExprKind::Break(..) |
hir::ExprKind::Continue(_) |
Expand Down Expand Up @@ -1221,6 +1222,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
hir::ExprKind::AddrOf(_, ref e) |
hir::ExprKind::Cast(ref e, _) |
hir::ExprKind::Type(ref e, _) |
hir::ExprKind::Use(ref e) |
hir::ExprKind::Unary(_, ref e) |
hir::ExprKind::Yield(ref e) |
hir::ExprKind::Repeat(ref e, _) => {
Expand Down Expand Up @@ -1524,9 +1526,9 @@ fn check_expr<'a, 'tcx>(this: &mut Liveness<'a, 'tcx>, expr: &'tcx Expr) {
hir::ExprKind::Match(..) | hir::ExprKind::While(..) | hir::ExprKind::Loop(..) |
hir::ExprKind::Index(..) | hir::ExprKind::Field(..) |
hir::ExprKind::Array(..) | hir::ExprKind::Tup(..) | hir::ExprKind::Binary(..) |
hir::ExprKind::Cast(..) | hir::ExprKind::Unary(..) | hir::ExprKind::Ret(..) |
hir::ExprKind::Break(..) | hir::ExprKind::Continue(..) | hir::ExprKind::Lit(_) |
hir::ExprKind::Block(..) | hir::ExprKind::AddrOf(..) |
hir::ExprKind::Cast(..) | hir::ExprKind::Use(..) | hir::ExprKind::Unary(..) |
hir::ExprKind::Ret(..) | hir::ExprKind::Break(..) | hir::ExprKind::Continue(..) |
hir::ExprKind::Lit(_) | hir::ExprKind::Block(..) | hir::ExprKind::AddrOf(..) |
hir::ExprKind::Struct(..) | hir::ExprKind::Repeat(..) |
hir::ExprKind::Closure(..) | hir::ExprKind::Path(_) | hir::ExprKind::Yield(..) |
hir::ExprKind::Box(..) | hir::ExprKind::Type(..) | hir::ExprKind::Err => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/mem_categorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
hir::ExprKind::Assign(..) | hir::ExprKind::AssignOp(..) |
hir::ExprKind::Closure(..) | hir::ExprKind::Ret(..) |
hir::ExprKind::Unary(..) | hir::ExprKind::Yield(..) |
hir::ExprKind::MethodCall(..) | hir::ExprKind::Cast(..) |
hir::ExprKind::MethodCall(..) | hir::ExprKind::Cast(..) | hir::ExprKind::Use(..) |
hir::ExprKind::Array(..) | hir::ExprKind::Tup(..) | hir::ExprKind::If(..) |
hir::ExprKind::Binary(..) | hir::ExprKind::While(..) |
hir::ExprKind::Block(..) | hir::ExprKind::Loop(..) | hir::ExprKind::Match(..) |
Expand Down
6 changes: 6 additions & 0 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,12 @@ fn resolve_expr<'a, 'tcx>(visitor: &mut RegionResolutionVisitor<'a, 'tcx>, expr:
visitor.cx.var_parent = visitor.cx.parent;
}

hir::ExprKind::Use(ref expr) => {
// `Use(expr)` does not denote a conditional scope.
// Rather, we want to achieve the same behavior as `{ let _t = expr; _t }`.
terminating(expr.hir_id.local_id);
}

hir::ExprKind::AssignOp(..) | hir::ExprKind::Index(..) |
hir::ExprKind::Unary(..) | hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) => {
// FIXME(https://github.com/rust-lang/rfcs/issues/811) Nested method calls
Expand Down
Loading