Skip to content

Commit 9f4d9dc

Browse files
committed
Auto merge of rust-lang#135769 - jieyouxu:rollup-3h384pz, r=jieyouxu
Rollup of 5 pull requests Successful merges: - rust-lang#135433 (Add Profile Override for Non-Git Sources) - rust-lang#135626 (doc: Point to methods on `Command` as alternatives to `set/remove_var`) - rust-lang#135658 (Do not include GCC source code in source tarballs) - rust-lang#135676 (rustc_resolve: use structured fields in traces) - rust-lang#135762 (Correct counting to four in cell module docs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6a64e3b + ecfb557 commit 9f4d9dc

File tree

6 files changed

+44
-31
lines changed

6 files changed

+44
-31
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+15-24
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rustc_span::hygiene::MacroKind;
3030
use rustc_span::source_map::SourceMap;
3131
use rustc_span::{BytePos, Ident, Span, Symbol, SyntaxContext, kw, sym};
3232
use thin_vec::{ThinVec, thin_vec};
33-
use tracing::debug;
33+
use tracing::{debug, instrument};
3434

3535
use crate::errors::{
3636
self, AddedMacroUse, ChangeImportBinding, ChangeImportBindingSuggestion, ConsiderAddingADerive,
@@ -2235,14 +2235,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22352235
}
22362236

22372237
/// Adds suggestions for a path that cannot be resolved.
2238+
#[instrument(level = "debug", skip(self, parent_scope))]
22382239
pub(crate) fn make_path_suggestion(
22392240
&mut self,
22402241
span: Span,
22412242
mut path: Vec<Segment>,
22422243
parent_scope: &ParentScope<'ra>,
22432244
) -> Option<(Vec<Segment>, Option<String>)> {
2244-
debug!("make_path_suggestion: span={:?} path={:?}", span, path);
2245-
22462245
match (path.get(0), path.get(1)) {
22472246
// `{{root}}::ident::...` on both editions.
22482247
// On 2015 `{{root}}` is usually added implicitly.
@@ -2271,6 +2270,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22712270
/// LL | use foo::Bar;
22722271
/// | ^^^ did you mean `self::foo`?
22732272
/// ```
2273+
#[instrument(level = "debug", skip(self, parent_scope))]
22742274
fn make_missing_self_suggestion(
22752275
&mut self,
22762276
mut path: Vec<Segment>,
@@ -2279,7 +2279,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22792279
// Replace first ident with `self` and check if that is valid.
22802280
path[0].ident.name = kw::SelfLower;
22812281
let result = self.maybe_resolve_path(&path, None, parent_scope, None);
2282-
debug!("make_missing_self_suggestion: path={:?} result={:?}", path, result);
2282+
debug!(?path, ?result);
22832283
if let PathResult::Module(..) = result { Some((path, None)) } else { None }
22842284
}
22852285

@@ -2290,6 +2290,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22902290
/// LL | use foo::Bar;
22912291
/// | ^^^ did you mean `crate::foo`?
22922292
/// ```
2293+
#[instrument(level = "debug", skip(self, parent_scope))]
22932294
fn make_missing_crate_suggestion(
22942295
&mut self,
22952296
mut path: Vec<Segment>,
@@ -2298,7 +2299,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
22982299
// Replace first ident with `crate` and check if that is valid.
22992300
path[0].ident.name = kw::Crate;
23002301
let result = self.maybe_resolve_path(&path, None, parent_scope, None);
2301-
debug!("make_missing_crate_suggestion: path={:?} result={:?}", path, result);
2302+
debug!(?path, ?result);
23022303
if let PathResult::Module(..) = result {
23032304
Some((
23042305
path,
@@ -2321,6 +2322,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
23212322
/// LL | use foo::Bar;
23222323
/// | ^^^ did you mean `super::foo`?
23232324
/// ```
2325+
#[instrument(level = "debug", skip(self, parent_scope))]
23242326
fn make_missing_super_suggestion(
23252327
&mut self,
23262328
mut path: Vec<Segment>,
@@ -2329,7 +2331,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
23292331
// Replace first ident with `crate` and check if that is valid.
23302332
path[0].ident.name = kw::Super;
23312333
let result = self.maybe_resolve_path(&path, None, parent_scope, None);
2332-
debug!("make_missing_super_suggestion: path={:?} result={:?}", path, result);
2334+
debug!(?path, ?result);
23332335
if let PathResult::Module(..) = result { Some((path, None)) } else { None }
23342336
}
23352337

@@ -2343,6 +2345,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
23432345
///
23442346
/// Used when importing a submodule of an external crate but missing that crate's
23452347
/// name as the first part of path.
2348+
#[instrument(level = "debug", skip(self, parent_scope))]
23462349
fn make_external_crate_suggestion(
23472350
&mut self,
23482351
mut path: Vec<Segment>,
@@ -2363,10 +2366,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
23632366
// Replace first ident with a crate name and check if that is valid.
23642367
path[0].ident.name = name;
23652368
let result = self.maybe_resolve_path(&path, None, parent_scope, None);
2366-
debug!(
2367-
"make_external_crate_suggestion: name={:?} path={:?} result={:?}",
2368-
name, path, result
2369-
);
2369+
debug!(?path, ?name, ?result);
23702370
if let PathResult::Module(..) = result {
23712371
return Some((path, None));
23722372
}
@@ -2433,10 +2433,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
24332433
import.span,
24342434
import.use_span,
24352435
);
2436-
debug!(
2437-
"check_for_module_export_macro: found_closing_brace={:?} binding_span={:?}",
2438-
found_closing_brace, binding_span
2439-
);
2436+
debug!(found_closing_brace, ?binding_span);
24402437

24412438
let mut removal_span = binding_span;
24422439
if found_closing_brace {
@@ -2450,11 +2447,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
24502447
if let Some(previous_span) =
24512448
extend_span_to_previous_binding(self.tcx.sess, binding_span)
24522449
{
2453-
debug!("check_for_module_export_macro: previous_span={:?}", previous_span);
2450+
debug!(?previous_span);
24542451
removal_span = removal_span.with_lo(previous_span.lo());
24552452
}
24562453
}
2457-
debug!("check_for_module_export_macro: removal_span={:?}", removal_span);
2454+
debug!(?removal_span);
24582455

24592456
// Remove the `removal_span`.
24602457
corrections.push((removal_span, "".to_string()));
@@ -2470,10 +2467,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
24702467
module_name,
24712468
import.use_span,
24722469
);
2473-
debug!(
2474-
"check_for_module_export_macro: has_nested={:?} after_crate_name={:?}",
2475-
has_nested, after_crate_name
2476-
);
2470+
debug!(has_nested, ?after_crate_name);
24772471

24782472
let source_map = self.tcx.sess.source_map();
24792473

@@ -2677,15 +2671,12 @@ fn extend_span_to_previous_binding(sess: &Session, binding_span: Span) -> Option
26772671
/// use foo::{a, b::{c, d}};
26782672
/// // ^^^^^^^^^^^^^^^ -- true
26792673
/// ```
2674+
#[instrument(level = "debug", skip(sess))]
26802675
fn find_span_immediately_after_crate_name(
26812676
sess: &Session,
26822677
module_name: Symbol,
26832678
use_span: Span,
26842679
) -> (bool, Span) {
2685-
debug!(
2686-
"find_span_immediately_after_crate_name: module_name={:?} use_span={:?}",
2687-
module_name, use_span
2688-
);
26892680
let source_map = sess.source_map();
26902681

26912682
// Using `use issue_59764::foo::{baz, makro};` as an example throughout..

library/core/src/cell.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
//! (mutable via `&T`), in contrast with typical Rust types that exhibit 'inherited mutability'
2323
//! (mutable only via `&mut T`).
2424
//!
25-
//! Cell types come in three flavors: `Cell<T>`, `RefCell<T>`, and `OnceCell<T>`. Each provides
26-
//! a different way of providing safe interior mutability.
25+
//! Cell types come in four flavors: `Cell<T>`, `RefCell<T>`, `OnceCell<T>`, and `LazyCell<T>`.
26+
//! Each provides a different way of providing safe interior mutability.
2727
//!
2828
//! ## `Cell<T>`
2929
//!

library/std/src/env.rs

+8
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,10 @@ impl Error for VarError {
336336
/// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188)
337337
/// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2)
338338
///
339+
/// To pass an environment variable to a child process, you can instead use [`Command::env`].
340+
///
339341
/// [`std::net::ToSocketAddrs`]: crate::net::ToSocketAddrs
342+
/// [`Command::env`]: crate::process::Command::env
340343
///
341344
/// # Panics
342345
///
@@ -396,7 +399,12 @@ pub unsafe fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(key: K, value: V) {
396399
/// - [Austin Group Bugzilla](https://austingroupbugs.net/view.php?id=188)
397400
/// - [GNU C library Bugzilla](https://sourceware.org/bugzilla/show_bug.cgi?id=15607#c2)
398401
///
402+
/// To prevent a child process from inheriting an environment variable, you can
403+
/// instead use [`Command::env_remove`] or [`Command::env_clear`].
404+
///
399405
/// [`std::net::ToSocketAddrs`]: crate::net::ToSocketAddrs
406+
/// [`Command::env_remove`]: crate::process::Command::env_remove
407+
/// [`Command::env_clear`]: crate::process::Command::env_clear
400408
///
401409
/// # Panics
402410
///

src/bootstrap/bootstrap.py

+5
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,11 @@ def bootstrap(args):
12681268
config_toml = ""
12691269

12701270
profile = RustBuild.get_toml_static(config_toml, "profile")
1271+
is_non_git_source = not os.path.exists(os.path.join(rust_root, ".git"))
1272+
1273+
if profile is None and is_non_git_source:
1274+
profile = "dist"
1275+
12711276
if profile is not None:
12721277
# Allows creating alias for profile names, allowing
12731278
# profiles to be renamed while maintaining back compatibility

src/bootstrap/src/core/build_steps/dist.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,18 @@ impl Step for PlainSourceTarball {
10151015
];
10161016
let src_dirs = ["src", "compiler", "library", "tests", "LICENSES"];
10171017

1018-
copy_src_dirs(builder, &builder.src, &src_dirs, &[], plain_dst_src);
1018+
copy_src_dirs(
1019+
builder,
1020+
&builder.src,
1021+
&src_dirs,
1022+
&[
1023+
// We don't currently use the GCC source code for building any official components,
1024+
// it is very big, and has unclear licensing implications due to being GPL licensed.
1025+
// We thus exclude it from the source tarball from now.
1026+
"src/gcc",
1027+
],
1028+
plain_dst_src,
1029+
);
10191030

10201031
// Copy the files normally
10211032
for item in &src_files {

src/bootstrap/src/core/config/config.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -2931,10 +2931,8 @@ impl Config {
29312931
let if_unchanged = || {
29322932
if self.rust_info.is_from_tarball() {
29332933
// Git is needed for running "if-unchanged" logic.
2934-
println!(
2935-
"WARNING: 'if-unchanged' has no effect on tarball sources; ignoring `download-ci-llvm`."
2936-
);
2937-
return false;
2934+
println!("ERROR: 'if-unchanged' is only compatible with Git managed sources.");
2935+
crate::exit!(1);
29382936
}
29392937

29402938
// Fetching the LLVM submodule is unnecessary for self-tests.

0 commit comments

Comments
 (0)