Skip to content

Commit f312650

Browse files
committed
Auto merge of rust-lang#107601 - matthiaskrgr:rollup-07zaafe, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#106919 (Recover `_` as `..` in field pattern) - rust-lang#107493 (Improve diagnostic for missing space in range pattern) - rust-lang#107515 (Improve pretty-printing of `HirIdValidator` errors) - rust-lang#107524 (Remove both StorageLive and StorageDead in CopyProp.) - rust-lang#107532 (Erase regions before doing uninhabited check in borrowck) - rust-lang#107559 (Rename `rust_2015` → `is_rust_2015`) - rust-lang#107577 (Reinstate the `hir-stats.rs` tests on stage 1.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 97872b7 + 08181ea commit f312650

File tree

52 files changed

+322
-170
lines changed

Some content is hidden

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

52 files changed

+322
-170
lines changed

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ pub fn print_crate<'a>(
131131

132132
// Currently, in Rust 2018 we don't have `extern crate std;` at the crate
133133
// root, so this is not needed, and actually breaks things.
134-
if edition.rust_2015() {
134+
if edition.is_rust_2015() {
135135
// `#![no_std]`
136136
let fake_attr = attr::mk_attr_word(g, ast::AttrStyle::Inner, sym::no_std, DUMMY_SP);
137137
s.print_attribute(&fake_attr);

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
14841484
}
14851485
}
14861486
None => {
1487-
if !sig.output().is_privately_uninhabited(self.tcx(), self.param_env) {
1487+
// The signature in this call can reference region variables,
1488+
// so erase them before calling a query.
1489+
let output_ty = self.tcx().erase_regions(sig.output());
1490+
if !output_ty.is_privately_uninhabited(self.tcx(), self.param_env) {
14881491
span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig);
14891492
}
14901493
}

compiler/rustc_error_messages/locales/en-US/parse.ftl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,9 @@ parse_inclusive_range_extra_equals = unexpected `=` after inclusive range
203203
.suggestion_remove_eq = use `..=` instead
204204
.note = inclusive ranges end with a single equals sign (`..=`)
205205
206-
parse_inclusive_range_match_arrow = unexpected `=>` after open range
207-
.suggestion_add_space = add a space between the pattern and `=>`
206+
parse_inclusive_range_match_arrow = unexpected `>` after inclusive range
207+
.label = this is parsed as an inclusive range `..=`
208+
.suggestion = add a space between the pattern and `=>`
208209
209210
parse_inclusive_range_no_end = inclusive range with no end
210211
.suggestion_open_range = use `..` instead
@@ -535,8 +536,8 @@ parse_dot_dot_dot_range_to_pattern_not_allowed = range-to patterns with `...` ar
535536
536537
parse_enum_pattern_instead_of_identifier = expected identifier, found enum pattern
537538
538-
parse_dot_dot_dot_for_remaining_fields = expected field pattern, found `...`
539-
.suggestion = to omit remaining fields, use one fewer `.`
539+
parse_dot_dot_dot_for_remaining_fields = expected field pattern, found `{$token_str}`
540+
.suggestion = to omit remaining fields, use `..`
540541
541542
parse_expected_comma_after_pattern_field = expected `,`
542543

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
454454
None if let Some(e) = self.tainted_by_errors() => self.tcx.ty_error_with_guaranteed(e),
455455
None => {
456456
bug!(
457-
"no type for node {}: {} in fcx {}",
458-
id,
457+
"no type for node {} in fcx {}",
459458
self.tcx.hir().node_to_string(id),
460459
self.tag()
461460
);

compiler/rustc_hir_typeck/src/mem_categorization.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
155155
None if self.is_tainted_by_errors() => Err(()),
156156
None => {
157157
bug!(
158-
"no type for node {}: {} in mem_categorization",
159-
id,
158+
"no type for node {} in mem_categorization",
160159
self.tcx().hir().node_to_string(id)
161160
);
162161
}

compiler/rustc_middle/src/hir/map/mod.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ impl<'hir> Map<'hir> {
290290
#[track_caller]
291291
pub fn parent_id(self, hir_id: HirId) -> HirId {
292292
self.opt_parent_id(hir_id)
293-
.unwrap_or_else(|| bug!("No parent for node {:?}", self.node_to_string(hir_id)))
293+
.unwrap_or_else(|| bug!("No parent for node {}", self.node_to_string(hir_id)))
294294
}
295295

296296
pub fn get_parent(self, hir_id: HirId) -> Node<'hir> {
@@ -1191,12 +1191,10 @@ fn upstream_crates(tcx: TyCtxt<'_>) -> Vec<(StableCrateId, Svh)> {
11911191
}
11921192

11931193
fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
1194-
let id_str = format!(" (hir_id={})", id);
1195-
11961194
let path_str = |def_id: LocalDefId| map.tcx.def_path_str(def_id.to_def_id());
11971195

11981196
let span_str = || map.tcx.sess.source_map().span_to_snippet(map.span(id)).unwrap_or_default();
1199-
let node_str = |prefix| format!("{} {}{}", prefix, span_str(), id_str);
1197+
let node_str = |prefix| format!("{id} ({prefix} `{}`)", span_str());
12001198

12011199
match map.find(id) {
12021200
Some(Node::Item(item)) => {
@@ -1225,18 +1223,18 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
12251223
ItemKind::TraitAlias(..) => "trait alias",
12261224
ItemKind::Impl { .. } => "impl",
12271225
};
1228-
format!("{} {}{}", item_str, path_str(item.owner_id.def_id), id_str)
1226+
format!("{id} ({item_str} {})", path_str(item.owner_id.def_id))
12291227
}
12301228
Some(Node::ForeignItem(item)) => {
1231-
format!("foreign item {}{}", path_str(item.owner_id.def_id), id_str)
1229+
format!("{id} (foreign item {})", path_str(item.owner_id.def_id))
12321230
}
12331231
Some(Node::ImplItem(ii)) => {
12341232
let kind = match ii.kind {
12351233
ImplItemKind::Const(..) => "assoc const",
12361234
ImplItemKind::Fn(..) => "method",
12371235
ImplItemKind::Type(_) => "assoc type",
12381236
};
1239-
format!("{} {} in {}{}", kind, ii.ident, path_str(ii.owner_id.def_id), id_str)
1237+
format!("{id} ({kind} `{}` in {})", ii.ident, path_str(ii.owner_id.def_id))
12401238
}
12411239
Some(Node::TraitItem(ti)) => {
12421240
let kind = match ti.kind {
@@ -1245,13 +1243,13 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
12451243
TraitItemKind::Type(..) => "assoc type",
12461244
};
12471245

1248-
format!("{} {} in {}{}", kind, ti.ident, path_str(ti.owner_id.def_id), id_str)
1246+
format!("{id} ({kind} `{}` in {})", ti.ident, path_str(ti.owner_id.def_id))
12491247
}
12501248
Some(Node::Variant(ref variant)) => {
1251-
format!("variant {} in {}{}", variant.ident, path_str(variant.def_id), id_str)
1249+
format!("{id} (variant `{}` in {})", variant.ident, path_str(variant.def_id))
12521250
}
12531251
Some(Node::Field(ref field)) => {
1254-
format!("field {} in {}{}", field.ident, path_str(field.def_id), id_str)
1252+
format!("{id} (field `{}` in {})", field.ident, path_str(field.def_id))
12551253
}
12561254
Some(Node::AnonConst(_)) => node_str("const"),
12571255
Some(Node::Expr(_)) => node_str("expr"),
@@ -1269,16 +1267,15 @@ fn hir_id_to_string(map: Map<'_>, id: HirId) -> String {
12691267
Some(Node::Infer(_)) => node_str("infer"),
12701268
Some(Node::Local(_)) => node_str("local"),
12711269
Some(Node::Ctor(ctor)) => format!(
1272-
"ctor {}{}",
1270+
"{id} (ctor {})",
12731271
ctor.ctor_def_id().map_or("<missing path>".into(), |def_id| path_str(def_id)),
1274-
id_str
12751272
),
12761273
Some(Node::Lifetime(_)) => node_str("lifetime"),
12771274
Some(Node::GenericParam(ref param)) => {
1278-
format!("generic_param {}{}", path_str(param.def_id), id_str)
1275+
format!("{id} (generic_param {})", path_str(param.def_id))
12791276
}
1280-
Some(Node::Crate(..)) => String::from("root_crate"),
1281-
None => format!("unknown node{}", id_str),
1277+
Some(Node::Crate(..)) => String::from("(root_crate)"),
1278+
None => format!("{id} (unknown node)"),
12821279
}
12831280
}
12841281

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2171,7 +2171,7 @@ impl<'tcx> TyCtxt<'tcx> {
21712171
self.late_bound_vars_map(id.owner)
21722172
.and_then(|map| map.get(&id.local_id).cloned())
21732173
.unwrap_or_else(|| {
2174-
bug!("No bound vars found for {:?} ({:?})", self.hir().node_to_string(id), id)
2174+
bug!("No bound vars found for {}", self.hir().node_to_string(id))
21752175
})
21762176
.iter(),
21772177
)

compiler/rustc_middle/src/ty/typeck_results.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ impl<'tcx> TypeckResults<'tcx> {
372372

373373
pub fn node_type(&self, id: hir::HirId) -> Ty<'tcx> {
374374
self.node_type_opt(id).unwrap_or_else(|| {
375-
bug!("node_type: no type for node `{}`", tls::with(|tcx| tcx.hir().node_to_string(id)))
375+
bug!("node_type: no type for node {}", tls::with(|tcx| tcx.hir().node_to_string(id)))
376376
})
377377
}
378378

@@ -551,9 +551,8 @@ fn validate_hir_id_for_typeck_results(hir_owner: OwnerId, hir_id: hir::HirId) {
551551
fn invalid_hir_id_for_typeck_results(hir_owner: OwnerId, hir_id: hir::HirId) {
552552
ty::tls::with(|tcx| {
553553
bug!(
554-
"node {} with HirId::owner {:?} cannot be placed in TypeckResults with hir_owner {:?}",
554+
"node {} cannot be placed in TypeckResults with hir_owner {:?}",
555555
tcx.hir().node_to_string(hir_id),
556-
hir_id.owner,
557556
hir_owner
558557
)
559558
});

compiler/rustc_mir_transform/src/copy_prop.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,17 +162,20 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> {
162162
}
163163

164164
fn visit_statement(&mut self, stmt: &mut Statement<'tcx>, loc: Location) {
165-
if let StatementKind::StorageDead(l) = stmt.kind
166-
&& self.storage_to_remove.contains(l)
167-
{
168-
stmt.make_nop();
169-
} else if let StatementKind::Assign(box (ref place, ref mut rvalue)) = stmt.kind
170-
&& place.as_local().is_some()
171-
{
172-
// Do not replace assignments.
173-
self.visit_rvalue(rvalue, loc)
174-
} else {
175-
self.super_statement(stmt, loc);
165+
match stmt.kind {
166+
// When removing storage statements, we need to remove both (#107511).
167+
StatementKind::StorageLive(l) | StatementKind::StorageDead(l)
168+
if self.storage_to_remove.contains(l) =>
169+
{
170+
stmt.make_nop()
171+
}
172+
StatementKind::Assign(box (ref place, ref mut rvalue))
173+
if place.as_local().is_some() =>
174+
{
175+
// Do not replace assignments.
176+
self.visit_rvalue(rvalue, loc)
177+
}
178+
_ => self.super_statement(stmt, loc),
176179
}
177180
}
178181
}

compiler/rustc_parse/src/errors.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::borrow::Cow;
2+
13
use rustc_ast::token::Token;
24
use rustc_ast::{Path, Visibility};
35
use rustc_errors::{fluent, AddToDiagnostic, Applicability, EmissionGuarantee, IntoDiagnostic};
@@ -668,13 +670,10 @@ pub(crate) struct InclusiveRangeExtraEquals {
668670
#[diag(parse_inclusive_range_match_arrow)]
669671
pub(crate) struct InclusiveRangeMatchArrow {
670672
#[primary_span]
673+
pub arrow: Span,
674+
#[label]
671675
pub span: Span,
672-
#[suggestion(
673-
suggestion_add_space,
674-
style = "verbose",
675-
code = " ",
676-
applicability = "machine-applicable"
677-
)]
676+
#[suggestion(style = "verbose", code = " ", applicability = "machine-applicable")]
678677
pub after_pat: Span,
679678
}
680679

@@ -1802,8 +1801,9 @@ pub(crate) struct EnumPatternInsteadOfIdentifier {
18021801
#[diag(parse_dot_dot_dot_for_remaining_fields)]
18031802
pub(crate) struct DotDotDotForRemainingFields {
18041803
#[primary_span]
1805-
#[suggestion(code = "..", applicability = "machine-applicable")]
1804+
#[suggestion(code = "..", style = "verbose", applicability = "machine-applicable")]
18061805
pub span: Span,
1806+
pub token_str: Cow<'static, str>,
18071807
}
18081808

18091809
#[derive(Diagnostic)]

0 commit comments

Comments
 (0)