Skip to content

Commit 49c67bd

Browse files
committed
Auto merge of #40806 - frewsxcv:rollup, r=frewsxcv
Rollup of 8 pull requests - Successful merges: #40567, #40602, #40636, #40739, #40756, #40790, #40794, #40803 - Failed merges:
2 parents 3da4023 + 6cd4660 commit 49c67bd

File tree

22 files changed

+188
-122
lines changed

22 files changed

+188
-122
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,13 @@ To save @bors some work, and to get small changes through more quickly, when
311311
the other rollup-eligible patches too, and they'll get tested and merged at
312312
the same time.
313313

314-
To find documentation-related issues, sort by the [A-docs label][adocs].
314+
To find documentation-related issues, sort by the [T-doc label][tdoc].
315315

316-
[adocs]: https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3AA-docs
316+
[tdoc]: https://github.com/rust-lang/rust/issues?q=is%3Aopen%20is%3Aissue%20label%3AT-doc
317+
318+
You can find documentation style guidelines in [RFC 1574][rfc1574].
319+
320+
[rfc1574]: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
317321

318322
In many cases, you don't need a full `./x.py doc`. You can use `rustdoc` directly
319323
to check small fixes. For example, `rustdoc src/doc/reference.md` will render

src/libcollections/btree/map.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ pub struct BTreeMap<K, V> {
141141
unsafe impl<#[may_dangle] K, #[may_dangle] V> Drop for BTreeMap<K, V> {
142142
fn drop(&mut self) {
143143
unsafe {
144-
for _ in ptr::read(self).into_iter() {
145-
}
144+
drop(ptr::read(self).into_iter());
146145
}
147146
}
148147
}

src/libcollections/slice.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ impl<T> [T] {
11621162
///
11631163
/// # Current implementation
11641164
///
1165-
/// The current algorithm is based on Orson Peters' [pdqsort][pattern-defeating quicksort],
1165+
/// The current algorithm is based on Orson Peters' [pattern-defeating quicksort][pdqsort],
11661166
/// which is a quicksort variant designed to be very fast on certain kinds of patterns,
11671167
/// sometimes achieving linear time. It is randomized but deterministic, and falls back to
11681168
/// heapsort on degenerate inputs.
@@ -1199,7 +1199,7 @@ impl<T> [T] {
11991199
///
12001200
/// # Current implementation
12011201
///
1202-
/// The current algorithm is based on Orson Peters' [pdqsort][pattern-defeating quicksort],
1202+
/// The current algorithm is based on Orson Peters' [pattern-defeating quicksort][pdqsort],
12031203
/// which is a quicksort variant designed to be very fast on certain kinds of patterns,
12041204
/// sometimes achieving linear time. It is randomized but deterministic, and falls back to
12051205
/// heapsort on degenerate inputs.
@@ -1239,7 +1239,7 @@ impl<T> [T] {
12391239
///
12401240
/// # Current implementation
12411241
///
1242-
/// The current algorithm is based on Orson Peters' [pdqsort][pattern-defeating quicksort],
1242+
/// The current algorithm is based on Orson Peters' [pattern-defeating quicksort][pdqsort],
12431243
/// which is a quicksort variant designed to be very fast on certain kinds of patterns,
12441244
/// sometimes achieving linear time. It is randomized but deterministic, and falls back to
12451245
/// heapsort on degenerate inputs.

src/librustc/mir/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -983,16 +983,16 @@ impl<'tcx> Debug for Operand<'tcx> {
983983
}
984984

985985
impl<'tcx> Operand<'tcx> {
986-
pub fn item<'a>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
987-
def_id: DefId,
988-
substs: &'tcx Substs<'tcx>,
989-
span: Span)
990-
-> Self
991-
{
986+
pub fn function_handle<'a>(
987+
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
988+
def_id: DefId,
989+
substs: &'tcx Substs<'tcx>,
990+
span: Span,
991+
) -> Self {
992992
Operand::Constant(Constant {
993993
span: span,
994994
ty: tcx.item_type(def_id).subst(tcx, substs),
995-
literal: Literal::Item { def_id, substs }
995+
literal: Literal::Value { value: ConstVal::Function(def_id, substs) },
996996
})
997997
}
998998

src/librustc_mir/build/scope.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ should go to.
8989
use build::{BlockAnd, BlockAndExtension, Builder, CFG};
9090
use rustc::middle::region::{CodeExtent, CodeExtentData};
9191
use rustc::middle::lang_items;
92+
use rustc::middle::const_val::ConstVal;
9293
use rustc::ty::subst::{Kind, Subst};
9394
use rustc::ty::{Ty, TyCtxt};
9495
use rustc::mir::*;
@@ -784,9 +785,8 @@ fn build_free<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
784785
func: Operand::Constant(Constant {
785786
span: data.span,
786787
ty: tcx.item_type(free_func).subst(tcx, substs),
787-
literal: Literal::Item {
788-
def_id: free_func,
789-
substs: substs
788+
literal: Literal::Value {
789+
value: ConstVal::Function(free_func, substs),
790790
}
791791
}),
792792
args: vec![Operand::Consume(data.value.clone())],

src/librustc_mir/hair/cx/expr.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -714,9 +714,8 @@ fn method_callee<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
714714
ty: callee.ty,
715715
span: expr.span,
716716
kind: ExprKind::Literal {
717-
literal: Literal::Item {
718-
def_id: callee.def_id,
719-
substs: callee.substs,
717+
literal: Literal::Value {
718+
value: ConstVal::Function(callee.def_id, callee.substs),
720719
},
721720
},
722721
}
@@ -743,22 +742,32 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
743742
-> ExprKind<'tcx> {
744743
let substs = cx.tables().node_id_item_substs(expr.id)
745744
.unwrap_or_else(|| cx.tcx.intern_substs(&[]));
746-
let def_id = match def {
745+
match def {
747746
// A regular function, constructor function or a constant.
748747
Def::Fn(def_id) |
749748
Def::Method(def_id) |
750749
Def::StructCtor(def_id, CtorKind::Fn) |
751-
Def::VariantCtor(def_id, CtorKind::Fn) |
750+
Def::VariantCtor(def_id, CtorKind::Fn) => ExprKind::Literal {
751+
literal: Literal::Value {
752+
value: ConstVal::Function(def_id, substs),
753+
},
754+
},
755+
752756
Def::Const(def_id) |
753-
Def::AssociatedConst(def_id) => def_id,
757+
Def::AssociatedConst(def_id) => ExprKind::Literal {
758+
literal: Literal::Item {
759+
def_id: def_id,
760+
substs: substs,
761+
},
762+
},
754763

755764
Def::StructCtor(def_id, CtorKind::Const) |
756765
Def::VariantCtor(def_id, CtorKind::Const) => {
757766
match cx.tables().node_id_to_type(expr.id).sty {
758767
// A unit struct/variant which is used as a value.
759768
// We return a completely different ExprKind here to account for this special case.
760769
ty::TyAdt(adt_def, substs) => {
761-
return ExprKind::Adt {
770+
ExprKind::Adt {
762771
adt_def: adt_def,
763772
variant_index: adt_def.variant_index_with_id(def_id),
764773
substs: substs,
@@ -770,17 +779,11 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
770779
}
771780
}
772781

773-
Def::Static(node_id, _) => return ExprKind::StaticRef { id: node_id },
782+
Def::Static(node_id, _) => ExprKind::StaticRef { id: node_id },
774783

775-
Def::Local(..) | Def::Upvar(..) => return convert_var(cx, expr, def),
784+
Def::Local(..) | Def::Upvar(..) => convert_var(cx, expr, def),
776785

777786
_ => span_bug!(expr.span, "def `{:?}` not yet implemented", def),
778-
};
779-
ExprKind::Literal {
780-
literal: Literal::Item {
781-
def_id: def_id,
782-
substs: substs,
783-
},
784787
}
785788
}
786789

src/librustc_mir/hair/cx/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,8 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
132132
let method_ty = self.tcx.item_type(item.def_id);
133133
let method_ty = method_ty.subst(self.tcx, substs);
134134
return (method_ty,
135-
Literal::Item {
136-
def_id: item.def_id,
137-
substs: substs,
135+
Literal::Value {
136+
value: ConstVal::Function(item.def_id, substs),
138137
});
139138
}
140139
}

src/librustc_mir/shim.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use rustc::hir;
1212
use rustc::hir::def_id::DefId;
1313
use rustc::infer;
1414
use rustc::middle::region::ROOT_CODE_EXTENT;
15+
use rustc::middle::const_val::ConstVal;
1516
use rustc::mir::*;
1617
use rustc::mir::transform::MirSource;
1718
use rustc::ty::{self, Ty};
@@ -335,7 +336,9 @@ fn build_call_shim<'a, 'tcx>(tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
335336
Operand::Constant(Constant {
336337
span: span,
337338
ty: tcx.item_type(def_id).subst(tcx, param_env.free_substs),
338-
literal: Literal::Item { def_id, substs: param_env.free_substs },
339+
literal: Literal::Value {
340+
value: ConstVal::Function(def_id, param_env.free_substs),
341+
},
339342
}),
340343
vec![rcvr]
341344
)

src/librustc_mir/transform/qualify_consts.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -568,11 +568,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> {
568568
});
569569
}
570570
Operand::Constant(ref constant) => {
571-
// Only functions and methods can have these types.
572-
if let ty::TyFnDef(..) = constant.ty.sty {
573-
return;
574-
}
575-
576571
if let Literal::Item { def_id, substs } = constant.literal {
577572
// Don't peek inside generic (associated) constants.
578573
if substs.types().next().is_some() {

src/librustc_mir/transform/type_check.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use rustc::infer::{self, InferCtxt, InferOk};
1515
use rustc::traits::{self, Reveal};
1616
use rustc::ty::fold::TypeFoldable;
1717
use rustc::ty::{self, Ty, TyCtxt, TypeVariants};
18+
use rustc::middle::const_val::ConstVal;
1819
use rustc::mir::*;
1920
use rustc::mir::tcx::LvalueTy;
2021
use rustc::mir::transform::{MirPass, MirSource, Pass};
@@ -526,7 +527,9 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
526527
fn is_box_free(&self, operand: &Operand<'tcx>) -> bool {
527528
match operand {
528529
&Operand::Constant(Constant {
529-
literal: Literal::Item { def_id, .. }, ..
530+
literal: Literal::Value {
531+
value: ConstVal::Function(def_id, _), ..
532+
}, ..
530533
}) => {
531534
Some(def_id) == self.tcx().lang_items.box_free_fn()
532535
}

0 commit comments

Comments
 (0)