Skip to content

Commit 0271499

Browse files
committed
Auto merge of rust-lang#72222 - Dylan-DPC:rollup-vaw44dg, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - rust-lang#71809 (Use `LocalDefId` in `DumpVisitor::nest_tables`) - rust-lang#72062 (Add built in PSP target) - rust-lang#72146 (Provide separate option for std debug asserts) - rust-lang#72172 (Forbid stage arguments to check) - rust-lang#72173 (Make intra links work inside trait impl block) - rust-lang#72200 (Add prioritize_on attribute to triagebot) - rust-lang#72214 (Minor fixes to comments) Failed merges: r? @ghost
2 parents 85f0da6 + 49d50e6 commit 0271499

File tree

16 files changed

+280
-52
lines changed

16 files changed

+280
-52
lines changed

config.toml.example

+4
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,10 @@
314314
# library.
315315
#debug-assertions = false
316316

317+
# Whether or not debug assertions are enabled for the standard library.
318+
# Overrides the `debug-assertions` option, if defined.
319+
#debug-assertions-std = false
320+
317321
# Debuginfo level for most of Rust code, corresponds to the `-C debuginfo=N` option of `rustc`.
318322
# `0` - no debug info
319323
# `1` - line tables only

src/bootstrap/builder.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,14 @@ impl<'a> Builder<'a> {
915915
.env("RUSTC", self.out.join("bootstrap/debug/rustc"))
916916
.env("RUSTC_REAL", self.rustc(compiler))
917917
.env("RUSTC_STAGE", stage.to_string())
918-
.env("RUSTC_DEBUG_ASSERTIONS", self.config.rust_debug_assertions.to_string())
918+
.env(
919+
"RUSTC_DEBUG_ASSERTIONS",
920+
if mode == Mode::Std {
921+
self.config.rust_debug_assertions_std.to_string()
922+
} else {
923+
self.config.rust_debug_assertions.to_string()
924+
},
925+
)
919926
.env("RUSTC_SYSROOT", &sysroot)
920927
.env("RUSTC_LIBDIR", &libdir)
921928
.env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))

src/bootstrap/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ pub struct Config {
9797
pub rust_codegen_units: Option<u32>,
9898
pub rust_codegen_units_std: Option<u32>,
9999
pub rust_debug_assertions: bool,
100+
pub rust_debug_assertions_std: bool,
100101
pub rust_debuginfo_level_rustc: u32,
101102
pub rust_debuginfo_level_std: u32,
102103
pub rust_debuginfo_level_tools: u32,
@@ -314,6 +315,7 @@ struct Rust {
314315
codegen_units: Option<u32>,
315316
codegen_units_std: Option<u32>,
316317
debug_assertions: Option<bool>,
318+
debug_assertions_std: Option<bool>,
317319
debuginfo_level: Option<u32>,
318320
debuginfo_level_rustc: Option<u32>,
319321
debuginfo_level_std: Option<u32>,
@@ -518,6 +520,7 @@ impl Config {
518520
let mut llvm_assertions = None;
519521
let mut debug = None;
520522
let mut debug_assertions = None;
523+
let mut debug_assertions_std = None;
521524
let mut debuginfo_level = None;
522525
let mut debuginfo_level_rustc = None;
523526
let mut debuginfo_level_std = None;
@@ -560,6 +563,7 @@ impl Config {
560563
if let Some(ref rust) = toml.rust {
561564
debug = rust.debug;
562565
debug_assertions = rust.debug_assertions;
566+
debug_assertions_std = rust.debug_assertions_std;
563567
debuginfo_level = rust.debuginfo_level;
564568
debuginfo_level_rustc = rust.debuginfo_level_rustc;
565569
debuginfo_level_std = rust.debuginfo_level_std;
@@ -658,6 +662,8 @@ impl Config {
658662

659663
let default = debug == Some(true);
660664
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
665+
config.rust_debug_assertions_std =
666+
debug_assertions_std.unwrap_or(config.rust_debug_assertions);
661667

662668
let with_defaults = |debuginfo_level_specific: Option<u32>| {
663669
debuginfo_level_specific.or(debuginfo_level).unwrap_or(if debug == Some(true) {

src/bootstrap/flags.rs

+14
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,20 @@ Arguments:
503503
}
504504
};
505505

506+
if let Subcommand::Check { .. } = &cmd {
507+
if matches.opt_str("stage").is_some() {
508+
println!("{}", "--stage not supported for x.py check, always treated as stage 0");
509+
process::exit(1);
510+
}
511+
if matches.opt_str("keep-stage").is_some() {
512+
println!(
513+
"{}",
514+
"--keep-stage not supported for x.py check, only one stage available"
515+
);
516+
process::exit(1);
517+
}
518+
}
519+
506520
Flags {
507521
verbose: matches.opt_count("verbose"),
508522
stage: matches.opt_str("stage").map(|j| j.parse().expect("`stage` should be a number")),

src/librustc_ast_passes/node_count.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Simply gives a rought count of the number of nodes in an AST.
1+
// Simply gives a rough count of the number of nodes in an AST.
22

33
use rustc_ast::ast::*;
44
use rustc_ast::visit::*;

src/librustc_codegen_ssa/back/link.rs

+25
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,28 @@ fn add_pre_link_args(
11791179
cmd.args(&sess.opts.debugging_opts.pre_link_args);
11801180
}
11811181

1182+
/// Add a link script embedded in the target, if applicable.
1183+
fn add_link_script(cmd: &mut dyn Linker, sess: &Session, tmpdir: &Path, crate_type: CrateType) {
1184+
match (crate_type, &sess.target.target.options.link_script) {
1185+
(CrateType::Cdylib | CrateType::Executable, Some(script)) => {
1186+
if !sess.target.target.options.linker_is_gnu {
1187+
sess.fatal("can only use link script when linking with GNU-like linker");
1188+
}
1189+
1190+
let file_name = ["rustc", &sess.target.target.llvm_target, "linkfile.ld"].join("-");
1191+
1192+
let path = tmpdir.join(file_name);
1193+
if let Err(e) = fs::write(&path, script) {
1194+
sess.fatal(&format!("failed to write link script to {}: {}", path.display(), e));
1195+
}
1196+
1197+
cmd.arg("--script");
1198+
cmd.arg(path);
1199+
}
1200+
_ => {}
1201+
}
1202+
}
1203+
11821204
/// Add arbitrary "user defined" args defined from command line and by `#[link_args]` attributes.
11831205
/// FIXME: Determine where exactly these args need to be inserted.
11841206
fn add_user_defined_link_args(
@@ -1421,6 +1443,9 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
14211443
// NO-OPT-OUT, OBJECT-FILES-MAYBE, CUSTOMIZATION-POINT
14221444
add_pre_link_args(cmd, sess, flavor, crate_type);
14231445

1446+
// NO-OPT-OUT
1447+
add_link_script(cmd, sess, tmpdir, crate_type);
1448+
14241449
// NO-OPT-OUT, OBJECT-FILES-NO, AUDIT-ORDER
14251450
if sess.target.target.options.is_like_fuchsia {
14261451
let prefix = match sess.opts.debugging_opts.sanitizer {

src/librustc_middle/middle/region.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//! For more information about how MIR-based region-checking works,
55
//! see the [rustc dev guide].
66
//!
7-
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/mir/borrowck.html
7+
//! [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/borrow_check.html
88
99
use crate::ich::{NodeIdHashingMode, StableHashingContext};
1010
use crate::ty::{self, DefIdTree, TyCtxt};
@@ -181,7 +181,7 @@ impl Scope {
181181
// `blk`; reuse span of `blk` and shift `lo`
182182
// forward to end of indexed statement.
183183
//
184-
// (This is the special case aluded to in the
184+
// (This is the special case alluded to in the
185185
// doc-comment for this method)
186186

187187
let stmt_span = blk.stmts[first_statement_index.index()].span;

src/librustc_save_analysis/dump_visitor.rs

+41-29
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_ast::walk_list;
2121
use rustc_ast_pretty::pprust::{bounds_to_string, generic_params_to_string, ty_to_string};
2222
use rustc_data_structures::fx::FxHashSet;
2323
use rustc_hir::def::{DefKind as HirDefKind, Res};
24-
use rustc_hir::def_id::DefId;
24+
use rustc_hir::def_id::{DefId, LocalDefId};
2525
use rustc_middle::span_bug;
2626
use rustc_middle::ty::{self, DefIdTree, TyCtxt};
2727
use rustc_session::config::Input;
@@ -104,12 +104,10 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
104104
self.dumper.analysis()
105105
}
106106

107-
fn nest_tables<F>(&mut self, item_id: NodeId, f: F)
107+
fn nest_tables<F>(&mut self, item_def_id: LocalDefId, f: F)
108108
where
109109
F: FnOnce(&mut Self),
110110
{
111-
let item_def_id = self.tcx.hir().local_def_id_from_node_id(item_id);
112-
113111
let tables = if self.tcx.has_typeck_tables(item_def_id) {
114112
self.tcx.typeck_tables_of(item_def_id)
115113
} else {
@@ -272,8 +270,9 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
272270
) {
273271
debug!("process_method: {}:{}", id, ident);
274272

275-
let hir_id = self.tcx.hir().node_id_to_hir_id(id);
276-
self.nest_tables(id, |v| {
273+
let map = &self.tcx.hir();
274+
let hir_id = map.node_id_to_hir_id(id);
275+
self.nest_tables(map.local_def_id(hir_id), |v| {
277276
if let Some(mut method_data) = v.save_ctxt.get_method_data(id, ident, span) {
278277
v.process_formals(&sig.decl.inputs, &method_data.qualname);
279278
v.process_generic_params(&generics, &method_data.qualname, id);
@@ -296,7 +295,8 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
296295
// start walking from the newly-created definition.
297296
match sig.header.asyncness {
298297
ast::Async::Yes { return_impl_trait_id, .. } => {
299-
v.nest_tables(return_impl_trait_id, |v| v.visit_ty(ret_ty))
298+
let hir_id = map.node_id_to_hir_id(return_impl_trait_id);
299+
v.nest_tables(map.local_def_id(hir_id), |v| v.visit_ty(ret_ty))
300300
}
301301
_ => v.visit_ty(ret_ty),
302302
}
@@ -364,8 +364,9 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
364364
ty_params: &'l ast::Generics,
365365
body: Option<&'l ast::Block>,
366366
) {
367-
let hir_id = self.tcx.hir().node_id_to_hir_id(item.id);
368-
self.nest_tables(item.id, |v| {
367+
let map = &self.tcx.hir();
368+
let hir_id = map.node_id_to_hir_id(item.id);
369+
self.nest_tables(map.local_def_id(hir_id), |v| {
369370
if let Some(fn_data) = v.save_ctxt.get_item_data(item) {
370371
down_cast_data!(fn_data, DefData, item.span);
371372
v.process_formals(&decl.inputs, &fn_data.qualname);
@@ -389,7 +390,8 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
389390
// start walking from the newly-created definition.
390391
match header.asyncness {
391392
ast::Async::Yes { return_impl_trait_id, .. } => {
392-
v.nest_tables(return_impl_trait_id, |v| v.visit_ty(ret_ty))
393+
let hir_id = map.node_id_to_hir_id(return_impl_trait_id);
394+
v.nest_tables(map.local_def_id(hir_id), |v| v.visit_ty(ret_ty))
393395
}
394396
_ => v.visit_ty(ret_ty),
395397
}
@@ -407,7 +409,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
407409
expr: Option<&'l ast::Expr>,
408410
) {
409411
let hir_id = self.tcx.hir().node_id_to_hir_id(item.id);
410-
self.nest_tables(item.id, |v| {
412+
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
411413
if let Some(var_data) = v.save_ctxt.get_item_data(item) {
412414
down_cast_data!(var_data, DefData, item.span);
413415
v.dumper.dump_def(&access_from!(v.save_ctxt, item, hir_id), var_data);
@@ -427,15 +429,13 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
427429
vis: ast::Visibility,
428430
attrs: &'l [Attribute],
429431
) {
430-
let qualname = format!(
431-
"::{}",
432-
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(id).to_def_id())
433-
);
432+
let hir_id = self.tcx.hir().node_id_to_hir_id(id);
433+
let qualname =
434+
format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id(hir_id).to_def_id()));
434435

435436
if !self.span.filter_generated(ident.span) {
436437
let sig = sig::assoc_const_signature(id, ident.name, typ, expr, &self.save_ctxt);
437438
let span = self.span_from_span(ident.span);
438-
let hir_id = self.tcx.hir().node_id_to_hir_id(id);
439439

440440
self.dumper.dump_def(
441441
&access_from_vis!(self.save_ctxt, vis, hir_id),
@@ -457,7 +457,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
457457
}
458458

459459
// walk type and init value
460-
self.nest_tables(id, |v| {
460+
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
461461
v.visit_ty(typ);
462462
if let Some(expr) = expr {
463463
v.visit_expr(expr);
@@ -474,10 +474,9 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
474474
) {
475475
debug!("process_struct {:?} {:?}", item, item.span);
476476
let name = item.ident.to_string();
477-
let qualname = format!(
478-
"::{}",
479-
self.tcx.def_path_str(self.tcx.hir().local_def_id_from_node_id(item.id).to_def_id())
480-
);
477+
let hir_id = self.tcx.hir().node_id_to_hir_id(item.id);
478+
let qualname =
479+
format!("::{}", self.tcx.def_path_str(self.tcx.hir().local_def_id(hir_id).to_def_id()));
481480

482481
let kind = match item.kind {
483482
ast::ItemKind::Struct(_, _) => DefKind::Struct,
@@ -509,7 +508,6 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
509508

510509
if !self.span.filter_generated(item.ident.span) {
511510
let span = self.span_from_span(item.ident.span);
512-
let hir_id = self.tcx.hir().node_id_to_hir_id(item.id);
513511
self.dumper.dump_def(
514512
&access_from!(self.save_ctxt, item, hir_id),
515513
Def {
@@ -529,7 +527,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
529527
);
530528
}
531529

532-
self.nest_tables(item.id, |v| {
530+
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
533531
for field in def.fields() {
534532
v.process_struct_field_def(field, item.id);
535533
v.visit_ty(&field.ty);
@@ -669,14 +667,15 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
669667
}
670668

671669
let map = &self.tcx.hir();
672-
self.nest_tables(item.id, |v| {
670+
let hir_id = map.node_id_to_hir_id(item.id);
671+
self.nest_tables(map.local_def_id(hir_id), |v| {
673672
v.visit_ty(&typ);
674673
if let &Some(ref trait_ref) = trait_ref {
675674
v.process_path(trait_ref.ref_id, &trait_ref.path);
676675
}
677676
v.process_generic_params(generics, "", item.id);
678677
for impl_item in impl_items {
679-
v.process_impl_item(impl_item, map.local_def_id_from_node_id(item.id).to_def_id());
678+
v.process_impl_item(impl_item, map.local_def_id(hir_id).to_def_id());
680679
}
681680
});
682681
}
@@ -1411,7 +1410,10 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
14111410
}
14121411
ast::TyKind::Array(ref element, ref length) => {
14131412
self.visit_ty(element);
1414-
self.nest_tables(length.id, |v| v.visit_expr(&length.value));
1413+
let hir_id = self.tcx.hir().node_id_to_hir_id(length.id);
1414+
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
1415+
v.visit_expr(&length.value)
1416+
});
14151417
}
14161418
ast::TyKind::ImplTrait(id, ref bounds) => {
14171419
// FIXME: As of writing, the opaque type lowering introduces
@@ -1423,7 +1425,13 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
14231425
// bounds...
14241426
// This will panic if called on return type `impl Trait`, which
14251427
// we guard against in `process_fn`.
1426-
self.nest_tables(id, |v| v.process_bounds(bounds));
1428+
// FIXME(#71104) Should really be using just `node_id_to_hir_id` but
1429+
// some `NodeId` do not seem to have a corresponding HirId.
1430+
if let Some(hir_id) = self.tcx.hir().opt_node_id_to_hir_id(id) {
1431+
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
1432+
v.process_bounds(bounds)
1433+
});
1434+
}
14271435
}
14281436
_ => visit::walk_ty(self, t),
14291437
}
@@ -1471,7 +1479,8 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
14711479
}
14721480

14731481
// walk the body
1474-
self.nest_tables(ex.id, |v| {
1482+
let hir_id = self.tcx.hir().node_id_to_hir_id(ex.id);
1483+
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
14751484
v.process_formals(&decl.inputs, &id);
14761485
v.visit_expr(body)
14771486
});
@@ -1488,7 +1497,10 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
14881497
}
14891498
ast::ExprKind::Repeat(ref element, ref count) => {
14901499
self.visit_expr(element);
1491-
self.nest_tables(count.id, |v| v.visit_expr(&count.value));
1500+
let hir_id = self.tcx.hir().node_id_to_hir_id(count.id);
1501+
self.nest_tables(self.tcx.hir().local_def_id(hir_id), |v| {
1502+
v.visit_expr(&count.value)
1503+
});
14921504
}
14931505
// In particular, we take this branch for call and path expressions,
14941506
// where we'll index the idents involved just by continuing to walk.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, RelocModel};
2+
use crate::spec::{Target, TargetOptions, TargetResult};
3+
4+
// The PSP has custom linker requirements.
5+
const LINKER_SCRIPT: &str = include_str!("./mipsel_sony_psp_linker_script.ld");
6+
7+
pub fn target() -> TargetResult {
8+
let mut pre_link_args = LinkArgs::new();
9+
pre_link_args.insert(
10+
LinkerFlavor::Lld(LldFlavor::Ld),
11+
vec!["--eh-frame-hdr".to_string(), "--emit-relocs".to_string()],
12+
);
13+
14+
Ok(Target {
15+
llvm_target: "mipsel-sony-psp".to_string(),
16+
target_endian: "little".to_string(),
17+
target_pointer_width: "32".to_string(),
18+
target_c_int_width: "32".to_string(),
19+
data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
20+
arch: "mips".to_string(),
21+
target_os: "psp".to_string(),
22+
target_env: "".to_string(),
23+
target_vendor: "sony".to_string(),
24+
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
25+
26+
options: TargetOptions {
27+
cpu: "mips2".to_string(),
28+
executables: true,
29+
linker: Some("rust-lld".to_owned()),
30+
linker_is_gnu: true,
31+
relocation_model: RelocModel::Static,
32+
33+
// PSP FPU only supports single precision floats.
34+
features: "+single-float".to_string(),
35+
36+
// PSP does not support trap-on-condition instructions.
37+
llvm_args: vec!["-mno-check-zero-division".to_string()],
38+
pre_link_args,
39+
link_script: Some(LINKER_SCRIPT.to_string()),
40+
..Default::default()
41+
},
42+
})
43+
}

0 commit comments

Comments
 (0)