From 6ca8a26318e6dd898ce5c53689566729a8f1299c Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Mon, 7 Apr 2025 19:30:51 +0200 Subject: [PATCH 01/21] Explicitly export core and std macros Currently all core and std macros are automatically added to the prelude via #[macro_use]. However a situation arose where we want to add a new macro `assert_matches` but don't want to pull it into the standard prelude for compatibility reasons. By explicitly exporting the macros found in the core and std crates we get to decide on a per macro basis and can later add them via the rust_20xx preludes. --- .../src/standard_library_imports.rs | 2 +- library/core/src/prelude/v1.rs | 53 +++++++++++++++++- library/proc_macro/src/bridge/symbol.rs | 4 +- library/std/src/prelude/v1.rs | 55 +++++++++++++++++-- 4 files changed, 105 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_builtin_macros/src/standard_library_imports.rs b/compiler/rustc_builtin_macros/src/standard_library_imports.rs index 2068b5ca54dd0..9f22d9eacb33c 100644 --- a/compiler/rustc_builtin_macros/src/standard_library_imports.rs +++ b/compiler/rustc_builtin_macros/src/standard_library_imports.rs @@ -43,7 +43,7 @@ pub fn inject( let item = cx.item( span, - thin_vec![cx.attr_word(sym::macro_use, span)], + ast::AttrVec::new(), ast::ItemKind::ExternCrate(None, Ident::new(name, ident_span)), ); diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index d8d82afb0e625..7927bcd813c79 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -60,11 +60,17 @@ pub use crate::hash::macros::Hash; #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] pub use crate::{ - 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, + assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq, debug_assert_ne, env, file, format_args, include, include_bytes, include_str, line, matches, module_path, option_env, panic, stringify, todo, r#try, unimplemented, unreachable, write, writeln, }; +#[unstable(feature = "ub_checks", issue = "none")] +#[doc(no_inline)] +pub use crate::assert_unsafe_precondition; + +#[unstable(feature = "cfg_match", issue = "115585")] +#[doc(no_inline)] +pub use crate::cfg_match; + #[unstable( feature = "concat_bytes", issue = "87555", @@ -73,6 +79,47 @@ pub use crate::{ #[doc(no_inline)] pub use crate::concat_bytes; +#[unstable( + feature = "concat_idents", + issue = "29599", + reason = "`concat_idents` is not stable enough for use and is subject to change" +)] +#[doc(no_inline)] +pub use crate::concat_idents; + +#[unstable(feature = "const_format_args", issue = "none")] +#[doc(no_inline)] +pub use crate::const_format_args; + +#[unstable( + feature = "format_args_nl", + issue = "none", + reason = "`format_args_nl` is only for internal \ + language use and is subject to change" +)] +#[doc(no_inline)] +pub use crate::format_args_nl; + +#[unstable( + feature = "log_syntax", + issue = "29598", + reason = "`log_syntax!` is not stable enough for use and is subject to change" +)] +#[doc(no_inline)] +pub use crate::log_syntax; + +#[unstable(feature = "pattern_type_macro", issue = "123646")] +#[doc(no_inline)] +pub use crate::pattern_type; + +#[unstable( + feature = "trace_macros", + issue = "29598", + reason = "`trace_macros` is not stable enough for use and is subject to change" +)] +#[doc(no_inline)] +pub use crate::trace_macros; + // Do not `doc(no_inline)` so that they become doc items on their own // (no public module for them to be re-exported from). #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] diff --git a/library/proc_macro/src/bridge/symbol.rs b/library/proc_macro/src/bridge/symbol.rs index 57ca7db9fcdd7..bb5ba1227b974 100644 --- a/library/proc_macro/src/bridge/symbol.rs +++ b/library/proc_macro/src/bridge/symbol.rs @@ -12,8 +12,10 @@ use std::cell::RefCell; use std::num::NonZero; use std::str; +use std::fmt; -use super::*; +// Explicit import to avoid macro namespace collision. +use super::{arena, client, DecodeMut, Encode, fxhash, Mark, Marked, Reader, server, Unmark, Writer}; /// Handle for a symbol string stored within the Interner. #[derive(Copy, Clone, PartialEq, Eq, Hash)] diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index 70c1113155656..e38a93f0373d1 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -43,15 +43,25 @@ pub use crate::option::Option::{self, None, Some}; #[doc(no_inline)] pub use crate::result::Result::{self, Err, Ok}; -// Re-exported built-in macros +// Re-exported built-in macros and traits #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] pub use core::prelude::v1::{ - 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, + assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq, debug_assert_ne, env, file, format_args, include, include_bytes, include_str, line, matches, + module_path, option_env, panic, stringify, todo, r#try, unimplemented, unreachable, write, + writeln, Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, }; +#[stable(feature = "builtin_macro_prelude", since = "1.38.0")] +#[doc(no_inline)] +pub use crate::{ + dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local, vec, +}; + +#[unstable(feature = "cfg_match", issue = "115585")] +#[doc(no_inline)] +pub use core::prelude::v1::cfg_match; + #[unstable( feature = "concat_bytes", issue = "87555", @@ -60,6 +70,43 @@ pub use core::prelude::v1::{ #[doc(no_inline)] pub use core::prelude::v1::concat_bytes; +#[unstable( + feature = "concat_idents", + issue = "29599", + reason = "`concat_idents` is not stable enough for use and is subject to change" +)] +#[doc(no_inline)] +pub use core::prelude::v1::concat_idents; + +#[unstable(feature = "const_format_args", issue = "none")] +#[doc(no_inline)] +pub use core::prelude::v1::const_format_args; + +#[unstable( + feature = "format_args_nl", + issue = "none", + reason = "`format_args_nl` is only for internal \ + language use and is subject to change" +)] +#[doc(no_inline)] +pub use core::prelude::v1::format_args_nl; + +#[unstable( + feature = "log_syntax", + issue = "29598", + reason = "`log_syntax!` is not stable enough for use and is subject to change" +)] +#[doc(no_inline)] +pub use core::prelude::v1::log_syntax; + +#[unstable( + feature = "trace_macros", + issue = "29598", + reason = "`trace_macros` is not stable enough for use and is subject to change" +)] +#[doc(no_inline)] +pub use core::prelude::v1::trace_macros; + // Do not `doc(no_inline)` so that they become doc items on their own // (no public module for them to be re-exported from). #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] From b5d09435c01fa17c63d8d0701849ed4e378b900a Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Tue, 8 Apr 2025 10:55:39 +0200 Subject: [PATCH 02/21] Apply review comments --- library/core/src/prelude/v1.rs | 13 ------------- library/std/src/prelude/v1.rs | 9 --------- library/std/src/process.rs | 2 +- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index 7927bcd813c79..291490ea1a23a 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -63,10 +63,6 @@ pub use crate::{ assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq, debug_assert_ne, env, file, format_args, include, include_bytes, include_str, line, matches, module_path, option_env, panic, stringify, todo, r#try, unimplemented, unreachable, write, writeln, }; -#[unstable(feature = "ub_checks", issue = "none")] -#[doc(no_inline)] -pub use crate::assert_unsafe_precondition; - #[unstable(feature = "cfg_match", issue = "115585")] #[doc(no_inline)] pub use crate::cfg_match; @@ -91,15 +87,6 @@ pub use crate::concat_idents; #[doc(no_inline)] pub use crate::const_format_args; -#[unstable( - feature = "format_args_nl", - issue = "none", - reason = "`format_args_nl` is only for internal \ - language use and is subject to change" -)] -#[doc(no_inline)] -pub use crate::format_args_nl; - #[unstable( feature = "log_syntax", issue = "29598", diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index e38a93f0373d1..8b702a9ddffb9 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -82,15 +82,6 @@ pub use core::prelude::v1::concat_idents; #[doc(no_inline)] pub use core::prelude::v1::const_format_args; -#[unstable( - feature = "format_args_nl", - issue = "none", - reason = "`format_args_nl` is only for internal \ - language use and is subject to change" -)] -#[doc(no_inline)] -pub use core::prelude::v1::format_args_nl; - #[unstable( feature = "log_syntax", issue = "29598", diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 373584d0117ce..3e776e10e0b19 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -169,7 +169,7 @@ use crate::path::Path; use crate::sys::pipe::{AnonPipe, read2}; use crate::sys::process as imp; use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; -use crate::{fmt, fs, str}; +use crate::{fmt, format_args_nl, fs, str}; /// Representation of a running or exited child process. /// From 62f35bfe38cdcb4cd76e7cc951a0aa155572bde3 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Tue, 8 Apr 2025 11:03:08 +0200 Subject: [PATCH 03/21] Fix formatting tidy issues --- library/proc_macro/src/bridge/symbol.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/proc_macro/src/bridge/symbol.rs b/library/proc_macro/src/bridge/symbol.rs index bb5ba1227b974..e0f3a6a2860b2 100644 --- a/library/proc_macro/src/bridge/symbol.rs +++ b/library/proc_macro/src/bridge/symbol.rs @@ -11,11 +11,12 @@ use std::cell::RefCell; use std::num::NonZero; -use std::str; -use std::fmt; +use std::{fmt, str}; // Explicit import to avoid macro namespace collision. -use super::{arena, client, DecodeMut, Encode, fxhash, Mark, Marked, Reader, server, Unmark, Writer}; +use super::{ + DecodeMut, Encode, Mark, Marked, Reader, Unmark, Writer, arena, client, fxhash, server, +}; /// Handle for a symbol string stored within the Interner. #[derive(Copy, Clone, PartialEq, Eq, Hash)] From b3762fe6da2cb9580cd7e8fc945727d7bcc2281d Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Tue, 8 Apr 2025 19:52:28 +0200 Subject: [PATCH 04/21] Special case vec macro --- library/std/src/prelude/v1.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index 8b702a9ddffb9..7363b3cc151b6 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -55,9 +55,20 @@ pub use core::prelude::v1::{ #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] pub use crate::{ - dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local, vec, + dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local, }; +// The `vec` macro needs special handling, so that we don't export it *and* the `std::vec` module at +// the same time. We only want the macro in the prelude. +mod vec_macro_only { + #[allow(hidden_glob_reexports)] + mod vec {} + #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] + pub use crate::*; +} +#[stable(feature = "builtin_macro_prelude", since = "1.38.0")] +pub use self::vec_macro_only::vec; + #[unstable(feature = "cfg_match", issue = "115585")] #[doc(no_inline)] pub use core::prelude::v1::cfg_match; From fb454daabe37a3dd2518cfc42793caafda10c116 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Wed, 9 Apr 2025 08:48:43 +0200 Subject: [PATCH 05/21] Explicitly import format_args_nl --- src/librustdoc/html/highlight.rs | 1 + .../rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs | 2 +- tests/ui/hygiene/format-args.rs | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 272180fb9904c..1aab669c60f6d 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -7,6 +7,7 @@ use std::collections::VecDeque; use std::fmt::{self, Display, Write}; +use std::format_args_nl; use rustc_data_structures::fx::FxIndexMap; use rustc_lexer::{Cursor, FrontmatterAllowed, LiteralKind, TokenKind}; diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs index dd359326c61d6..d732fc250f25a 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs @@ -445,7 +445,7 @@ fn test_string_highlighting() { //- minicore: fmt, assert, asm, concat, panic macro_rules! println { ($($arg:tt)*) => ({ - $crate::io::_print(format_args_nl!($($arg)*)); + $crate::io::_print(std::format_args_nl!($($arg)*)); }) } diff --git a/tests/ui/hygiene/format-args.rs b/tests/ui/hygiene/format-args.rs index ff08aecfd9eb7..f845f5d8a4c8f 100644 --- a/tests/ui/hygiene/format-args.rs +++ b/tests/ui/hygiene/format-args.rs @@ -3,6 +3,8 @@ #![allow(non_upper_case_globals)] #![feature(format_args_nl)] +use std::format_args_nl; + static arg0: () = (); fn main() { From 5281f64b5b8835d8a0d18fdf7a8500cfde8b1d74 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Wed, 9 Apr 2025 08:59:57 +0200 Subject: [PATCH 06/21] Exclude panic and env namespaces from prelude --- library/core/src/prelude/v1.rs | 15 ++++++++++++++- library/std/src/prelude/v1.rs | 8 ++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index 291490ea1a23a..82aed3cff361b 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -60,9 +60,22 @@ pub use crate::hash::macros::Hash; #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] pub use crate::{ - assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq, debug_assert_ne, env, file, format_args, include, include_bytes, include_str, line, matches, module_path, option_env, panic, stringify, todo, r#try, unimplemented, unreachable, write, writeln, + assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq, debug_assert_ne, file, format_args, include, include_bytes, include_str, line, matches, module_path, option_env, stringify, todo, r#try, unimplemented, unreachable, write, writeln, }; +// These macros needs special handling, so that we don't export it *and* the modules of the same +// name. We only want the macro in the prelude. +mod ambiguous_macro_only { + #[allow(hidden_glob_reexports)] + mod env {} + #[allow(hidden_glob_reexports)] + mod panic {} + #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] + pub use crate::*; +} +#[stable(feature = "builtin_macro_prelude", since = "1.38.0")] +pub use self::ambiguous_macro_only::{env, panic}; + #[unstable(feature = "cfg_match", issue = "115585")] #[doc(no_inline)] pub use crate::cfg_match; diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index 7363b3cc151b6..669212a442e89 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -58,16 +58,16 @@ pub use crate::{ dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local, }; -// The `vec` macro needs special handling, so that we don't export it *and* the `std::vec` module at -// the same time. We only want the macro in the prelude. -mod vec_macro_only { +// These macros needs special handling, so that we don't export it *and* the modules of the same +// name. We only want the macro in the prelude. +mod ambiguous_macro_only_std { #[allow(hidden_glob_reexports)] mod vec {} #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] pub use crate::*; } #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] -pub use self::vec_macro_only::vec; +pub use self::ambiguous_macro_only_std::vec; #[unstable(feature = "cfg_match", issue = "115585")] #[doc(no_inline)] From e4715797dd5557efc34ac79d2396848cc45b525e Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Fri, 11 Apr 2025 15:23:34 +0200 Subject: [PATCH 07/21] Explicitly use std panic over core panic --- library/std/src/prelude/mod.rs | 15 +++++++++++++++ library/std/src/prelude/v1.rs | 8 +++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/library/std/src/prelude/mod.rs b/library/std/src/prelude/mod.rs index 5f7097c26e228..8a0a293c4e1d1 100644 --- a/library/std/src/prelude/mod.rs +++ b/library/std/src/prelude/mod.rs @@ -145,6 +145,11 @@ pub mod rust_2021 { #[stable(feature = "prelude_2021", since = "1.55.0")] #[doc(no_inline)] pub use core::prelude::rust_2021::*; + + // There are two different panic macros, one in `core` and one in `std`. They are slightly + // different. For `std` we explicitly want the one defined in `std`. + #[stable(feature = "prelude_2021", since = "1.55.0")] + pub use super::v1::panic; } /// The 2024 version of the prelude of The Rust Standard Library. @@ -159,6 +164,11 @@ pub mod rust_2024 { #[stable(feature = "prelude_2024", since = "1.85.0")] #[doc(no_inline)] pub use core::prelude::rust_2024::*; + + // There are two different panic macros, one in `core` and one in `std`. They are slightly + // different. For `std` we explicitly want the one defined in `std`. + #[stable(feature = "prelude_2024", since = "1.85.0")] + pub use super::v1::panic; } /// The Future version of the prelude of The Rust Standard Library. @@ -174,4 +184,9 @@ pub mod rust_future { #[unstable(feature = "prelude_next", issue = "none")] #[doc(no_inline)] pub use core::prelude::rust_future::*; + + // There are two different panic macros, one in `core` and one in `std`. They are slightly + // different. For `std` we explicitly want the one defined in `std`. + #[unstable(feature = "prelude_next", issue = "none")] + pub use super::v1::panic; } diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index 669212a442e89..af201843ed669 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -48,14 +48,14 @@ pub use crate::result::Result::{self, Err, Ok}; #[doc(no_inline)] pub use core::prelude::v1::{ assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq, debug_assert_ne, env, file, format_args, include, include_bytes, include_str, line, matches, - module_path, option_env, panic, stringify, todo, r#try, unimplemented, unreachable, write, + module_path, option_env, stringify, todo, r#try, unimplemented, unreachable, write, writeln, Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, }; #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] pub use crate::{ - dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local, + dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local }; // These macros needs special handling, so that we don't export it *and* the modules of the same @@ -63,11 +63,13 @@ pub use crate::{ mod ambiguous_macro_only_std { #[allow(hidden_glob_reexports)] mod vec {} + #[allow(hidden_glob_reexports)] + mod panic {} #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] pub use crate::*; } #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] -pub use self::ambiguous_macro_only_std::vec; +pub use self::ambiguous_macro_only_std::{vec, panic}; #[unstable(feature = "cfg_match", issue = "115585")] #[doc(no_inline)] From 27ece43ef09bd41f1574aa28d2749a1f9d0cf117 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Fri, 11 Apr 2025 15:57:10 +0200 Subject: [PATCH 08/21] Remove #[macro_use] std/core from tests --- library/alloctests/lib.rs | 1 - .../ide-diagnostics/src/handlers/unresolved_macro_call.rs | 1 - tests/pretty/asm.pp | 3 ++- tests/pretty/autodiff/autodiff_forward.pp | 3 ++- tests/pretty/autodiff/autodiff_reverse.pp | 3 ++- tests/pretty/cast-lt.pp | 3 ++- tests/pretty/dollar-crate.pp | 3 ++- tests/pretty/expanded-and-path-remap-80832.pp | 3 ++- tests/pretty/format-args-str-escape.pp | 3 ++- tests/pretty/hir-fn-params.pp | 1 + tests/pretty/hir-fn-variadic.pp | 1 + tests/pretty/hir-lifetimes.pp | 1 + tests/pretty/hir-pretty-attr.pp | 1 + tests/pretty/hir-pretty-loop.pp | 1 + tests/pretty/hir-struct-expr.pp | 1 + tests/pretty/issue-12590-c.pp | 3 ++- tests/pretty/issue-4264.pp | 1 + tests/pretty/issue-85089.pp | 1 + tests/pretty/postfix-match/precedence.pp | 3 ++- tests/pretty/tests-are-sorted.pp | 3 ++- tests/ui/asm/unpretty-expanded.stdout | 3 ++- .../return-type-notation/unpretty-parenthesized.stdout | 3 ++- tests/ui/codemap_tests/unicode.expanded.stdout | 3 ++- tests/ui/const-generics/defaults/pretty-printing-ast.stdout | 3 ++- tests/ui/deriving/built-in-proc-macro-scope.stdout | 3 ++- tests/ui/deriving/deriving-all-codegen.stdout | 4 ++-- tests/ui/deriving/deriving-coerce-pointee-expanded.stdout | 3 ++- tests/ui/deriving/proc-macro-attribute-mixing.stdout | 3 ++- tests/ui/feature-gates/feature-gate-format_args_nl.rs | 2 ++ tests/ui/lint/dead-code/with-core-crate.rs | 1 - .../no_ice_for_partial_compiler_runs.stdout | 3 ++- tests/ui/macros/genercs-in-path-with-prettry-hir.stdout | 1 + .../non-consuming-methods-have-optimized-codegen.stdout | 3 ++- tests/ui/match/issue-82392.stdout | 1 + tests/ui/proc-macro/meta-macro-hygiene.stdout | 3 ++- tests/ui/proc-macro/nonterminal-token-hygiene.stdout | 3 ++- tests/ui/proc-macro/quote/debug.stdout | 3 ++- tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.stdout | 3 ++- tests/ui/type-alias-impl-trait/issue-60662.stdout | 1 + tests/ui/unpretty/bad-literal.stdout | 1 + tests/ui/unpretty/debug-fmt-hir.stdout | 1 + tests/ui/unpretty/deprecated-attr.stdout | 1 + tests/ui/unpretty/diagnostic-attr.stdout | 1 + tests/ui/unpretty/exhaustive.expanded.stdout | 3 ++- tests/ui/unpretty/flattened-format-args.stdout | 1 + tests/ui/unpretty/interpolation-expanded.stdout | 5 +++-- tests/ui/unpretty/let-else-hir.stdout | 1 + tests/ui/unpretty/self-hir.stdout | 1 + tests/ui/unpretty/unpretty-expr-fn-arg.stdout | 1 + 49 files changed, 74 insertions(+), 31 deletions(-) diff --git a/library/alloctests/lib.rs b/library/alloctests/lib.rs index 3241b4b00454b..731d23bdb99d5 100644 --- a/library/alloctests/lib.rs +++ b/library/alloctests/lib.rs @@ -61,7 +61,6 @@ // Allow testing this library extern crate alloc as realalloc; -#[macro_use] extern crate std; #[cfg(test)] extern crate test; diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs index a87b8c42ac1d0..241a42e5fda43 100644 --- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs +++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs @@ -93,7 +93,6 @@ macro_rules! panic { } //- /lib.rs crate:foo deps:core -#[macro_use] extern crate core; fn foo() { diff --git a/tests/pretty/asm.pp b/tests/pretty/asm.pp index dca28f99a37d5..2ec58a449e124 100644 --- a/tests/pretty/asm.pp +++ b/tests/pretty/asm.pp @@ -1,6 +1,7 @@ #![feature(prelude_import)] #![no_std] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/autodiff/autodiff_forward.pp b/tests/pretty/autodiff/autodiff_forward.pp index 6eddb5669c7ab..e3400516212f1 100644 --- a/tests/pretty/autodiff/autodiff_forward.pp +++ b/tests/pretty/autodiff/autodiff_forward.pp @@ -3,7 +3,8 @@ //@ needs-enzyme #![feature(autodiff)] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/autodiff/autodiff_reverse.pp b/tests/pretty/autodiff/autodiff_reverse.pp index 8f598b865c7b2..c9dd6d5b0e878 100644 --- a/tests/pretty/autodiff/autodiff_reverse.pp +++ b/tests/pretty/autodiff/autodiff_reverse.pp @@ -3,7 +3,8 @@ //@ needs-enzyme #![feature(autodiff)] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/cast-lt.pp b/tests/pretty/cast-lt.pp index e82636edca7e5..ce6d440000cd8 100644 --- a/tests/pretty/cast-lt.pp +++ b/tests/pretty/cast-lt.pp @@ -1,6 +1,7 @@ #![feature(prelude_import)] #![no_std] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/dollar-crate.pp b/tests/pretty/dollar-crate.pp index 31a55ec2bdaa8..b6aad86cf704d 100644 --- a/tests/pretty/dollar-crate.pp +++ b/tests/pretty/dollar-crate.pp @@ -1,6 +1,7 @@ #![feature(prelude_import)] #![no_std] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/expanded-and-path-remap-80832.pp b/tests/pretty/expanded-and-path-remap-80832.pp index 6206498e4a2be..f028e446864c3 100644 --- a/tests/pretty/expanded-and-path-remap-80832.pp +++ b/tests/pretty/expanded-and-path-remap-80832.pp @@ -1,6 +1,7 @@ #![feature(prelude_import)] #![no_std] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/format-args-str-escape.pp b/tests/pretty/format-args-str-escape.pp index d0bd7cf0c72a3..bb4872edff6e3 100644 --- a/tests/pretty/format-args-str-escape.pp +++ b/tests/pretty/format-args-str-escape.pp @@ -1,6 +1,7 @@ #![feature(prelude_import)] #![no_std] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/hir-fn-params.pp b/tests/pretty/hir-fn-params.pp index fb4ea0304e5a9..67106f0de716b 100644 --- a/tests/pretty/hir-fn-params.pp +++ b/tests/pretty/hir-fn-params.pp @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ pretty-compare-only //@ pretty-mode:hir //@ pp-exact:hir-fn-params.pp diff --git a/tests/pretty/hir-fn-variadic.pp b/tests/pretty/hir-fn-variadic.pp index c0f5b7069a2d7..473f3f08cc480 100644 --- a/tests/pretty/hir-fn-variadic.pp +++ b/tests/pretty/hir-fn-variadic.pp @@ -7,6 +7,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; extern "C" { unsafe fn foo(x: i32, va1: ...); diff --git a/tests/pretty/hir-lifetimes.pp b/tests/pretty/hir-lifetimes.pp index 00c052d3f7986..1f29bf93d2dab 100644 --- a/tests/pretty/hir-lifetimes.pp +++ b/tests/pretty/hir-lifetimes.pp @@ -9,6 +9,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; struct Foo<'a> { x: &'a u32, diff --git a/tests/pretty/hir-pretty-attr.pp b/tests/pretty/hir-pretty-attr.pp index 01bfe2c095476..cdfebb2b1b746 100644 --- a/tests/pretty/hir-pretty-attr.pp +++ b/tests/pretty/hir-pretty-attr.pp @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ pretty-compare-only //@ pretty-mode:hir //@ pp-exact:hir-pretty-attr.pp diff --git a/tests/pretty/hir-pretty-loop.pp b/tests/pretty/hir-pretty-loop.pp index a0830c5188ada..659ca6aa72bd6 100644 --- a/tests/pretty/hir-pretty-loop.pp +++ b/tests/pretty/hir-pretty-loop.pp @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ pretty-compare-only //@ pretty-mode:hir //@ pp-exact:hir-pretty-loop.pp diff --git a/tests/pretty/hir-struct-expr.pp b/tests/pretty/hir-struct-expr.pp index bb222dc2e5f10..edc7e020f84d7 100644 --- a/tests/pretty/hir-struct-expr.pp +++ b/tests/pretty/hir-struct-expr.pp @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ pretty-compare-only //@ pretty-mode:hir //@ pp-exact:hir-struct-expr.pp diff --git a/tests/pretty/issue-12590-c.pp b/tests/pretty/issue-12590-c.pp index 0df095b0ee554..412031d9031b5 100644 --- a/tests/pretty/issue-12590-c.pp +++ b/tests/pretty/issue-12590-c.pp @@ -1,6 +1,7 @@ #![feature(prelude_import)] #![no_std] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/issue-4264.pp b/tests/pretty/issue-4264.pp index 1344923f4c47c..74d1360fb9eb8 100644 --- a/tests/pretty/issue-4264.pp +++ b/tests/pretty/issue-4264.pp @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ pretty-compare-only //@ pretty-mode:hir,typed //@ pp-exact:issue-4264.pp diff --git a/tests/pretty/issue-85089.pp b/tests/pretty/issue-85089.pp index 28a85bdf4ad8b..bfd79f7392417 100644 --- a/tests/pretty/issue-85089.pp +++ b/tests/pretty/issue-85089.pp @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; // Test to print lifetimes on HIR pretty-printing. //@ pretty-compare-only diff --git a/tests/pretty/postfix-match/precedence.pp b/tests/pretty/postfix-match/precedence.pp index b6ff45daea120..36972df44d725 100644 --- a/tests/pretty/postfix-match/precedence.pp +++ b/tests/pretty/postfix-match/precedence.pp @@ -1,7 +1,8 @@ #![feature(prelude_import)] #![no_std] #![feature(postfix_match)] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/tests-are-sorted.pp b/tests/pretty/tests-are-sorted.pp index 9e1566b2eff3b..b3a4edd8b7950 100644 --- a/tests/pretty/tests-are-sorted.pp +++ b/tests/pretty/tests-are-sorted.pp @@ -1,6 +1,7 @@ #![feature(prelude_import)] #![no_std] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/asm/unpretty-expanded.stdout b/tests/ui/asm/unpretty-expanded.stdout index 7678f6bc3450c..c159270e96f29 100644 --- a/tests/ui/asm/unpretty-expanded.stdout +++ b/tests/ui/asm/unpretty-expanded.stdout @@ -1,6 +1,7 @@ #![feature(prelude_import)] #![no_std] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout index 7499df5be5da1..9af994c50193e 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout +++ b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout @@ -1,5 +1,6 @@ #![feature(prelude_import)] -#[macro_use] +#[prelude_import] +use std::prelude::rust_2021::*; extern crate std; #[prelude_import] use std::prelude::rust_2021::*; diff --git a/tests/ui/codemap_tests/unicode.expanded.stdout b/tests/ui/codemap_tests/unicode.expanded.stdout index af375108b4780..10b2eea138e53 100644 --- a/tests/ui/codemap_tests/unicode.expanded.stdout +++ b/tests/ui/codemap_tests/unicode.expanded.stdout @@ -1,6 +1,7 @@ #![feature(prelude_import)] #![no_std] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/const-generics/defaults/pretty-printing-ast.stdout b/tests/ui/const-generics/defaults/pretty-printing-ast.stdout index 030fcec9cf2a7..bf64725b728b9 100644 --- a/tests/ui/const-generics/defaults/pretty-printing-ast.stdout +++ b/tests/ui/const-generics/defaults/pretty-printing-ast.stdout @@ -6,7 +6,8 @@ //@ edition: 2015 #![crate_type = "lib"] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/deriving/built-in-proc-macro-scope.stdout b/tests/ui/deriving/built-in-proc-macro-scope.stdout index 4fbce5edb8194..44aa4ba3e79db 100644 --- a/tests/ui/deriving/built-in-proc-macro-scope.stdout +++ b/tests/ui/deriving/built-in-proc-macro-scope.stdout @@ -6,7 +6,8 @@ //@ edition:2015 #![feature(derive_coerce_pointee)] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/deriving/deriving-all-codegen.stdout b/tests/ui/deriving/deriving-all-codegen.stdout index 78b93f39b9ea1..ec34c1d15a7f3 100644 --- a/tests/ui/deriving/deriving-all-codegen.stdout +++ b/tests/ui/deriving/deriving-all-codegen.stdout @@ -17,8 +17,8 @@ #![crate_type = "lib"] #![allow(dead_code)] #![allow(deprecated)] -#![feature(derive_from)] -#[macro_use] +#[prelude_import] +use std::prelude::rust_2021::*; extern crate std; #[prelude_import] use std::prelude::rust_2021::*; diff --git a/tests/ui/deriving/deriving-coerce-pointee-expanded.stdout b/tests/ui/deriving/deriving-coerce-pointee-expanded.stdout index 89300a5c6d0ca..ca0979263fbf0 100644 --- a/tests/ui/deriving/deriving-coerce-pointee-expanded.stdout +++ b/tests/ui/deriving/deriving-coerce-pointee-expanded.stdout @@ -4,7 +4,8 @@ //@ compile-flags: -Zunpretty=expanded //@ edition: 2015 #![feature(derive_coerce_pointee)] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/deriving/proc-macro-attribute-mixing.stdout b/tests/ui/deriving/proc-macro-attribute-mixing.stdout index b81110682d68f..647a34ecca1db 100644 --- a/tests/ui/deriving/proc-macro-attribute-mixing.stdout +++ b/tests/ui/deriving/proc-macro-attribute-mixing.stdout @@ -12,7 +12,8 @@ //@ edition: 2015 #![feature(derive_coerce_pointee)] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/feature-gates/feature-gate-format_args_nl.rs b/tests/ui/feature-gates/feature-gate-format_args_nl.rs index aeee2fbad9071..5b3c5de0aec28 100644 --- a/tests/ui/feature-gates/feature-gate-format_args_nl.rs +++ b/tests/ui/feature-gates/feature-gate-format_args_nl.rs @@ -1,3 +1,5 @@ +use std::format_args_nl; + fn main() { format_args_nl!(""); //~ ERROR `format_args_nl` is only for internal language use } diff --git a/tests/ui/lint/dead-code/with-core-crate.rs b/tests/ui/lint/dead-code/with-core-crate.rs index 0a94b528f3339..9ccb6aecb75fb 100644 --- a/tests/ui/lint/dead-code/with-core-crate.rs +++ b/tests/ui/lint/dead-code/with-core-crate.rs @@ -1,7 +1,6 @@ #![deny(dead_code)] #![allow(unreachable_code)] -#[macro_use] extern crate core; fn foo() { //~ ERROR function `foo` is never used diff --git a/tests/ui/lint/rfc-2383-lint-reason/no_ice_for_partial_compiler_runs.stdout b/tests/ui/lint/rfc-2383-lint-reason/no_ice_for_partial_compiler_runs.stdout index 80abac44ca84c..fbc5abfb20c65 100644 --- a/tests/ui/lint/rfc-2383-lint-reason/no_ice_for_partial_compiler_runs.stdout +++ b/tests/ui/lint/rfc-2383-lint-reason/no_ice_for_partial_compiler_runs.stdout @@ -1,6 +1,7 @@ #![feature(prelude_import)] #![no_std] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout b/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout index ba93384644d59..98200ada95728 100644 --- a/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout +++ b/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ compile-flags: -Zunpretty=hir //@ edition: 2015 diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout b/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout index e29655faabe58..0b5d9defa765f 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout @@ -5,7 +5,8 @@ //@ edition: 2015 #![feature(core_intrinsics, generic_assert)] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/match/issue-82392.stdout b/tests/ui/match/issue-82392.stdout index d7eef0497392b..284ab0463d775 100644 --- a/tests/ui/match/issue-82392.stdout +++ b/tests/ui/match/issue-82392.stdout @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; // https://github.com/rust-lang/rust/issues/82329 //@ compile-flags: -Zunpretty=hir,typed //@ check-pass diff --git a/tests/ui/proc-macro/meta-macro-hygiene.stdout b/tests/ui/proc-macro/meta-macro-hygiene.stdout index 452598c372c17..3acc22c705e64 100644 --- a/tests/ui/proc-macro/meta-macro-hygiene.stdout +++ b/tests/ui/proc-macro/meta-macro-hygiene.stdout @@ -16,7 +16,8 @@ Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro // in the stdout #![no_std /* 0#0 */] -#[macro_use /* 0#1 */] +#[prelude_import /* 0#1 */] +use core /* 0#1 */::prelude /* 0#1 */::rust_2018 /* 0#1 */::*; extern crate core /* 0#1 */; #[prelude_import /* 0#1 */] use core /* 0#1 */::prelude /* 0#1 */::rust_2018 /* 0#1 */::*; diff --git a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout index e10a5199f1793..6455386873c87 100644 --- a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout +++ b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout @@ -36,7 +36,8 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ #![feature /* 0#0 */(decl_macro)] #![no_std /* 0#0 */] -#[macro_use /* 0#1 */] +#[prelude_import /* 0#1 */] +use ::core /* 0#1 */::prelude /* 0#1 */::rust_2015 /* 0#1 */::*; extern crate core /* 0#2 */; #[prelude_import /* 0#1 */] use ::core /* 0#1 */::prelude /* 0#1 */::rust_2015 /* 0#1 */::*; diff --git a/tests/ui/proc-macro/quote/debug.stdout b/tests/ui/proc-macro/quote/debug.stdout index 77c52f02a33c1..9a9f4b0401f12 100644 --- a/tests/ui/proc-macro/quote/debug.stdout +++ b/tests/ui/proc-macro/quote/debug.stdout @@ -12,7 +12,8 @@ #![feature(proc_macro_quote)] #![crate_type = "proc-macro"] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.stdout b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.stdout index 66ba726fb9a49..9e6b56142b630 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.stdout +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.stdout @@ -1,6 +1,7 @@ #![feature(prelude_import)] #![no_std] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/type-alias-impl-trait/issue-60662.stdout b/tests/ui/type-alias-impl-trait/issue-60662.stdout index 7ad29c88bcfe5..93d2e1d6df976 100644 --- a/tests/ui/type-alias-impl-trait/issue-60662.stdout +++ b/tests/ui/type-alias-impl-trait/issue-60662.stdout @@ -7,6 +7,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; trait Animal { } diff --git a/tests/ui/unpretty/bad-literal.stdout b/tests/ui/unpretty/bad-literal.stdout index 1f697aff27c9b..47c52adcb58fa 100644 --- a/tests/ui/unpretty/bad-literal.stdout +++ b/tests/ui/unpretty/bad-literal.stdout @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ compile-flags: -Zunpretty=hir //@ check-fail //@ edition: 2015 diff --git a/tests/ui/unpretty/debug-fmt-hir.stdout b/tests/ui/unpretty/debug-fmt-hir.stdout index 9c79421e32aba..5256169539e59 100644 --- a/tests/ui/unpretty/debug-fmt-hir.stdout +++ b/tests/ui/unpretty/debug-fmt-hir.stdout @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ compile-flags: -Zunpretty=hir //@ check-pass //@ edition: 2015 diff --git a/tests/ui/unpretty/deprecated-attr.stdout b/tests/ui/unpretty/deprecated-attr.stdout index 26cc74c11604d..43aa96df8c574 100644 --- a/tests/ui/unpretty/deprecated-attr.stdout +++ b/tests/ui/unpretty/deprecated-attr.stdout @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ compile-flags: -Zunpretty=hir //@ check-pass //@ edition: 2015 diff --git a/tests/ui/unpretty/diagnostic-attr.stdout b/tests/ui/unpretty/diagnostic-attr.stdout index 4822cf4700b94..be502ba05dd5a 100644 --- a/tests/ui/unpretty/diagnostic-attr.stdout +++ b/tests/ui/unpretty/diagnostic-attr.stdout @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ compile-flags: -Zunpretty=hir //@ check-pass //@ edition: 2015 diff --git a/tests/ui/unpretty/exhaustive.expanded.stdout b/tests/ui/unpretty/exhaustive.expanded.stdout index 0327ad5f92bb3..ca02a6343d0cd 100644 --- a/tests/ui/unpretty/exhaustive.expanded.stdout +++ b/tests/ui/unpretty/exhaustive.expanded.stdout @@ -29,7 +29,8 @@ #![feature(try_blocks)] #![feature(yeet_expr)] #![allow(incomplete_features)] -#[macro_use] +#[prelude_import] +use std::prelude::rust_2024::*; extern crate std; #[prelude_import] use std::prelude::rust_2024::*; diff --git a/tests/ui/unpretty/flattened-format-args.stdout b/tests/ui/unpretty/flattened-format-args.stdout index 0792dc10e946b..2f36d2c2ea1e1 100644 --- a/tests/ui/unpretty/flattened-format-args.stdout +++ b/tests/ui/unpretty/flattened-format-args.stdout @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ compile-flags: -Zunpretty=hir -Zflatten-format-args=yes //@ check-pass //@ edition: 2015 diff --git a/tests/ui/unpretty/interpolation-expanded.stdout b/tests/ui/unpretty/interpolation-expanded.stdout index 7284a89e7a9b0..e73b7d44c583e 100644 --- a/tests/ui/unpretty/interpolation-expanded.stdout +++ b/tests/ui/unpretty/interpolation-expanded.stdout @@ -10,7 +10,8 @@ // synthesizing parentheses indiscriminately; only where necessary. #![feature(if_let_guard)] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2024::*; extern crate std; #[prelude_import] use std::prelude::rust_2024::*; @@ -61,7 +62,7 @@ fn local() { macro_rules! let_expr_else_return { ($pat:pat, $expr:expr) => { let $pat = $expr else { return; }; }; } - let + let no_paren = void() else { return; }; } diff --git a/tests/ui/unpretty/let-else-hir.stdout b/tests/ui/unpretty/let-else-hir.stdout index 14270a5720274..b091fbe746c21 100644 --- a/tests/ui/unpretty/let-else-hir.stdout +++ b/tests/ui/unpretty/let-else-hir.stdout @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ compile-flags: -Zunpretty=hir //@ check-pass //@ edition: 2015 diff --git a/tests/ui/unpretty/self-hir.stdout b/tests/ui/unpretty/self-hir.stdout index b190565dcc472..c0656416afb06 100644 --- a/tests/ui/unpretty/self-hir.stdout +++ b/tests/ui/unpretty/self-hir.stdout @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ compile-flags: -Zunpretty=hir //@ check-pass //@ edition: 2015 diff --git a/tests/ui/unpretty/unpretty-expr-fn-arg.stdout b/tests/ui/unpretty/unpretty-expr-fn-arg.stdout index c04909a736136..fa543b85fb517 100644 --- a/tests/ui/unpretty/unpretty-expr-fn-arg.stdout +++ b/tests/ui/unpretty/unpretty-expr-fn-arg.stdout @@ -12,6 +12,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; fn main() ({ } as ()) From 4dfc0774169ba8f6cf019fbf300cf2d115422a1f Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Wed, 25 Jun 2025 13:15:35 +0200 Subject: [PATCH 09/21] Update prelude macros --- library/core/src/prelude/v1.rs | 13 +++---------- library/std/src/prelude/v1.rs | 13 +++---------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index 82aed3cff361b..8b6ce1558197b 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -59,6 +59,7 @@ pub use crate::hash::macros::Hash; #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] +#[allow(deprecated)] pub use crate::{ assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq, debug_assert_ne, file, format_args, include, include_bytes, include_str, line, matches, module_path, option_env, stringify, todo, r#try, unimplemented, unreachable, write, writeln, }; @@ -76,9 +77,9 @@ mod ambiguous_macro_only { #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] pub use self::ambiguous_macro_only::{env, panic}; -#[unstable(feature = "cfg_match", issue = "115585")] +#[unstable(feature = "cfg_select", issue = "115585")] #[doc(no_inline)] -pub use crate::cfg_match; +pub use crate::cfg_select; #[unstable( feature = "concat_bytes", @@ -88,14 +89,6 @@ pub use crate::cfg_match; #[doc(no_inline)] pub use crate::concat_bytes; -#[unstable( - feature = "concat_idents", - issue = "29599", - reason = "`concat_idents` is not stable enough for use and is subject to change" -)] -#[doc(no_inline)] -pub use crate::concat_idents; - #[unstable(feature = "const_format_args", issue = "none")] #[doc(no_inline)] pub use crate::const_format_args; diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index af201843ed669..3c4fe8b7d8428 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -46,6 +46,7 @@ pub use crate::result::Result::{self, Err, Ok}; // Re-exported built-in macros and traits #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] +#[allow(deprecated)] pub use core::prelude::v1::{ assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq, debug_assert_ne, env, file, format_args, include, include_bytes, include_str, line, matches, module_path, option_env, stringify, todo, r#try, unimplemented, unreachable, write, @@ -71,9 +72,9 @@ mod ambiguous_macro_only_std { #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] pub use self::ambiguous_macro_only_std::{vec, panic}; -#[unstable(feature = "cfg_match", issue = "115585")] +#[unstable(feature = "cfg_select", issue = "115585")] #[doc(no_inline)] -pub use core::prelude::v1::cfg_match; +pub use core::prelude::v1::cfg_select; #[unstable( feature = "concat_bytes", @@ -83,14 +84,6 @@ pub use core::prelude::v1::cfg_match; #[doc(no_inline)] pub use core::prelude::v1::concat_bytes; -#[unstable( - feature = "concat_idents", - issue = "29599", - reason = "`concat_idents` is not stable enough for use and is subject to change" -)] -#[doc(no_inline)] -pub use core::prelude::v1::concat_idents; - #[unstable(feature = "const_format_args", issue = "none")] #[doc(no_inline)] pub use core::prelude::v1::const_format_args; From 2f00aee95ec346fa0ef749ba3b46ed574bf8874b Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Wed, 25 Jun 2025 13:30:12 +0200 Subject: [PATCH 10/21] Fix feature-gate-format_args_nl UI test --- tests/ui/feature-gates/feature-gate-format_args_nl.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/feature-gates/feature-gate-format_args_nl.rs b/tests/ui/feature-gates/feature-gate-format_args_nl.rs index 5b3c5de0aec28..4749eea13a6db 100644 --- a/tests/ui/feature-gates/feature-gate-format_args_nl.rs +++ b/tests/ui/feature-gates/feature-gate-format_args_nl.rs @@ -1,4 +1,4 @@ -use std::format_args_nl; +use std::format_args_nl; //~ ERROR `format_args_nl` is only for internal language use fn main() { format_args_nl!(""); //~ ERROR `format_args_nl` is only for internal language use From 41aef47461131e4d113977c2578b57159143d589 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Wed, 25 Jun 2025 17:08:47 +0200 Subject: [PATCH 11/21] Apply review comments --- .../ide-diagnostics/src/handlers/unresolved_macro_call.rs | 1 + .../rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs index 241a42e5fda43..a87b8c42ac1d0 100644 --- a/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs +++ b/src/tools/rust-analyzer/crates/ide-diagnostics/src/handlers/unresolved_macro_call.rs @@ -93,6 +93,7 @@ macro_rules! panic { } //- /lib.rs crate:foo deps:core +#[macro_use] extern crate core; fn foo() { diff --git a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs index d732fc250f25a..dd359326c61d6 100644 --- a/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs +++ b/src/tools/rust-analyzer/crates/ide/src/syntax_highlighting/tests.rs @@ -445,7 +445,7 @@ fn test_string_highlighting() { //- minicore: fmt, assert, asm, concat, panic macro_rules! println { ($($arg:tt)*) => ({ - $crate::io::_print(std::format_args_nl!($($arg)*)); + $crate::io::_print(format_args_nl!($($arg)*)); }) } From 0d0f3df37c17615536a8724a8f945002a4c3f7e8 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Mon, 7 Jul 2025 11:06:40 +0200 Subject: [PATCH 12/21] Fix macro import in alloctests --- library/alloctests/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/library/alloctests/lib.rs b/library/alloctests/lib.rs index 731d23bdb99d5..b130dae74b36f 100644 --- a/library/alloctests/lib.rs +++ b/library/alloctests/lib.rs @@ -52,6 +52,7 @@ #![feature(negative_impls)] #![feature(never_type)] #![feature(optimize_attribute)] +#![feature(prelude_import)] #![feature(rustc_allow_const_fn_unstable)] #![feature(rustc_attrs)] #![feature(staged_api)] @@ -61,10 +62,17 @@ // Allow testing this library extern crate alloc as realalloc; + +// This is needed to provide macros to the directly imported alloc modules below. +#[prelude_import] +#[allow(unused_imports)] +use std::prelude::rust_2024::*; extern crate std; + #[cfg(test)] extern crate test; mod testing; + use realalloc::*; // We are directly including collections and raw_vec here as both use non-public @@ -85,8 +93,7 @@ pub(crate) mod test_helpers { let mut hasher = std::hash::RandomState::new().build_hasher(); std::panic::Location::caller().hash(&mut hasher); let hc64 = hasher.finish(); - let seed_vec = - hc64.to_le_bytes().into_iter().chain(0u8..8).collect::>(); + let seed_vec = hc64.to_le_bytes().into_iter().chain(0u8..8).collect::>(); let seed: [u8; 16] = seed_vec.as_slice().try_into().unwrap(); rand::SeedableRng::from_seed(seed) } From 32005243a1f668713dad00d81b96a3955a175057 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Thu, 10 Jul 2025 13:15:48 +0200 Subject: [PATCH 13/21] Fix rustdoc macro inlining issues Missing `#[doc(no_inline)]` for ambiguous_macro_only_std resulted in new and broken doc html files. --- library/core/src/prelude/v1.rs | 1 + library/std/src/prelude/v1.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index 8b6ce1558197b..d2bd3aafd7fce 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -75,6 +75,7 @@ mod ambiguous_macro_only { pub use crate::*; } #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] +#[doc(no_inline)] pub use self::ambiguous_macro_only::{env, panic}; #[unstable(feature = "cfg_select", issue = "115585")] diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index 3c4fe8b7d8428..4b2214d7b2d6f 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -70,6 +70,7 @@ mod ambiguous_macro_only_std { pub use crate::*; } #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] +#[doc(no_inline)] pub use self::ambiguous_macro_only_std::{vec, panic}; #[unstable(feature = "cfg_select", issue = "115585")] From 181015933dd98ba6793e5d6359ccd68ae124659a Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Thu, 10 Jul 2025 18:08:53 +0200 Subject: [PATCH 14/21] Adapt pretty tests expected outputs --- tests/pretty/autodiff/inherent_impl.pp | 3 ++- tests/pretty/hir-delegation.pp | 1 + tests/pretty/hir-if-else.pp | 1 + tests/pretty/if-else.pp | 3 ++- tests/pretty/never-pattern.pp | 3 ++- tests/pretty/pin-ergonomics-hir.pp | 1 + tests/pretty/shebang-at-top.pp | 3 ++- 7 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/pretty/autodiff/inherent_impl.pp b/tests/pretty/autodiff/inherent_impl.pp index 36a9222640ae5..fc3e8960b3ad7 100644 --- a/tests/pretty/autodiff/inherent_impl.pp +++ b/tests/pretty/autodiff/inherent_impl.pp @@ -3,7 +3,8 @@ //@ needs-enzyme #![feature(autodiff)] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/hir-delegation.pp b/tests/pretty/hir-delegation.pp index f8ad02f2fccce..cc2c9fcb3dc96 100644 --- a/tests/pretty/hir-delegation.pp +++ b/tests/pretty/hir-delegation.pp @@ -8,6 +8,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; fn b(e: C) { } diff --git a/tests/pretty/hir-if-else.pp b/tests/pretty/hir-if-else.pp index af5d31b07cb18..324fa295849c4 100644 --- a/tests/pretty/hir-if-else.pp +++ b/tests/pretty/hir-if-else.pp @@ -2,6 +2,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; //@ pretty-compare-only //@ pretty-mode:hir //@ pp-exact:hir-if-else.pp diff --git a/tests/pretty/if-else.pp b/tests/pretty/if-else.pp index f29b693e571eb..49c5159e0e9cd 100644 --- a/tests/pretty/if-else.pp +++ b/tests/pretty/if-else.pp @@ -1,6 +1,7 @@ #![feature(prelude_import)] #![no_std] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/never-pattern.pp b/tests/pretty/never-pattern.pp index 1ce332ea50643..6ba5fa3f3a338 100644 --- a/tests/pretty/never-pattern.pp +++ b/tests/pretty/never-pattern.pp @@ -7,7 +7,8 @@ #![allow(incomplete_features)] #![feature(never_patterns)] #![feature(never_type)] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/pin-ergonomics-hir.pp b/tests/pretty/pin-ergonomics-hir.pp index beca5988017dc..1cb7f94ad649e 100644 --- a/tests/pretty/pin-ergonomics-hir.pp +++ b/tests/pretty/pin-ergonomics-hir.pp @@ -8,6 +8,7 @@ extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; +extern crate std; use std::pin::Pin; diff --git a/tests/pretty/shebang-at-top.pp b/tests/pretty/shebang-at-top.pp index 197def4a154b1..c27ac52d0960d 100644 --- a/tests/pretty/shebang-at-top.pp +++ b/tests/pretty/shebang-at-top.pp @@ -1,7 +1,8 @@ #!/usr/bin/env rust #![feature(prelude_import)] #![no_std] -#[macro_use] +#[prelude_import] +use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; From 083b63ab97a9afab772a99162c919dd4f210951a Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Thu, 14 Aug 2025 12:37:27 +0200 Subject: [PATCH 15/21] Silence unproblematic warning --- library/std/src/prelude/v1.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index 4b2214d7b2d6f..27bf745f640a5 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -66,6 +66,7 @@ mod ambiguous_macro_only_std { mod vec {} #[allow(hidden_glob_reexports)] mod panic {} + #[allow(exported_private_dependencies)] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] pub use crate::*; } From fac8837d6fc6ccffd7053d9b9cfb99b04f32d513 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Thu, 14 Aug 2025 12:43:04 +0200 Subject: [PATCH 16/21] Bless UI tests --- tests/ui/asm/unpretty-expanded.stdout | 2 -- .../unpretty-parenthesized.stdout | 2 -- tests/ui/codemap_tests/unicode.expanded.stdout | 2 -- .../defaults/pretty-printing-ast.stdout | 2 -- .../ui/deriving/built-in-proc-macro-scope.stdout | 2 -- tests/ui/deriving/deriving-all-codegen.stdout | 2 -- .../deriving-coerce-pointee-expanded.stdout | 2 -- .../deriving/proc-macro-attribute-mixing.stdout | 2 -- .../feature-gate-format_args_nl.stderr | 13 +++++++++++-- tests/ui/imports/glob-shadowing.stderr | 10 ++++++---- .../local-modularized-tricky-fail-1.stderr | 10 ++++++---- tests/ui/imports/shadow_builtin_macros.stderr | 15 +++++++++------ tests/ui/lint/dead-code/with-core-crate.stderr | 2 +- .../no_ice_for_partial_compiler_runs.stdout | 2 -- .../genercs-in-path-with-prettry-hir.stdout | 2 -- ...onsuming-methods-have-optimized-codegen.stdout | 2 -- tests/ui/match/issue-82392.stdout | 2 -- tests/ui/proc-macro/meta-macro-hygiene.stdout | 2 -- .../proc-macro/nonterminal-token-hygiene.stdout | 2 -- tests/ui/proc-macro/quote/debug.stdout | 2 -- .../ast-pretty-check.stdout | 2 -- tests/ui/stats/input-stats.stderr | 12 ++++++------ tests/ui/type-alias-impl-trait/issue-60662.stdout | 2 -- tests/ui/unpretty/bad-literal.stdout | 2 -- tests/ui/unpretty/debug-fmt-hir.stdout | 2 -- tests/ui/unpretty/deprecated-attr.stdout | 2 -- tests/ui/unpretty/diagnostic-attr.stdout | 2 -- tests/ui/unpretty/exhaustive-asm.expanded.stdout | 1 - tests/ui/unpretty/exhaustive-asm.hir.stdout | 1 - tests/ui/unpretty/exhaustive.expanded.stdout | 2 -- tests/ui/unpretty/exhaustive.hir.stdout | 1 - tests/ui/unpretty/flattened-format-args.stdout | 2 -- tests/ui/unpretty/interpolation-expanded.stdout | 4 +--- tests/ui/unpretty/let-else-hir.stdout | 2 -- tests/ui/unpretty/self-hir.stdout | 2 -- tests/ui/unpretty/unpretty-expr-fn-arg.stdout | 2 -- 36 files changed, 40 insertions(+), 81 deletions(-) diff --git a/tests/ui/asm/unpretty-expanded.stdout b/tests/ui/asm/unpretty-expanded.stdout index c159270e96f29..ce636c150c1cc 100644 --- a/tests/ui/asm/unpretty-expanded.stdout +++ b/tests/ui/asm/unpretty-expanded.stdout @@ -1,7 +1,5 @@ #![feature(prelude_import)] #![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout index 9af994c50193e..c53491a6747c6 100644 --- a/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout +++ b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout @@ -1,6 +1,4 @@ #![feature(prelude_import)] -#[prelude_import] -use std::prelude::rust_2021::*; extern crate std; #[prelude_import] use std::prelude::rust_2021::*; diff --git a/tests/ui/codemap_tests/unicode.expanded.stdout b/tests/ui/codemap_tests/unicode.expanded.stdout index 10b2eea138e53..4a29277fe3bff 100644 --- a/tests/ui/codemap_tests/unicode.expanded.stdout +++ b/tests/ui/codemap_tests/unicode.expanded.stdout @@ -1,7 +1,5 @@ #![feature(prelude_import)] #![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/const-generics/defaults/pretty-printing-ast.stdout b/tests/ui/const-generics/defaults/pretty-printing-ast.stdout index bf64725b728b9..efd703b24b435 100644 --- a/tests/ui/const-generics/defaults/pretty-printing-ast.stdout +++ b/tests/ui/const-generics/defaults/pretty-printing-ast.stdout @@ -6,8 +6,6 @@ //@ edition: 2015 #![crate_type = "lib"] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/deriving/built-in-proc-macro-scope.stdout b/tests/ui/deriving/built-in-proc-macro-scope.stdout index 44aa4ba3e79db..e2a9119af3d61 100644 --- a/tests/ui/deriving/built-in-proc-macro-scope.stdout +++ b/tests/ui/deriving/built-in-proc-macro-scope.stdout @@ -6,8 +6,6 @@ //@ edition:2015 #![feature(derive_coerce_pointee)] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/deriving/deriving-all-codegen.stdout b/tests/ui/deriving/deriving-all-codegen.stdout index ec34c1d15a7f3..c2d448c02a977 100644 --- a/tests/ui/deriving/deriving-all-codegen.stdout +++ b/tests/ui/deriving/deriving-all-codegen.stdout @@ -17,8 +17,6 @@ #![crate_type = "lib"] #![allow(dead_code)] #![allow(deprecated)] -#[prelude_import] -use std::prelude::rust_2021::*; extern crate std; #[prelude_import] use std::prelude::rust_2021::*; diff --git a/tests/ui/deriving/deriving-coerce-pointee-expanded.stdout b/tests/ui/deriving/deriving-coerce-pointee-expanded.stdout index ca0979263fbf0..ace45c4d760f6 100644 --- a/tests/ui/deriving/deriving-coerce-pointee-expanded.stdout +++ b/tests/ui/deriving/deriving-coerce-pointee-expanded.stdout @@ -4,8 +4,6 @@ //@ compile-flags: -Zunpretty=expanded //@ edition: 2015 #![feature(derive_coerce_pointee)] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/deriving/proc-macro-attribute-mixing.stdout b/tests/ui/deriving/proc-macro-attribute-mixing.stdout index 647a34ecca1db..e82f1780d0959 100644 --- a/tests/ui/deriving/proc-macro-attribute-mixing.stdout +++ b/tests/ui/deriving/proc-macro-attribute-mixing.stdout @@ -12,8 +12,6 @@ //@ edition: 2015 #![feature(derive_coerce_pointee)] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/feature-gates/feature-gate-format_args_nl.stderr b/tests/ui/feature-gates/feature-gate-format_args_nl.stderr index c7e8f8c686f90..1265bd447f40e 100644 --- a/tests/ui/feature-gates/feature-gate-format_args_nl.stderr +++ b/tests/ui/feature-gates/feature-gate-format_args_nl.stderr @@ -1,5 +1,5 @@ error[E0658]: use of unstable library feature `format_args_nl`: `format_args_nl` is only for internal language use and is subject to change - --> $DIR/feature-gate-format_args_nl.rs:2:5 + --> $DIR/feature-gate-format_args_nl.rs:4:5 | LL | format_args_nl!(""); | ^^^^^^^^^^^^^^ @@ -7,6 +7,15 @@ LL | format_args_nl!(""); = help: add `#![feature(format_args_nl)]` 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 1 previous error +error[E0658]: use of unstable library feature `format_args_nl`: `format_args_nl` is only for internal language use and is subject to change + --> $DIR/feature-gate-format_args_nl.rs:1:5 + | +LL | use std::format_args_nl; + | ^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(format_args_nl)]` 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`. diff --git a/tests/ui/imports/glob-shadowing.stderr b/tests/ui/imports/glob-shadowing.stderr index 0ce8d4f54f8d5..025147d08f014 100644 --- a/tests/ui/imports/glob-shadowing.stderr +++ b/tests/ui/imports/glob-shadowing.stderr @@ -5,14 +5,15 @@ LL | let x = env!("PATH"); | ^^^ ambiguous name | = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution - = note: `env` could refer to a macro from prelude -note: `env` could also refer to the macro imported here +note: `env` could refer to the macro imported here --> $DIR/glob-shadowing.rs:9:9 | LL | use crate::m::*; | ^^^^^^^^^^^ = help: consider adding an explicit import of `env` to disambiguate = help: or use `self::env` to refer to this macro unambiguously +note: `env` could also refer to a macro from prelude + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL error[E0659]: `env` is ambiguous --> $DIR/glob-shadowing.rs:19:21 @@ -21,13 +22,14 @@ LL | let x = env!("PATH"); | ^^^ ambiguous name | = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution - = note: `env` could refer to a macro from prelude -note: `env` could also refer to the macro imported here +note: `env` could refer to the macro imported here --> $DIR/glob-shadowing.rs:17:13 | LL | use crate::m::*; | ^^^^^^^^^^^ = help: consider adding an explicit import of `env` to disambiguate +note: `env` could also refer to a macro from prelude + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL error[E0659]: `fenv` is ambiguous --> $DIR/glob-shadowing.rs:29:21 diff --git a/tests/ui/imports/local-modularized-tricky-fail-1.stderr b/tests/ui/imports/local-modularized-tricky-fail-1.stderr index 52a01e8bcdfe3..5e87531a05333 100644 --- a/tests/ui/imports/local-modularized-tricky-fail-1.stderr +++ b/tests/ui/imports/local-modularized-tricky-fail-1.stderr @@ -30,8 +30,7 @@ LL | panic!(); | ^^^^^ ambiguous name | = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution - = note: `panic` could refer to a macro from prelude -note: `panic` could also refer to the macro defined here +note: `panic` could refer to the macro defined here --> $DIR/local-modularized-tricky-fail-1.rs:12:5 | LL | / macro_rules! panic { @@ -42,6 +41,8 @@ LL | | } LL | define_panic!(); | --------------- in this macro invocation = help: use `crate::panic` to refer to this macro unambiguously +note: `panic` could also refer to a macro from prelude + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL = note: this error originates in the macro `define_panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `include` is ambiguous @@ -51,8 +52,7 @@ LL | include!(); | ^^^^^^^ ambiguous name | = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution - = note: `include` could refer to a macro from prelude -note: `include` could also refer to the macro defined here +note: `include` could refer to the macro defined here --> $DIR/local-modularized-tricky-fail-1.rs:18:5 | LL | / macro_rules! include { @@ -63,6 +63,8 @@ LL | | } LL | define_include!(); | ----------------- in this macro invocation = help: use `crate::include` to refer to this macro unambiguously +note: `include` could also refer to a macro from prelude + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL = note: this error originates in the macro `define_include` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/tests/ui/imports/shadow_builtin_macros.stderr b/tests/ui/imports/shadow_builtin_macros.stderr index c828b1193d81e..7799fb230d434 100644 --- a/tests/ui/imports/shadow_builtin_macros.stderr +++ b/tests/ui/imports/shadow_builtin_macros.stderr @@ -5,14 +5,15 @@ LL | fn f() { panic!(); } | ^^^^^ ambiguous name | = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution - = note: `panic` could refer to a macro from prelude -note: `panic` could also refer to the macro imported here +note: `panic` could refer to the macro imported here --> $DIR/shadow_builtin_macros.rs:14:9 | LL | use crate::foo::*; | ^^^^^^^^^^^^^ = help: consider adding an explicit import of `panic` to disambiguate = help: or use `self::panic` to refer to this macro unambiguously +note: `panic` could also refer to a macro from prelude + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL error[E0659]: `panic` is ambiguous --> $DIR/shadow_builtin_macros.rs:33:5 @@ -21,8 +22,7 @@ LL | panic!(); | ^^^^^ ambiguous name | = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution - = note: `panic` could refer to a macro from prelude -note: `panic` could also refer to the macro defined here +note: `panic` could refer to the macro defined here --> $DIR/shadow_builtin_macros.rs:30:9 | LL | macro_rules! panic { () => {} } @@ -30,6 +30,8 @@ LL | macro_rules! panic { () => {} } LL | } } LL | m!(); | ---- in this macro invocation +note: `panic` could also refer to a macro from prelude + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `n` is ambiguous @@ -59,13 +61,14 @@ LL | fn f() { panic!(); } | ^^^^^ ambiguous name | = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution - = note: `panic` could refer to a macro from prelude -note: `panic` could also refer to the macro imported here +note: `panic` could refer to the macro imported here --> $DIR/shadow_builtin_macros.rs:19:26 | LL | ::two_macros::m!(use crate::foo::panic;); | ^^^^^^^^^^^^^^^^^ = help: use `self::panic` to refer to this macro unambiguously +note: `panic` could also refer to a macro from prelude + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL error: aborting due to 4 previous errors diff --git a/tests/ui/lint/dead-code/with-core-crate.stderr b/tests/ui/lint/dead-code/with-core-crate.stderr index f466a616580c5..9db26c956298e 100644 --- a/tests/ui/lint/dead-code/with-core-crate.stderr +++ b/tests/ui/lint/dead-code/with-core-crate.stderr @@ -1,5 +1,5 @@ error: function `foo` is never used - --> $DIR/with-core-crate.rs:7:4 + --> $DIR/with-core-crate.rs:6:4 | LL | fn foo() { | ^^^ diff --git a/tests/ui/lint/rfc-2383-lint-reason/no_ice_for_partial_compiler_runs.stdout b/tests/ui/lint/rfc-2383-lint-reason/no_ice_for_partial_compiler_runs.stdout index fbc5abfb20c65..0fcfc936a59bc 100644 --- a/tests/ui/lint/rfc-2383-lint-reason/no_ice_for_partial_compiler_runs.stdout +++ b/tests/ui/lint/rfc-2383-lint-reason/no_ice_for_partial_compiler_runs.stdout @@ -1,7 +1,5 @@ #![feature(prelude_import)] #![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout b/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout index 98200ada95728..6e41432ad7df1 100644 --- a/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout +++ b/tests/ui/macros/genercs-in-path-with-prettry-hir.stdout @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ compile-flags: -Zunpretty=hir //@ edition: 2015 diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout b/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout index 0b5d9defa765f..d47f733d40edb 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/non-consuming-methods-have-optimized-codegen.stdout @@ -5,8 +5,6 @@ //@ edition: 2015 #![feature(core_intrinsics, generic_assert)] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/match/issue-82392.stdout b/tests/ui/match/issue-82392.stdout index 284ab0463d775..d44ffbe216716 100644 --- a/tests/ui/match/issue-82392.stdout +++ b/tests/ui/match/issue-82392.stdout @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; // https://github.com/rust-lang/rust/issues/82329 //@ compile-flags: -Zunpretty=hir,typed //@ check-pass diff --git a/tests/ui/proc-macro/meta-macro-hygiene.stdout b/tests/ui/proc-macro/meta-macro-hygiene.stdout index 3acc22c705e64..b5db9922b31a8 100644 --- a/tests/ui/proc-macro/meta-macro-hygiene.stdout +++ b/tests/ui/proc-macro/meta-macro-hygiene.stdout @@ -16,8 +16,6 @@ Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro // in the stdout #![no_std /* 0#0 */] -#[prelude_import /* 0#1 */] -use core /* 0#1 */::prelude /* 0#1 */::rust_2018 /* 0#1 */::*; extern crate core /* 0#1 */; #[prelude_import /* 0#1 */] use core /* 0#1 */::prelude /* 0#1 */::rust_2018 /* 0#1 */::*; diff --git a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout index 6455386873c87..e45abab03b4c4 100644 --- a/tests/ui/proc-macro/nonterminal-token-hygiene.stdout +++ b/tests/ui/proc-macro/nonterminal-token-hygiene.stdout @@ -36,8 +36,6 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ #![feature /* 0#0 */(decl_macro)] #![no_std /* 0#0 */] -#[prelude_import /* 0#1 */] -use ::core /* 0#1 */::prelude /* 0#1 */::rust_2015 /* 0#1 */::*; extern crate core /* 0#2 */; #[prelude_import /* 0#1 */] use ::core /* 0#1 */::prelude /* 0#1 */::rust_2015 /* 0#1 */::*; diff --git a/tests/ui/proc-macro/quote/debug.stdout b/tests/ui/proc-macro/quote/debug.stdout index 9a9f4b0401f12..896c809fedaba 100644 --- a/tests/ui/proc-macro/quote/debug.stdout +++ b/tests/ui/proc-macro/quote/debug.stdout @@ -12,8 +12,6 @@ #![feature(proc_macro_quote)] #![crate_type = "proc-macro"] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.stdout b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.stdout index 9e6b56142b630..9a34d6c1af7ac 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.stdout +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/ast-pretty-check.stdout @@ -1,7 +1,5 @@ #![feature(prelude_import)] #![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/ui/stats/input-stats.stderr b/tests/ui/stats/input-stats.stderr index 72a9820bb6431..b0393a2c89ef0 100644 --- a/tests/ui/stats/input-stats.stderr +++ b/tests/ui/stats/input-stats.stderr @@ -15,7 +15,7 @@ ast-stats - Ptr 64 (NN.N%) 1 ast-stats - Ref 64 (NN.N%) 1 ast-stats - ImplicitSelf 128 (NN.N%) 2 ast-stats - Path 640 (NN.N%) 10 -ast-stats PathSegment 888 (NN.N%) 37 24 +ast-stats PathSegment 864 (NN.N%) 36 24 ast-stats Expr 648 (NN.N%) 9 72 ast-stats - InlineAsm 72 (NN.N%) 1 ast-stats - Match 72 (NN.N%) 1 @@ -41,9 +41,9 @@ ast-stats - Let 32 (NN.N%) 1 ast-stats - Semi 32 (NN.N%) 1 ast-stats - Expr 96 (NN.N%) 3 ast-stats Param 160 (NN.N%) 4 40 -ast-stats Attribute 160 (NN.N%) 5 32 +ast-stats Attribute 128 (NN.N%) 4 32 ast-stats - DocComment 32 (NN.N%) 1 -ast-stats - Normal 128 (NN.N%) 4 +ast-stats - Normal 96 (NN.N%) 3 ast-stats InlineAsm 120 (NN.N%) 1 120 ast-stats FnDecl 120 (NN.N%) 5 24 ast-stats Local 96 (NN.N%) 1 96 @@ -57,7 +57,7 @@ ast-stats GenericArgs 40 (NN.N%) 1 40 ast-stats - AngleBracketed 40 (NN.N%) 1 ast-stats Crate 40 (NN.N%) 1 40 ast-stats ---------------------------------------------------------------- -ast-stats Total 7_472 129 +ast-stats Total 7_416 127 ast-stats ================================================================ hir-stats ================================================================ hir-stats HIR STATS: input_stats @@ -93,7 +93,7 @@ hir-stats - Binding 216 (NN.N%) 3 hir-stats Block 288 (NN.N%) 6 48 hir-stats GenericBound 256 (NN.N%) 4 64 hir-stats - Trait 256 (NN.N%) 4 -hir-stats Attribute 200 (NN.N%) 5 40 +hir-stats Attribute 160 (NN.N%) 4 40 hir-stats Variant 144 (NN.N%) 2 72 hir-stats GenericArgs 144 (NN.N%) 3 48 hir-stats FieldDef 128 (NN.N%) 2 64 @@ -119,5 +119,5 @@ hir-stats TraitItemId 8 (NN.N%) 2 4 hir-stats ImplItemId 8 (NN.N%) 2 4 hir-stats ForeignItemId 4 (NN.N%) 1 4 hir-stats ---------------------------------------------------------------- -hir-stats Total 8_584 173 +hir-stats Total 8_544 172 hir-stats ================================================================ diff --git a/tests/ui/type-alias-impl-trait/issue-60662.stdout b/tests/ui/type-alias-impl-trait/issue-60662.stdout index 93d2e1d6df976..d1f337819f8b0 100644 --- a/tests/ui/type-alias-impl-trait/issue-60662.stdout +++ b/tests/ui/type-alias-impl-trait/issue-60662.stdout @@ -3,11 +3,9 @@ //@ edition: 2015 #![feature(type_alias_impl_trait)] -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; trait Animal { } diff --git a/tests/ui/unpretty/bad-literal.stdout b/tests/ui/unpretty/bad-literal.stdout index 47c52adcb58fa..267d59a868e41 100644 --- a/tests/ui/unpretty/bad-literal.stdout +++ b/tests/ui/unpretty/bad-literal.stdout @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ compile-flags: -Zunpretty=hir //@ check-fail //@ edition: 2015 diff --git a/tests/ui/unpretty/debug-fmt-hir.stdout b/tests/ui/unpretty/debug-fmt-hir.stdout index 5256169539e59..342dc144909ce 100644 --- a/tests/ui/unpretty/debug-fmt-hir.stdout +++ b/tests/ui/unpretty/debug-fmt-hir.stdout @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ compile-flags: -Zunpretty=hir //@ check-pass //@ edition: 2015 diff --git a/tests/ui/unpretty/deprecated-attr.stdout b/tests/ui/unpretty/deprecated-attr.stdout index 43aa96df8c574..0b0f17d556665 100644 --- a/tests/ui/unpretty/deprecated-attr.stdout +++ b/tests/ui/unpretty/deprecated-attr.stdout @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ compile-flags: -Zunpretty=hir //@ check-pass //@ edition: 2015 diff --git a/tests/ui/unpretty/diagnostic-attr.stdout b/tests/ui/unpretty/diagnostic-attr.stdout index be502ba05dd5a..80cd11753493a 100644 --- a/tests/ui/unpretty/diagnostic-attr.stdout +++ b/tests/ui/unpretty/diagnostic-attr.stdout @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ compile-flags: -Zunpretty=hir //@ check-pass //@ edition: 2015 diff --git a/tests/ui/unpretty/exhaustive-asm.expanded.stdout b/tests/ui/unpretty/exhaustive-asm.expanded.stdout index 9a58e4c2877b1..9b3c60b03ba77 100644 --- a/tests/ui/unpretty/exhaustive-asm.expanded.stdout +++ b/tests/ui/unpretty/exhaustive-asm.expanded.stdout @@ -1,5 +1,4 @@ #![feature(prelude_import)] -#[macro_use] extern crate std; #[prelude_import] use std::prelude::rust_2024::*; diff --git a/tests/ui/unpretty/exhaustive-asm.hir.stdout b/tests/ui/unpretty/exhaustive-asm.hir.stdout index b33b38c2caba4..ed98191e1dd56 100644 --- a/tests/ui/unpretty/exhaustive-asm.hir.stdout +++ b/tests/ui/unpretty/exhaustive-asm.hir.stdout @@ -1,4 +1,3 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use std::prelude::rust_2024::*; diff --git a/tests/ui/unpretty/exhaustive.expanded.stdout b/tests/ui/unpretty/exhaustive.expanded.stdout index ca02a6343d0cd..8a653e6674fe2 100644 --- a/tests/ui/unpretty/exhaustive.expanded.stdout +++ b/tests/ui/unpretty/exhaustive.expanded.stdout @@ -29,8 +29,6 @@ #![feature(try_blocks)] #![feature(yeet_expr)] #![allow(incomplete_features)] -#[prelude_import] -use std::prelude::rust_2024::*; extern crate std; #[prelude_import] use std::prelude::rust_2024::*; diff --git a/tests/ui/unpretty/exhaustive.hir.stdout b/tests/ui/unpretty/exhaustive.hir.stdout index 68356a33c9e60..b6713878a37f4 100644 --- a/tests/ui/unpretty/exhaustive.hir.stdout +++ b/tests/ui/unpretty/exhaustive.hir.stdout @@ -28,7 +28,6 @@ #![feature(try_blocks)] #![feature(yeet_expr)] #![allow(incomplete_features)] -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use std::prelude::rust_2024::*; diff --git a/tests/ui/unpretty/flattened-format-args.stdout b/tests/ui/unpretty/flattened-format-args.stdout index 2f36d2c2ea1e1..19d4b7471182c 100644 --- a/tests/ui/unpretty/flattened-format-args.stdout +++ b/tests/ui/unpretty/flattened-format-args.stdout @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ compile-flags: -Zunpretty=hir -Zflatten-format-args=yes //@ check-pass //@ edition: 2015 diff --git a/tests/ui/unpretty/interpolation-expanded.stdout b/tests/ui/unpretty/interpolation-expanded.stdout index e73b7d44c583e..d385a021ed57a 100644 --- a/tests/ui/unpretty/interpolation-expanded.stdout +++ b/tests/ui/unpretty/interpolation-expanded.stdout @@ -10,8 +10,6 @@ // synthesizing parentheses indiscriminately; only where necessary. #![feature(if_let_guard)] -#[prelude_import] -use ::std::prelude::rust_2024::*; extern crate std; #[prelude_import] use std::prelude::rust_2024::*; @@ -62,7 +60,7 @@ fn local() { macro_rules! let_expr_else_return { ($pat:pat, $expr:expr) => { let $pat = $expr else { return; }; }; } - let + let no_paren = void() else { return; }; } diff --git a/tests/ui/unpretty/let-else-hir.stdout b/tests/ui/unpretty/let-else-hir.stdout index b091fbe746c21..cc19f392c3a43 100644 --- a/tests/ui/unpretty/let-else-hir.stdout +++ b/tests/ui/unpretty/let-else-hir.stdout @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ compile-flags: -Zunpretty=hir //@ check-pass //@ edition: 2015 diff --git a/tests/ui/unpretty/self-hir.stdout b/tests/ui/unpretty/self-hir.stdout index c0656416afb06..c973e143275cd 100644 --- a/tests/ui/unpretty/self-hir.stdout +++ b/tests/ui/unpretty/self-hir.stdout @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ compile-flags: -Zunpretty=hir //@ check-pass //@ edition: 2015 diff --git a/tests/ui/unpretty/unpretty-expr-fn-arg.stdout b/tests/ui/unpretty/unpretty-expr-fn-arg.stdout index fa543b85fb517..41d62d11aaa61 100644 --- a/tests/ui/unpretty/unpretty-expr-fn-arg.stdout +++ b/tests/ui/unpretty/unpretty-expr-fn-arg.stdout @@ -8,11 +8,9 @@ //@ compile-flags: -Zunpretty=hir,typed //@ edition: 2015 #![allow(dead_code)] -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; fn main() ({ } as ()) From 9f200d71976dc7fe524562ef0a5a374cd15eda9e Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Fri, 15 Aug 2025 16:38:41 +0200 Subject: [PATCH 17/21] Fix alloctests again --- library/alloctests/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloctests/lib.rs b/library/alloctests/lib.rs index b130dae74b36f..d1519c8c04604 100644 --- a/library/alloctests/lib.rs +++ b/library/alloctests/lib.rs @@ -64,10 +64,10 @@ extern crate alloc as realalloc; // This is needed to provide macros to the directly imported alloc modules below. +extern crate std; #[prelude_import] #[allow(unused_imports)] use std::prelude::rust_2024::*; -extern crate std; #[cfg(test)] extern crate test; From 233fc10c3dc57ff275d36a5247aefbe5038baf3f Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Fri, 15 Aug 2025 19:07:08 +0200 Subject: [PATCH 18/21] Appease clippy --- library/std/src/prelude/v1.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index 27bf745f640a5..86fe3c7ab840d 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -66,6 +66,9 @@ mod ambiguous_macro_only_std { mod vec {} #[allow(hidden_glob_reexports)] mod panic {} + // Building std without the allow exported_private_dependencies will create warnings, but then + // clippy claims its a useless_attribute. So silence both. + #[allow(clippy::useless_attribute)] #[allow(exported_private_dependencies)] #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] pub use crate::*; From b38483646b68e51e27cbe43215a78f171e3eb9a9 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Fri, 15 Aug 2025 19:25:52 +0200 Subject: [PATCH 19/21] Export new hash_map macro --- library/std/src/prelude/v1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index 86fe3c7ab840d..a641278f646f9 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -56,7 +56,7 @@ pub use core::prelude::v1::{ #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[doc(no_inline)] pub use crate::{ - dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local + dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local, hash_map }; // These macros needs special handling, so that we don't export it *and* the modules of the same From 29d06b4fb3c38948e7282c3ea17a63c0466b9024 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Sat, 16 Aug 2025 18:48:07 +0200 Subject: [PATCH 20/21] Fix deriving-all-codegen UI test An incorrect merge conflict resolution had deleted a relevant new line. --- tests/ui/deriving/deriving-all-codegen.stdout | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/ui/deriving/deriving-all-codegen.stdout b/tests/ui/deriving/deriving-all-codegen.stdout index c2d448c02a977..961c7f4b0481e 100644 --- a/tests/ui/deriving/deriving-all-codegen.stdout +++ b/tests/ui/deriving/deriving-all-codegen.stdout @@ -17,6 +17,7 @@ #![crate_type = "lib"] #![allow(dead_code)] #![allow(deprecated)] +#![feature(derive_from)] extern crate std; #[prelude_import] use std::prelude::rust_2021::*; From fd2bbf92cdd4a1b5a73445396155c802c493ec81 Mon Sep 17 00:00:00 2001 From: Lukas Bergdoll Date: Sun, 17 Aug 2025 11:15:47 +0200 Subject: [PATCH 21/21] Bless pretty test output changes --- tests/pretty/asm.pp | 2 -- tests/pretty/cast-lt.pp | 2 -- tests/pretty/dollar-crate.pp | 2 -- tests/pretty/expanded-and-path-remap-80832.pp | 2 -- tests/pretty/format-args-str-escape.pp | 2 -- tests/pretty/hir-delegation.pp | 2 -- tests/pretty/hir-fn-params.pp | 2 -- tests/pretty/hir-fn-variadic.pp | 2 -- tests/pretty/hir-if-else.pp | 2 -- tests/pretty/hir-lifetimes.pp | 2 -- tests/pretty/hir-pretty-attr.pp | 2 -- tests/pretty/hir-pretty-loop.pp | 2 -- tests/pretty/hir-struct-expr.pp | 2 -- tests/pretty/if-else.pp | 2 -- tests/pretty/issue-12590-c.pp | 2 -- tests/pretty/issue-4264.pp | 2 -- tests/pretty/issue-85089.pp | 2 -- tests/pretty/never-pattern.pp | 2 -- tests/pretty/pin-ergonomics-hir.pp | 2 -- tests/pretty/postfix-match/precedence.pp | 2 -- tests/pretty/shebang-at-top.pp | 2 -- tests/pretty/tests-are-sorted.pp | 2 -- 22 files changed, 44 deletions(-) diff --git a/tests/pretty/asm.pp b/tests/pretty/asm.pp index 2ec58a449e124..f1f020a68fb64 100644 --- a/tests/pretty/asm.pp +++ b/tests/pretty/asm.pp @@ -1,7 +1,5 @@ #![feature(prelude_import)] #![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/cast-lt.pp b/tests/pretty/cast-lt.pp index ce6d440000cd8..deca38fc09627 100644 --- a/tests/pretty/cast-lt.pp +++ b/tests/pretty/cast-lt.pp @@ -1,7 +1,5 @@ #![feature(prelude_import)] #![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/dollar-crate.pp b/tests/pretty/dollar-crate.pp index b6aad86cf704d..f7f6e5c3d4939 100644 --- a/tests/pretty/dollar-crate.pp +++ b/tests/pretty/dollar-crate.pp @@ -1,7 +1,5 @@ #![feature(prelude_import)] #![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/expanded-and-path-remap-80832.pp b/tests/pretty/expanded-and-path-remap-80832.pp index f028e446864c3..d434633b7c4bd 100644 --- a/tests/pretty/expanded-and-path-remap-80832.pp +++ b/tests/pretty/expanded-and-path-remap-80832.pp @@ -1,7 +1,5 @@ #![feature(prelude_import)] #![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/format-args-str-escape.pp b/tests/pretty/format-args-str-escape.pp index bb4872edff6e3..bf944f445e1c1 100644 --- a/tests/pretty/format-args-str-escape.pp +++ b/tests/pretty/format-args-str-escape.pp @@ -1,7 +1,5 @@ #![feature(prelude_import)] #![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/hir-delegation.pp b/tests/pretty/hir-delegation.pp index cc2c9fcb3dc96..5a27bf34ebf7b 100644 --- a/tests/pretty/hir-delegation.pp +++ b/tests/pretty/hir-delegation.pp @@ -4,11 +4,9 @@ #![allow(incomplete_features)] #![feature(fn_delegation)] -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; fn b(e: C) { } diff --git a/tests/pretty/hir-fn-params.pp b/tests/pretty/hir-fn-params.pp index 67106f0de716b..52310d5024cd6 100644 --- a/tests/pretty/hir-fn-params.pp +++ b/tests/pretty/hir-fn-params.pp @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ pretty-compare-only //@ pretty-mode:hir //@ pp-exact:hir-fn-params.pp diff --git a/tests/pretty/hir-fn-variadic.pp b/tests/pretty/hir-fn-variadic.pp index 473f3f08cc480..d40b3be27903a 100644 --- a/tests/pretty/hir-fn-variadic.pp +++ b/tests/pretty/hir-fn-variadic.pp @@ -3,11 +3,9 @@ //@ pp-exact:hir-fn-variadic.pp #![feature(c_variadic)] -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; extern "C" { unsafe fn foo(x: i32, va1: ...); diff --git a/tests/pretty/hir-if-else.pp b/tests/pretty/hir-if-else.pp index 324fa295849c4..d3721e1758157 100644 --- a/tests/pretty/hir-if-else.pp +++ b/tests/pretty/hir-if-else.pp @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ pretty-compare-only //@ pretty-mode:hir //@ pp-exact:hir-if-else.pp diff --git a/tests/pretty/hir-lifetimes.pp b/tests/pretty/hir-lifetimes.pp index 1f29bf93d2dab..51598333b125e 100644 --- a/tests/pretty/hir-lifetimes.pp +++ b/tests/pretty/hir-lifetimes.pp @@ -5,11 +5,9 @@ // This tests the pretty-printing of lifetimes in lots of ways. #![allow(unused)] -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; struct Foo<'a> { x: &'a u32, diff --git a/tests/pretty/hir-pretty-attr.pp b/tests/pretty/hir-pretty-attr.pp index cdfebb2b1b746..a9d8b5e7e5770 100644 --- a/tests/pretty/hir-pretty-attr.pp +++ b/tests/pretty/hir-pretty-attr.pp @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ pretty-compare-only //@ pretty-mode:hir //@ pp-exact:hir-pretty-attr.pp diff --git a/tests/pretty/hir-pretty-loop.pp b/tests/pretty/hir-pretty-loop.pp index 659ca6aa72bd6..e6614ce318cce 100644 --- a/tests/pretty/hir-pretty-loop.pp +++ b/tests/pretty/hir-pretty-loop.pp @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ pretty-compare-only //@ pretty-mode:hir //@ pp-exact:hir-pretty-loop.pp diff --git a/tests/pretty/hir-struct-expr.pp b/tests/pretty/hir-struct-expr.pp index edc7e020f84d7..198d7ad6a9b6b 100644 --- a/tests/pretty/hir-struct-expr.pp +++ b/tests/pretty/hir-struct-expr.pp @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ pretty-compare-only //@ pretty-mode:hir //@ pp-exact:hir-struct-expr.pp diff --git a/tests/pretty/if-else.pp b/tests/pretty/if-else.pp index 49c5159e0e9cd..6ca71a3a3d347 100644 --- a/tests/pretty/if-else.pp +++ b/tests/pretty/if-else.pp @@ -1,7 +1,5 @@ #![feature(prelude_import)] #![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/issue-12590-c.pp b/tests/pretty/issue-12590-c.pp index 412031d9031b5..b79b73337adbd 100644 --- a/tests/pretty/issue-12590-c.pp +++ b/tests/pretty/issue-12590-c.pp @@ -1,7 +1,5 @@ #![feature(prelude_import)] #![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/issue-4264.pp b/tests/pretty/issue-4264.pp index 74d1360fb9eb8..583358f6f53c9 100644 --- a/tests/pretty/issue-4264.pp +++ b/tests/pretty/issue-4264.pp @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; //@ pretty-compare-only //@ pretty-mode:hir,typed //@ pp-exact:issue-4264.pp diff --git a/tests/pretty/issue-85089.pp b/tests/pretty/issue-85089.pp index bfd79f7392417..919573220fddd 100644 --- a/tests/pretty/issue-85089.pp +++ b/tests/pretty/issue-85089.pp @@ -1,8 +1,6 @@ -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; // Test to print lifetimes on HIR pretty-printing. //@ pretty-compare-only diff --git a/tests/pretty/never-pattern.pp b/tests/pretty/never-pattern.pp index 6ba5fa3f3a338..bb95a1ed442a4 100644 --- a/tests/pretty/never-pattern.pp +++ b/tests/pretty/never-pattern.pp @@ -7,8 +7,6 @@ #![allow(incomplete_features)] #![feature(never_patterns)] #![feature(never_type)] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/pin-ergonomics-hir.pp b/tests/pretty/pin-ergonomics-hir.pp index 1cb7f94ad649e..f00536de571c9 100644 --- a/tests/pretty/pin-ergonomics-hir.pp +++ b/tests/pretty/pin-ergonomics-hir.pp @@ -4,11 +4,9 @@ #![feature(pin_ergonomics)] #![allow(dead_code, incomplete_features)] -#[attr = MacroUse {arguments: UseAll}] extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; -extern crate std; use std::pin::Pin; diff --git a/tests/pretty/postfix-match/precedence.pp b/tests/pretty/postfix-match/precedence.pp index 36972df44d725..56ee1f1061af2 100644 --- a/tests/pretty/postfix-match/precedence.pp +++ b/tests/pretty/postfix-match/precedence.pp @@ -1,8 +1,6 @@ #![feature(prelude_import)] #![no_std] #![feature(postfix_match)] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/shebang-at-top.pp b/tests/pretty/shebang-at-top.pp index c27ac52d0960d..0c19c0c44e458 100644 --- a/tests/pretty/shebang-at-top.pp +++ b/tests/pretty/shebang-at-top.pp @@ -1,8 +1,6 @@ #!/usr/bin/env rust #![feature(prelude_import)] #![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*; diff --git a/tests/pretty/tests-are-sorted.pp b/tests/pretty/tests-are-sorted.pp index b3a4edd8b7950..43f9838e68ce9 100644 --- a/tests/pretty/tests-are-sorted.pp +++ b/tests/pretty/tests-are-sorted.pp @@ -1,7 +1,5 @@ #![feature(prelude_import)] #![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; extern crate std; #[prelude_import] use ::std::prelude::rust_2015::*;