Skip to content

Commit

Permalink
Auto merge of #62041 - Centril:rollup-95eeyx7, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 9 pull requests

Successful merges:

 - #60971 (Add DocFS layer to rustdoc)
 - #61146 (SliceConcatExt::connect defaults to calling join)
 - #61181 (Fix theme-checker failure)
 - #61267 (rustc-book: Update the rustc/clang compatibility table for xLTO.)
 - #61270 (Remove warnings about incr. comp. generating less debugging output.)
 - #61681 (Changed the error message to more clearly explain what is allowed)
 - #61984 (More NodeId pruning)
 - #62016 (Add test for issue-27697)
 - #62019 (Remove needless lifetimes)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Jun 22, 2019
2 parents 8d6f4b9 + 64e5818 commit e562b24
Show file tree
Hide file tree
Showing 87 changed files with 517 additions and 390 deletions.
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3254,6 +3254,7 @@ dependencies = [
"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.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
]

Expand Down
5 changes: 3 additions & 2 deletions src/doc/rustc/src/linker-plugin-lto.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ LLVM. However, the approximation is usually reliable.

The following table shows known good combinations of toolchain versions.

| | Clang 7 | Clang 8 |
| | Clang 7 | Clang 8 |
|-----------|-----------|-----------|
| Rust 1.34 |||
| Rust 1.35 || ✓(?) |
| Rust 1.35 |||
| Rust 1.36 |||

Note that the compatibility policy for this feature might change in the future.
8 changes: 3 additions & 5 deletions src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,9 @@ pub trait SliceConcatExt<T: ?Sized> {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.3.0", reason = "renamed to join")]
fn connect(&self, sep: &T) -> Self::Output;
fn connect(&self, sep: &T) -> Self::Output {
self.join(sep)
}
}

#[unstable(feature = "slice_concat_ext",
Expand Down Expand Up @@ -615,10 +617,6 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
}
result
}

fn connect(&self, sep: &T) -> Vec<T> {
self.join(sep)
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 0 additions & 4 deletions src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ impl<S: Borrow<str>> SliceConcatExt<str> for [S] {
String::from_utf8_unchecked( join_generic_copy(self, sep.as_bytes()) )
}
}

fn connect(&self, sep: &str) -> String {
self.join(sep)
}
}

macro_rules! spezialize_for_lengths {
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/map/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::hir as ast;
use crate::hir::map;
use crate::hir::{Expr, FnDecl, Node};
use crate::hir::intravisit::FnKind;
use syntax::ast::{Attribute, Ident, NodeId};
use syntax::ast::{Attribute, Ident};
use syntax_pos::Span;

/// An FnLikeNode is a Node that is like a fn, in that it has a decl
Expand Down Expand Up @@ -83,11 +83,11 @@ impl<'a> Code<'a> {
}

/// Attempts to construct a Code from presumed FnLike or Expr node input.
pub fn from_node(map: &map::Map<'a>, id: NodeId) -> Option<Code<'a>> {
pub fn from_node(map: &map::Map<'a>, id: ast::HirId) -> Option<Code<'a>> {
match map.get(id) {
map::Node::Block(_) => {
// Use the parent, hopefully an expression node.
Code::from_node(map, map.get_parent_node(id))
Code::from_node(map, map.get_parent_node_by_hir_id(id))
}
map::Node::Expr(expr) => Some(Code::Expr(expr)),
node => FnLikeNode::from_node(node).map(Code::FnLike)
Expand Down
5 changes: 0 additions & 5 deletions src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,6 @@ impl Definitions {
self.node_to_hir_id[node_id]
}

#[inline]
pub fn def_index_to_node_id(&self, def_index: DefIndex) -> ast::NodeId {
self.as_local_node_id(DefId::local(def_index)).unwrap()
}

/// Retrieves the span of the given `DefId` if `DefId` is in the local crate, the span exists
/// and it's not `DUMMY_SP`.
#[inline]
Expand Down
51 changes: 16 additions & 35 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ impl<'hir> Map<'hir> {
self.definitions.def_index_to_hir_id(def_id.to_def_id().index)
}

fn def_kind(&self, node_id: NodeId) -> Option<DefKind> {
let node = if let Some(node) = self.find(node_id) {
fn def_kind(&self, hir_id: HirId) -> Option<DefKind> {
let node = if let Some(node) = self.find_by_hir_id(hir_id) {
node
} else {
return None
Expand Down Expand Up @@ -347,7 +347,7 @@ impl<'hir> Map<'hir> {
if variant_data.ctor_hir_id().is_none() {
return None;
}
let ctor_of = match self.find(self.get_parent_node(node_id)) {
let ctor_of = match self.find_by_hir_id(self.get_parent_node_by_hir_id(hir_id)) {
Some(Node::Item(..)) => def::CtorOf::Struct,
Some(Node::Variant(..)) => def::CtorOf::Variant,
_ => unreachable!(),
Expand Down Expand Up @@ -458,7 +458,7 @@ impl<'hir> Map<'hir> {
}

pub fn body_owner_kind(&self, id: HirId) -> BodyOwnerKind {
match self.get_by_hir_id(id) {
match self.get(id) {
Node::Item(&Item { node: ItemKind::Const(..), .. }) |
Node::TraitItem(&TraitItem { node: TraitItemKind::Const(..), .. }) |
Node::ImplItem(&ImplItem { node: ImplItemKind::Const(..), .. }) |
Expand All @@ -482,7 +482,7 @@ impl<'hir> Map<'hir> {
}

pub fn ty_param_owner(&self, id: HirId) -> HirId {
match self.get_by_hir_id(id) {
match self.get(id) {
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => id,
Node::GenericParam(_) => self.get_parent_node_by_hir_id(id),
Expand All @@ -491,7 +491,7 @@ impl<'hir> Map<'hir> {
}

pub fn ty_param_name(&self, id: HirId) -> Name {
match self.get_by_hir_id(id) {
match self.get(id) {
Node::Item(&Item { node: ItemKind::Trait(..), .. }) |
Node::Item(&Item { node: ItemKind::TraitAlias(..), .. }) => kw::SelfUpper,
Node::GenericParam(param) => param.name.ident().name,
Expand Down Expand Up @@ -561,20 +561,14 @@ impl<'hir> Map<'hir> {
}

/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
pub fn get(&self, id: NodeId) -> Node<'hir> {
let hir_id = self.node_to_hir_id(id);
self.get_by_hir_id(hir_id)
}

// FIXME(@ljedrz): replace the `NodeId` variant.
pub fn get_by_hir_id(&self, id: HirId) -> Node<'hir> {
pub fn get(&self, id: HirId) -> Node<'hir> {
// read recorded by `find`
self.find_by_hir_id(id).unwrap_or_else(||
bug!("couldn't find hir id {} in the HIR map", id))
}

pub fn get_if_local(&self, id: DefId) -> Option<Node<'hir>> {
self.as_local_node_id(id).map(|id| self.get(id)) // read recorded by `get`
self.as_local_hir_id(id).map(|id| self.get(id)) // read recorded by `get`
}

pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics> {
Expand Down Expand Up @@ -846,7 +840,7 @@ impl<'hir> Map<'hir> {
if scope == CRATE_HIR_ID {
return Some(CRATE_HIR_ID);
}
match self.get_by_hir_id(scope) {
match self.get(scope) {
Node::Item(i) => {
match i.node {
ItemKind::Existential(ExistTy { impl_trait_fn: None, .. }) => {}
Expand Down Expand Up @@ -927,28 +921,15 @@ impl<'hir> Map<'hir> {
}
}

pub fn expect_expr(&self, id: NodeId) -> &'hir Expr {
let hir_id = self.node_to_hir_id(id);
self.expect_expr_by_hir_id(hir_id)
}

// FIXME(@ljedrz): replace the `NodeId` variant.
pub fn expect_expr_by_hir_id(&self, id: HirId) -> &'hir Expr {
pub fn expect_expr(&self, id: HirId) -> &'hir Expr {
match self.find_by_hir_id(id) { // read recorded by find
Some(Node::Expr(expr)) => expr,
_ => bug!("expected expr, found {}", self.node_to_string(id))
}
}

/// Returns the name associated with the given `NodeId`'s AST.
pub fn name(&self, id: NodeId) -> Name {
let hir_id = self.node_to_hir_id(id);
self.name_by_hir_id(hir_id)
}

// FIXME(@ljedrz): replace the `NodeId` variant.
pub fn name_by_hir_id(&self, id: HirId) -> Name {
match self.get_by_hir_id(id) {
pub fn name(&self, id: HirId) -> Name {
match self.get(id) {
Node::Item(i) => i.ident.name,
Node::ForeignItem(fi) => fi.ident.name,
Node::ImplItem(ii) => ii.ident.name,
Expand All @@ -958,7 +939,7 @@ impl<'hir> Map<'hir> {
Node::Lifetime(lt) => lt.name.ident().name,
Node::GenericParam(param) => param.name.ident().name,
Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name,
Node::Ctor(..) => self.name_by_hir_id(self.get_parent_item(id)),
Node::Ctor(..) => self.name(self.get_parent_item(id)),
_ => bug!("no name for {}", self.node_to_string(id))
}
}
Expand Down Expand Up @@ -1080,7 +1061,7 @@ impl<'hir> Map<'hir> {
}

pub fn hir_to_pretty_string(&self, id: HirId) -> String {
print::to_string(self, |s| s.print_node(self.get_by_hir_id(id)))
print::to_string(self, |s| s.print_node(self.get(id)))
}
}

Expand Down Expand Up @@ -1407,8 +1388,8 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {

pub fn provide(providers: &mut Providers<'_>) {
providers.def_kind = |tcx, def_id| {
if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
tcx.hir().def_kind(node_id)
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
tcx.hir().def_kind(hir_id)
} else {
bug!("calling local def_kind query provider for upstream DefId: {:?}",
def_id
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
}
hir::MatchSource::TryDesugar => {
if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found {
let discrim_expr = self.tcx.hir().expect_expr_by_hir_id(discrim_hir_id);
let discrim_expr = self.tcx.hir().expect_expr(discrim_hir_id);
let discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.node {
let arg_expr = args.first().expect("try desugaring call w/out arg");
self.in_progress_tables.and_then(|tables| {
Expand Down Expand Up @@ -1335,7 +1335,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
// We do this to avoid suggesting code that ends up as `T: 'a'b`,
// instead we suggest `T: 'a + 'b` in that case.
let mut has_bounds = false;
if let Node::GenericParam(ref param) = hir.get_by_hir_id(id) {
if let Node::GenericParam(ref param) = hir.get(id) {
has_bounds = !param.bounds.is_empty();
}
let sp = hir.span(id);
Expand Down Expand Up @@ -1583,7 +1583,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
format!(" for lifetime parameter `{}` in coherence check", name)
}
infer::UpvarRegion(ref upvar_id, _) => {
let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
format!(" for capture of `{}` by closure", var_name)
}
infer::NLL(..) => bug!("NLL variable found in lexical phase"),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/error_reporting/need_type_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
};

if let Some(body_id) = body_id {
let expr = self.tcx.hir().expect_expr_by_hir_id(body_id.hir_id);
let expr = self.tcx.hir().expect_expr(body_id.hir_id);
local_visitor.visit_expr(expr);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
if let Some(anon_reg) = self.tcx().is_suitable_region(region) {
let def_id = anon_reg.def_id;
if let Some(hir_id) = self.tcx().hir().as_local_hir_id(def_id) {
let fndecl = match self.tcx().hir().get_by_hir_id(hir_id) {
let fndecl = match self.tcx().hir().get(hir_id) {
Node::Item(&hir::Item {
node: hir::ItemKind::Fn(ref fndecl, ..),
..
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
if let Node::Expr(Expr {
node: Closure(_, _, _, closure_span, None),
..
}) = hir.get_by_hir_id(hir_id) {
}) = hir.get(hir_id) {
let sup_sp = sup_origin.span();
let origin_sp = origin.span();
let mut err = self.tcx().sess.struct_span_err(
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/error_reporting/note.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
"...so that reference does not outlive borrowed content");
}
infer::ReborrowUpvar(span, ref upvar_id) => {
let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
err.span_note(span,
&format!("...so that closure can access `{}`", var_name));
}
Expand Down Expand Up @@ -163,7 +163,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
err
}
infer::ReborrowUpvar(span, ref upvar_id) => {
let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
let mut err = struct_span_err!(self.tcx.sess,
span,
E0313,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ pub enum SubregionOrigin<'tcx> {
DerefPointer(Span),

/// Closure bound must not outlive captured variables
ClosureCapture(Span, ast::NodeId),
ClosureCapture(Span, hir::HirId),

/// Index into slice must be within its lifetime
IndexSlice(Span),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,8 +945,8 @@ pub fn may_define_existential_type(
let mut hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
trace!(
"may_define_existential_type(def={:?}, opaque_node={:?})",
tcx.hir().get_by_hir_id(hir_id),
tcx.hir().get_by_hir_id(opaque_hir_id)
tcx.hir().get(hir_id),
tcx.hir().get(opaque_hir_id)
);

// Named existential types can be defined by any siblings or children of siblings.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
);

if self.ir.variable_is_shorthand(var) {
if let Node::Binding(pat) = self.ir.tcx.hir().get_by_hir_id(hir_id) {
if let Node::Binding(pat) = self.ir.tcx.hir().get(hir_id) {
// Handle `ref` and `ref mut`.
let spans = spans.iter()
.map(|_span| (pat.span, format!("{}: _", name)))
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 @@ -344,7 +344,7 @@ impl MutabilityCategory {
tables: &ty::TypeckTables<'_>,
id: hir::HirId,
) -> MutabilityCategory {
let ret = match tcx.hir().get_by_hir_id(id) {
let ret = match tcx.hir().get(id) {
Node::Binding(p) => match p.node {
PatKind::Binding(..) => {
let bm = *tables.pat_binding_modes()
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ impl Scope {
}
let span = tcx.hir().span(hir_id);
if let ScopeData::Remainder(first_statement_index) = self.data {
if let Node::Block(ref blk) = tcx.hir().get_by_hir_id(hir_id) {
if let Node::Block(ref blk) = tcx.hir().get(hir_id) {
// Want span for scope starting after the
// indexed statement and ending at end of
// `blk`; reuse span of `blk` and shift `lo`
Expand Down Expand Up @@ -1368,7 +1368,7 @@ fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ScopeTree
// If the item is an associated const or a method,
// record its impl/trait parent, as it can also have
// lifetime parameters free in this body.
match tcx.hir().get_by_hir_id(id) {
match tcx.hir().get(id) {
Node::ImplItem(_) |
Node::TraitItem(_) => {
visitor.scope_tree.root_parent = Some(tcx.hir().get_parent_item(id));
Expand Down
Loading

0 comments on commit e562b24

Please sign in to comment.