Skip to content

Commit

Permalink
Auto merge of #41972 - frewsxcv:rollup, r=frewsxcv
Browse files Browse the repository at this point in the history
Rollup of 5 pull requests

- Successful merges: #41826, #41919, #41946, #41967, #41969
- Failed merges: #41939
  • Loading branch information
bors committed May 13, 2017
2 parents 77f1bec + 9d65556 commit 2a03443
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 27 deletions.
8 changes: 0 additions & 8 deletions src/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ exclude = [
"tools/rls",
]

# Curiously, compiletest will segfault if compiled with opt-level=3 on 64-bit
# MSVC when running the compile-fail test suite when a should-fail test panics.
# But hey if this is removed and it gets past the bots, sounds good to me.
[profile.release]
opt-level = 2
[profile.bench]
opt-level = 2

# These options are controlled from our rustc wrapper script, so turn them off
# here and have them controlled elsewhere.
[profile.dev]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ impl<'a> ast_visit::Visitor<'a> for EarlyContext<'a> {
run_lints!(self, check_ident, early_passes, sp, id);
}

fn visit_mod(&mut self, m: &'a ast::Mod, s: Span, n: ast::NodeId) {
fn visit_mod(&mut self, m: &'a ast::Mod, s: Span, _a: &[ast::Attribute], n: ast::NodeId) {
run_lints!(self, check_mod, early_passes, m, s, n);
ast_visit::walk_mod(self, m);
run_lints!(self, check_mod_post, early_passes, m, s, n);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/hir_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {

impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {

fn visit_mod(&mut self, m: &'v ast::Mod, _s: Span, _n: NodeId) {
fn visit_mod(&mut self, m: &'v ast::Mod, _s: Span, _a: &[ast::Attribute], _n: NodeId) {
self.record("Mod", Id::None, m);
ast_visit::walk_mod(self, m)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ pub struct ModData {
pub items: Vec<NodeId>,
pub visibility: Visibility,
pub docs: String,
pub sig: Signature,
pub sig: Option<Signature>,
pub attributes: Vec<Attribute>,
}

Expand Down
25 changes: 25 additions & 0 deletions src/librustc_save_analysis/dump_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,31 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
}

impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll, D> {
fn visit_mod(&mut self, m: &'l ast::Mod, span: Span, attrs: &[ast::Attribute], id: NodeId) {
// Since we handle explicit modules ourselves in visit_item, this should
// only get called for the root module of a crate.
assert_eq!(id, ast::CRATE_NODE_ID);

let qualname = format!("::{}", self.tcx.node_path_str(id));

let cm = self.tcx.sess.codemap();
let filename = cm.span_to_filename(span);
self.dumper.mod_data(ModData {
id: id,
name: String::new(),
qualname: qualname,
span: span,
scope: id,
filename: filename,
items: m.items.iter().map(|i| i.id).collect(),
visibility: Visibility::Public,
docs: docs_for_attrs(attrs),
sig: None,
attributes: attrs.to_owned(),
}.lower(self.tcx));
self.nest_scope(id, |v| visit::walk_mod(v, m));
}

fn visit_item(&mut self, item: &'l ast::Item) {
use syntax::ast::ItemKind::*;
self.process_macro_use(item.span, item.id);
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_save_analysis/external_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ pub struct ModData {
pub items: Vec<DefId>,
pub visibility: Visibility,
pub docs: String,
pub sig: Signature,
pub sig: Option<Signature>,
pub attributes: Vec<Attribute>,
}

Expand All @@ -410,7 +410,7 @@ impl Lower for data::ModData {
items: self.items.into_iter().map(|id| make_def_id(id, &tcx.hir)).collect(),
visibility: self.visibility,
docs: self.docs,
sig: self.sig.lower(tcx),
sig: self.sig.map(|s| s.lower(tcx)),
attributes: self.attributes.lower(tcx),
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/json_api_dumper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ impl Into<Option<Def>> for ModData {
parent: None,
decl_id: None,
docs: self.docs,
sig: Some(self.sig.into()),
sig: self.sig.map(|s| s.into()),
attributes: vec![],
}),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/json_dumper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl<'b, O: DumpOutput + 'b> Dump for JsonDumper<O> {
children: data.items.into_iter().map(|id| id_from_def_id(id)).collect(),
decl_id: None,
docs: data.docs,
sig: Some(data.sig.into()),
sig: data.sig.map(|s| s.into()),
attributes: data.attributes.into_iter().map(|a| a.into()).collect(),
};
if def.span.file_name.to_str().unwrap() != def.value {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_save_analysis/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
items: m.items.iter().map(|i| i.id).collect(),
visibility: From::from(&item.vis),
docs: docs_for_attrs(&item.attrs),
sig: self.sig_base(item),
sig: Some(self.sig_base(item)),
attributes: item.attrs.clone(),
}))
}
Expand Down
12 changes: 11 additions & 1 deletion src/librustdoc/externalfiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::io::prelude::*;
use std::io;
use std::path::Path;
use std::str;
use html::markdown::{Markdown, RenderType};

#[derive(Clone)]
pub struct ExternalHtml{
Expand All @@ -28,17 +29,26 @@ pub struct ExternalHtml{
}

impl ExternalHtml {
pub fn load(in_header: &[String], before_content: &[String], after_content: &[String])
pub fn load(in_header: &[String], before_content: &[String], after_content: &[String],
md_before_content: &[String], md_after_content: &[String], render: RenderType)
-> Option<ExternalHtml> {
load_external_files(in_header)
.and_then(|ih|
load_external_files(before_content)
.map(|bc| (ih, bc))
)
.and_then(|(ih, bc)|
load_external_files(md_before_content)
.map(|m_bc| (ih, format!("{}{}", bc, Markdown(&m_bc, render))))
)
.and_then(|(ih, bc)|
load_external_files(after_content)
.map(|ac| (ih, bc, ac))
)
.and_then(|(ih, bc, ac)|
load_external_files(md_after_content)
.map(|m_ac| (ih, bc, format!("{}{}", ac, Markdown(&m_ac, render))))
)
.map(|(ih, bc, ac)|
ExternalHtml {
in_header: ih,
Expand Down
13 changes: 12 additions & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ pub fn opts() -> Vec<RustcOptGroup> {
"files to include inline between the content and </body> of a rendered \
Markdown file or generated documentation",
"FILES")),
unstable(optmulti("", "markdown-before-content",
"files to include inline between <body> and the content of a rendered \
Markdown file or generated documentation",
"FILES")),
unstable(optmulti("", "markdown-after-content",
"files to include inline between the content and </body> of a rendered \
Markdown file or generated documentation",
"FILES")),
stable(optopt("", "markdown-playground-url",
"URL to send code snippets to", "URL")),
stable(optflag("", "markdown-no-toc", "don't include table of contents")),
Expand Down Expand Up @@ -275,7 +283,10 @@ pub fn main_args(args: &[String]) -> isize {
let external_html = match ExternalHtml::load(
&matches.opt_strs("html-in-header"),
&matches.opt_strs("html-before-content"),
&matches.opt_strs("html-after-content")) {
&matches.opt_strs("html-after-content"),
&matches.opt_strs("markdown-before-content"),
&matches.opt_strs("markdown-after-content"),
render_type) {
Some(eh) => eh,
None => return 3,
};
Expand Down
4 changes: 1 addition & 3 deletions src/libsyntax/parse/lexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,9 +754,7 @@ impl<'a> StringReader<'a> {
// integer literal followed by field/method access or a range pattern
// (`0..2` and `12.foo()`)
if self.ch_is('.') && !self.nextch_is('.') &&
!self.nextch()
.unwrap_or('\0')
.is_xid_start() {
!ident_start(self.nextch()) {
// might have stuff after the ., and if it does, it needs to start
// with a number
self.bump();
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/util/node_count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl<'ast> Visitor<'ast> for NodeCounter {
self.count += 1;
walk_ident(self, span, ident);
}
fn visit_mod(&mut self, m: &Mod, _s: Span, _n: NodeId) {
fn visit_mod(&mut self, m: &Mod, _s: Span, _a: &[Attribute], _n: NodeId) {
self.count += 1;
walk_mod(self, m)
}
Expand Down
8 changes: 5 additions & 3 deletions src/libsyntax/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ pub trait Visitor<'ast>: Sized {
fn visit_ident(&mut self, span: Span, ident: Ident) {
walk_ident(self, span, ident);
}
fn visit_mod(&mut self, m: &'ast Mod, _s: Span, _n: NodeId) { walk_mod(self, m) }
fn visit_mod(&mut self, m: &'ast Mod, _s: Span, _attrs: &[Attribute], _n: NodeId) {
walk_mod(self, m);
}
fn visit_foreign_item(&mut self, i: &'ast ForeignItem) { walk_foreign_item(self, i) }
fn visit_global_asm(&mut self, ga: &'ast GlobalAsm) { walk_global_asm(self, ga) }
fn visit_item(&mut self, i: &'ast Item) { walk_item(self, i) }
Expand Down Expand Up @@ -172,7 +174,7 @@ pub fn walk_ident<'a, V: Visitor<'a>>(visitor: &mut V, span: Span, ident: Ident)
}

pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) {
visitor.visit_mod(&krate.module, krate.span, CRATE_NODE_ID);
visitor.visit_mod(&krate.module, krate.span, &krate.attrs, CRATE_NODE_ID);
walk_list!(visitor, visit_attribute, &krate.attrs);
}

Expand Down Expand Up @@ -249,7 +251,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
item.id)
}
ItemKind::Mod(ref module) => {
visitor.visit_mod(module, item.span, item.id)
visitor.visit_mod(module, item.span, &item.attrs, item.id)
}
ItemKind::ForeignMod(ref foreign_module) => {
walk_list!(visitor, visit_foreign_item, &foreign_module.items);
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/proc_macro_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
visit::walk_item(self, item);
}

fn visit_mod(&mut self, m: &'a ast::Mod, _s: Span, id: NodeId) {
fn visit_mod(&mut self, m: &'a ast::Mod, _s: Span, _a: &[ast::Attribute], id: NodeId) {
let mut prev_in_root = self.in_root;
if id != ast::CRATE_NODE_ID {
prev_in_root = mem::replace(&mut self.in_root, false);
Expand Down
13 changes: 13 additions & 0 deletions src/test/parse-fail/underscore-suffix-for-float.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

fn main() {
let a = 42._; //~ ERROR unexpected token: `_`
}
19 changes: 19 additions & 0 deletions src/test/run-pass/underscore-method-after-integer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

trait Tr : Sized {
fn _method_on_numbers(self) {}
}

impl Tr for i32 {}

fn main() {
42._method_on_numbers();
}
2 changes: 1 addition & 1 deletion src/tools/rls
Submodule rls updated from 207c18 to 6fb840

0 comments on commit 2a03443

Please sign in to comment.