Skip to content

Rollup of 7 pull requests #57957

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

Merged
merged 25 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c738e60
Extend E0106, E0261
purple-ice Jan 3, 2019
adadefd
Fix changes for E0106, E0261
purple-ice Jan 4, 2019
da06898
Avoid erase_regions_ty queries if there are no regions to erase
dotdash Jan 16, 2019
2ec0e85
Print a slightly clearer message when failing to spawn a thread
Jan 22, 2019
0cf9704
Fix invalid background color
GuillaumeGomez Jan 23, 2019
c375333
Pretty print `$crate` as `crate` or `crate_name` in more cases
petrochenkov Jan 26, 2019
5e67021
add typo suggestion to unknown attribute error
euclio Jan 25, 2019
c775c2f
libcore: remove unneeded allow(deprecated)
RalfJung Dec 20, 2018
c11e514
liballoc: remove unneeded allow(deprecated)
RalfJung Dec 20, 2018
a88414e
libcore: avoid mem::uninitialized and raw ptr casts
RalfJung Dec 21, 2018
ffd73df
avoid mem::uninitialized in BTreeMap
RalfJung Dec 21, 2018
630aaa4
avoid some raw ptr casts in BTreeMap
RalfJung Dec 21, 2018
22a947f
add macro for creating uninitialized array
RalfJung Dec 22, 2018
0e8fb93
Use warn() for extra diagnostics; with -D warnings this leads to errors
RalfJung Jan 28, 2019
33a969d
fix typos, improve docs
RalfJung Jan 28, 2019
6a52ca3
rename first_mut_ptr -> first_ptr_mut
RalfJung Jan 28, 2019
a2b75ed
review comments
QuietMisdreavus Jan 28, 2019
489a792
fix gdb debug printing
RalfJung Jan 28, 2019
f21f83d
Rollup merge of #57045 - RalfJung:kill-more-uninit, r=SimonSapin
Centril Jan 28, 2019
76dbfdd
Rollup merge of #57674 - dotdash:erase_reg, r=varkor
Centril Jan 28, 2019
42dae3a
Rollup merge of #57833 - jethrogb:jb/thread-spawn-unwrap, r=alexcrichton
Centril Jan 28, 2019
b1b67cd
Rollup merge of #57859 - GuillaumeGomez:fix-background, r=QuietMisdre…
Centril Jan 28, 2019
d3bb907
Rollup merge of #57904 - euclio:attribute-typos, r=davidtwco
Centril Jan 28, 2019
3fe8b4c
Rollup merge of #57915 - petrochenkov:notto-disu, r=zackmdavis
Centril Jan 28, 2019
d77db2e
Rollup merge of #57950 - QuietMisdreavus:lifetime-err-desc, r=estebank
Centril Jan 28, 2019
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
Prev Previous commit
Next Next commit
Pretty print $crate as crate or crate_name in more cases
  • Loading branch information
petrochenkov committed Jan 26, 2019
commit c375333362bd1b5f006f6d627ff129c2c54d620c
10 changes: 5 additions & 5 deletions src/librustc_resolve/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use syntax::ast::{self, Ident};
use syntax::attr;
use syntax::errors::DiagnosticBuilder;
use syntax::ext::base::{self, Determinacy};
use syntax::ext::base::{Annotatable, MacroKind, SyntaxExtension};
use syntax::ext::base::{MacroKind, SyntaxExtension};
use syntax::ext::expand::{AstFragment, Invocation, InvocationKind};
use syntax::ext::hygiene::{self, Mark};
use syntax::ext::tt::macro_rules;
Expand Down Expand Up @@ -127,9 +127,9 @@ impl<'a> base::Resolver for Resolver<'a> {
mark
}

fn resolve_dollar_crates(&mut self, annotatable: &Annotatable) {
pub struct ResolveDollarCrates<'a, 'b: 'a> {
pub resolver: &'a mut Resolver<'b>,
fn resolve_dollar_crates(&mut self, fragment: &AstFragment) {
struct ResolveDollarCrates<'a, 'b: 'a> {
resolver: &'a mut Resolver<'b>
}
impl<'a> Visitor<'a> for ResolveDollarCrates<'a, '_> {
fn visit_ident(&mut self, ident: Ident) {
Expand All @@ -144,7 +144,7 @@ impl<'a> base::Resolver for Resolver<'a> {
fn visit_mac(&mut self, _: &ast::Mac) {}
}

annotatable.visit_with(&mut ResolveDollarCrates { resolver: self });
fragment.visit_with(&mut ResolveDollarCrates { resolver: self });
}

fn visit_ast_fragment_with_placeholders(&mut self, mark: Mark, fragment: &AstFragment,
Expand Down
5 changes: 1 addition & 4 deletions src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,8 @@ impl<'a> Resolver<'a> {
primary_binding: &'a NameBinding<'a>, secondary_binding: &'a NameBinding<'a>)
-> &'a NameBinding<'a> {
self.arenas.alloc_name_binding(NameBinding {
kind: primary_binding.kind.clone(),
ambiguity: Some((secondary_binding, kind)),
vis: primary_binding.vis,
span: primary_binding.span,
expansion: primary_binding.expansion,
..primary_binding.clone()
})
}

Expand Down
16 changes: 2 additions & 14 deletions src/libsyntax/ext/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use parse::token;
use ptr::P;
use smallvec::SmallVec;
use symbol::{keywords, Ident, Symbol};
use visit::Visitor;
use ThinVec;

use rustc_data_structures::fx::FxHashMap;
Expand Down Expand Up @@ -136,17 +135,6 @@ impl Annotatable {
_ => false,
}
}

pub fn visit_with<'a, V: Visitor<'a>>(&'a self, visitor: &mut V) {
match self {
Annotatable::Item(item) => visitor.visit_item(item),
Annotatable::TraitItem(trait_item) => visitor.visit_trait_item(trait_item),
Annotatable::ImplItem(impl_item) => visitor.visit_impl_item(impl_item),
Annotatable::ForeignItem(foreign_item) => visitor.visit_foreign_item(foreign_item),
Annotatable::Stmt(stmt) => visitor.visit_stmt(stmt),
Annotatable::Expr(expr) => visitor.visit_expr(expr),
}
}
}

// A more flexible ItemDecorator.
Expand Down Expand Up @@ -742,7 +730,7 @@ pub trait Resolver {
fn next_node_id(&mut self) -> ast::NodeId;
fn get_module_scope(&mut self, id: ast::NodeId) -> Mark;

fn resolve_dollar_crates(&mut self, annotatable: &Annotatable);
fn resolve_dollar_crates(&mut self, fragment: &AstFragment);
fn visit_ast_fragment_with_placeholders(&mut self, mark: Mark, fragment: &AstFragment,
derives: &[Mark]);
fn add_builtin(&mut self, ident: ast::Ident, ext: Lrc<SyntaxExtension>);
Expand Down Expand Up @@ -776,7 +764,7 @@ impl Resolver for DummyResolver {
fn next_node_id(&mut self) -> ast::NodeId { ast::DUMMY_NODE_ID }
fn get_module_scope(&mut self, _id: ast::NodeId) -> Mark { Mark::root() }

fn resolve_dollar_crates(&mut self, _annotatable: &Annotatable) {}
fn resolve_dollar_crates(&mut self, _fragment: &AstFragment) {}
fn visit_ast_fragment_with_placeholders(&mut self, _invoc: Mark, _fragment: &AstFragment,
_derives: &[Mark]) {}
fn add_builtin(&mut self, _ident: ast::Ident, _ext: Lrc<SyntaxExtension>) {}
Expand Down
7 changes: 3 additions & 4 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,9 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
/// prepares data for resolving paths of macro invocations.
fn collect_invocations(&mut self, fragment: AstFragment, derives: &[Mark])
-> (AstFragment, Vec<Invocation>) {
// Resolve `$crate`s in the fragment for pretty-printing.
self.cx.resolver.resolve_dollar_crates(&fragment);

let (fragment_with_placeholders, invocations) = {
let mut collector = InvocationCollector {
cfg: StripUnconfigured {
Expand Down Expand Up @@ -574,8 +577,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
Some(invoc.fragment_kind.expect_from_annotatables(items))
}
AttrProcMacro(ref mac, ..) => {
// Resolve `$crate`s in case we have to go though stringification.
self.cx.resolver.resolve_dollar_crates(&item);
self.gate_proc_macro_attr_item(attr.span, &item);
let item_tok = TokenTree::Token(DUMMY_SP, Token::interpolated(match item {
Annotatable::Item(item) => token::NtItem(item),
Expand Down Expand Up @@ -917,8 +918,6 @@ impl<'a, 'b> MacroExpander<'a, 'b> {

match *ext {
ProcMacroDerive(ref ext, ..) => {
// Resolve `$crate`s in case we have to go though stringification.
self.cx.resolver.resolve_dollar_crates(&item);
invoc.expansion_data.mark.set_expn_info(expn_info);
let span = span.with_ctxt(self.cx.backtrace());
let dummy = ast::MetaItem { // FIXME(jseyfried) avoid this
Expand Down
18 changes: 18 additions & 0 deletions src/test/pretty/dollar-crate.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![feature(prelude_import)]
#![no_std]
#[prelude_import]
use ::std::prelude::v1::*;
#[macro_use]
extern crate std;
// pretty-compare-only
// pretty-mode:expanded
// pp-exact:dollar-crate.pp

fn main() {
{
::std::io::_print(::std::fmt::Arguments::new_v1(&["rust\n"],
&match () {
() => [],
}));
};
}
7 changes: 7 additions & 0 deletions src/test/pretty/dollar-crate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// pretty-compare-only
// pretty-mode:expanded
// pp-exact:dollar-crate.pp

fn main() {
println!("rust");
}