Skip to content

Commit 481068a

Browse files
committed
Auto merge of #62419 - Centril:rollup-82umycq, r=Centril
Rollup of 13 pull requests Successful merges: - #61545 (Implement another internal lints) - #62110 (Improve -Ztime-passes) - #62133 (Feature gate `rustc` attributes harder) - #62158 (Add MemoryExtra in InterpretCx constructor params) - #62168 (The (almost) culmination of HirIdification) - #62193 (Create async version of the dynamic-drop test) - #62369 (Remove `compile-pass` from compiletest) - #62380 (rustc_target: avoid negative register counts in the SysV x86_64 ABI.) - #62381 (Fix a typo in Write::write_vectored docs) - #62390 (Update README.md) - #62396 (remove Scalar::is_null_ptr) - #62406 (Lint on invalid values passed to x.py --warnings) - #62414 (Remove last use of mem::uninitialized in SGX) Failed merges: r? @ghost
2 parents 853f300 + e89bd8c commit 481068a

File tree

178 files changed

+1310
-687
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+1310
-687
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Read ["Installation"] from [The Book].
1818

1919
_Note: If you wish to contribute to the compiler, you should read
2020
[this chapter](https://rust-lang.github.io/rustc-guide/how-to-build-and-run.html)
21-
of the rustc-guide instead._
21+
of the rustc-guide instead of this section._
2222

2323
### Building on *nix
2424
1. Make sure you have installed the dependencies:

src/bootstrap/bin/rustc.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,20 @@ fn main() {
306306
}
307307

308308
// This is required for internal lints.
309-
cmd.arg("-Zunstable-options");
309+
if let Some(crate_name) = args.windows(2).find(|a| &*a[0] == "--crate-name") {
310+
let crate_name = crate_name[1].to_string_lossy();
311+
if crate_name != "rustc_version"
312+
&& (crate_name.starts_with("rustc")
313+
|| crate_name.starts_with("syntax")
314+
|| crate_name == "arena"
315+
|| crate_name == "fmt_macros")
316+
{
317+
cmd.arg("-Zunstable-options");
318+
if stage != "0" {
319+
cmd.arg("-Wrustc::internal");
320+
}
321+
}
322+
}
310323

311324
// Force all crates compiled by this compiler to (a) be unstable and (b)
312325
// allow the `rustc_private` feature to link to other unstable crates

src/bootstrap/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ impl Config {
405405
config.incremental = flags.incremental;
406406
config.dry_run = flags.dry_run;
407407
config.keep_stage = flags.keep_stage;
408-
if let Some(value) = flags.warnings {
408+
if let Some(value) = flags.deny_warnings {
409409
config.deny_warnings = value;
410410
}
411411

@@ -571,7 +571,7 @@ impl Config {
571571
config.rustc_default_linker = rust.default_linker.clone();
572572
config.musl_root = rust.musl_root.clone().map(PathBuf::from);
573573
config.save_toolstates = rust.save_toolstates.clone().map(PathBuf::from);
574-
set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
574+
set(&mut config.deny_warnings, flags.deny_warnings.or(rust.deny_warnings));
575575
set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
576576
set(&mut config.rust_verify_llvm_ir, rust.verify_llvm_ir);
577577
set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo);

src/bootstrap/flags.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ pub struct Flags {
3333
pub rustc_error_format: Option<String>,
3434
pub dry_run: bool,
3535

36-
// true => deny
37-
pub warnings: Option<bool>,
36+
// This overrides the deny-warnings configuation option,
37+
// which passes -Dwarnings to the compiler invocations.
38+
//
39+
// true => deny, false => allow
40+
pub deny_warnings: Option<bool>,
3841
}
3942

4043
pub enum Subcommand {
@@ -468,7 +471,7 @@ Arguments:
468471
.into_iter()
469472
.map(|p| p.into())
470473
.collect::<Vec<_>>(),
471-
warnings: matches.opt_str("warnings").map(|v| v == "deny"),
474+
deny_warnings: parse_deny_warnings(&matches),
472475
}
473476
}
474477
}
@@ -549,3 +552,18 @@ fn split(s: &[String]) -> Vec<String> {
549552
.map(|s| s.to_string())
550553
.collect()
551554
}
555+
556+
fn parse_deny_warnings(matches: &getopts::Matches) -> Option<bool> {
557+
match matches.opt_str("warnings").as_ref().map(|v| v.as_str()) {
558+
Some("deny") => Some(true),
559+
Some("allow") => Some(false),
560+
Some(value) => {
561+
eprintln!(
562+
r#"invalid value for --warnings: {:?}, expected "allow" or "deny""#,
563+
value,
564+
);
565+
process::exit(1);
566+
},
567+
None => None,
568+
}
569+
}

src/doc/rustc-guide

src/libarena/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
test(no_crate_inject, attr(deny(warnings))))]
1313

1414
#![deny(rust_2018_idioms)]
15-
#![deny(internal)]
1615
#![deny(unused_lifetimes)]
1716

1817
#![feature(core_intrinsics)]

src/libcore/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
#![feature(concat_idents)]
7575
#![feature(const_fn)]
7676
#![feature(const_fn_union)]
77+
#![feature(custom_inner_attributes)]
7778
#![feature(doc_cfg)]
7879
#![feature(doc_spotlight)]
7980
#![feature(extern_types)]

src/libfmt_macros/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
test(attr(deny(warnings))))]
1010

1111
#![deny(rust_2018_idioms)]
12-
#![deny(internal)]
1312
#![deny(unused_lifetimes)]
1413

1514
#![feature(nll)]

src/librustc/dep_graph/dep_tracking_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<M: DepTrackingMapConfig> MemoizationMap for RefCell<DepTrackingMap<M>> {
5555
///
5656
/// ```
5757
/// fn type_of_item(..., item: &hir::Item) -> Ty<'tcx> {
58-
/// let item_def_id = ccx.tcx.hir().local_def_id(it.id);
58+
/// let item_def_id = ccx.tcx.hir().local_def_id(it.hir_id);
5959
/// ccx.tcx.item_types.memoized(item_def_id, || {
6060
/// ccx.tcx.dep_graph.read(DepNode::Hir(item_def_id)); // (*)
6161
/// compute_type_of_item(ccx, item)

src/librustc/hir/check_attr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl CheckAttrVisitor<'tcx> {
9595
/// Checks any attribute.
9696
fn check_attributes(&self, item: &hir::Item, target: Target) {
9797
if target == Target::Fn || target == Target::Const {
98-
self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id_from_hir_id(item.hir_id));
98+
self.tcx.codegen_fn_attrs(self.tcx.hir().local_def_id(item.hir_id));
9999
} else if let Some(a) = item.attrs.iter().find(|a| a.check_name(sym::target_feature)) {
100100
self.tcx.sess.struct_span_err(a.span, "attribute should be applied to a function")
101101
.span_label(item.span, "not a function")

src/librustc/hir/map/definitions.rs

-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ impl Definitions {
371371
None
372372
}
373373

374-
// FIXME(@ljedrz): replace the NodeId variant
375374
#[inline]
376375
pub fn as_local_hir_id(&self, def_id: DefId) -> Option<hir::HirId> {
377376
if def_id.krate == LOCAL_CRATE {

src/librustc/hir/map/hir_id_validator.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ pub fn check_crate(hir_map: &hir::map::Map<'_>) {
1010
let errors = Lock::new(Vec::new());
1111

1212
par_iter(&hir_map.krate().modules).for_each(|(module_id, _)| {
13-
hir_map.visit_item_likes_in_module(hir_map.local_def_id(*module_id), &mut OuterVisitor {
13+
let local_def_id = hir_map.local_def_id_from_node_id(*module_id);
14+
hir_map.visit_item_likes_in_module(local_def_id, &mut OuterVisitor {
1415
hir_map,
1516
errors: &errors,
1617
});
@@ -79,7 +80,7 @@ impl<'a, 'hir> HirIdValidator<'a, 'hir> {
7980
hir_id: HirId,
8081
walk: F) {
8182
assert!(self.owner_def_index.is_none());
82-
let owner_def_index = self.hir_map.local_def_id_from_hir_id(hir_id).index;
83+
let owner_def_index = self.hir_map.local_def_id(hir_id).index;
8384
self.owner_def_index = Some(owner_def_index);
8485
walk(self);
8586

src/librustc/hir/map/mod.rs

+13-16
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl<'hir> Map<'hir> {
219219
}
220220

221221
pub fn def_path_from_hir_id(&self, id: HirId) -> Option<DefPath> {
222-
self.opt_local_def_id_from_hir_id(id).map(|def_id| {
222+
self.opt_local_def_id(id).map(|def_id| {
223223
self.def_path(def_id)
224224
})
225225
}
@@ -230,32 +230,30 @@ impl<'hir> Map<'hir> {
230230
}
231231

232232
#[inline]
233-
pub fn local_def_id(&self, node: NodeId) -> DefId {
234-
self.opt_local_def_id(node).unwrap_or_else(|| {
233+
pub fn local_def_id_from_node_id(&self, node: NodeId) -> DefId {
234+
self.opt_local_def_id_from_node_id(node).unwrap_or_else(|| {
235235
let hir_id = self.node_to_hir_id(node);
236-
bug!("local_def_id: no entry for `{}`, which has a map of `{:?}`",
236+
bug!("local_def_id_from_node_id: no entry for `{}`, which has a map of `{:?}`",
237237
node, self.find_entry(hir_id))
238238
})
239239
}
240240

241-
// FIXME(@ljedrz): replace the `NodeId` variant.
242241
#[inline]
243-
pub fn local_def_id_from_hir_id(&self, hir_id: HirId) -> DefId {
244-
self.opt_local_def_id_from_hir_id(hir_id).unwrap_or_else(|| {
245-
bug!("local_def_id_from_hir_id: no entry for `{:?}`, which has a map of `{:?}`",
242+
pub fn local_def_id(&self, hir_id: HirId) -> DefId {
243+
self.opt_local_def_id(hir_id).unwrap_or_else(|| {
244+
bug!("local_def_id: no entry for `{:?}`, which has a map of `{:?}`",
246245
hir_id, self.find_entry(hir_id))
247246
})
248247
}
249248

250-
// FIXME(@ljedrz): replace the `NodeId` variant.
251249
#[inline]
252-
pub fn opt_local_def_id_from_hir_id(&self, hir_id: HirId) -> Option<DefId> {
250+
pub fn opt_local_def_id(&self, hir_id: HirId) -> Option<DefId> {
253251
let node_id = self.hir_to_node_id(hir_id);
254252
self.definitions.opt_local_def_id(node_id)
255253
}
256254

257255
#[inline]
258-
pub fn opt_local_def_id(&self, node: NodeId) -> Option<DefId> {
256+
pub fn opt_local_def_id_from_node_id(&self, node: NodeId) -> Option<DefId> {
259257
self.definitions.opt_local_def_id(node)
260258
}
261259

@@ -264,7 +262,6 @@ impl<'hir> Map<'hir> {
264262
self.definitions.as_local_node_id(def_id)
265263
}
266264

267-
// FIXME(@ljedrz): replace the `NodeId` variant.
268265
#[inline]
269266
pub fn as_local_hir_id(&self, def_id: DefId) -> Option<HirId> {
270267
self.definitions.as_local_hir_id(def_id)
@@ -429,7 +426,7 @@ impl<'hir> Map<'hir> {
429426
}
430427

431428
pub fn body_owner_def_id(&self, id: BodyId) -> DefId {
432-
self.local_def_id_from_hir_id(self.body_owner(id))
429+
self.local_def_id(self.body_owner(id))
433430
}
434431

435432
/// Given a `HirId`, returns the `BodyId` associated with it,
@@ -765,7 +762,7 @@ impl<'hir> Map<'hir> {
765762
/// Returns the `DefId` of `id`'s nearest module parent, or `id` itself if no
766763
/// module parent is in this map.
767764
pub fn get_module_parent(&self, id: HirId) -> DefId {
768-
self.local_def_id_from_hir_id(self.get_module_parent_node(id))
765+
self.local_def_id(self.get_module_parent_node(id))
769766
}
770767

771768
/// Returns the `HirId` of `id`'s nearest module parent, or `id` itself if no
@@ -841,7 +838,7 @@ impl<'hir> Map<'hir> {
841838
}
842839

843840
pub fn get_parent_did(&self, id: HirId) -> DefId {
844-
self.local_def_id_from_hir_id(self.get_parent_item(id))
841+
self.local_def_id(self.get_parent_item(id))
845842
}
846843

847844
pub fn get_foreign_abi(&self, hir_id: HirId) -> Abi {
@@ -1247,7 +1244,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
12471244
// the user-friendly path, otherwise fall back to stringifying DefPath.
12481245
crate::ty::tls::with_opt(|tcx| {
12491246
if let Some(tcx) = tcx {
1250-
let def_id = map.local_def_id_from_hir_id(id);
1247+
let def_id = map.local_def_id(id);
12511248
tcx.def_path_str(def_id)
12521249
} else if let Some(path) = map.def_path_from_hir_id(id) {
12531250
path.data.into_iter().map(|elem| {

src/librustc/hir/upvars.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl Visitor<'tcx> for CaptureCollector<'a, 'tcx> {
8383

8484
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
8585
if let hir::ExprKind::Closure(..) = expr.node {
86-
let closure_def_id = self.tcx.hir().local_def_id_from_hir_id(expr.hir_id);
86+
let closure_def_id = self.tcx.hir().local_def_id(expr.hir_id);
8787
if let Some(upvars) = self.tcx.upvars(closure_def_id) {
8888
// Every capture of a closure expression is a local in scope,
8989
// that is moved/copied/borrowed into the closure value, and

src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
139139
// error. We will then search the function parameters for a bound
140140
// region at the right depth with the same index
141141
(Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => {
142-
debug!(
143-
"EarlyBound self.infcx.tcx.hir().local_def_id(id)={:?} \
144-
def_id={:?}",
145-
id,
146-
def_id
147-
);
142+
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
148143
if id == def_id {
149144
self.found_type = Some(arg);
150145
return; // we can stop visiting now
@@ -162,8 +157,7 @@ impl Visitor<'tcx> for FindNestedTypeVisitor<'tcx> {
162157
"FindNestedTypeVisitor::visit_ty: LateBound depth = {:?}",
163158
debruijn_index
164159
);
165-
debug!("self.infcx.tcx.hir().local_def_id(id)={:?}", id);
166-
debug!("def_id={:?}", def_id);
160+
debug!("LateBound id={:?} def_id={:?}", id, def_id);
167161
if debruijn_index == self.current_index && id == def_id {
168162
self.found_type = Some(arg);
169163
return; // we can stop visiting now
@@ -231,12 +225,7 @@ impl Visitor<'tcx> for TyPathVisitor<'tcx> {
231225
}
232226

233227
(Some(rl::Region::EarlyBound(_, id, _)), ty::BrNamed(def_id, _)) => {
234-
debug!(
235-
"EarlyBound self.infcx.tcx.hir().local_def_id(id)={:?} \
236-
def_id={:?}",
237-
id,
238-
def_id
239-
);
228+
debug!("EarlyBound id={:?} def_id={:?}", id, def_id);
240229
if id == def_id {
241230
self.found_it = true;
242231
return; // we can stop visiting now

src/librustc/infer/opaque_types/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,8 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
951951
let parent_def_id = self.parent_def_id;
952952
let def_scope_default = || {
953953
let opaque_parent_hir_id = tcx.hir().get_parent_item(opaque_hir_id);
954-
parent_def_id
955-
== tcx.hir().local_def_id_from_hir_id(opaque_parent_hir_id)
954+
parent_def_id == tcx.hir()
955+
.local_def_id(opaque_parent_hir_id)
956956
};
957957
let (in_definition_scope, origin) = match tcx.hir().find(opaque_hir_id) {
958958
Some(Node::Item(item)) => match item.node {

src/librustc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
3030

3131
#![deny(rust_2018_idioms)]
32-
#![deny(internal)]
3332
#![deny(unused_lifetimes)]
3433

3534
#![feature(arbitrary_self_types)]

src/librustc/lint/context.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ impl<'a, 'tcx, T: LateLintPass<'a, 'tcx>> LateContextAndPass<'a, 'tcx, T> {
926926
{
927927
let old_param_env = self.context.param_env;
928928
self.context.param_env = self.context.tcx.param_env(
929-
self.context.tcx.hir().local_def_id_from_hir_id(id)
929+
self.context.tcx.hir().local_def_id(id)
930930
);
931931
f(self);
932932
self.context.param_env = old_param_env;
@@ -1341,6 +1341,7 @@ struct LateLintPassObjects<'a> {
13411341
lints: &'a mut [LateLintPassObject],
13421342
}
13431343

1344+
#[cfg_attr(not(bootstrap), allow(rustc::lint_pass_impl_without_macro))]
13441345
impl LintPass for LateLintPassObjects<'_> {
13451346
fn name(&self) -> &'static str {
13461347
panic!()
@@ -1500,7 +1501,7 @@ pub fn check_crate<'tcx, T: for<'a> LateLintPass<'a, 'tcx>>(
15001501
time(tcx.sess, "module lints", || {
15011502
// Run per-module lints
15021503
par_iter(&tcx.hir().krate().modules).for_each(|(&module, _)| {
1503-
tcx.ensure().lint_mod(tcx.hir().local_def_id(module));
1504+
tcx.ensure().lint_mod(tcx.hir().local_def_id_from_node_id(module));
15041505
});
15051506
});
15061507
});
@@ -1510,6 +1511,7 @@ struct EarlyLintPassObjects<'a> {
15101511
lints: &'a mut [EarlyLintPassObject],
15111512
}
15121513

1514+
#[cfg_attr(not(bootstrap), allow(rustc::lint_pass_impl_without_macro))]
15131515
impl LintPass for EarlyLintPassObjects<'_> {
15141516
fn name(&self) -> &'static str {
15151517
panic!()

0 commit comments

Comments
 (0)