Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 14 pull requests #76231

Merged
merged 46 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
f3d7645
Add trailing comma support to matches macro
chrisduerr Jul 28, 2020
cc3b2f9
Add more examples to lexicographic cmp on Iterators.
hbina Aug 29, 2020
4aae781
Add info about `!` and `impl Trait`
camelid Aug 30, 2020
fd985e2
cannot have divergence -> cannot diverge
camelid Aug 30, 2020
0d9a2ab
It's only an issue without an `impl Trait for !`
camelid Aug 30, 2020
26eab6a
Specify `0` of type `u32`
camelid Aug 30, 2020
80dcad9
Be more specific about polymorphic return types
camelid Aug 30, 2020
bd31962
other branch -> `else` branch
camelid Aug 30, 2020
7e2548f
Import `Debug` instead of redefining it
camelid Aug 30, 2020
37ea97c
Explain why the `0` is a `u32`
camelid Aug 30, 2020
090b167
Factor out StmtKind::MacCall fields into `MacCallStmt` struct
Aaron1011 Aug 30, 2020
ee19021
Fix clippy
Aaron1011 Aug 30, 2020
23f0ccf
Stabilise link-self-contained option
mati865 Jul 30, 2020
e13a701
Redefine `Debug` instead of importing it
camelid Aug 31, 2020
cdd6f11
Remove empty comment
camelid Aug 31, 2020
c4c058c
Improve wording
camelid Sep 1, 2020
913354b
Improve `assert!` section in `bool` docs
camelid Sep 1, 2020
55637f5
Break line at 100 characters
camelid Sep 1, 2020
6b5869a
Add new `-Z dump-mir-spanview` option
richkadel Aug 29, 2020
be2947d
Give a better error message for duplicate built-in macros
jyn514 Aug 31, 2020
9c7fb6c
Use intra-doc links
denisvasilik Sep 1, 2020
b639cb1
Enhance wording
denisvasilik Sep 1, 2020
b31cc8f
Make all methods of `std::net::Ipv6Addr` const
Sep 1, 2020
e7d0743
Use intra-doc links
denisvasilik Sep 1, 2020
3510c56
Improve readability
denisvasilik Sep 1, 2020
7eb4b1b
Document lint missing_doc_code_examples is nightly-only
JesHansen Sep 1, 2020
cd08def
Add test for `Ipv6Addr` methods in a const context
Sep 1, 2020
a43dd4f
Change implementation of `Ipv6Addr::is_unspecified` and `is_loopback`…
Sep 1, 2020
9afe97c
Add trailing newline to `ipv6.rs`
CDirkx Sep 1, 2020
c86d249
Use "Fira Sans" for crate list font
camelid Aug 30, 2020
b1491ea
lexer: Tiny improvement to shebang detection
petrochenkov Sep 1, 2020
e5c17bf
Clean up header in `iter` docs for `for` loops
camelid Sep 1, 2020
383da5e
Rollup merge of #74880 - chrisduerr:fix_matches, r=dtolnay
tmandry Sep 2, 2020
5f28831
Rollup merge of #76074 - richkadel:llvm-coverage-map-gen-6b.5.1, r=we…
tmandry Sep 2, 2020
7c1c7de
Rollup merge of #76088 - hbina:add_example, r=LukasKalbertodt
tmandry Sep 2, 2020
34c8b7a
Rollup merge of #76099 - camelid:patch-8, r=jyn514
tmandry Sep 2, 2020
9a05582
Rollup merge of #76126 - camelid:crate-list-font, r=GuillaumeGomez
tmandry Sep 2, 2020
738b8ea
Rollup merge of #76132 - Aaron1011:mac-call-stmt, r=petrochenkov
tmandry Sep 2, 2020
b01d0b1
Rollup merge of #76143 - jyn514:duplicate-builtin-macros, r=petrochenkov
tmandry Sep 2, 2020
4a6aa35
Rollup merge of #76158 - mati865:self-contained-option, r=petrochenkov
tmandry Sep 2, 2020
17fa733
Rollup merge of #76201 - denisvasilik:intra-doc-links-core-panic, r=k…
tmandry Sep 2, 2020
11ff32f
Rollup merge of #76206 - CDirkx:const-ipv6, r=ecstatic-morse
tmandry Sep 2, 2020
7edc93b
Rollup merge of #76207 - denisvasilik:intra-doc-links-core-clone, r=j…
tmandry Sep 2, 2020
c22de44
Rollup merge of #76212 - JesHansen:fix-lint-doc, r=jyn514
tmandry Sep 2, 2020
56b5de2
Rollup merge of #76218 - petrochenkov:shebang3, r=matklad
tmandry Sep 2, 2020
4dd75f8
Rollup merge of #76221 - camelid:cleanup-iter-for, r=jyn514
tmandry Sep 2, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,9 +922,13 @@ impl Stmt {
pub fn add_trailing_semicolon(mut self) -> Self {
self.kind = match self.kind {
StmtKind::Expr(expr) => StmtKind::Semi(expr),
StmtKind::MacCall(mac) => StmtKind::MacCall(
mac.map(|(mac, _style, attrs)| (mac, MacStmtStyle::Semicolon, attrs)),
),
StmtKind::MacCall(mac) => {
StmtKind::MacCall(mac.map(|MacCallStmt { mac, style: _, attrs }| MacCallStmt {
mac,
style: MacStmtStyle::Semicolon,
attrs,
}))
}
kind => kind,
};
self
Expand Down Expand Up @@ -958,7 +962,14 @@ pub enum StmtKind {
/// Just a trailing semi-colon.
Empty,
/// Macro.
MacCall(P<(MacCall, MacStmtStyle, AttrVec)>),
MacCall(P<MacCallStmt>),
}

#[derive(Clone, Encodable, Decodable, Debug)]
pub struct MacCallStmt {
pub mac: MacCall,
pub style: MacStmtStyle,
pub attrs: AttrVec,
}

#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug)]
Expand Down
9 changes: 2 additions & 7 deletions compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use rustc_span::symbol::{sym, Ident, Symbol};
use rustc_span::Span;

use std::iter;
use std::ops::DerefMut;

pub struct MarkedAttrs(GrowableBitSet<AttrId>);

Expand Down Expand Up @@ -634,10 +633,7 @@ impl HasAttrs for StmtKind {
StmtKind::Local(ref local) => local.attrs(),
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => expr.attrs(),
StmtKind::Empty | StmtKind::Item(..) => &[],
StmtKind::MacCall(ref mac) => {
let (_, _, ref attrs) = **mac;
attrs.attrs()
}
StmtKind::MacCall(ref mac) => mac.attrs.attrs(),
}
}

Expand All @@ -647,8 +643,7 @@ impl HasAttrs for StmtKind {
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.visit_attrs(f),
StmtKind::Empty | StmtKind::Item(..) => {}
StmtKind::MacCall(mac) => {
let (_mac, _style, attrs) = mac.deref_mut();
attrs.visit_attrs(f);
mac.attrs.visit_attrs(f);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ pub fn noop_flat_map_stmt_kind<T: MutVisitor>(
StmtKind::Semi(expr) => vis.filter_map_expr(expr).into_iter().map(StmtKind::Semi).collect(),
StmtKind::Empty => smallvec![StmtKind::Empty],
StmtKind::MacCall(mut mac) => {
let (mac_, _semi, attrs) = mac.deref_mut();
let MacCallStmt { mac: mac_, style: _, attrs } = mac.deref_mut();
vis.visit_mac(mac_);
visit_thin_attrs(attrs, vis);
smallvec![StmtKind::MacCall(mac)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) {
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => visitor.visit_expr(expr),
StmtKind::Empty => {}
StmtKind::MacCall(ref mac) => {
let (ref mac, _, ref attrs) = **mac;
let MacCallStmt { ref mac, style: _, ref attrs } = **mac;
visitor.visit_mac(mac);
for attr in attrs.iter() {
visitor.visit_attribute(attr);
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_ast_pretty/src/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1507,11 +1507,10 @@ impl<'a> State<'a> {
self.s.word(";");
}
ast::StmtKind::MacCall(ref mac) => {
let (ref mac, style, ref attrs) = **mac;
self.space_if_not_bol();
self.print_outer_attributes(attrs);
self.print_mac(mac);
if style == ast::MacStmtStyle::Semicolon {
self.print_outer_attributes(&mac.attrs);
self.print_mac(&mac.mac);
if mac.style == ast::MacStmtStyle::Semicolon {
self.s.word(";");
}
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ fn get_crt_libs_path(sess: &Session) -> Option<PathBuf> {

fn get_object_file_path(sess: &Session, name: &str, self_contained: bool) -> PathBuf {
// prefer system {,dll}crt2.o libs, see get_crt_libs_path comment for more details
if sess.opts.debugging_opts.link_self_contained.is_none()
if sess.opts.cg.link_self_contained.is_none()
&& sess.target.target.llvm_target.contains("windows-gnu")
{
if let Some(compiler_libs_path) = get_crt_libs_path(sess) {
Expand Down Expand Up @@ -1289,7 +1289,7 @@ fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
/// Whether we link to our own CRT objects instead of relying on gcc to pull them.
/// We only provide such support for a very limited number of targets.
fn crt_objects_fallback(sess: &Session, crate_type: CrateType) -> bool {
if let Some(self_contained) = sess.opts.debugging_opts.link_self_contained {
if let Some(self_contained) = sess.opts.cg.link_self_contained {
return self_contained;
}

Expand Down Expand Up @@ -1499,7 +1499,7 @@ fn link_local_crate_native_libs_and_dependent_crate_libs<'a, B: ArchiveBuilder<'
/// Add sysroot and other globally set directories to the directory search list.
fn add_library_search_dirs(cmd: &mut dyn Linker, sess: &Session, self_contained: bool) {
// Prefer system mingw-w64 libs, see get_crt_libs_path comment for more details.
if sess.opts.debugging_opts.link_self_contained.is_none()
if sess.opts.cg.link_self_contained.is_none()
&& cfg!(windows)
&& sess.target.target.llvm_target.contains("windows-gnu")
{
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ E0768: include_str!("./error_codes/E0768.md"),
E0769: include_str!("./error_codes/E0769.md"),
E0770: include_str!("./error_codes/E0770.md"),
E0771: include_str!("./error_codes/E0771.md"),
E0773: include_str!("./error_codes/E0773.md"),
;
// E0006, // merged with E0005
// E0008, // cannot bind by-move into a pattern guard
Expand Down
38 changes: 38 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0773.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
A builtin-macro was defined more than once.

Erroneous code example:

```compile_fail,E0773
#![feature(decl_macro)]
#![feature(rustc_attrs)]

#[rustc_builtin_macro]
pub macro test($item:item) {
/* compiler built-in */
}

mod inner {
#[rustc_builtin_macro]
pub macro test($item:item) {
/* compiler built-in */
}
}
```

To fix the issue, remove the duplicate declaration:

```
#![feature(decl_macro)]
#![feature(rustc_attrs)]

#[rustc_builtin_macro]
pub macro test($item:item) {
/* compiler built-in */
}
```

In very rare edge cases, this may happen when loading `core` or `std` twice,
once with `check` metadata and once with `build` metadata.
For more information, see [#75176].

[#75176]: https://github.com/rust-lang/rust/pull/75176#issuecomment-683234468
4 changes: 2 additions & 2 deletions compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rustc_ast::token;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::visit::{self, AssocCtxt, Visitor};
use rustc_ast::{self as ast, AttrItem, Block, LitKind, NodeId, PatKind, Path};
use rustc_ast::{ItemKind, MacArgs, MacStmtStyle, StmtKind};
use rustc_ast::{ItemKind, MacArgs, MacCallStmt, MacStmtStyle, StmtKind};
use rustc_ast_pretty::pprust;
use rustc_attr::{self as attr, is_builtin_attr, HasAttrs};
use rustc_data_structures::map_in_place::MapInPlace;
Expand Down Expand Up @@ -1363,7 +1363,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
}

if let StmtKind::MacCall(mac) = stmt.kind {
let (mac, style, attrs) = mac.into_inner();
let MacCallStmt { mac, style, attrs } = mac.into_inner();
self.check_attributes(&attrs);
let mut placeholder =
self.collect_bang(mac, stmt.span, AstFragmentKind::Stmts).make_stmts();
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_expand/src/placeholders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ pub fn placeholder(
AstFragment::Ty(P(ast::Ty { id, span, kind: ast::TyKind::MacCall(mac_placeholder()) }))
}
AstFragmentKind::Stmts => AstFragment::Stmts(smallvec![{
let mac = P((mac_placeholder(), ast::MacStmtStyle::Braces, ast::AttrVec::new()));
let mac = P(ast::MacCallStmt {
mac: mac_placeholder(),
style: ast::MacStmtStyle::Braces,
attrs: ast::AttrVec::new(),
});
ast::Stmt { id, span, kind: ast::StmtKind::MacCall(mac) }
}]),
AstFragmentKind::Arms => AstFragment::Arms(smallvec![ast::Arm {
Expand Down Expand Up @@ -293,7 +297,7 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {

fn flat_map_stmt(&mut self, stmt: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
let (style, mut stmts) = match stmt.kind {
ast::StmtKind::MacCall(mac) => (mac.1, self.remove(stmt.id).make_stmts()),
ast::StmtKind::MacCall(mac) => (mac.style, self.remove(stmt.id).make_stmts()),
_ => return noop_flat_map_stmt(stmt, self),
};

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ fn test_codegen_options_tracking_hash() {
// `link_arg` is omitted because it just forwards to `link_args`.
untracked!(link_args, vec![String::from("abc"), String::from("def")]);
untracked!(link_dead_code, Some(true));
untracked!(link_self_contained, Some(true));
untracked!(linker, Some(PathBuf::from("linker")));
untracked!(linker_flavor, Some(LinkerFlavor::Gcc));
untracked!(no_stack_check, true);
Expand Down
14 changes: 9 additions & 5 deletions compiler/rustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,16 @@ pub fn strip_shebang(input: &str) -> Option<usize> {
// For simplicity we consider any line starting with `#!` a shebang,
// regardless of restrictions put on shebangs by specific platforms.
if let Some(input_tail) = input.strip_prefix("#!") {
// Ok, this is a shebang but if the next non-whitespace token is `[` or maybe
// a doc comment (due to `TokenKind::(Line,Block)Comment` ambiguity at lexer level),
// Ok, this is a shebang but if the next non-whitespace token is `[`,
// then it may be valid Rust code, so consider it Rust code.
let next_non_whitespace_token = tokenize(input_tail).map(|tok| tok.kind).find(|tok|
!matches!(tok, TokenKind::Whitespace | TokenKind::LineComment { .. } | TokenKind::BlockComment { .. })
);
let next_non_whitespace_token = tokenize(input_tail).map(|tok| tok.kind).find(|tok| {
!matches!(
tok,
TokenKind::Whitespace
| TokenKind::LineComment { doc_style: None }
| TokenKind::BlockComment { doc_style: None, .. }
)
});
if next_non_whitespace_token != Some(TokenKind::OpenBracket) {
// No other choice than to consider this a shebang.
return Some(2 + input_tail.lines().next().unwrap_or_default().len());
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir/src/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mod alignment;
pub mod collect_writes;
mod graphviz;
pub(crate) mod pretty;
pub(crate) mod spanview;

pub use self::aggregate::expand_aggregate;
pub use self::alignment::is_disaligned;
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_mir/src/util/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::io::{self, Write};
use std::path::{Path, PathBuf};

use super::graphviz::write_mir_fn_graphviz;
use super::spanview::write_mir_fn_spanview;
use crate::transform::MirSource;
use either::Either;
use rustc_data_structures::fx::FxHashMap;
Expand Down Expand Up @@ -147,6 +148,16 @@ fn dump_matched_mir_node<'tcx, F>(
write_mir_fn_graphviz(tcx, source.def_id(), body, false, &mut file)?;
};
}

if let Some(spanview) = tcx.sess.opts.debugging_opts.dump_mir_spanview {
let _: io::Result<()> = try {
let mut file =
create_dump_file(tcx, "html", pass_num, pass_name, disambiguator, source)?;
if source.def_id().is_local() {
write_mir_fn_spanview(tcx, source.def_id(), body, spanview, &mut file)?;
}
};
}
}

/// Returns the path to the filename where we should dump a given MIR.
Expand Down
Loading