From f7c2d1194d31f34238765afb2d5dee583e2a3cfc Mon Sep 17 00:00:00 2001 From: clubby789 Date: Fri, 17 Jan 2025 12:53:58 +0000 Subject: [PATCH 1/5] doc: Point to methods on `Command` as alternatives to `set/remove_var` --- library/std/src/env.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 11a29cdae62e..bbd506127fb6 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -336,7 +336,10 @@ impl Error for VarError { /// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188) /// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2) /// +/// To pass an environment variable to a child process, you can instead use [`Command::env`]. +/// /// [`std::net::ToSocketAddrs`]: crate::net::ToSocketAddrs +/// [`Command::env`]: crate::process::Command::env /// /// # Panics /// @@ -396,7 +399,12 @@ pub unsafe fn set_var, V: AsRef>(key: K, value: V) { /// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188) /// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2) /// +/// To prevent a child process from inheriting an environment variable, you can +/// instead use [`Command::env_remove`] or [`Command::env_clear`]. +/// /// [`std::net::ToSocketAddrs`]: crate::net::ToSocketAddrs +/// [`Command::env_remove`]: crate::process::Command::env_remove +/// [`Command::env_clear`]: crate::process::Command::env_clear /// /// # Panics /// From f854f34a502c358b0f6826ea3ebf40fb7f146de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 17 Jan 2025 23:01:48 +0100 Subject: [PATCH 2/5] Do not include GCC source code in source tarballs The licensing story is unclear, it makes the archive much larger, and we should not need it for building anything in the tarballs (yet). --- src/bootstrap/src/core/build_steps/dist.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index afa409aa8350..87f48331bfe1 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -1011,7 +1011,18 @@ impl Step for PlainSourceTarball { ]; let src_dirs = ["src", "compiler", "library", "tests", "LICENSES"]; - copy_src_dirs(builder, &builder.src, &src_dirs, &[], plain_dst_src); + copy_src_dirs( + builder, + &builder.src, + &src_dirs, + &[ + // We don't currently use the GCC source code for building any official components, + // it is very big, and has unclear licensing implications due to being GPL licensed. + // We thus exclude it from the source tarball from now. + "src/gcc", + ], + plain_dst_src, + ); // Copy the files normally for item in &src_files { From 7d806171d00f53a720e6784a878a98cbef5c3d4a Mon Sep 17 00:00:00 2001 From: Tanvi Pooranmal Meena Date: Mon, 13 Jan 2025 15:38:39 +0530 Subject: [PATCH 3/5] Add logic to override profile for non git sources --- src/bootstrap/bootstrap.py | 5 +++++ src/bootstrap/src/core/config/config.rs | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 76ee40c6f45f..74923af15558 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -1268,6 +1268,11 @@ def bootstrap(args): config_toml = "" profile = RustBuild.get_toml_static(config_toml, "profile") + is_non_git_source = not os.path.exists(os.path.join(rust_root, ".git")) + + if profile is None and is_non_git_source: + profile = "dist" + if profile is not None: # Allows creating alias for profile names, allowing # profiles to be renamed while maintaining back compatibility diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 1c49063ef5c6..a09902a4c384 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -2926,10 +2926,8 @@ impl Config { let if_unchanged = || { if self.rust_info.is_from_tarball() { // Git is needed for running "if-unchanged" logic. - println!( - "WARNING: 'if-unchanged' has no effect on tarball sources; ignoring `download-ci-llvm`." - ); - return false; + println!("ERROR: 'if-unchanged' is only compatible with Git managed sources."); + crate::exit!(1); } // Fetching the LLVM submodule is unnecessary for self-tests. From 539b4d8555943682b67dc1953093e172bfa95de2 Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Sun, 19 Jan 2025 07:10:13 +0000 Subject: [PATCH 4/5] rustc_resolve: use structured fields in traces --- compiler/rustc_resolve/src/diagnostics.rs | 39 +++++++++-------------- 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index dc26d4de57a7..392d9d676d93 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -30,7 +30,7 @@ use rustc_span::hygiene::MacroKind; use rustc_span::source_map::SourceMap; use rustc_span::{BytePos, Ident, Span, Symbol, SyntaxContext, kw, sym}; use thin_vec::{ThinVec, thin_vec}; -use tracing::debug; +use tracing::{debug, instrument}; use crate::errors::{ self, AddedMacroUse, ChangeImportBinding, ChangeImportBindingSuggestion, ConsiderAddingADerive, @@ -2235,14 +2235,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { } /// Adds suggestions for a path that cannot be resolved. + #[instrument(level = "debug", skip(self, parent_scope))] pub(crate) fn make_path_suggestion( &mut self, span: Span, mut path: Vec, parent_scope: &ParentScope<'ra>, ) -> Option<(Vec, Option)> { - debug!("make_path_suggestion: span={:?} path={:?}", span, path); - match (path.get(0), path.get(1)) { // `{{root}}::ident::...` on both editions. // On 2015 `{{root}}` is usually added implicitly. @@ -2271,6 +2270,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { /// LL | use foo::Bar; /// | ^^^ did you mean `self::foo`? /// ``` + #[instrument(level = "debug", skip(self, parent_scope))] fn make_missing_self_suggestion( &mut self, mut path: Vec, @@ -2279,7 +2279,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // Replace first ident with `self` and check if that is valid. path[0].ident.name = kw::SelfLower; let result = self.maybe_resolve_path(&path, None, parent_scope, None); - debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result); + debug!(?path, ?result); if let PathResult::Module(..) = result { Some((path, None)) } else { None } } @@ -2290,6 +2290,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { /// LL | use foo::Bar; /// | ^^^ did you mean `crate::foo`? /// ``` + #[instrument(level = "debug", skip(self, parent_scope))] fn make_missing_crate_suggestion( &mut self, mut path: Vec, @@ -2298,7 +2299,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // Replace first ident with `crate` and check if that is valid. path[0].ident.name = kw::Crate; let result = self.maybe_resolve_path(&path, None, parent_scope, None); - debug!("make_missing_crate_suggestion: path={:?} result={:?}", path, result); + debug!(?path, ?result); if let PathResult::Module(..) = result { Some(( path, @@ -2321,6 +2322,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { /// LL | use foo::Bar; /// | ^^^ did you mean `super::foo`? /// ``` + #[instrument(level = "debug", skip(self, parent_scope))] fn make_missing_super_suggestion( &mut self, mut path: Vec, @@ -2329,7 +2331,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // Replace first ident with `crate` and check if that is valid. path[0].ident.name = kw::Super; let result = self.maybe_resolve_path(&path, None, parent_scope, None); - debug!("make_missing_super_suggestion: path={:?} result={:?}", path, result); + debug!(?path, ?result); if let PathResult::Module(..) = result { Some((path, None)) } else { None } } @@ -2343,6 +2345,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { /// /// Used when importing a submodule of an external crate but missing that crate's /// name as the first part of path. + #[instrument(level = "debug", skip(self, parent_scope))] fn make_external_crate_suggestion( &mut self, mut path: Vec, @@ -2363,10 +2366,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { // Replace first ident with a crate name and check if that is valid. path[0].ident.name = name; let result = self.maybe_resolve_path(&path, None, parent_scope, None); - debug!( - "make_external_crate_suggestion: name={:?} path={:?} result={:?}", - name, path, result - ); + debug!(?path, ?name, ?result); if let PathResult::Module(..) = result { return Some((path, None)); } @@ -2433,10 +2433,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { import.span, import.use_span, ); - debug!( - "check_for_module_export_macro: found_closing_brace={:?} binding_span={:?}", - found_closing_brace, binding_span - ); + debug!(found_closing_brace, ?binding_span); let mut removal_span = binding_span; if found_closing_brace { @@ -2450,11 +2447,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { if let Some(previous_span) = extend_span_to_previous_binding(self.tcx.sess, binding_span) { - debug!("check_for_module_export_macro: previous_span={:?}", previous_span); + debug!(?previous_span); removal_span = removal_span.with_lo(previous_span.lo()); } } - debug!("check_for_module_export_macro: removal_span={:?}", removal_span); + debug!(?removal_span); // Remove the `removal_span`. corrections.push((removal_span, "".to_string())); @@ -2470,10 +2467,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { module_name, import.use_span, ); - debug!( - "check_for_module_export_macro: has_nested={:?} after_crate_name={:?}", - has_nested, after_crate_name - ); + debug!(has_nested, ?after_crate_name); let source_map = self.tcx.sess.source_map(); @@ -2677,15 +2671,12 @@ fn extend_span_to_previous_binding(sess: &Session, binding_span: Span) -> Option /// use foo::{a, b::{c, d}}; /// // ^^^^^^^^^^^^^^^ -- true /// ``` +#[instrument(level = "debug", skip(sess))] fn find_span_immediately_after_crate_name( sess: &Session, module_name: Symbol, use_span: Span, ) -> (bool, Span) { - debug!( - "find_span_immediately_after_crate_name: module_name={:?} use_span={:?}", - module_name, use_span - ); let source_map = sess.source_map(); // Using `use issue_59764::foo::{baz, makro};` as an example throughout.. From 8ba0d2db1819acc5570579301f0557a53938f890 Mon Sep 17 00:00:00 2001 From: Tom Fryers Date: Mon, 20 Jan 2025 10:16:27 +0000 Subject: [PATCH 5/5] Correct counting to four in cell module docs --- library/core/src/cell.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index 306d565a77e6..20187e478aac 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -22,8 +22,8 @@ //! (mutable via `&T`), in contrast with typical Rust types that exhibit 'inherited mutability' //! (mutable only via `&mut T`). //! -//! Cell types come in three flavors: `Cell`, `RefCell`, and `OnceCell`. Each provides -//! a different way of providing safe interior mutability. +//! Cell types come in four flavors: `Cell`, `RefCell`, `OnceCell`, and `LazyCell`. +//! Each provides a different way of providing safe interior mutability. //! //! ## `Cell` //!