() => ();
( $($name:ident,)+ ) => (
#[stable(feature = "rust1", since = "1.0.0")]
- impl<$($name:Debug),*> Debug for ($($name,)*) where last_type!($($name,)+): ?Sized {
+ impl<$($name:Debug),+> Debug for ($($name,)+) where last_type!($($name,)+): ?Sized {
#[allow(non_snake_case, unused_assignments)]
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
let mut builder = f.debug_tuple("");
- let ($(ref $name,)*) = *self;
+ let ($(ref $name,)+) = *self;
$(
builder.field(&$name);
- )*
+ )+
builder.finish()
}
}
- peel! { $($name,)* }
+ peel! { $($name,)+ }
)
}
( $($name:ident)+) => (
#[stable(feature = "rust1", since = "1.0.0")]
- impl<$($name: Hash),*> Hash for ($($name,)*) where last_type!($($name,)+): ?Sized {
+ impl<$($name: Hash),+> Hash for ($($name,)+) where last_type!($($name,)+): ?Sized {
#[allow(non_snake_case)]
fn hash<S: Hasher>(&self, state: &mut S) {
- let ($(ref $name,)*) = *self;
- $($name.hash(state);)*
+ let ($(ref $name,)+) = *self;
+ $($name.hash(state);)+
}
}
);
($($a:ty)*) => (
integer_sum_product!(@impls 0, 1,
#[stable(feature = "iter_arith_traits", since = "1.12.0")],
- $($a)+);
+ $($a)*);
integer_sum_product!(@impls Wrapping(0), Wrapping(1),
#[stable(feature = "wrapping_iter_arith", since = "1.14.0")],
- $(Wrapping<$a>)+);
+ $(Wrapping<$a>)*);
);
}
$crate::panic!($msg)
);
($fmt:expr, $($arg:tt)+) => ({
- $crate::panicking::panic_fmt(format_args!($fmt, $($arg)*),
+ $crate::panicking::panic_fmt(format_args!($fmt, $($arg)+),
&(file!(), line!(), __rust_unstable_column!()))
});
}
#[stable(feature = "rust1", since = "1.0.0")]
macro_rules! unimplemented {
() => (panic!("not yet implemented"));
- ($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
+ ($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)+)));
}
/// Indicates unfinished code.
#[unstable(feature = "todo_macro", issue = "59277")]
macro_rules! todo {
() => (panic!("not yet implemented"));
- ($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)*)));
+ ($($arg:tt)+) => (panic!("not yet implemented: {}", format_args!($($arg)+)));
}
/// Creates an array of [`MaybeUninit`].
/// `Unsize` is implemented for:
///
/// - `[T; N]` is `Unsize<[T]>`
-/// - `T` is `Unsize<Trait>` when `T: Trait`
+/// - `T` is `Unsize<dyn Trait>` when `T: Trait`
/// - `Foo<..., T, ...>` is `Unsize<Foo<..., U, ...>>` if:
/// - `T: Unsize<U>`
/// - Foo is a struct
macro_rules! fnptr_impls_args {
($($Arg: ident),+) => {
- fnptr_impls_safety_abi! { extern "Rust" fn($($Arg),*) -> Ret, $($Arg),* }
- fnptr_impls_safety_abi! { extern "C" fn($($Arg),*) -> Ret, $($Arg),* }
- fnptr_impls_safety_abi! { extern "C" fn($($Arg),* , ...) -> Ret, $($Arg),* }
- fnptr_impls_safety_abi! { unsafe extern "Rust" fn($($Arg),*) -> Ret, $($Arg),* }
- fnptr_impls_safety_abi! { unsafe extern "C" fn($($Arg),*) -> Ret, $($Arg),* }
- fnptr_impls_safety_abi! { unsafe extern "C" fn($($Arg),* , ...) -> Ret, $($Arg),* }
+ fnptr_impls_safety_abi! { extern "Rust" fn($($Arg),+) -> Ret, $($Arg),+ }
+ fnptr_impls_safety_abi! { extern "C" fn($($Arg),+) -> Ret, $($Arg),+ }
+ fnptr_impls_safety_abi! { extern "C" fn($($Arg),+ , ...) -> Ret, $($Arg),+ }
+ fnptr_impls_safety_abi! { unsafe extern "Rust" fn($($Arg),+) -> Ret, $($Arg),+ }
+ fnptr_impls_safety_abi! { unsafe extern "C" fn($($Arg),+) -> Ret, $($Arg),+ }
+ fnptr_impls_safety_abi! { unsafe extern "C" fn($($Arg),+ , ...) -> Ret, $($Arg),+ }
};
() => {
// No variadic functions with 0 parameters
}
};
(enum $name:ident $(<$($T:ident),+>)? { $($variant:ident $(($field:ident))*),* $(,)? }) => {
- impl<S, $($($T: Encode<S>),+)?> Encode<S> for $name $(<$($T),+>)* {
+ impl<S, $($($T: Encode<S>),+)?> Encode<S> for $name $(<$($T),+>)? {
fn encode(self, w: &mut Writer, s: &mut S) {
// HACK(eddyb): `Tag` enum duplicated between the
// two impls as there's no other place to stash it.
}
}
- impl<S, $($($T: for<'s> DecodeMut<'a, 's, S>),+)*> DecodeMut<'a, '_, S>
- for $name $(<$($T),+>)*
+ impl<S, $($($T: for<'s> DecodeMut<'a, 's, S>),+)?> DecodeMut<'a, '_, S>
+ for $name $(<$($T),+>)?
{
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
// HACK(eddyb): `Tag` enum duplicated between the
fn visit_impl_item(&mut self, impl_item: &'hir ImplItem);
}
-pub struct DeepVisitor<'v, V: 'v> {
+pub struct DeepVisitor<'v, V> {
visitor: &'v mut V,
}
/// [blog post]: https://is.gd/0hKvIr
struct TypeGeneralizer<'me, 'tcx, D>
where
- D: TypeRelatingDelegate<'tcx> + 'me,
+ D: TypeRelatingDelegate<'tcx>,
{
infcx: &'me InferCtxt<'me, 'tcx>,
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
-#![allow(explicit_outlives_requirements)]
#![feature(arbitrary_self_types)]
#![feature(box_patterns)]
let lang_items = self.lang_items();
let did = Some(item_def_id);
- $(lang_items.$name() == did)||+
+ $(lang_items.$name() == did)||*
}
}
pub err: &'tcx Const<'tcx>,
}
-pub struct LocalTableInContext<'a, V: 'a> {
+pub struct LocalTableInContext<'a, V> {
local_id_root: Option<DefId>,
data: &'a ItemLocalMap<V>
}
}
}
-pub struct LocalTableInContextMut<'a, V: 'a> {
+pub struct LocalTableInContextMut<'a, V> {
local_id_root: Option<DefId>,
data: &'a mut ItemLocalMap<V>
}
/// An entry in an interner.
-struct Interned<'tcx, T: 'tcx+?Sized>(&'tcx T);
+struct Interned<'tcx, T: ?Sized>(&'tcx T);
impl<'tcx, T: 'tcx+?Sized> Clone for Interned<'tcx, T> {
fn clone(&self) -> Self {
/// A type representing the responsibility to execute the job in the `job` field.
/// This will poison the relevant query if dropped.
-pub(super) struct JobOwner<'a, 'tcx, Q: QueryDescription<'tcx> + 'a> {
+pub(super) struct JobOwner<'a, 'tcx, Q: QueryDescription<'tcx>> {
cache: &'a Lock<QueryCache<'tcx, Q>>,
key: Q::Key,
job: Lrc<QueryJob<'tcx>>,
}
/// The result of `try_get_lock`
-pub(super) enum TryGetJob<'a, 'tcx, D: QueryDescription<'tcx> + 'a> {
+pub(super) enum TryGetJob<'a, 'tcx, D: QueryDescription<'tcx>> {
/// The query is not yet started. Contains a guard to the cache eventually used to start it.
NotYetStarted(JobOwner<'a, 'tcx, D>),
unsafe {
llvm::$llvm_capi(self.llbuilder, $($arg,)* UNNAMED)
}
- })*
+ })+
}
}
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
-#![allow(explicit_outlives_requirements)]
use back::write::{create_target_machine, create_informational_target_machine};
use syntax_pos::symbol::Symbol;
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
-#![allow(explicit_outlives_requirements)]
#![recursion_limit="256"]
(@derives [$($derives:ident,)*]
@attrs [$(#[$attrs:meta])*]
@type [$type:ident]
- @max [$_max:expr]
+ @max [$max:expr]
@vis [$v:vis]
@debug_format [$debug_format:tt]
$(#[doc = $doc:expr])*
return Some(format!("{:?}", $itypes))
})*
None
- },)*
+ },)+
_ => None
}
}
fn flow_state(&self) -> &DataflowState<'tcx, Self::BD> { &self.flow_state.flow_state }
}
-struct Graph<'a, 'tcx, MWF:'a, P> where
+struct Graph<'a, 'tcx, MWF, P> where
MWF: MirWithFlowState<'tcx>
{
mbcx: &'a MWF,
struct PropagationContext<'b, 'a, 'tcx, O>
where
- O: 'b + BitDenotation<'tcx>,
+ O: BitDenotation<'tcx>,
{
builder: &'b mut DataflowAnalysis<'a, 'tcx, O>,
}
};
use crate::const_eval::{CompileTimeInterpreter, CompileTimeEvalContext};
-struct InternVisitor<'rt, 'mir: 'rt, 'tcx: 'rt + 'mir> {
+struct InternVisitor<'rt, 'mir, 'tcx> {
/// previously encountered safe references
ref_tracking: &'rt mut RefTracking<(MPlaceTy<'tcx>, Mutability, InternMode)>,
ecx: &'rt mut CompileTimeEvalContext<'mir, 'tcx>,
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
-#![allow(explicit_outlives_requirements)]
#[macro_use] extern crate log;
#[macro_use]
#[derive(Debug)]
struct DropCtxt<'l, 'b, 'tcx, D>
where
- D: DropElaborator<'b, 'tcx> + 'l,
+ D: DropElaborator<'b, 'tcx>,
{
elaborator: &'l mut D,
($((($($flavor:tt)*), $string:expr),)*) => (
impl LinkerFlavor {
pub const fn one_of() -> &'static str {
- concat!("one of: ", $($string, " ",)+)
+ concat!("one of: ", $($string, " ",)*)
}
pub fn from_str(s: &str) -> Option<Self> {
Some(match s {
- $($string => $($flavor)*,)+
+ $($string => $($flavor)*,)*
_ => return None,
})
}
pub fn desc(&self) -> &str {
match *self {
- $($($flavor)* => $string,)+
+ $($($flavor)* => $string,)*
}
}
}
#![deny(rust_2018_idioms)]
#![deny(internal)]
#![deny(unused_lifetimes)]
-#![allow(explicit_outlives_requirements)]
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
macro_rules! tuple {
() => ();
( $($name:ident,)+ ) => (
- impl<$($name:Decodable),*> Decodable for ($($name,)*) {
+ impl<$($name:Decodable),+> Decodable for ($($name,)+) {
#[allow(non_snake_case)]
- fn decode<D: Decoder>(d: &mut D) -> Result<($($name,)*), D::Error> {
- let len: usize = count!($($name)*);
+ fn decode<D: Decoder>(d: &mut D) -> Result<($($name,)+), D::Error> {
+ let len: usize = count!($($name)+);
d.read_tuple(len, |d| {
let mut i = 0;
let ret = ($(d.read_tuple_arg({ i+=1; i-1 }, |d| -> Result<$name, D::Error> {
Decodable::decode(d)
- })?,)*);
+ })?,)+);
Ok(ret)
})
}
}
- impl<$($name:Encodable),*> Encodable for ($($name,)*) {
+ impl<$($name:Encodable),+> Encodable for ($($name,)+) {
#[allow(non_snake_case)]
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
- let ($(ref $name,)*) = *self;
+ let ($(ref $name,)+) = *self;
let mut n = 0;
- $(let $name = $name; n += 1;)*
+ $(let $name = $name; n += 1;)+
s.emit_tuple(n, |s| {
let mut i = 0;
- $(s.emit_tuple_arg({ i+=1; i-1 }, |s| $name.encode(s))?;)*
+ $(s.emit_tuple_arg({ i+=1; i-1 }, |s| $name.encode(s))?;)+
Ok(())
})
}
}
- peel! { $($name,)* }
+ peel! { $($name,)+ }
)
}
/// is in the original source file. Gives a compiler error if the syntax of
/// the attribute is incorrect.
fn process_cfg_attr(&mut self, attr: ast::Attribute) -> Vec<ast::Attribute> {
- if !attr.check_name(sym::cfg_attr) {
+ if attr.path != sym::cfg_attr {
return vec![attr];
}
- if attr.tokens.len() == 0 {
+ if attr.tokens.is_empty() {
self.sess.span_diagnostic
.struct_span_err(
attr.span,
<https://doc.rust-lang.org/reference/conditional-compilation.html\
#the-cfg_attr-attribute>")
.emit();
- return Vec::new();
+ return vec![];
}
let (cfg_predicate, expanded_attrs) = match attr.parse(self.sess, |parser| {
Ok(result) => result,
Err(mut e) => {
e.emit();
- return Vec::new();
+ return vec![];
}
};
- // Check feature gate and lint on zero attributes in source. Even if the feature is gated,
- // we still compute as if it wasn't, since the emitted error will stop compilation further
- // along the compilation.
- if expanded_attrs.len() == 0 {
- // FIXME: Emit unused attribute lint here.
+ // Lint on zero attributes in source.
+ if expanded_attrs.is_empty() {
+ return vec![attr];
}
+ // At this point we know the attribute is considered used.
+ attr::mark_used(&attr);
+
if attr::cfg_matches(&cfg_predicate, self.sess, self.features) {
// We call `process_cfg_attr` recursively in case there's a
// `cfg_attr` inside of another `cfg_attr`. E.g.
}))
.collect()
} else {
- Vec::new()
+ vec![]
}
}
match attr.parse_list(cx.parse_sess,
|parser| parser.parse_path_allowing_meta(PathStyle::Mod)) {
- Ok(ref traits) if traits.is_empty() => {
- cx.span_warn(attr.span, "empty trait list in `derive`");
- false
- }
Ok(traits) => {
result.extend(traits);
true
}
});
}
- $($(AstFragment::$Kind(ast) => vis.$mut_visit_ast(ast),)*)*
+ $($(AstFragment::$Kind(ast) => vis.$mut_visit_ast(ast),)?)*
$($(AstFragment::$Kind(ast) =>
- ast.flat_map_in_place(|ast| vis.$flat_map_ast_elt(ast)),)*)*
+ ast.flat_map_in_place(|ast| vis.$flat_map_ast_elt(ast)),)?)*
}
}
match *self {
AstFragment::OptExpr(Some(ref expr)) => visitor.visit_expr(expr),
AstFragment::OptExpr(None) => {}
- $($(AstFragment::$Kind(ref ast) => visitor.$visit_ast(ast),)*)*
+ $($(AstFragment::$Kind(ref ast) => visitor.$visit_ast(ast),)?)*
$($(AstFragment::$Kind(ref ast) => for ast_elt in &ast[..] {
visitor.$visit_ast_elt(ast_elt);
- })*)*
+ })?)*
}
}
}
}
$($(fn $mut_visit_ast(&mut self, ast: &mut $AstTy) {
visit_clobber(ast, |ast| self.expand_fragment(AstFragment::$Kind(ast)).$make_ast());
- })*)*
+ })?)*
$($(fn $flat_map_ast_elt(&mut self, ast_elt: <$AstTy as IntoIterator>::Item) -> $AstTy {
self.expand_fragment(AstFragment::$Kind(smallvec![ast_elt])).$make_ast()
- })*)*
+ })?)*
}
impl<'a> MacResult for crate::ext::tt::macro_rules::ParserAnyMacro<'a> {
macro_rules! tt {
($ty:ident { $($field:ident $(: $value:expr)*),+ $(,)? }) => (
TokenTree::$ty(self::$ty {
- $($field $(: $value)*,)*
+ $($field $(: $value)*,)+
span,
})
);
--- /dev/null
+// Check that `#[cfg_attr($PREDICATE,)]` triggers the `unused_attribute` lint.
+
+// compile-flags: --cfg TRUE
+
+#![deny(unused)]
+
+#[cfg_attr(FALSE,)] //~ ERROR unused attribute
+fn _f() {}
+
+#[cfg_attr(TRUE,)] //~ ERROR unused attribute
+fn _g() {}
+
+fn main() {}
--- /dev/null
+error: unused attribute
+ --> $DIR/cfg-attr-empty-is-unused.rs:7:1
+ |
+LL | #[cfg_attr(FALSE,)]
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+note: lint level defined here
+ --> $DIR/cfg-attr-empty-is-unused.rs:5:9
+ |
+LL | #![deny(unused)]
+ | ^^^^^^
+ = note: #[deny(unused_attributes)] implied by #[deny(unused)]
+
+error: unused attribute
+ --> $DIR/cfg-attr-empty-is-unused.rs:10:1
+ |
+LL | #[cfg_attr(TRUE,)]
+ | ^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
-// compile-pass
+#![deny(unused)]
-#[derive()] //~ WARNING empty trait list in `derive`
-struct Bar;
+#[derive()] //~ ERROR unused attribute
+struct _Bar;
pub fn main() {}
-warning: empty trait list in `derive`
+error: unused attribute
--> $DIR/deriving-meta-empty-trait-list.rs:3:1
|
LL | #[derive()]
| ^^^^^^^^^^^
+ |
+note: lint level defined here
+ --> $DIR/deriving-meta-empty-trait-list.rs:1:9
+ |
+LL | #![deny(unused)]
+ | ^^^^^^
+ = note: #[deny(unused_attributes)] implied by #[deny(unused)]
+
+error: aborting due to previous error
macro_rules! test {
( $($name:ident)+) => (
- impl<$($name: Test),*> Test for ($($name,)*) {
+ impl<$($name: Test),+> Test for ($($name,)+) {
}
)
}
#[derive(Copy="bad")] //~ ERROR expected one of `)`, `,`, or `::`, found `=`
struct Test2;
-#[derive()] //~ WARNING empty trait list
-struct Test3;
-
#[derive] //~ ERROR malformed `derive` attribute input
struct Test4;
LL | #[derive(Copy="bad")]
| ^ expected one of `)`, `,`, or `::` here
-warning: empty trait list in `derive`
- --> $DIR/malformed-derive-entry.rs:7:1
- |
-LL | #[derive()]
- | ^^^^^^^^^^^
-
error: malformed `derive` attribute input
- --> $DIR/malformed-derive-entry.rs:10:1
+ --> $DIR/malformed-derive-entry.rs:7:1
|
LL | #[derive]
| ^^^^^^^^^ help: missing traits to be derived: `#[derive(Trait1, Trait2, ...)]`