Skip to content

Commit e562b24

Browse files
committed
Auto merge of #62041 - Centril:rollup-95eeyx7, r=Centril
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
2 parents 8d6f4b9 + 64e5818 commit e562b24

File tree

87 files changed

+517
-390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+517
-390
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -3254,6 +3254,7 @@ dependencies = [
32543254
"minifier 0.0.30 (registry+https://github.com/rust-lang/crates.io-index)",
32553255
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
32563256
"pulldown-cmark 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
3257+
"rustc-rayon 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
32573258
"tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
32583259
]
32593260

src/doc/rustc/src/linker-plugin-lto.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ LLVM. However, the approximation is usually reliable.
100100

101101
The following table shows known good combinations of toolchain versions.
102102

103-
| | Clang 7 | Clang 8 |
103+
| | Clang 7 | Clang 8 |
104104
|-----------|-----------|-----------|
105105
| Rust 1.34 |||
106-
| Rust 1.35 || ✓(?) |
106+
| Rust 1.35 |||
107+
| Rust 1.36 |||
107108

108109
Note that the compatibility policy for this feature might change in the future.

src/liballoc/slice.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,9 @@ pub trait SliceConcatExt<T: ?Sized> {
581581
/// ```
582582
#[stable(feature = "rust1", since = "1.0.0")]
583583
#[rustc_deprecated(since = "1.3.0", reason = "renamed to join")]
584-
fn connect(&self, sep: &T) -> Self::Output;
584+
fn connect(&self, sep: &T) -> Self::Output {
585+
self.join(sep)
586+
}
585587
}
586588

587589
#[unstable(feature = "slice_concat_ext",
@@ -615,10 +617,6 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
615617
}
616618
result
617619
}
618-
619-
fn connect(&self, sep: &T) -> Vec<T> {
620-
self.join(sep)
621-
}
622620
}
623621

624622
////////////////////////////////////////////////////////////////////////////////

src/liballoc/str.rs

-4
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ impl<S: Borrow<str>> SliceConcatExt<str> for [S] {
8686
String::from_utf8_unchecked( join_generic_copy(self, sep.as_bytes()) )
8787
}
8888
}
89-
90-
fn connect(&self, sep: &str) -> String {
91-
self.join(sep)
92-
}
9389
}
9490

9591
macro_rules! spezialize_for_lengths {

src/librustc/hir/map/blocks.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::hir as ast;
1515
use crate::hir::map;
1616
use crate::hir::{Expr, FnDecl, Node};
1717
use crate::hir::intravisit::FnKind;
18-
use syntax::ast::{Attribute, Ident, NodeId};
18+
use syntax::ast::{Attribute, Ident};
1919
use syntax_pos::Span;
2020

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

8585
/// Attempts to construct a Code from presumed FnLike or Expr node input.
86-
pub fn from_node(map: &map::Map<'a>, id: NodeId) -> Option<Code<'a>> {
86+
pub fn from_node(map: &map::Map<'a>, id: ast::HirId) -> Option<Code<'a>> {
8787
match map.get(id) {
8888
map::Node::Block(_) => {
8989
// Use the parent, hopefully an expression node.
90-
Code::from_node(map, map.get_parent_node(id))
90+
Code::from_node(map, map.get_parent_node_by_hir_id(id))
9191
}
9292
map::Node::Expr(expr) => Some(Code::Expr(expr)),
9393
node => FnLikeNode::from_node(node).map(Code::FnLike)

src/librustc/hir/map/definitions.rs

-5
Original file line numberDiff line numberDiff line change
@@ -397,11 +397,6 @@ impl Definitions {
397397
self.node_to_hir_id[node_id]
398398
}
399399

400-
#[inline]
401-
pub fn def_index_to_node_id(&self, def_index: DefIndex) -> ast::NodeId {
402-
self.as_local_node_id(DefId::local(def_index)).unwrap()
403-
}
404-
405400
/// Retrieves the span of the given `DefId` if `DefId` is in the local crate, the span exists
406401
/// and it's not `DUMMY_SP`.
407402
#[inline]

src/librustc/hir/map/mod.rs

+16-35
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,8 @@ impl<'hir> Map<'hir> {
291291
self.definitions.def_index_to_hir_id(def_id.to_def_id().index)
292292
}
293293

294-
fn def_kind(&self, node_id: NodeId) -> Option<DefKind> {
295-
let node = if let Some(node) = self.find(node_id) {
294+
fn def_kind(&self, hir_id: HirId) -> Option<DefKind> {
295+
let node = if let Some(node) = self.find_by_hir_id(hir_id) {
296296
node
297297
} else {
298298
return None
@@ -347,7 +347,7 @@ impl<'hir> Map<'hir> {
347347
if variant_data.ctor_hir_id().is_none() {
348348
return None;
349349
}
350-
let ctor_of = match self.find(self.get_parent_node(node_id)) {
350+
let ctor_of = match self.find_by_hir_id(self.get_parent_node_by_hir_id(hir_id)) {
351351
Some(Node::Item(..)) => def::CtorOf::Struct,
352352
Some(Node::Variant(..)) => def::CtorOf::Variant,
353353
_ => unreachable!(),
@@ -458,7 +458,7 @@ impl<'hir> Map<'hir> {
458458
}
459459

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

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

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

563563
/// Retrieves the `Node` corresponding to `id`, panicking if it cannot be found.
564-
pub fn get(&self, id: NodeId) -> Node<'hir> {
565-
let hir_id = self.node_to_hir_id(id);
566-
self.get_by_hir_id(hir_id)
567-
}
568-
569-
// FIXME(@ljedrz): replace the `NodeId` variant.
570-
pub fn get_by_hir_id(&self, id: HirId) -> Node<'hir> {
564+
pub fn get(&self, id: HirId) -> Node<'hir> {
571565
// read recorded by `find`
572566
self.find_by_hir_id(id).unwrap_or_else(||
573567
bug!("couldn't find hir id {} in the HIR map", id))
574568
}
575569

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

580574
pub fn get_generics(&self, id: DefId) -> Option<&'hir Generics> {
@@ -846,7 +840,7 @@ impl<'hir> Map<'hir> {
846840
if scope == CRATE_HIR_ID {
847841
return Some(CRATE_HIR_ID);
848842
}
849-
match self.get_by_hir_id(scope) {
843+
match self.get(scope) {
850844
Node::Item(i) => {
851845
match i.node {
852846
ItemKind::Existential(ExistTy { impl_trait_fn: None, .. }) => {}
@@ -927,28 +921,15 @@ impl<'hir> Map<'hir> {
927921
}
928922
}
929923

930-
pub fn expect_expr(&self, id: NodeId) -> &'hir Expr {
931-
let hir_id = self.node_to_hir_id(id);
932-
self.expect_expr_by_hir_id(hir_id)
933-
}
934-
935-
// FIXME(@ljedrz): replace the `NodeId` variant.
936-
pub fn expect_expr_by_hir_id(&self, id: HirId) -> &'hir Expr {
924+
pub fn expect_expr(&self, id: HirId) -> &'hir Expr {
937925
match self.find_by_hir_id(id) { // read recorded by find
938926
Some(Node::Expr(expr)) => expr,
939927
_ => bug!("expected expr, found {}", self.node_to_string(id))
940928
}
941929
}
942930

943-
/// Returns the name associated with the given `NodeId`'s AST.
944-
pub fn name(&self, id: NodeId) -> Name {
945-
let hir_id = self.node_to_hir_id(id);
946-
self.name_by_hir_id(hir_id)
947-
}
948-
949-
// FIXME(@ljedrz): replace the `NodeId` variant.
950-
pub fn name_by_hir_id(&self, id: HirId) -> Name {
951-
match self.get_by_hir_id(id) {
931+
pub fn name(&self, id: HirId) -> Name {
932+
match self.get(id) {
952933
Node::Item(i) => i.ident.name,
953934
Node::ForeignItem(fi) => fi.ident.name,
954935
Node::ImplItem(ii) => ii.ident.name,
@@ -958,7 +939,7 @@ impl<'hir> Map<'hir> {
958939
Node::Lifetime(lt) => lt.name.ident().name,
959940
Node::GenericParam(param) => param.name.ident().name,
960941
Node::Binding(&Pat { node: PatKind::Binding(_, _, l, _), .. }) => l.name,
961-
Node::Ctor(..) => self.name_by_hir_id(self.get_parent_item(id)),
942+
Node::Ctor(..) => self.name(self.get_parent_item(id)),
962943
_ => bug!("no name for {}", self.node_to_string(id))
963944
}
964945
}
@@ -1080,7 +1061,7 @@ impl<'hir> Map<'hir> {
10801061
}
10811062

10821063
pub fn hir_to_pretty_string(&self, id: HirId) -> String {
1083-
print::to_string(self, |s| s.print_node(self.get_by_hir_id(id)))
1064+
print::to_string(self, |s| s.print_node(self.get(id)))
10841065
}
10851066
}
10861067

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

14081389
pub fn provide(providers: &mut Providers<'_>) {
14091390
providers.def_kind = |tcx, def_id| {
1410-
if let Some(node_id) = tcx.hir().as_local_node_id(def_id) {
1411-
tcx.hir().def_kind(node_id)
1391+
if let Some(hir_id) = tcx.hir().as_local_hir_id(def_id) {
1392+
tcx.hir().def_kind(hir_id)
14121393
} else {
14131394
bug!("calling local def_kind query provider for upstream DefId: {:?}",
14141395
def_id

src/librustc/infer/error_reporting/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
617617
}
618618
hir::MatchSource::TryDesugar => {
619619
if let Some(ty::error::ExpectedFound { expected, .. }) = exp_found {
620-
let discrim_expr = self.tcx.hir().expect_expr_by_hir_id(discrim_hir_id);
620+
let discrim_expr = self.tcx.hir().expect_expr(discrim_hir_id);
621621
let discrim_ty = if let hir::ExprKind::Call(_, args) = &discrim_expr.node {
622622
let arg_expr = args.first().expect("try desugaring call w/out arg");
623623
self.in_progress_tables.and_then(|tables| {
@@ -1335,7 +1335,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
13351335
// We do this to avoid suggesting code that ends up as `T: 'a'b`,
13361336
// instead we suggest `T: 'a + 'b` in that case.
13371337
let mut has_bounds = false;
1338-
if let Node::GenericParam(ref param) = hir.get_by_hir_id(id) {
1338+
if let Node::GenericParam(ref param) = hir.get(id) {
13391339
has_bounds = !param.bounds.is_empty();
13401340
}
13411341
let sp = hir.span(id);
@@ -1583,7 +1583,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15831583
format!(" for lifetime parameter `{}` in coherence check", name)
15841584
}
15851585
infer::UpvarRegion(ref upvar_id, _) => {
1586-
let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
1586+
let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
15871587
format!(" for capture of `{}` by closure", var_name)
15881588
}
15891589
infer::NLL(..) => bug!("NLL variable found in lexical phase"),

src/librustc/infer/error_reporting/need_type_info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
133133
};
134134

135135
if let Some(body_id) = body_id {
136-
let expr = self.tcx.hir().expect_expr_by_hir_id(body_id.hir_id);
136+
let expr = self.tcx.hir().expect_expr(body_id.hir_id);
137137
local_visitor.visit_expr(expr);
138138
}
139139

src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
2929
if let Some(anon_reg) = self.tcx().is_suitable_region(region) {
3030
let def_id = anon_reg.def_id;
3131
if let Some(hir_id) = self.tcx().hir().as_local_hir_id(def_id) {
32-
let fndecl = match self.tcx().hir().get_by_hir_id(hir_id) {
32+
let fndecl = match self.tcx().hir().get(hir_id) {
3333
Node::Item(&hir::Item {
3434
node: hir::ItemKind::Fn(ref fndecl, ..),
3535
..

src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
5252
if let Node::Expr(Expr {
5353
node: Closure(_, _, _, closure_span, None),
5454
..
55-
}) = hir.get_by_hir_id(hir_id) {
55+
}) = hir.get(hir_id) {
5656
let sup_sp = sup_origin.span();
5757
let origin_sp = origin.span();
5858
let mut err = self.tcx().sess.struct_span_err(

src/librustc/infer/error_reporting/note.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
3131
"...so that reference does not outlive borrowed content");
3232
}
3333
infer::ReborrowUpvar(span, ref upvar_id) => {
34-
let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
34+
let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
3535
err.span_note(span,
3636
&format!("...so that closure can access `{}`", var_name));
3737
}
@@ -163,7 +163,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
163163
err
164164
}
165165
infer::ReborrowUpvar(span, ref upvar_id) => {
166-
let var_name = self.tcx.hir().name_by_hir_id(upvar_id.var_path.hir_id);
166+
let var_name = self.tcx.hir().name(upvar_id.var_path.hir_id);
167167
let mut err = struct_span_err!(self.tcx.sess,
168168
span,
169169
E0313,

src/librustc/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ pub enum SubregionOrigin<'tcx> {
265265
DerefPointer(Span),
266266

267267
/// Closure bound must not outlive captured variables
268-
ClosureCapture(Span, ast::NodeId),
268+
ClosureCapture(Span, hir::HirId),
269269

270270
/// Index into slice must be within its lifetime
271271
IndexSlice(Span),

src/librustc/infer/opaque_types/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -945,8 +945,8 @@ pub fn may_define_existential_type(
945945
let mut hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
946946
trace!(
947947
"may_define_existential_type(def={:?}, opaque_node={:?})",
948-
tcx.hir().get_by_hir_id(hir_id),
949-
tcx.hir().get_by_hir_id(opaque_hir_id)
948+
tcx.hir().get(hir_id),
949+
tcx.hir().get(opaque_hir_id)
950950
);
951951

952952
// Named existential types can be defined by any siblings or children of siblings.

src/librustc/middle/liveness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
16301630
);
16311631

16321632
if self.ir.variable_is_shorthand(var) {
1633-
if let Node::Binding(pat) = self.ir.tcx.hir().get_by_hir_id(hir_id) {
1633+
if let Node::Binding(pat) = self.ir.tcx.hir().get(hir_id) {
16341634
// Handle `ref` and `ref mut`.
16351635
let spans = spans.iter()
16361636
.map(|_span| (pat.span, format!("{}: _", name)))

src/librustc/middle/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl MutabilityCategory {
344344
tables: &ty::TypeckTables<'_>,
345345
id: hir::HirId,
346346
) -> MutabilityCategory {
347-
let ret = match tcx.hir().get_by_hir_id(id) {
347+
let ret = match tcx.hir().get(id) {
348348
Node::Binding(p) => match p.node {
349349
PatKind::Binding(..) => {
350350
let bm = *tables.pat_binding_modes()

src/librustc/middle/region.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl Scope {
190190
}
191191
let span = tcx.hir().span(hir_id);
192192
if let ScopeData::Remainder(first_statement_index) = self.data {
193-
if let Node::Block(ref blk) = tcx.hir().get_by_hir_id(hir_id) {
193+
if let Node::Block(ref blk) = tcx.hir().get(hir_id) {
194194
// Want span for scope starting after the
195195
// indexed statement and ending at end of
196196
// `blk`; reuse span of `blk` and shift `lo`
@@ -1368,7 +1368,7 @@ fn region_scope_tree<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> &'tcx ScopeTree
13681368
// If the item is an associated const or a method,
13691369
// record its impl/trait parent, as it can also have
13701370
// lifetime parameters free in this body.
1371-
match tcx.hir().get_by_hir_id(id) {
1371+
match tcx.hir().get(id) {
13721372
Node::ImplItem(_) |
13731373
Node::TraitItem(_) => {
13741374
visitor.scope_tree.root_parent = Some(tcx.hir().get_parent_item(id));

0 commit comments

Comments
 (0)