Remove the deprecated concat_idents! macro
In [137653], the lang and libs-API teams did a joint FCP to deprecate
and eventually remove the long-unstable `concat_idents!` macro. The
deprecation is landing in 1.88, so do the removal here (target version
1.90).
This macro has been superseded by the more recent `${concat(...)}`
metavariable expression language feature, which avoids some of the
limitations of `concat_idents!`. The metavar expression is unstably
available under the [`macro_metavar_expr_concat`] feature.
History is mildly interesting here: `concat_idents!` goes back to 2011
when it was introduced with 513276e595 ("Add #concat_idents[] and
about the same:
let asdf_fdsa = "<.<";
assert(#concat_idents[asd,f_f,dsa] == "<.<");
assert(#ident_to_str[use_mention_distinction]
== "use_mention_distinction");
(That test existed from introduction until its removal here.)
Closes: https://www.github.com/rust-lang/rust/issues/29599
[137653]: https://www.github.com/rust-lang/rust/pull/137653
[`macro_metavar_expr_concat`]: https://www.github.com/rust-lang/rust/issues/124225
This commit is contained in:
parent
c978c8986f
commit
0e4de4ceb0
21 changed files with 53 additions and 335 deletions
|
|
@ -116,10 +116,6 @@ builtin_macros_concat_bytes_oob = numeric literal is out of bounds
|
|||
builtin_macros_concat_bytestr = cannot concatenate a byte string literal
|
||||
builtin_macros_concat_c_str_lit = cannot concatenate a C string literal
|
||||
|
||||
builtin_macros_concat_idents_ident_args = `concat_idents!()` requires ident args
|
||||
|
||||
builtin_macros_concat_idents_missing_args = `concat_idents!()` takes 1 or more arguments
|
||||
builtin_macros_concat_idents_missing_comma = `concat_idents!()` expecting comma
|
||||
builtin_macros_concat_missing_literal = expected a literal
|
||||
.note = only literals (like `"foo"`, `-42` and `3.14`) can be passed to `concat!()`
|
||||
|
||||
|
|
|
|||
|
|
@ -1,71 +0,0 @@
|
|||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::token::{self, Token};
|
||||
use rustc_ast::tokenstream::{TokenStream, TokenTree};
|
||||
use rustc_ast::{AttrVec, DUMMY_NODE_ID, Expr, ExprKind, Path, Ty, TyKind};
|
||||
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacResult, MacroExpanderResult};
|
||||
use rustc_span::{Ident, Span, Symbol};
|
||||
|
||||
use crate::errors;
|
||||
|
||||
pub(crate) fn expand_concat_idents<'cx>(
|
||||
cx: &'cx mut ExtCtxt<'_>,
|
||||
sp: Span,
|
||||
tts: TokenStream,
|
||||
) -> MacroExpanderResult<'cx> {
|
||||
if tts.is_empty() {
|
||||
let guar = cx.dcx().emit_err(errors::ConcatIdentsMissingArgs { span: sp });
|
||||
return ExpandResult::Ready(DummyResult::any(sp, guar));
|
||||
}
|
||||
|
||||
let mut res_str = String::new();
|
||||
for (i, e) in tts.iter().enumerate() {
|
||||
if i & 1 == 1 {
|
||||
match e {
|
||||
TokenTree::Token(Token { kind: token::Comma, .. }, _) => {}
|
||||
_ => {
|
||||
let guar = cx.dcx().emit_err(errors::ConcatIdentsMissingComma { span: sp });
|
||||
return ExpandResult::Ready(DummyResult::any(sp, guar));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if let TokenTree::Token(token, _) = e {
|
||||
if let Some((ident, _)) = token.ident() {
|
||||
res_str.push_str(ident.name.as_str());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let guar = cx.dcx().emit_err(errors::ConcatIdentsIdentArgs { span: sp });
|
||||
return ExpandResult::Ready(DummyResult::any(sp, guar));
|
||||
}
|
||||
}
|
||||
|
||||
let ident = Ident::new(Symbol::intern(&res_str), cx.with_call_site_ctxt(sp));
|
||||
|
||||
struct ConcatIdentsResult {
|
||||
ident: Ident,
|
||||
}
|
||||
|
||||
impl MacResult for ConcatIdentsResult {
|
||||
fn make_expr(self: Box<Self>) -> Option<P<Expr>> {
|
||||
Some(P(Expr {
|
||||
id: DUMMY_NODE_ID,
|
||||
kind: ExprKind::Path(None, Path::from_ident(self.ident)),
|
||||
span: self.ident.span,
|
||||
attrs: AttrVec::new(),
|
||||
tokens: None,
|
||||
}))
|
||||
}
|
||||
|
||||
fn make_ty(self: Box<Self>) -> Option<P<Ty>> {
|
||||
Some(P(Ty {
|
||||
id: DUMMY_NODE_ID,
|
||||
kind: TyKind::Path(None, Path::from_ident(self.ident)),
|
||||
span: self.ident.span,
|
||||
tokens: None,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
ExpandResult::Ready(Box::new(ConcatIdentsResult { ident }))
|
||||
}
|
||||
|
|
@ -290,27 +290,6 @@ pub(crate) struct ConcatBytesBadRepeat {
|
|||
pub(crate) span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(builtin_macros_concat_idents_missing_args)]
|
||||
pub(crate) struct ConcatIdentsMissingArgs {
|
||||
#[primary_span]
|
||||
pub(crate) span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(builtin_macros_concat_idents_missing_comma)]
|
||||
pub(crate) struct ConcatIdentsMissingComma {
|
||||
#[primary_span]
|
||||
pub(crate) span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(builtin_macros_concat_idents_ident_args)]
|
||||
pub(crate) struct ConcatIdentsIdentArgs {
|
||||
#[primary_span]
|
||||
pub(crate) span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(builtin_macros_bad_derive_target, code = E0774)]
|
||||
pub(crate) struct BadDeriveTarget {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ mod cfg_eval;
|
|||
mod compile_error;
|
||||
mod concat;
|
||||
mod concat_bytes;
|
||||
mod concat_idents;
|
||||
mod define_opaque;
|
||||
mod derive;
|
||||
mod deriving;
|
||||
|
|
@ -84,7 +83,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
|
|||
compile_error: compile_error::expand_compile_error,
|
||||
concat: concat::expand_concat,
|
||||
concat_bytes: concat_bytes::expand_concat_bytes,
|
||||
concat_idents: concat_idents::expand_concat_idents,
|
||||
const_format_args: format::expand_format_args,
|
||||
core_panic: edition_panic::expand_panic,
|
||||
env: env::expand_env,
|
||||
|
|
|
|||
|
|
@ -285,4 +285,18 @@ declare_features! (
|
|||
// -------------------------------------------------------------------------
|
||||
// feature-group-end: removed features
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// feature-group-start: removed library features
|
||||
// -------------------------------------------------------------------------
|
||||
//
|
||||
// FIXME(#141617): we should have a better way to track removed library features, but we reuse
|
||||
// the infrastructure here so users still get hints. The symbols used here can be remove from
|
||||
// `symbol.rs` when that happens.
|
||||
(removed, concat_idents, "CURRENT_RUSTC_VERSION", Some(29599),
|
||||
Some("use the `${concat(..)}` metavariable expression instead"), 142704),
|
||||
// -------------------------------------------------------------------------
|
||||
// feature-group-end: removed library features
|
||||
// -------------------------------------------------------------------------
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1109,45 +1109,6 @@ pub(crate) mod builtin {
|
|||
($name:expr $(,)?) => {{ /* compiler built-in */ }};
|
||||
}
|
||||
|
||||
/// Concatenates identifiers into one identifier.
|
||||
///
|
||||
/// This macro takes any number of comma-separated identifiers, and
|
||||
/// concatenates them all into one, yielding an expression which is a new
|
||||
/// identifier. Note that hygiene makes it such that this macro cannot
|
||||
/// capture local variables. Also, as a general rule, macros are only
|
||||
/// allowed in item, statement or expression position. That means while
|
||||
/// you may use this macro for referring to existing variables, functions or
|
||||
/// modules etc, you cannot define a new one with it.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(concat_idents)]
|
||||
///
|
||||
/// # fn main() {
|
||||
/// fn foobar() -> u32 { 23 }
|
||||
///
|
||||
/// let f = concat_idents!(foo, bar);
|
||||
/// println!("{}", f());
|
||||
///
|
||||
/// // fn concat_idents!(new, fun, name) { } // not usable in this way!
|
||||
/// # }
|
||||
/// ```
|
||||
#[unstable(
|
||||
feature = "concat_idents",
|
||||
issue = "29599",
|
||||
reason = "`concat_idents` is not stable enough for use and is subject to change"
|
||||
)]
|
||||
#[deprecated(
|
||||
since = "1.88.0",
|
||||
note = "use `${concat(...)}` with the `macro_metavar_expr_concat` feature instead"
|
||||
)]
|
||||
#[rustc_builtin_macro]
|
||||
#[macro_export]
|
||||
macro_rules! concat_idents {
|
||||
($($e:ident),+ $(,)?) => {{ /* compiler built-in */ }};
|
||||
}
|
||||
|
||||
/// Concatenates literals into a byte slice.
|
||||
///
|
||||
/// This macro takes any number of comma-separated literals, and concatenates them all into
|
||||
|
|
|
|||
|
|
@ -58,10 +58,9 @@ pub use crate::fmt::macros::Debug;
|
|||
pub use crate::hash::macros::Hash;
|
||||
|
||||
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
|
||||
#[allow(deprecated)]
|
||||
#[doc(no_inline)]
|
||||
pub use crate::{
|
||||
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
|
||||
assert, cfg, column, compile_error, concat, env, file, format_args,
|
||||
format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env,
|
||||
stringify, trace_macros,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -281,7 +281,6 @@
|
|||
#![feature(cfg_target_thread_local)]
|
||||
#![feature(cfi_encoding)]
|
||||
#![feature(char_max_len)]
|
||||
#![feature(concat_idents)]
|
||||
#![feature(core_float_math)]
|
||||
#![feature(decl_macro)]
|
||||
#![feature(deprecated_suggestion)]
|
||||
|
|
@ -717,10 +716,9 @@ pub use core::primitive;
|
|||
pub use core::todo;
|
||||
// Re-export built-in macros defined through core.
|
||||
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
|
||||
#[allow(deprecated)]
|
||||
pub use core::{
|
||||
assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args,
|
||||
env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax,
|
||||
assert, assert_matches, cfg, column, compile_error, concat, const_format_args, env, file,
|
||||
format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax,
|
||||
module_path, option_env, stringify, trace_macros,
|
||||
};
|
||||
// Re-export macros defined in core.
|
||||
|
|
|
|||
|
|
@ -45,10 +45,9 @@ pub use crate::result::Result::{self, Err, Ok};
|
|||
|
||||
// Re-exported built-in macros
|
||||
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
|
||||
#[allow(deprecated)]
|
||||
#[doc(no_inline)]
|
||||
pub use core::prelude::v1::{
|
||||
assert, cfg, column, compile_error, concat, concat_idents, env, file, format_args,
|
||||
assert, cfg, column, compile_error, concat, env, file, format_args,
|
||||
format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env,
|
||||
stringify, trace_macros, Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ In stable Rust, there is no way to create new identifiers by joining identifiers
|
|||
`#![feature(macro_metavar_expr_concat)]` introduces a way to do this, using the concat metavariable expression.
|
||||
|
||||
> This feature uses the syntax from [`macro_metavar_expr`] but is otherwise
|
||||
> independent. It replaces the old unstable feature [`concat_idents`].
|
||||
> independent. It replaces the since-removed unstable feature
|
||||
> [`concat_idents`].
|
||||
|
||||
> This is an experimental feature; it and its syntax will require a RFC before stabilization.
|
||||
|
||||
|
|
@ -126,8 +127,7 @@ test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
|
|||
|
||||
[`paste`]: https://crates.io/crates/paste
|
||||
[RFC 3086]: https://rust-lang.github.io/rfcs/3086-macro-metavar-expr.html
|
||||
[`concat_idents!`]: https://doc.rust-lang.org/nightly/std/macro.concat_idents.html
|
||||
[`macro_metavar_expr`]: ../language-features/macro-metavar-expr.md
|
||||
[`concat_idents`]: ../library-features/concat-idents.md
|
||||
[`concat_idents`]: https://github.com/rust-lang/rust/issues/29599
|
||||
[#124225]: https://github.com/rust-lang/rust/issues/124225
|
||||
[declarative macros]: https://doc.rust-lang.org/stable/reference/macros-by-example.html
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
# `concat_idents`
|
||||
|
||||
The tracking issue for this feature is: [#29599]
|
||||
|
||||
This feature is deprecated, to be replaced by [`macro_metavar_expr_concat`].
|
||||
|
||||
[#29599]: https://github.com/rust-lang/rust/issues/29599
|
||||
[`macro_metavar_expr_concat`]: https://github.com/rust-lang/rust/issues/124225
|
||||
|
||||
------------------------
|
||||
|
||||
> This feature is expected to be superseded by [`macro_metavar_expr_concat`](../language-features/macro-metavar-expr-concat.md).
|
||||
|
||||
The `concat_idents` feature adds a macro for concatenating multiple identifiers
|
||||
into one identifier.
|
||||
|
||||
## Examples
|
||||
|
||||
```rust
|
||||
#![feature(concat_idents)]
|
||||
|
||||
fn main() {
|
||||
fn foobar() -> u32 { 23 }
|
||||
let f = concat_idents!(foo, bar);
|
||||
assert_eq!(f(), 23);
|
||||
}
|
||||
```
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
#![expect(deprecated)] // concat_idents is deprecated
|
||||
|
||||
const XY_1: i32 = 10;
|
||||
|
||||
fn main() {
|
||||
const XY_2: i32 = 20;
|
||||
let a = concat_idents!(X, Y_1); //~ ERROR `concat_idents` is not stable
|
||||
let b = concat_idents!(X, Y_2); //~ ERROR `concat_idents` is not stable
|
||||
assert_eq!(a, 10);
|
||||
assert_eq!(b, 20);
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-concat_idents.rs:7:13
|
||||
|
|
||||
LL | let a = concat_idents!(X, Y_1);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information
|
||||
= help: add `#![feature(concat_idents)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-concat_idents.rs:8:13
|
||||
|
|
||||
LL | let b = concat_idents!(X, Y_2);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information
|
||||
= help: add `#![feature(concat_idents)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#![expect(deprecated)] // concat_idents is deprecated
|
||||
|
||||
fn main() {
|
||||
concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough
|
||||
//~| ERROR cannot find value `ab` in this scope
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-concat_idents2.rs:4:5
|
||||
|
|
||||
LL | concat_idents!(a, b);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information
|
||||
= help: add `#![feature(concat_idents)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0425]: cannot find value `ab` in this scope
|
||||
--> $DIR/feature-gate-concat_idents2.rs:4:5
|
||||
|
|
||||
LL | concat_idents!(a, b);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0425, E0658.
|
||||
For more information about an error, try `rustc --explain E0425`.
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
#![expect(deprecated)] // concat_idents is deprecated
|
||||
|
||||
const XY_1: i32 = 10;
|
||||
|
||||
fn main() {
|
||||
const XY_2: i32 = 20;
|
||||
assert_eq!(10, concat_idents!(X, Y_1)); //~ ERROR `concat_idents` is not stable
|
||||
assert_eq!(20, concat_idents!(X, Y_2)); //~ ERROR `concat_idents` is not stable
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-concat_idents3.rs:7:20
|
||||
|
|
||||
LL | assert_eq!(10, concat_idents!(X, Y_1));
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information
|
||||
= help: add `#![feature(concat_idents)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change
|
||||
--> $DIR/feature-gate-concat_idents3.rs:8:20
|
||||
|
|
||||
LL | assert_eq!(20, concat_idents!(X, Y_2));
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information
|
||||
= help: add `#![feature(concat_idents)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
|
@ -15,7 +15,6 @@
|
|||
#![cfg_attr(core, no_std)]
|
||||
|
||||
#![allow(deprecated)] // for deprecated `try!()` macro
|
||||
#![feature(concat_idents)]
|
||||
|
||||
#[cfg(std)] use std::fmt;
|
||||
#[cfg(core)] use core::fmt;
|
||||
|
|
@ -79,17 +78,6 @@ fn concat() {
|
|||
let _ = concat!("hello", " world",);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn concat_idents() {
|
||||
fn foo() {}
|
||||
fn foobar() {}
|
||||
|
||||
concat_idents!(foo)();
|
||||
concat_idents!(foo,)();
|
||||
concat_idents!(foo, bar)();
|
||||
concat_idents!(foo, bar,)();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn debug_assert() {
|
||||
debug_assert!(true);
|
||||
|
|
|
|||
|
|
@ -3,9 +3,8 @@
|
|||
// test that errors in a (selection) of macros don't kill compilation
|
||||
// immediately, so that we get more errors listed at a time.
|
||||
|
||||
#![feature(trace_macros, concat_idents)]
|
||||
#![feature(trace_macros)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![expect(deprecated)] // concat_idents is deprecated
|
||||
|
||||
use std::arch::asm;
|
||||
|
||||
|
|
@ -105,8 +104,6 @@ fn main() {
|
|||
asm!(invalid); //~ ERROR
|
||||
llvm_asm!(invalid); //~ ERROR
|
||||
|
||||
concat_idents!("not", "idents"); //~ ERROR
|
||||
|
||||
option_env!(invalid); //~ ERROR
|
||||
env!(invalid); //~ ERROR
|
||||
env!(foo, abr, baz); //~ ERROR
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
error: the `#[default]` attribute may only be used on unit enum variants
|
||||
--> $DIR/macros-nonfatal-errors.rs:14:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:13:5
|
||||
|
|
||||
LL | #[default]
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -7,7 +7,7 @@ LL | #[default]
|
|||
= help: consider a manual implementation of `Default`
|
||||
|
||||
error: the `#[default]` attribute may only be used on unit enum variants
|
||||
--> $DIR/macros-nonfatal-errors.rs:19:36
|
||||
--> $DIR/macros-nonfatal-errors.rs:18:36
|
||||
|
|
||||
LL | struct DefaultInnerAttrTupleStruct(#[default] ());
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -15,7 +15,7 @@ LL | struct DefaultInnerAttrTupleStruct(#[default] ());
|
|||
= help: consider a manual implementation of `Default`
|
||||
|
||||
error: the `#[default]` attribute may only be used on unit enum variants
|
||||
--> $DIR/macros-nonfatal-errors.rs:23:1
|
||||
--> $DIR/macros-nonfatal-errors.rs:22:1
|
||||
|
|
||||
LL | #[default]
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -23,7 +23,7 @@ LL | #[default]
|
|||
= help: consider a manual implementation of `Default`
|
||||
|
||||
error: the `#[default]` attribute may only be used on unit enum variants
|
||||
--> $DIR/macros-nonfatal-errors.rs:27:1
|
||||
--> $DIR/macros-nonfatal-errors.rs:26:1
|
||||
|
|
||||
LL | #[default]
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -31,7 +31,7 @@ LL | #[default]
|
|||
= help: consider a manual implementation of `Default`
|
||||
|
||||
error: the `#[default]` attribute may only be used on unit enum variants
|
||||
--> $DIR/macros-nonfatal-errors.rs:37:11
|
||||
--> $DIR/macros-nonfatal-errors.rs:36:11
|
||||
|
|
||||
LL | Foo = #[default] 0,
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -39,7 +39,7 @@ LL | Foo = #[default] 0,
|
|||
= help: consider a manual implementation of `Default`
|
||||
|
||||
error: the `#[default]` attribute may only be used on unit enum variants
|
||||
--> $DIR/macros-nonfatal-errors.rs:38:14
|
||||
--> $DIR/macros-nonfatal-errors.rs:37:14
|
||||
|
|
||||
LL | Bar([u8; #[default] 1]),
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -47,7 +47,7 @@ LL | Bar([u8; #[default] 1]),
|
|||
= help: consider a manual implementation of `Default`
|
||||
|
||||
error[E0665]: `#[derive(Default)]` on enum with no `#[default]`
|
||||
--> $DIR/macros-nonfatal-errors.rs:43:10
|
||||
--> $DIR/macros-nonfatal-errors.rs:42:10
|
||||
|
|
||||
LL | #[derive(Default)]
|
||||
| ^^^^^^^
|
||||
|
|
@ -67,7 +67,7 @@ LL | #[default] Bar,
|
|||
| ++++++++++
|
||||
|
||||
error[E0665]: `#[derive(Default)]` on enum with no `#[default]`
|
||||
--> $DIR/macros-nonfatal-errors.rs:49:10
|
||||
--> $DIR/macros-nonfatal-errors.rs:48:10
|
||||
|
|
||||
LL | #[derive(Default)]
|
||||
| ^^^^^^^
|
||||
|
|
@ -78,7 +78,7 @@ LL | | }
|
|||
| |_- this enum needs a unit variant marked with `#[default]`
|
||||
|
||||
error: multiple declared defaults
|
||||
--> $DIR/macros-nonfatal-errors.rs:55:10
|
||||
--> $DIR/macros-nonfatal-errors.rs:54:10
|
||||
|
|
||||
LL | #[derive(Default)]
|
||||
| ^^^^^^^
|
||||
|
|
@ -95,7 +95,7 @@ LL | Baz,
|
|||
= note: only one variant can be default
|
||||
|
||||
error: `#[default]` attribute does not accept a value
|
||||
--> $DIR/macros-nonfatal-errors.rs:67:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:66:5
|
||||
|
|
||||
LL | #[default = 1]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
@ -103,7 +103,7 @@ LL | #[default = 1]
|
|||
= help: try using `#[default]`
|
||||
|
||||
error: multiple `#[default]` attributes
|
||||
--> $DIR/macros-nonfatal-errors.rs:75:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:74:5
|
||||
|
|
||||
LL | #[default]
|
||||
| ---------- `#[default]` used here
|
||||
|
|
@ -114,13 +114,13 @@ LL | Foo,
|
|||
|
|
||||
= note: only one `#[default]` attribute is needed
|
||||
help: try removing this
|
||||
--> $DIR/macros-nonfatal-errors.rs:74:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:73:5
|
||||
|
|
||||
LL | #[default]
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: multiple `#[default]` attributes
|
||||
--> $DIR/macros-nonfatal-errors.rs:85:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:84:5
|
||||
|
|
||||
LL | #[default]
|
||||
| ---------- `#[default]` used here
|
||||
|
|
@ -132,7 +132,7 @@ LL | Foo,
|
|||
|
|
||||
= note: only one `#[default]` attribute is needed
|
||||
help: try removing these
|
||||
--> $DIR/macros-nonfatal-errors.rs:82:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:81:5
|
||||
|
|
||||
LL | #[default]
|
||||
| ^^^^^^^^^^
|
||||
|
|
@ -142,7 +142,7 @@ LL | #[default]
|
|||
| ^^^^^^^^^^
|
||||
|
||||
error: the `#[default]` attribute may only be used on unit enum variants
|
||||
--> $DIR/macros-nonfatal-errors.rs:92:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:91:5
|
||||
|
|
||||
LL | Foo {},
|
||||
| ^^^
|
||||
|
|
@ -150,7 +150,7 @@ LL | Foo {},
|
|||
= help: consider a manual implementation of `Default`
|
||||
|
||||
error: default variant must be exhaustive
|
||||
--> $DIR/macros-nonfatal-errors.rs:100:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:99:5
|
||||
|
|
||||
LL | #[non_exhaustive]
|
||||
| ----------------- declared `#[non_exhaustive]` here
|
||||
|
|
@ -160,37 +160,31 @@ LL | Foo,
|
|||
= help: consider a manual implementation of `Default`
|
||||
|
||||
error: asm template must be a string literal
|
||||
--> $DIR/macros-nonfatal-errors.rs:105:10
|
||||
--> $DIR/macros-nonfatal-errors.rs:104:10
|
||||
|
|
||||
LL | asm!(invalid);
|
||||
| ^^^^^^^
|
||||
|
||||
error: `concat_idents!()` requires ident args
|
||||
--> $DIR/macros-nonfatal-errors.rs:108:5
|
||||
|
|
||||
LL | concat_idents!("not", "idents");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: argument must be a string literal
|
||||
--> $DIR/macros-nonfatal-errors.rs:110:17
|
||||
--> $DIR/macros-nonfatal-errors.rs:107:17
|
||||
|
|
||||
LL | option_env!(invalid);
|
||||
| ^^^^^^^
|
||||
|
||||
error: expected string literal
|
||||
--> $DIR/macros-nonfatal-errors.rs:111:10
|
||||
--> $DIR/macros-nonfatal-errors.rs:108:10
|
||||
|
|
||||
LL | env!(invalid);
|
||||
| ^^^^^^^
|
||||
|
||||
error: `env!()` takes 1 or 2 arguments
|
||||
--> $DIR/macros-nonfatal-errors.rs:112:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:109:5
|
||||
|
|
||||
LL | env!(foo, abr, baz);
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: environment variable `RUST_HOPEFULLY_THIS_DOESNT_EXIST` not defined at compile time
|
||||
--> $DIR/macros-nonfatal-errors.rs:113:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:110:5
|
||||
|
|
||||
LL | env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -198,7 +192,7 @@ LL | env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST");
|
|||
= help: use `std::env::var("RUST_HOPEFULLY_THIS_DOESNT_EXIST")` to read the variable at run time
|
||||
|
||||
error: format argument must be a string literal
|
||||
--> $DIR/macros-nonfatal-errors.rs:115:13
|
||||
--> $DIR/macros-nonfatal-errors.rs:112:13
|
||||
|
|
||||
LL | format!(invalid);
|
||||
| ^^^^^^^
|
||||
|
|
@ -209,43 +203,43 @@ LL | format!("{}", invalid);
|
|||
| +++++
|
||||
|
||||
error: argument must be a string literal
|
||||
--> $DIR/macros-nonfatal-errors.rs:117:14
|
||||
--> $DIR/macros-nonfatal-errors.rs:114:14
|
||||
|
|
||||
LL | include!(invalid);
|
||||
| ^^^^^^^
|
||||
|
||||
error: argument must be a string literal
|
||||
--> $DIR/macros-nonfatal-errors.rs:119:18
|
||||
--> $DIR/macros-nonfatal-errors.rs:116:18
|
||||
|
|
||||
LL | include_str!(invalid);
|
||||
| ^^^^^^^
|
||||
|
||||
error: couldn't read `$DIR/i'd be quite surprised if a file with this name existed`: $FILE_NOT_FOUND_MSG
|
||||
--> $DIR/macros-nonfatal-errors.rs:120:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:117:5
|
||||
|
|
||||
LL | include_str!("i'd be quite surprised if a file with this name existed");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: argument must be a string literal
|
||||
--> $DIR/macros-nonfatal-errors.rs:121:20
|
||||
--> $DIR/macros-nonfatal-errors.rs:118:20
|
||||
|
|
||||
LL | include_bytes!(invalid);
|
||||
| ^^^^^^^
|
||||
|
||||
error: couldn't read `$DIR/i'd be quite surprised if a file with this name existed`: $FILE_NOT_FOUND_MSG
|
||||
--> $DIR/macros-nonfatal-errors.rs:122:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:119:5
|
||||
|
|
||||
LL | include_bytes!("i'd be quite surprised if a file with this name existed");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: trace_macros! accepts only `true` or `false`
|
||||
--> $DIR/macros-nonfatal-errors.rs:124:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:121:5
|
||||
|
|
||||
LL | trace_macros!(invalid);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: default variant must be exhaustive
|
||||
--> $DIR/macros-nonfatal-errors.rs:134:9
|
||||
--> $DIR/macros-nonfatal-errors.rs:131:9
|
||||
|
|
||||
LL | #[non_exhaustive]
|
||||
| ----------------- declared `#[non_exhaustive]` here
|
||||
|
|
@ -255,11 +249,11 @@ LL | Foo,
|
|||
= help: consider a manual implementation of `Default`
|
||||
|
||||
error: cannot find macro `llvm_asm` in this scope
|
||||
--> $DIR/macros-nonfatal-errors.rs:106:5
|
||||
--> $DIR/macros-nonfatal-errors.rs:105:5
|
||||
|
|
||||
LL | llvm_asm!(invalid);
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 29 previous errors
|
||||
error: aborting due to 28 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0665`.
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
#![feature(concat_idents)]
|
||||
#![expect(deprecated)] // concat_idents is deprecated
|
||||
|
||||
pub fn main() {
|
||||
struct Foo;
|
||||
let _: concat_idents!(F, oo) = Foo; // Test that `concat_idents!` can be used in type positions
|
||||
|
||||
let asdf_fdsa = "<.<".to_string();
|
||||
// concat_idents should have call-site hygiene.
|
||||
assert!(concat_idents!(asd, f_f, dsa) == "<.<".to_string());
|
||||
|
||||
assert_eq!(stringify!(use_mention_distinction), "use_mention_distinction");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue