Skip to content

Commit 2a03443

Browse files
committed
Auto merge of #41972 - frewsxcv:rollup, r=frewsxcv
Rollup of 5 pull requests - Successful merges: #41826, #41919, #41946, #41967, #41969 - Failed merges: #41939
2 parents 77f1bec + 9d65556 commit 2a03443

File tree

18 files changed

+97
-27
lines changed

18 files changed

+97
-27
lines changed

src/Cargo.toml

-8
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,6 @@ exclude = [
2121
"tools/rls",
2222
]
2323

24-
# Curiously, compiletest will segfault if compiled with opt-level=3 on 64-bit
25-
# MSVC when running the compile-fail test suite when a should-fail test panics.
26-
# But hey if this is removed and it gets past the bots, sounds good to me.
27-
[profile.release]
28-
opt-level = 2
29-
[profile.bench]
30-
opt-level = 2
31-
3224
# These options are controlled from our rustc wrapper script, so turn them off
3325
# here and have them controlled elsewhere.
3426
[profile.dev]

src/librustc/lint/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1055,7 +1055,7 @@ impl<'a> ast_visit::Visitor<'a> for EarlyContext<'a> {
10551055
run_lints!(self, check_ident, early_passes, sp, id);
10561056
}
10571057

1058-
fn visit_mod(&mut self, m: &'a ast::Mod, s: Span, n: ast::NodeId) {
1058+
fn visit_mod(&mut self, m: &'a ast::Mod, s: Span, _a: &[ast::Attribute], n: ast::NodeId) {
10591059
run_lints!(self, check_mod, early_passes, m, s, n);
10601060
ast_visit::walk_mod(self, m);
10611061
run_lints!(self, check_mod_post, early_passes, m, s, n);

src/librustc_passes/hir_stats.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ impl<'v> hir_visit::Visitor<'v> for StatCollector<'v> {
252252

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

255-
fn visit_mod(&mut self, m: &'v ast::Mod, _s: Span, _n: NodeId) {
255+
fn visit_mod(&mut self, m: &'v ast::Mod, _s: Span, _a: &[ast::Attribute], _n: NodeId) {
256256
self.record("Mod", Id::None, m);
257257
ast_visit::walk_mod(self, m)
258258
}

src/librustc_save_analysis/data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ pub struct ModData {
267267
pub items: Vec<NodeId>,
268268
pub visibility: Visibility,
269269
pub docs: String,
270-
pub sig: Signature,
270+
pub sig: Option<Signature>,
271271
pub attributes: Vec<Attribute>,
272272
}
273273

src/librustc_save_analysis/dump_visitor.rs

+25
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,31 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
12111211
}
12121212

12131213
impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'l> for DumpVisitor<'l, 'tcx, 'll, D> {
1214+
fn visit_mod(&mut self, m: &'l ast::Mod, span: Span, attrs: &[ast::Attribute], id: NodeId) {
1215+
// Since we handle explicit modules ourselves in visit_item, this should
1216+
// only get called for the root module of a crate.
1217+
assert_eq!(id, ast::CRATE_NODE_ID);
1218+
1219+
let qualname = format!("::{}", self.tcx.node_path_str(id));
1220+
1221+
let cm = self.tcx.sess.codemap();
1222+
let filename = cm.span_to_filename(span);
1223+
self.dumper.mod_data(ModData {
1224+
id: id,
1225+
name: String::new(),
1226+
qualname: qualname,
1227+
span: span,
1228+
scope: id,
1229+
filename: filename,
1230+
items: m.items.iter().map(|i| i.id).collect(),
1231+
visibility: Visibility::Public,
1232+
docs: docs_for_attrs(attrs),
1233+
sig: None,
1234+
attributes: attrs.to_owned(),
1235+
}.lower(self.tcx));
1236+
self.nest_scope(id, |v| visit::walk_mod(v, m));
1237+
}
1238+
12141239
fn visit_item(&mut self, item: &'l ast::Item) {
12151240
use syntax::ast::ItemKind::*;
12161241
self.process_macro_use(item.span, item.id);

src/librustc_save_analysis/external_data.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ pub struct ModData {
392392
pub items: Vec<DefId>,
393393
pub visibility: Visibility,
394394
pub docs: String,
395-
pub sig: Signature,
395+
pub sig: Option<Signature>,
396396
pub attributes: Vec<Attribute>,
397397
}
398398

@@ -410,7 +410,7 @@ impl Lower for data::ModData {
410410
items: self.items.into_iter().map(|id| make_def_id(id, &tcx.hir)).collect(),
411411
visibility: self.visibility,
412412
docs: self.docs,
413-
sig: self.sig.lower(tcx),
413+
sig: self.sig.map(|s| s.lower(tcx)),
414414
attributes: self.attributes.lower(tcx),
415415
}
416416
}

src/librustc_save_analysis/json_api_dumper.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ impl Into<Option<Def>> for ModData {
293293
parent: None,
294294
decl_id: None,
295295
docs: self.docs,
296-
sig: Some(self.sig.into()),
296+
sig: self.sig.map(|s| s.into()),
297297
attributes: vec![],
298298
}),
299299
_ => None,

src/librustc_save_analysis/json_dumper.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'b, O: DumpOutput + 'b> Dump for JsonDumper<O> {
121121
children: data.items.into_iter().map(|id| id_from_def_id(id)).collect(),
122122
decl_id: None,
123123
docs: data.docs,
124-
sig: Some(data.sig.into()),
124+
sig: data.sig.map(|s| s.into()),
125125
attributes: data.attributes.into_iter().map(|a| a.into()).collect(),
126126
};
127127
if def.span.file_name.to_str().unwrap() != def.value {

src/librustc_save_analysis/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
258258
items: m.items.iter().map(|i| i.id).collect(),
259259
visibility: From::from(&item.vis),
260260
docs: docs_for_attrs(&item.attrs),
261-
sig: self.sig_base(item),
261+
sig: Some(self.sig_base(item)),
262262
attributes: item.attrs.clone(),
263263
}))
264264
}

src/librustdoc/externalfiles.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::io::prelude::*;
1313
use std::io;
1414
use std::path::Path;
1515
use std::str;
16+
use html::markdown::{Markdown, RenderType};
1617

1718
#[derive(Clone)]
1819
pub struct ExternalHtml{
@@ -28,17 +29,26 @@ pub struct ExternalHtml{
2829
}
2930

3031
impl ExternalHtml {
31-
pub fn load(in_header: &[String], before_content: &[String], after_content: &[String])
32+
pub fn load(in_header: &[String], before_content: &[String], after_content: &[String],
33+
md_before_content: &[String], md_after_content: &[String], render: RenderType)
3234
-> Option<ExternalHtml> {
3335
load_external_files(in_header)
3436
.and_then(|ih|
3537
load_external_files(before_content)
3638
.map(|bc| (ih, bc))
3739
)
40+
.and_then(|(ih, bc)|
41+
load_external_files(md_before_content)
42+
.map(|m_bc| (ih, format!("{}{}", bc, Markdown(&m_bc, render))))
43+
)
3844
.and_then(|(ih, bc)|
3945
load_external_files(after_content)
4046
.map(|ac| (ih, bc, ac))
4147
)
48+
.and_then(|(ih, bc, ac)|
49+
load_external_files(md_after_content)
50+
.map(|m_ac| (ih, bc, format!("{}{}", ac, Markdown(&m_ac, render))))
51+
)
4252
.map(|(ih, bc, ac)|
4353
ExternalHtml {
4454
in_header: ih,

src/librustdoc/lib.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,14 @@ pub fn opts() -> Vec<RustcOptGroup> {
160160
"files to include inline between the content and </body> of a rendered \
161161
Markdown file or generated documentation",
162162
"FILES")),
163+
unstable(optmulti("", "markdown-before-content",
164+
"files to include inline between <body> and the content of a rendered \
165+
Markdown file or generated documentation",
166+
"FILES")),
167+
unstable(optmulti("", "markdown-after-content",
168+
"files to include inline between the content and </body> of a rendered \
169+
Markdown file or generated documentation",
170+
"FILES")),
163171
stable(optopt("", "markdown-playground-url",
164172
"URL to send code snippets to", "URL")),
165173
stable(optflag("", "markdown-no-toc", "don't include table of contents")),
@@ -275,7 +283,10 @@ pub fn main_args(args: &[String]) -> isize {
275283
let external_html = match ExternalHtml::load(
276284
&matches.opt_strs("html-in-header"),
277285
&matches.opt_strs("html-before-content"),
278-
&matches.opt_strs("html-after-content")) {
286+
&matches.opt_strs("html-after-content"),
287+
&matches.opt_strs("markdown-before-content"),
288+
&matches.opt_strs("markdown-after-content"),
289+
render_type) {
279290
Some(eh) => eh,
280291
None => return 3,
281292
};

src/libsyntax/parse/lexer/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -754,9 +754,7 @@ impl<'a> StringReader<'a> {
754754
// integer literal followed by field/method access or a range pattern
755755
// (`0..2` and `12.foo()`)
756756
if self.ch_is('.') && !self.nextch_is('.') &&
757-
!self.nextch()
758-
.unwrap_or('\0')
759-
.is_xid_start() {
757+
!ident_start(self.nextch()) {
760758
// might have stuff after the ., and if it does, it needs to start
761759
// with a number
762760
self.bump();

src/libsyntax/util/node_count.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl<'ast> Visitor<'ast> for NodeCounter {
3131
self.count += 1;
3232
walk_ident(self, span, ident);
3333
}
34-
fn visit_mod(&mut self, m: &Mod, _s: Span, _n: NodeId) {
34+
fn visit_mod(&mut self, m: &Mod, _s: Span, _a: &[Attribute], _n: NodeId) {
3535
self.count += 1;
3636
walk_mod(self, m)
3737
}

src/libsyntax/visit.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ pub trait Visitor<'ast>: Sized {
5656
fn visit_ident(&mut self, span: Span, ident: Ident) {
5757
walk_ident(self, span, ident);
5858
}
59-
fn visit_mod(&mut self, m: &'ast Mod, _s: Span, _n: NodeId) { walk_mod(self, m) }
59+
fn visit_mod(&mut self, m: &'ast Mod, _s: Span, _attrs: &[Attribute], _n: NodeId) {
60+
walk_mod(self, m);
61+
}
6062
fn visit_foreign_item(&mut self, i: &'ast ForeignItem) { walk_foreign_item(self, i) }
6163
fn visit_global_asm(&mut self, ga: &'ast GlobalAsm) { walk_global_asm(self, ga) }
6264
fn visit_item(&mut self, i: &'ast Item) { walk_item(self, i) }
@@ -172,7 +174,7 @@ pub fn walk_ident<'a, V: Visitor<'a>>(visitor: &mut V, span: Span, ident: Ident)
172174
}
173175

174176
pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) {
175-
visitor.visit_mod(&krate.module, krate.span, CRATE_NODE_ID);
177+
visitor.visit_mod(&krate.module, krate.span, &krate.attrs, CRATE_NODE_ID);
176178
walk_list!(visitor, visit_attribute, &krate.attrs);
177179
}
178180

@@ -249,7 +251,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
249251
item.id)
250252
}
251253
ItemKind::Mod(ref module) => {
252-
visitor.visit_mod(module, item.span, item.id)
254+
visitor.visit_mod(module, item.span, &item.attrs, item.id)
253255
}
254256
ItemKind::ForeignMod(ref foreign_module) => {
255257
walk_list!(visitor, visit_foreign_item, &foreign_module.items);

src/libsyntax_ext/proc_macro_registrar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl<'a> Visitor<'a> for CollectProcMacros<'a> {
329329
visit::walk_item(self, item);
330330
}
331331

332-
fn visit_mod(&mut self, m: &'a ast::Mod, _s: Span, id: NodeId) {
332+
fn visit_mod(&mut self, m: &'a ast::Mod, _s: Span, _a: &[ast::Attribute], id: NodeId) {
333333
let mut prev_in_root = self.in_root;
334334
if id != ast::CRATE_NODE_ID {
335335
prev_in_root = mem::replace(&mut self.in_root, false);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let a = 42._; //~ ERROR unexpected token: `_`
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait Tr : Sized {
12+
fn _method_on_numbers(self) {}
13+
}
14+
15+
impl Tr for i32 {}
16+
17+
fn main() {
18+
42._method_on_numbers();
19+
}

src/tools/rls

Submodule rls updated from 207c18d to 6fb840b

0 commit comments

Comments
 (0)