Auto merge of #52303 - kennytm:rollup, r=kennytm

Rollup of 9 pull requests

Successful merges:

 - #51816 (bootstrap: write texts to a .tmp file first for atomicity)
 - #51912 (impl Clone for Box<CStr>, Box<OsStr>, Box<Path>)
 - #52164 (use proper footnote syntax for references)
 - #52220 (Deny bare trait objects in `src/bootstrap`)
 - #52276 (rustc: Verify #[proc_macro] is only a word)
 - #52277 (Uncapitalize "If")
 - #52287 (Deny bare trait objects in src/librustc_resolve)
 - #52295 (Deny bare trait objects in src/libsyntax_ext)
 - #52298 (make reference to dirs crate clickable in terminals)

Failed merges:

r? @ghost
This commit is contained in:
bors 2018-07-12 12:50:13 +00:00
commit 7db82ccd76
42 changed files with 182 additions and 68 deletions

View File

@ -303,6 +303,19 @@ def default_build_triple():
return "{}-{}".format(cputype, ostype)
@contextlib.contextmanager
def output(filepath):
tmp = filepath + '.tmp'
with open(tmp, 'w') as f:
yield f
try:
os.remove(filepath) # PermissionError/OSError on Win32 if in use
os.rename(tmp, filepath)
except OSError:
shutil.copy2(tmp, filepath)
os.remove(tmp)
class RustBuild(object):
"""Provide all the methods required to build Rust"""
def __init__(self):
@ -346,7 +359,7 @@ class RustBuild(object):
self._download_stage0_helper(filename, "rustc")
self.fix_executable("{}/bin/rustc".format(self.bin_root()))
self.fix_executable("{}/bin/rustdoc".format(self.bin_root()))
with open(self.rustc_stamp(), 'w') as rust_stamp:
with output(self.rustc_stamp()) as rust_stamp:
rust_stamp.write(self.date)
# This is required so that we don't mix incompatible MinGW
@ -363,7 +376,7 @@ class RustBuild(object):
filename = "cargo-{}-{}.tar.gz".format(cargo_channel, self.build)
self._download_stage0_helper(filename, "cargo")
self.fix_executable("{}/bin/cargo".format(self.bin_root()))
with open(self.cargo_stamp(), 'w') as cargo_stamp:
with output(self.cargo_stamp()) as cargo_stamp:
cargo_stamp.write(self.date)
def _download_stage0_helper(self, filename, pattern):
@ -776,7 +789,7 @@ def bootstrap(help_triggered):
if build.use_vendored_sources:
if not os.path.exists('.cargo'):
os.makedirs('.cargo')
with open('.cargo/config', 'w') as cargo_config:
with output('.cargo/config') as cargo_config:
cargo_config.write("""
[source.crates-io]
replace-with = 'vendored-sources'

View File

@ -44,7 +44,7 @@ pub struct Builder<'a> {
pub top_stage: u32,
pub kind: Kind,
cache: Cache,
stack: RefCell<Vec<Box<Any>>>,
stack: RefCell<Vec<Box<dyn Any>>>,
time_spent_on_dependencies: Cell<Duration>,
pub paths: Vec<PathBuf>,
graph_nodes: RefCell<HashMap<String, NodeIndex>>,

View File

@ -249,7 +249,7 @@ lazy_static! {
pub struct Cache(
RefCell<HashMap<
TypeId,
Box<Any>, // actually a HashMap<Step, Interned<Step::Output>>
Box<dyn Any>, // actually a HashMap<Step, Interned<Step::Output>>
>>
);

View File

@ -1189,7 +1189,7 @@ pub fn run_cargo(builder: &Builder, cargo: &mut Command, stamp: &Path, is_check:
pub fn stream_cargo(
builder: &Builder,
cargo: &mut Command,
cb: &mut FnMut(CargoMessage),
cb: &mut dyn FnMut(CargoMessage),
) -> bool {
if builder.config.dry_run {
return true;

View File

@ -432,7 +432,7 @@ for section_key in config:
# order that we read it in.
p("")
p("writing `config.toml` in current directory")
with open('config.toml', 'w') as f:
with bootstrap.output('config.toml') as f:
for section in section_order:
if section == 'target':
for target in targets:
@ -442,7 +442,7 @@ with open('config.toml', 'w') as f:
for line in sections[section]:
f.write(line + "\n")
with open('Makefile', 'w') as f:
with bootstrap.output('Makefile') as f:
contents = os.path.join(rust_dir, 'src', 'bootstrap', 'mk', 'Makefile.in')
contents = open(contents).read()
contents = contents.replace("$(CFG_SRC_DIR)", rust_dir + '/')

View File

@ -113,6 +113,7 @@
//! More documentation can be found in each respective module below, and you can
//! also check out the `src/bootstrap/README.md` file for more information.
#![deny(bare_trait_objects)]
#![deny(warnings)]
#![feature(core_intrinsics)]
#![feature(drain_filter)]
@ -1174,13 +1175,13 @@ impl Build {
/// Copies the `src` directory recursively to `dst`. Both are assumed to exist
/// when this function is called. Unwanted files or directories can be skipped
/// by returning `false` from the filter function.
pub fn cp_filtered(&self, src: &Path, dst: &Path, filter: &Fn(&Path) -> bool) {
pub fn cp_filtered(&self, src: &Path, dst: &Path, filter: &dyn Fn(&Path) -> bool) {
// Immediately recurse with an empty relative path
self.recurse_(src, dst, Path::new(""), filter)
}
// Inner function does the actual work
fn recurse_(&self, src: &Path, dst: &Path, relative: &Path, filter: &Fn(&Path) -> bool) {
fn recurse_(&self, src: &Path, dst: &Path, relative: &Path, filter: &dyn Fn(&Path) -> bool) {
for f in self.read_dir(src) {
let path = f.path();
let name = path.file_name().unwrap();

View File

@ -8,12 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
/*!
Almost direct (but slightly optimized) Rust translation of Figure 3 of \[1\].
\[1\] Burger, R. G. and Dybvig, R. K. 1996. Printing floating-point numbers
quickly and accurately. SIGPLAN Not. 31, 5 (May. 1996), 108-116.
*/
//! Almost direct (but slightly optimized) Rust translation of Figure 3 of "Printing
//! Floating-Point Numbers Quickly and Accurately"[^1].
//!
//! [^1]: Burger, R. G. and Dybvig, R. K. 1996. Printing floating-point numbers
//! quickly and accurately. SIGPLAN Not. 31, 5 (May. 1996), 108-116.
use cmp::Ordering;

View File

@ -8,13 +8,12 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
/*!
Rust adaptation of Grisu3 algorithm described in \[1\]. It uses about
1KB of precomputed table, and in turn, it's very quick for most inputs.
\[1\] Florian Loitsch. 2010. Printing floating-point numbers quickly and
accurately with integers. SIGPLAN Not. 45, 6 (June 2010), 233-243.
*/
//! Rust adaptation of the Grisu3 algorithm described in "Printing Floating-Point Numbers Quickly
//! and Accurately with Integers"[^1]. It uses about 1KB of precomputed table, and in turn, it's
//! very quick for most inputs.
//!
//! [^1]: Florian Loitsch. 2010. Printing floating-point numbers quickly and
//! accurately with integers. SIGPLAN Not. 45, 6 (June 2010), 233-243.
use num::diy_float::Fp;
use num::flt2dec::{Decoded, MAX_SIG_DIGITS, round_up};

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(bare_trait_objects)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
@ -1292,7 +1294,7 @@ impl PrimitiveTypeTable {
/// This is the visitor that walks the whole crate.
pub struct Resolver<'a> {
session: &'a Session,
cstore: &'a CrateStore,
cstore: &'a dyn CrateStore,
pub definitions: Definitions,
@ -1388,7 +1390,7 @@ pub struct Resolver<'a> {
/// true if `#![feature(use_extern_macros)]`
use_extern_macros: bool,
crate_loader: &'a mut CrateLoader,
crate_loader: &'a mut dyn CrateLoader,
macro_names: FxHashSet<Ident>,
global_macros: FxHashMap<Name, &'a NameBinding<'a>>,
pub all_macros: FxHashMap<Name, Def>,
@ -1604,11 +1606,11 @@ impl<'a> Resolver<'a> {
impl<'a> Resolver<'a> {
pub fn new(session: &'a Session,
cstore: &'a CrateStore,
cstore: &'a dyn CrateStore,
krate: &Crate,
crate_name: &str,
make_glob_map: MakeGlobMap,
crate_loader: &'a mut CrateLoader,
crate_loader: &'a mut dyn CrateLoader,
arenas: &'a ResolverArenas<'a>)
-> Resolver<'a> {
let root_def_id = DefId::local(CRATE_DEF_INDEX);

View File

@ -541,7 +541,7 @@ impl Error for JoinPathsError {
/// ```
#[rustc_deprecated(since = "1.29.0",
reason = "This function's behavior is unexpected and probably not what you want. \
Consider using the home_dir function from crates.io/crates/dirs instead.")]
Consider using the home_dir function from https://crates.io/crates/dirs instead.")]
#[stable(feature = "env", since = "1.0.0")]
pub fn home_dir() -> Option<PathBuf> {
os_imp::home_dir()

View File

@ -706,6 +706,14 @@ impl From<Box<CStr>> for CString {
}
}
#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
impl Clone for Box<CStr> {
#[inline]
fn clone(&self) -> Self {
(**self).into()
}
}
#[stable(feature = "box_from_c_string", since = "1.20.0")]
impl From<CString> for Box<CStr> {
#[inline]

View File

@ -642,6 +642,14 @@ impl From<OsString> for Box<OsStr> {
}
}
#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
impl Clone for Box<OsStr> {
#[inline]
fn clone(&self) -> Self {
self.to_os_string().into_boxed_os_str()
}
}
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
impl From<OsString> for Arc<OsStr> {
#[inline]

View File

@ -1410,6 +1410,14 @@ impl From<PathBuf> for Box<Path> {
}
}
#[stable(feature = "more_box_slice_clone", since = "1.29.0")]
impl Clone for Box<Path> {
#[inline]
fn clone(&self) -> Self {
self.to_path_buf().into_boxed_path()
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for PathBuf {
fn from(s: &'a T) -> PathBuf {

View File

@ -689,7 +689,7 @@ impl<T> UnsafeFlavor<T> for Receiver<T> {
/// only one [`Receiver`] is supported.
///
/// If the [`Receiver`] is disconnected while trying to [`send`] with the
/// [`Sender`], the [`send`] method will return a [`SendError`]. Similarly, If the
/// [`Sender`], the [`send`] method will return a [`SendError`]. Similarly, if the
/// [`Sender`] is disconnected while trying to [`recv`], the [`recv`] method will
/// return a [`RecvError`].
///

View File

@ -50,7 +50,7 @@ const OPTIONS: &'static [&'static str] = &["volatile", "alignstack", "intel"];
pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[tokenstream::TokenTree])
-> Box<base::MacResult + 'cx> {
-> Box<dyn base::MacResult + 'cx> {
if !cx.ecfg.enable_asm() {
feature_gate::emit_feature_err(&cx.parse_sess,
"asm",

View File

@ -22,7 +22,7 @@ pub fn expand_assert<'cx>(
cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[TokenTree],
) -> Box<MacResult + 'cx> {
) -> Box<dyn MacResult + 'cx> {
let mut parser = cx.new_parser_from_tts(tts);
let cond_expr = panictry!(parser.parse_expr());
let custom_msg_args = if parser.eat(&token::Comma) {

View File

@ -23,7 +23,7 @@ use syntax_pos::Span;
pub fn expand_cfg<'cx>(cx: &mut ExtCtxt,
sp: Span,
tts: &[tokenstream::TokenTree])
-> Box<base::MacResult + 'static> {
-> Box<dyn base::MacResult + 'static> {
let sp = sp.apply_mark(cx.current_expansion.mark);
let mut p = cx.new_parser_from_tts(tts);
let cfg = panictry!(p.parse_meta_item());

View File

@ -18,7 +18,7 @@ use syntax::tokenstream;
pub fn expand_compile_error<'cx>(cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[tokenstream::TokenTree])
-> Box<base::MacResult + 'cx> {
-> Box<dyn base::MacResult + 'cx> {
let var = match get_single_str_from_tts(cx, sp, tts, "compile_error!") {
None => return DummyResult::expr(sp),
Some(v) => v,

View File

@ -21,7 +21,7 @@ pub fn expand_syntax_ext(
cx: &mut base::ExtCtxt,
sp: syntax_pos::Span,
tts: &[tokenstream::TokenTree],
) -> Box<base::MacResult + 'static> {
) -> Box<dyn base::MacResult + 'static> {
let es = match base::get_exprs_from_tts(cx, sp, tts) {
Some(e) => e,
None => return base::DummyResult::expr(sp),

View File

@ -21,7 +21,7 @@ use syntax::tokenstream::TokenTree;
pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[TokenTree])
-> Box<base::MacResult + 'cx> {
-> Box<dyn base::MacResult + 'cx> {
if !cx.ecfg.enable_concat_idents() {
feature_gate::emit_feature_err(&cx.parse_sess,
"concat_idents",

View File

@ -19,7 +19,7 @@ pub fn expand_deriving_unsafe_bound(cx: &mut ExtCtxt,
span: Span,
_: &MetaItem,
_: &Annotatable,
_: &mut FnMut(Annotatable)) {
_: &mut dyn FnMut(Annotatable)) {
cx.span_err(span, "this unsafe trait should be implemented explicitly");
}
@ -27,7 +27,7 @@ pub fn expand_deriving_copy(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
let trait_def = TraitDef {
span,
attributes: Vec::new(),

View File

@ -25,7 +25,7 @@ pub fn expand_deriving_clone(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
// check if we can use a short form
//
// the short form is `fn clone(&self) -> Self { *self }`

View File

@ -23,7 +23,7 @@ pub fn expand_deriving_eq(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
let inline = cx.meta_word(span, Symbol::intern("inline"));
let hidden = cx.meta_list_item_word(span, Symbol::intern("hidden"));
let doc = cx.meta_list(span, Symbol::intern("doc"), vec![hidden]);

View File

@ -23,7 +23,7 @@ pub fn expand_deriving_ord(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
let inline = cx.meta_word(span, Symbol::intern("inline"));
let attrs = vec![cx.attribute(span, inline)];
let trait_def = TraitDef {

View File

@ -23,7 +23,7 @@ pub fn expand_deriving_partial_eq(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
// structures are equal if all fields are equal, and non equal, if
// any fields are not equal or if the enum variants are different
fn cs_op(cx: &mut ExtCtxt,

View File

@ -25,7 +25,7 @@ pub fn expand_deriving_partial_ord(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
macro_rules! md {
($name:expr, $op:expr, $equal:expr) => { {
let inline = cx.meta_word(span, Symbol::intern("inline"));

View File

@ -23,7 +23,7 @@ pub fn expand_deriving_debug(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
// &mut ::std::fmt::Formatter
let fmtr = Ptr(Box::new(Literal(path_std!(cx, fmt::Formatter))),
Borrowed(None, ast::Mutability::Mutable));

View File

@ -27,7 +27,7 @@ pub fn expand_deriving_rustc_decodable(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
expand_deriving_decodable_imp(cx, span, mitem, item, push, "rustc_serialize")
}
@ -35,7 +35,7 @@ pub fn expand_deriving_decodable(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
warn_if_deprecated(cx, span, "Decodable");
expand_deriving_decodable_imp(cx, span, mitem, item, push, "serialize")
}
@ -44,7 +44,7 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable),
push: &mut dyn FnMut(Annotatable),
krate: &'static str) {
let typaram = &*deriving::hygienic_type_parameter(item, "__D");

View File

@ -23,7 +23,7 @@ pub fn expand_deriving_default(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
let inline = cx.meta_word(span, Symbol::intern("inline"));
let attrs = vec![cx.attribute(span, inline)];
let trait_def = TraitDef {

View File

@ -108,7 +108,7 @@ pub fn expand_deriving_rustc_encodable(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
expand_deriving_encodable_imp(cx, span, mitem, item, push, "rustc_serialize")
}
@ -116,7 +116,7 @@ pub fn expand_deriving_encodable(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
warn_if_deprecated(cx, span, "Encodable");
expand_deriving_encodable_imp(cx, span, mitem, item, push, "serialize")
}
@ -125,7 +125,7 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable),
push: &mut dyn FnMut(Annotatable),
krate: &'static str) {
let typaram = &*deriving::hygienic_type_parameter(item, "__S");

View File

@ -330,7 +330,7 @@ pub enum SubstructureFields<'a> {
/// Combine the values of all the fields together. The last argument is
/// all the fields of all the structures.
pub type CombineSubstructureFunc<'a> =
Box<FnMut(&mut ExtCtxt, Span, &Substructure) -> P<Expr> + 'a>;
Box<dyn FnMut(&mut ExtCtxt, Span, &Substructure) -> P<Expr> + 'a>;
/// Deal with non-matching enum variants. The tuple is a list of
/// identifiers (one for each `Self` argument, which could be any of the
@ -338,7 +338,7 @@ pub type CombineSubstructureFunc<'a> =
/// holding the variant index value for each of the `Self` arguments. The
/// last argument is all the non-`Self` args of the method being derived.
pub type EnumNonMatchCollapsedFunc<'a> =
Box<FnMut(&mut ExtCtxt, Span, (&[Ident], &[Ident]), &[P<Expr>]) -> P<Expr> + 'a>;
Box<dyn FnMut(&mut ExtCtxt, Span, (&[Ident], &[Ident]), &[P<Expr>]) -> P<Expr> + 'a>;
pub fn combine_substructure<'a>(f: CombineSubstructureFunc<'a>)
-> RefCell<CombineSubstructureFunc<'a>> {
@ -398,7 +398,7 @@ impl<'a> TraitDef<'a> {
cx: &mut ExtCtxt,
mitem: &ast::MetaItem,
item: &'a Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
self.expand_ext(cx, mitem, item, push, false);
}
@ -406,7 +406,7 @@ impl<'a> TraitDef<'a> {
cx: &mut ExtCtxt,
mitem: &ast::MetaItem,
item: &'a Annotatable,
push: &mut FnMut(Annotatable),
push: &mut dyn FnMut(Annotatable),
from_scratch: bool) {
match *item {
Annotatable::Item(ref item) => {

View File

@ -22,7 +22,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt,
span: Span,
mitem: &MetaItem,
item: &Annotatable,
push: &mut FnMut(Annotatable)) {
push: &mut dyn FnMut(Annotatable)) {
let path = Path::new_(pathvec_std!(cx, hash::Hash), None, vec![], PathKind::Std);

View File

@ -72,7 +72,7 @@ macro_rules! derive_traits {
}
}
pub fn register_builtin_derives(resolver: &mut Resolver) {
pub fn register_builtin_derives(resolver: &mut dyn Resolver) {
$(
resolver.add_builtin(
ast::Ident::with_empty_ctxt(Symbol::intern($name)),

View File

@ -26,7 +26,7 @@ use std::env;
pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[tokenstream::TokenTree])
-> Box<base::MacResult + 'cx> {
-> Box<dyn base::MacResult + 'cx> {
let var = match get_single_str_from_tts(cx, sp, tts, "option_env!") {
None => return DummyResult::expr(sp),
Some(v) => v,
@ -57,7 +57,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt,
pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[tokenstream::TokenTree])
-> Box<base::MacResult + 'cx> {
-> Box<dyn base::MacResult + 'cx> {
let mut exprs = match get_exprs_from_tts(cx, sp, tts) {
Some(ref exprs) if exprs.is_empty() => {
cx.span_err(sp, "env! takes 1 or 2 arguments");

View File

@ -679,7 +679,7 @@ impl<'a, 'b> Context<'a, 'b> {
pub fn expand_format_args<'cx>(ecx: &'cx mut ExtCtxt,
mut sp: Span,
tts: &[tokenstream::TokenTree])
-> Box<base::MacResult + 'cx> {
-> Box<dyn base::MacResult + 'cx> {
sp = sp.apply_mark(ecx.current_expansion.mark);
match parse_args(ecx, sp, tts) {
Some((efmt, args, names)) => {

View File

@ -34,7 +34,7 @@ pub const MACRO: &'static str = "global_asm";
pub fn expand_global_asm<'cx>(cx: &'cx mut ExtCtxt,
sp: Span,
tts: &[tokenstream::TokenTree]) -> Box<base::MacResult + 'cx> {
tts: &[tokenstream::TokenTree]) -> Box<dyn base::MacResult + 'cx> {
if !cx.ecfg.enable_global_asm() {
feature_gate::emit_feature_err(&cx.parse_sess,
MACRO,

View File

@ -10,6 +10,8 @@
//! Syntax extensions in the Rust compiler.
#![deny(bare_trait_objects)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/")]
@ -59,7 +61,7 @@ use syntax::ext::base::{MacroExpanderFn, NormalTT, NamedSyntaxExtension};
use syntax::ext::hygiene;
use syntax::symbol::Symbol;
pub fn register_builtins(resolver: &mut syntax::ext::base::Resolver,
pub fn register_builtins(resolver: &mut dyn syntax::ext::base::Resolver,
user_exts: Vec<NamedSyntaxExtension>,
enable_quotes: bool) {
deriving::register_builtin_derives(resolver);

View File

@ -17,7 +17,7 @@ use syntax_pos;
pub fn expand_syntax_ext<'cx>(cx: &'cx mut base::ExtCtxt,
sp: syntax_pos::Span,
tts: &[tokenstream::TokenTree])
-> Box<base::MacResult + 'cx> {
-> Box<dyn base::MacResult + 'cx> {
if !cx.ecfg.enable_log_syntax() {
feature_gate::emit_feature_err(&cx.parse_sess,
"log_syntax",

View File

@ -55,7 +55,7 @@ struct CollectProcMacros<'a> {
}
pub fn modify(sess: &ParseSess,
resolver: &mut ::syntax::ext::base::Resolver,
resolver: &mut dyn (::syntax::ext::base::Resolver),
mut krate: ast::Crate,
is_proc_macro_crate: bool,
is_test_crate: bool,
@ -200,8 +200,8 @@ impl<'a> CollectProcMacros<'a> {
}
fn collect_attr_proc_macro(&mut self, item: &'a ast::Item, attr: &'a ast::Attribute) {
if let Some(_) = attr.meta_item_list() {
self.handler.span_err(attr.span, "`#[proc_macro_attribute]` attribute
if !attr.is_word() {
self.handler.span_err(attr.span, "`#[proc_macro_attribute]` attribute \
does not take any arguments");
return;
}
@ -223,8 +223,8 @@ impl<'a> CollectProcMacros<'a> {
}
fn collect_bang_proc_macro(&mut self, item: &'a ast::Item, attr: &'a ast::Attribute) {
if let Some(_) = attr.meta_item_list() {
self.handler.span_err(attr.span, "`#[proc_macro]` attribute
if !attr.is_word() {
self.handler.span_err(attr.span, "`#[proc_macro]` attribute \
does not take any arguments");
return;
}

View File

@ -18,7 +18,7 @@ use syntax::tokenstream::TokenTree;
pub fn expand_trace_macros(cx: &mut ExtCtxt,
sp: Span,
tt: &[TokenTree])
-> Box<base::MacResult + 'static> {
-> Box<dyn base::MacResult + 'static> {
if !cx.ecfg.enable_trace_macros() {
feature_gate::emit_feature_err(&cx.parse_sess,
"trace_macros",

View File

@ -0,0 +1,36 @@
// Copyright 2018 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.
// no-prefer-dynamic
#![crate_type = "proc-macro"]
#![feature(proc_macro)]
extern crate proc_macro;
use proc_macro::TokenStream;
#[proc_macro = "test"] //~ ERROR: does not take any arguments
pub fn a(a: TokenStream) -> TokenStream { a }
#[proc_macro()] //~ ERROR: does not take any arguments
pub fn c(a: TokenStream) -> TokenStream { a }
#[proc_macro(x)] //~ ERROR: does not take any arguments
pub fn d(a: TokenStream) -> TokenStream { a }
#[proc_macro_attribute = "test"] //~ ERROR: does not take any arguments
pub fn e(_: TokenStream, a: TokenStream) -> TokenStream { a }
#[proc_macro_attribute()] //~ ERROR: does not take any arguments
pub fn g(_: TokenStream, a: TokenStream) -> TokenStream { a }
#[proc_macro_attribute(x)] //~ ERROR: does not take any arguments
pub fn h(_: TokenStream, a: TokenStream) -> TokenStream { a }

View File

@ -0,0 +1,38 @@
error: `#[proc_macro]` attribute does not take any arguments
--> $DIR/invalid-attributes.rs:20:1
|
LL | #[proc_macro = "test"] //~ ERROR: does not take any arguments
| ^^^^^^^^^^^^^^^^^^^^^^
error: `#[proc_macro]` attribute does not take any arguments
--> $DIR/invalid-attributes.rs:23:1
|
LL | #[proc_macro()] //~ ERROR: does not take any arguments
| ^^^^^^^^^^^^^^^
error: `#[proc_macro]` attribute does not take any arguments
--> $DIR/invalid-attributes.rs:26:1
|
LL | #[proc_macro(x)] //~ ERROR: does not take any arguments
| ^^^^^^^^^^^^^^^^
error: `#[proc_macro_attribute]` attribute does not take any arguments
--> $DIR/invalid-attributes.rs:29:1
|
LL | #[proc_macro_attribute = "test"] //~ ERROR: does not take any arguments
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[proc_macro_attribute]` attribute does not take any arguments
--> $DIR/invalid-attributes.rs:32:1
|
LL | #[proc_macro_attribute()] //~ ERROR: does not take any arguments
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: `#[proc_macro_attribute]` attribute does not take any arguments
--> $DIR/invalid-attributes.rs:35:1
|
LL | #[proc_macro_attribute(x)] //~ ERROR: does not take any arguments
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 6 previous errors