Skip to content
Permalink
Browse files

Auto merge of #57607 - Centril:rollup, r=Centril

Rollup of 8 pull requests

Successful merges:

 - #57043 (Fix poor worst case performance of set intersection)
 - #57480 (Clean up and fix a bug in query plumbing)
 - #57481 (provide suggestion for invalid boolean cast)
 - #57540 (Modify some parser diagnostics to continue evaluating beyond the parser)
 - #57570 (Querify local `plugin_registrar_fn` and `proc_macro_decls_static`)
 - #57572 (Unaccept `extern_in_paths`)
 - #57585 (Recover from item trailing semicolon)
 - #57589 (Add a debug_assert to Vec::set_len)

Failed merges:

r? @ghost
  • Loading branch information...
bors committed Jan 14, 2019
2 parents 03acbd7 + 8a62e39 commit aea9f0aa976db2f5de28be3b6b287c6889cd926b
Showing with 715 additions and 496 deletions.
  1. +0 −40 src/doc/unstable-book/src/language-features/extern-in-paths.md
  2. +2 −0 src/liballoc/vec.rs
  3. +1 −1 src/librustc/middle/cstore.rs
  4. +0 −4 src/librustc/session/mod.rs
  5. +21 −20 src/librustc/ty/query/plumbing.rs
  6. +4 −6 src/librustc_codegen_ssa/back/symbol_export.rs
  7. +3 −3 src/librustc_codegen_utils/symbol_names.rs
  8. +10 −7 src/librustc_driver/driver.rs
  9. +21 −5 src/librustc_driver/proc_macro_decls.rs
  10. +2 −2 src/librustc_lint/builtin.rs
  11. +3 −6 src/librustc_metadata/encoder.rs
  12. +23 −8 src/librustc_plugin/build.rs
  13. +4 −5 src/librustc_resolve/lib.rs
  14. +22 −4 src/librustc_typeck/check/cast.rs
  15. +60 −7 src/libstd/collections/hash/set.rs
  16. +5 −24 src/libsyntax/feature_gate.rs
  17. +1 −1 src/libsyntax/parse/lexer/mod.rs
  18. +7 −1 src/libsyntax/parse/mod.rs
  19. +152 −63 src/libsyntax/parse/parser.rs
  20. +0 −1 src/libsyntax_pos/symbol.rs
  21. +1 −4 src/test/run-make-fulldeps/save-analysis-rfc2126/Makefile
  22. +0 −7 src/test/run-make-fulldeps/save-analysis-rfc2126/extern_in_paths.rs
  23. +0 −28 src/test/run-pass/rfcs/rfc-2126-extern-absolute-paths/extern.rs
  24. +1 −1 src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-1.stderr
  25. +1 −1 src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-2.stderr
  26. +3 −7 src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.rs
  27. +3 −3 src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.stderr
  28. +7 −2 src/test/ui/cast/cast-as-bool.rs
  29. +14 −4 src/test/ui/cast/cast-as-bool.stderr
  30. +1 −3 src/test/ui/cast/cast-rfc0401-2.stderr
  31. +1 −3 src/test/ui/error-codes/E0054.stderr
  32. +1 −3 src/test/ui/error-festival.stderr
  33. +0 −5 src/test/ui/feature-gates/feature-gate-extern_in_paths.rs
  34. +0 −11 src/test/ui/feature-gates/feature-gate-extern_in_paths.stderr
  35. +2 −1 src/test/ui/issues/issue-46186.rs
  36. +2 −2 src/test/ui/issues/issue-46186.stderr
  37. +1 −1 src/test/ui/issues/issue-49040.rs
  38. +7 −2 src/test/ui/issues/issue-49040.stderr
  39. +3 −0 src/test/ui/keyword/extern/keyword-extern-as-identifier-expr.rs
  40. +8 −0 src/test/ui/keyword/extern/keyword-extern-as-identifier-expr.stderr
  41. +3 −0 src/test/ui/keyword/extern/keyword-extern-as-identifier-pat.rs
  42. +8 −0 src/test/ui/keyword/extern/keyword-extern-as-identifier-pat.stderr
  43. +3 −0 src/test/ui/keyword/extern/keyword-extern-as-identifier-type.rs
  44. +8 −0 src/test/ui/keyword/extern/keyword-extern-as-identifier-type.stderr
  45. +3 −0 src/test/ui/keyword/extern/keyword-extern-as-identifier-use.rs
  46. +12 −0 src/test/ui/keyword/extern/keyword-extern-as-identifier-use.stderr
  47. +0 −5 src/test/ui/keyword/keyword-extern-as-identifier.rs
  48. +0 −9 src/test/ui/keyword/keyword-extern-as-identifier.stderr
  49. +1 −5 src/test/ui/mismatched_types/cast-rfc0401.stderr
  50. +2 −2 src/test/ui/old-suffixes-are-really-forbidden.stderr
  51. +12 −12 src/test/ui/parser/bad-lit-suffixes.stderr
  52. +1 −1 src/test/ui/parser/bad-pointer-type.rs
  53. +4 −2 src/test/ui/parser/bad-pointer-type.stderr
  54. +2 −2 src/test/ui/parser/impl-parsing.stderr
  55. +16 −5 src/test/ui/parser/issue-14303-fncall.rs
  56. +7 −3 src/test/ui/parser/issue-14303-fncall.stderr
  57. +10 −1 src/test/ui/parser/issue-14303-path.rs
  58. +9 −3 src/test/ui/parser/issue-14303-path.stderr
  59. +3 −4 src/test/ui/parser/issue-17383.rs
  60. +3 −3 src/test/ui/parser/issue-17383.stderr
  61. +4 −1 src/test/ui/parser/issue-1802-1.rs
  62. +1 −1 src/test/ui/parser/issue-1802-1.stderr
  63. +5 −2 src/test/ui/parser/issue-1802-2.rs
  64. +3 −3 src/test/ui/parser/issue-1802-2.stderr
  65. +8 −1 src/test/ui/parser/issue-27255.rs
  66. +18 −4 src/test/ui/parser/issue-27255.stderr
  67. +1 −1 src/test/ui/parser/issue-32214.stderr
  68. +3 −3 src/test/ui/parser/lex-bad-numeric-literals.stderr
  69. +3 −2 src/test/ui/parser/no-binary-float-literal.rs
  70. +16 −2 src/test/ui/parser/no-binary-float-literal.stderr
  71. +4 −2 src/test/ui/parser/no-hex-float-literal.rs
  72. +23 −2 src/test/ui/parser/no-hex-float-literal.stderr
  73. +6 −6 src/test/ui/parser/no-unsafe-self.stderr
  74. +3 −2 src/test/ui/parser/pat-tuple-2.rs
  75. +2 −2 src/test/ui/parser/pat-tuple-2.stderr
  76. +3 −2 src/test/ui/parser/pat-tuple-3.rs
  77. +2 −2 src/test/ui/parser/pat-tuple-3.stderr
  78. +8 −9 src/test/ui/parser/tag-variant-disr-non-nullary.rs
  79. +12 −3 src/test/ui/parser/tag-variant-disr-non-nullary.stderr
  80. +1 −0 src/test/ui/parser/where_with_bound.rs
  81. +9 −2 src/test/ui/parser/where_with_bound.stderr
  82. +0 −5 src/test/ui/rfc-2126-extern-in-paths/auxiliary/xcrate.rs
  83. +0 −5 src/test/ui/rfc-2126-extern-in-paths/non-existent-1.rs
  84. +0 −9 src/test/ui/rfc-2126-extern-in-paths/non-existent-1.stderr
  85. +0 −6 src/test/ui/rfc-2126-extern-in-paths/non-existent-2.rs
  86. +0 −9 src/test/ui/rfc-2126-extern-in-paths/non-existent-2.stderr
  87. +0 −5 src/test/ui/rfc-2126-extern-in-paths/non-existent-3.rs
  88. +0 −9 src/test/ui/rfc-2126-extern-in-paths/non-existent-3.stderr
  89. +0 −13 src/test/ui/rfc-2126-extern-in-paths/single-segment.rs
  90. +0 −22 src/test/ui/rfc-2126-extern-in-paths/single-segment.stderr
  91. +16 −0 src/test/ui/suggestions/recover-from-semicolon-trailing-item.rs
  92. +50 −0 src/test/ui/suggestions/recover-from-semicolon-trailing-item.stderr
  93. +0 −2 src/test/ui/traits/trait-object-vs-lifetime.rs
  94. +10 −6 src/test/ui/traits/trait-object-vs-lifetime.stderr

This file was deleted.

Oops, something went wrong.
@@ -819,6 +819,8 @@ impl<T> Vec<T> {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe fn set_len(&mut self, new_len: usize) {
debug_assert!(new_len <= self.capacity());

self.len = new_len;
}

@@ -140,7 +140,7 @@ pub enum ExternCrateSource {
),
// Crate is loaded by `use`.
Use,
/// Crate is implicitly loaded by an absolute or an `extern::` path.
/// Crate is implicitly loaded by an absolute path.
Path,
}

@@ -69,8 +69,6 @@ pub struct Session {
pub parse_sess: ParseSess,
/// For a library crate, this is always none
pub entry_fn: Once<Option<(NodeId, Span, config::EntryFnType)>>,
pub plugin_registrar_fn: Once<Option<ast::NodeId>>,
pub proc_macro_decls_static: Once<Option<ast::NodeId>>,
pub sysroot: PathBuf,
/// The name of the root source file of the crate, in the local file system.
/// `None` means that there is no source file.
@@ -1177,8 +1175,6 @@ pub fn build_session_(
parse_sess: p_s,
// For a library crate, this is always none
entry_fn: Once::new(),
plugin_registrar_fn: Once::new(),
proc_macro_decls_static: Once::new(),
sysroot,
local_crate_source_file,
working_dir,
@@ -402,7 +402,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
// expensive for some DepKinds.
if !self.dep_graph.is_fully_enabled() {
let null_dep_node = DepNode::new_no_params(::dep_graph::DepKind::Null);
return self.force_query_with_job::<Q>(key, job, null_dep_node).map(|(v, _)| v);
return Ok(self.force_query_with_job::<Q>(key, job, null_dep_node).0);
}

let dep_node = Q::to_dep_node(self, &key);
@@ -436,20 +436,18 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

if !dep_node.kind.is_input() {
if let Some(dep_node_index) = self.try_mark_green_and_read(&dep_node) {
return self.load_from_disk_and_cache_in_memory::<Q>(key,
job,
dep_node_index,
&dep_node)
return Ok(self.load_from_disk_and_cache_in_memory::<Q>(
key,
job,
dep_node_index,
&dep_node
))
}
}

match self.force_query_with_job::<Q>(key, job, dep_node) {
Ok((result, dep_node_index)) => {
self.dep_graph.read_index(dep_node_index);
Ok(result)
}
Err(e) => Err(e)
}
let (result, dep_node_index) = self.force_query_with_job::<Q>(key, job, dep_node);
self.dep_graph.read_index(dep_node_index);
Ok(result)
}

fn load_from_disk_and_cache_in_memory<Q: QueryDescription<'gcx>>(
@@ -458,7 +456,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
job: JobOwner<'a, 'gcx, Q>,
dep_node_index: DepNodeIndex,
dep_node: &DepNode
) -> Result<Q::Value, Box<CycleError<'gcx>>>
) -> Q::Value
{
// Note this function can be called concurrently from the same query
// We must ensure that this is handled correctly
@@ -523,7 +521,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

job.complete(&result, dep_node_index);

Ok(result)
result
}

#[inline(never)]
@@ -563,7 +561,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
key: Q::Key,
job: JobOwner<'_, 'gcx, Q>,
dep_node: DepNode)
-> Result<(Q::Value, DepNodeIndex), Box<CycleError<'gcx>>> {
-> (Q::Value, DepNodeIndex) {
// If the following assertion triggers, it can have two reasons:
// 1. Something is wrong with DepNode creation, either here or
// in DepGraph::try_mark_green()
@@ -610,7 +608,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {

job.complete(&result, dep_node_index);

Ok((result, dep_node_index))
(result, dep_node_index)
}

/// Ensure that either this query has all green inputs or been executed.
@@ -657,11 +655,14 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
// Ensure that only one of them runs the query
let job = match JobOwner::try_get(self, span, &key) {
TryGetJob::NotYetStarted(job) => job,
TryGetJob::JobCompleted(_) => return,
TryGetJob::JobCompleted(result) => {
if let Err(e) = result {
self.report_cycle(e).emit();
}
return
}
};
if let Err(e) = self.force_query_with_job::<Q>(key, job, dep_node) {
self.report_cycle(e).emit();
}
self.force_query_with_job::<Q>(key, job, dep_node);
}

pub(super) fn try_get_query<Q: QueryDescription<'gcx>>(
@@ -147,14 +147,12 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
})
.collect();

if let Some(id) = *tcx.sess.proc_macro_decls_static.get() {
let def_id = tcx.hir().local_def_id(id);
reachable_non_generics.insert(def_id, SymbolExportLevel::C);
if let Some(id) = tcx.proc_macro_decls_static(LOCAL_CRATE) {
reachable_non_generics.insert(id, SymbolExportLevel::C);
}

if let Some(id) = *tcx.sess.plugin_registrar_fn.get() {
let def_id = tcx.hir().local_def_id(id);
reachable_non_generics.insert(def_id, SymbolExportLevel::C);
if let Some(id) = tcx.plugin_registrar_fn(LOCAL_CRATE) {
reachable_non_generics.insert(id, SymbolExportLevel::C);
}

Lrc::new(reachable_non_generics)
@@ -242,12 +242,12 @@ fn compute_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance

let node_id = tcx.hir().as_local_node_id(def_id);

if let Some(id) = node_id {
if *tcx.sess.plugin_registrar_fn.get() == Some(id) {
if def_id.is_local() {
if tcx.plugin_registrar_fn(LOCAL_CRATE) == Some(def_id) {
let disambiguator = tcx.sess.local_crate_disambiguator();
return tcx.sess.generate_plugin_registrar_symbol(disambiguator);
}
if *tcx.sess.proc_macro_decls_static.get() == Some(id) {
if tcx.proc_macro_decls_static(LOCAL_CRATE) == Some(def_id) {
let disambiguator = tcx.sess.local_crate_disambiguator();
return tcx.sess.generate_proc_macro_decls_symbol(disambiguator);
}
@@ -1158,6 +1158,8 @@ where
}

pub fn default_provide(providers: &mut ty::query::Providers) {
proc_macro_decls::provide(providers);
plugin::build::provide(providers);
hir::provide(providers);
borrowck::provide(providers);
mir::provide(providers);
@@ -1212,13 +1214,6 @@ where
middle::entry::find_entry_point(sess, &hir_map, name)
});

sess.plugin_registrar_fn
.set(time(sess, "looking for plugin registrar", || {
plugin::build::find_plugin_registrar(sess.diagnostic(), &hir_map)
}));
sess.proc_macro_decls_static
.set(proc_macro_decls::find(&hir_map));

let mut local_providers = ty::query::Providers::default();
default_provide(&mut local_providers);
codegen_backend.provide(&mut local_providers);
@@ -1248,6 +1243,14 @@ where
// tcx available.
time(sess, "dep graph tcx init", || rustc_incremental::dep_graph_tcx_init(tcx));

time(sess, "looking for plugin registrar", || {
plugin::build::find_plugin_registrar(tcx)
});

time(sess, "looking for derive registrar", || {
proc_macro_decls::find(tcx)
});

time(sess, "loop checking", || loops::check_crate(tcx));

time(sess, "attribute checking", || {
@@ -1,15 +1,25 @@
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::hir::map::Map;
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc::hir;
use rustc::ty::TyCtxt;
use rustc::ty::query::Providers;
use syntax::ast;
use syntax::attr;

pub fn find(hir_map: &Map) -> Option<ast::NodeId> {
let krate = hir_map.krate();
pub fn find<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> Option<DefId> {
tcx.proc_macro_decls_static(LOCAL_CRATE)
}

fn proc_macro_decls_static<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
cnum: CrateNum,
) -> Option<DefId> {
assert_eq!(cnum, LOCAL_CRATE);

let mut finder = Finder { decls: None };
krate.visit_all_item_likes(&mut finder);
finder.decls
tcx.hir().krate().visit_all_item_likes(&mut finder);

finder.decls.map(|id| tcx.hir().local_def_id(id))
}

struct Finder {
@@ -30,3 +40,9 @@ impl<'v> ItemLikeVisitor<'v> for Finder {
}
}

pub(crate) fn provide(providers: &mut Providers<'_>) {
*providers = Providers {
proc_macro_decls_static,
..*providers
};
}
@@ -19,7 +19,7 @@
//! a `pub fn new()`.

use rustc::hir::def::Def;
use rustc::hir::def_id::DefId;
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
use rustc::ty::{self, Ty};
use hir::Node;
use util::nodemap::NodeSet;
@@ -860,7 +860,7 @@ impl LintPass for PluginAsLibrary {

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
if cx.sess().plugin_registrar_fn.get().is_some() {
if cx.tcx.plugin_registrar_fn(LOCAL_CRATE).is_some() {
// We're compiling a plugin; it's fine to link other plugins.
return;
}
@@ -482,13 +482,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
has_global_allocator: has_global_allocator,
has_panic_handler: has_panic_handler,
has_default_lib_allocator: has_default_lib_allocator,
plugin_registrar_fn: tcx.sess
.plugin_registrar_fn
.get()
.map(|id| tcx.hir().local_def_id(id).index),
plugin_registrar_fn: tcx.plugin_registrar_fn(LOCAL_CRATE).map(|id| id.index),
proc_macro_decls_static: if is_proc_macro {
let id = tcx.sess.proc_macro_decls_static.get().unwrap();
Some(tcx.hir().local_def_id(id).index)
let id = tcx.proc_macro_decls_static(LOCAL_CRATE).unwrap();
Some(id.index)
} else {
None
},
@@ -2,11 +2,12 @@

use syntax::ast;
use syntax::attr;
use errors;
use syntax_pos::Span;
use rustc::hir::map::Map;
use rustc::hir::itemlikevisit::ItemLikeVisitor;
use rustc::hir;
use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
use rustc::ty::TyCtxt;
use rustc::ty::query::Providers;

struct RegistrarFinder {
registrars: Vec<(ast::NodeId, Span)> ,
@@ -30,21 +31,27 @@ impl<'v> ItemLikeVisitor<'v> for RegistrarFinder {
}

/// Find the function marked with `#[plugin_registrar]`, if any.
pub fn find_plugin_registrar(diagnostic: &errors::Handler,
hir_map: &Map)
-> Option<ast::NodeId> {
let krate = hir_map.krate();
pub fn find_plugin_registrar<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> Option<DefId> {
tcx.plugin_registrar_fn(LOCAL_CRATE)
}

fn plugin_registrar_fn<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
cnum: CrateNum,
) -> Option<DefId> {
assert_eq!(cnum, LOCAL_CRATE);

let mut finder = RegistrarFinder { registrars: Vec::new() };
krate.visit_all_item_likes(&mut finder);
tcx.hir().krate().visit_all_item_likes(&mut finder);

match finder.registrars.len() {
0 => None,
1 => {
let (node_id, _) = finder.registrars.pop().unwrap();
Some(node_id)
Some(tcx.hir().local_def_id(node_id))
},
_ => {
let diagnostic = tcx.sess.diagnostic();
let mut e = diagnostic.struct_err("multiple plugin registration functions found");
for &(_, span) in &finder.registrars {
e.span_note(span, "one is here");
@@ -55,3 +62,11 @@ pub fn find_plugin_registrar(diagnostic: &errors::Handler,
}
}
}


pub fn provide(providers: &mut Providers<'_>) {
*providers = Providers {
plugin_registrar_fn,
..*providers
};
}
Oops, something went wrong.

0 comments on commit aea9f0a

Please sign in to comment.
You can’t perform that action at this time.