Skip to content

Commit 7665c35

Browse files
committed
Auto merge of rust-lang#98987 - GuillaumeGomez:rollup-bcy32bp, r=GuillaumeGomez
Rollup of 7 pull requests Successful merges: - rust-lang#96935 (Allow arithmetic and certain bitwise ops on AtomicPtr) - rust-lang#98519 (Replace some `guess_head_span` with `def_span`) - rust-lang#98911 (rustdoc: filter '_ lifetimes from ty::Generics) - rust-lang#98939 (rustdoc: Add more semantic information to impl IDs) - rust-lang#98971 (Fix typo in file descriptor docs) - rust-lang#98983 (docs: Add overview of `rustc_middle::mir::TerminatorKind`) - rust-lang#98984 (Remove erroneous doc comment) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3dcb616 + 4b88cba commit 7665c35

File tree

78 files changed

+701
-341
lines changed

Some content is hidden

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

78 files changed

+701
-341
lines changed

Diff for: compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -812,12 +812,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
812812
return FnSelfUse {
813813
var_span: stmt.source_info.span,
814814
fn_call_span: *fn_span,
815-
fn_span: self
816-
.infcx
817-
.tcx
818-
.sess
819-
.source_map()
820-
.guess_head_span(self.infcx.tcx.def_span(method_did)),
815+
fn_span: self.infcx.tcx.def_span(method_did),
821816
kind,
822817
};
823818
}

Diff for: compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -513,9 +513,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
513513
};
514514

515515
let ty = substs.type_at(0);
516-
if int_type_width_signed(ty, bx.tcx()).is_some()
517-
|| (ty.is_unsafe_ptr() && op == "xchg")
518-
{
516+
if int_type_width_signed(ty, bx.tcx()).is_some() || ty.is_unsafe_ptr() {
519517
let mut ptr = args[0].immediate();
520518
let mut val = args[1].immediate();
521519
if ty.is_unsafe_ptr() {

Diff for: compiler/rustc_const_eval/src/transform/check_consts/ops.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
155155
});
156156

157157
if let Ok(Some(ImplSource::UserDefined(data))) = implsrc {
158-
let span =
159-
tcx.sess.source_map().guess_head_span(tcx.def_span(data.impl_def_id));
158+
let span = tcx.def_span(data.impl_def_id);
160159
err.span_note(span, "impl defined here, but it is not `const`");
161160
}
162161
}
@@ -205,7 +204,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
205204

206205
match self_ty.kind() {
207206
FnDef(def_id, ..) => {
208-
let span = tcx.sess.source_map().guess_head_span(tcx.def_span(*def_id));
207+
let span = tcx.def_span(*def_id);
209208
if ccx.tcx.is_const_fn_raw(*def_id) {
210209
span_bug!(span, "calling const FnDef errored when it shouldn't");
211210
}

Diff for: compiler/rustc_infer/src/infer/error_reporting/mod.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,10 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>(
148148
tcx: TyCtxt<'tcx>,
149149
region: ty::Region<'tcx>,
150150
) -> (String, Span) {
151-
let sm = tcx.sess.source_map();
152-
153151
let scope = region.free_region_binding_scope(tcx).expect_local();
154152
match *region {
155153
ty::ReEarlyBound(ref br) => {
156-
let mut sp = sm.guess_head_span(tcx.def_span(scope));
154+
let mut sp = tcx.def_span(scope);
157155
if let Some(param) =
158156
tcx.hir().get_generics(scope).and_then(|generics| generics.get_named(br.name))
159157
{
@@ -174,7 +172,7 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>(
174172
} else {
175173
match fr.bound_region {
176174
ty::BoundRegionKind::BrNamed(_, name) => {
177-
let mut sp = sm.guess_head_span(tcx.def_span(scope));
175+
let mut sp = tcx.def_span(scope);
178176
if let Some(param) =
179177
tcx.hir().get_generics(scope).and_then(|generics| generics.get_named(name))
180178
{
@@ -193,7 +191,7 @@ fn msg_span_from_early_bound_and_free_regions<'tcx>(
193191
),
194192
_ => (
195193
format!("the lifetime `{}` as defined here", region),
196-
sm.guess_head_span(tcx.def_span(scope)),
194+
tcx.def_span(scope),
197195
),
198196
}
199197
}

Diff for: compiler/rustc_infer/src/traits/error_reporting/mod.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
2323

2424
let mut err = struct_span_err!(self.tcx.sess, sp, E0276, "{}", msg);
2525

26-
if let Some(trait_item_span) = self.tcx.hir().span_if_local(trait_item_def_id) {
27-
let span = self.tcx.sess.source_map().guess_head_span(trait_item_span);
26+
if trait_item_def_id.is_local() {
2827
let item_name = self.tcx.item_name(impl_item_def_id.to_def_id());
29-
err.span_label(span, format!("definition of `{}` from trait", item_name));
28+
err.span_label(
29+
self.tcx.def_span(trait_item_def_id),
30+
format!("definition of `{}` from trait", item_name),
31+
);
3032
}
3133

3234
err.span_label(sp, format!("impl has extra requirement {}", requirement));

Diff for: compiler/rustc_lint/src/builtin.rs

+13-24
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,6 @@ impl MissingDoc {
552552
&self,
553553
cx: &LateContext<'_>,
554554
def_id: LocalDefId,
555-
sp: Span,
556555
article: &'static str,
557556
desc: &'static str,
558557
) {
@@ -579,16 +578,12 @@ impl MissingDoc {
579578
let attrs = cx.tcx.hir().attrs(cx.tcx.hir().local_def_id_to_hir_id(def_id));
580579
let has_doc = attrs.iter().any(has_doc);
581580
if !has_doc {
582-
cx.struct_span_lint(
583-
MISSING_DOCS,
584-
cx.tcx.sess.source_map().guess_head_span(sp),
585-
|lint| {
586-
lint.build(fluent::lint::builtin_missing_doc)
587-
.set_arg("article", article)
588-
.set_arg("desc", desc)
589-
.emit();
590-
},
591-
);
581+
cx.struct_span_lint(MISSING_DOCS, cx.tcx.def_span(def_id), |lint| {
582+
lint.build(fluent::lint::builtin_missing_doc)
583+
.set_arg("article", article)
584+
.set_arg("desc", desc)
585+
.emit();
586+
});
592587
}
593588
}
594589
}
@@ -611,13 +606,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
611606
}
612607

613608
fn check_crate(&mut self, cx: &LateContext<'_>) {
614-
self.check_missing_docs_attrs(
615-
cx,
616-
CRATE_DEF_ID,
617-
cx.tcx.def_span(CRATE_DEF_ID),
618-
"the",
619-
"crate",
620-
);
609+
self.check_missing_docs_attrs(cx, CRATE_DEF_ID, "the", "crate");
621610
}
622611

623612
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
@@ -647,13 +636,13 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
647636

648637
let (article, desc) = cx.tcx.article_and_description(it.def_id.to_def_id());
649638

650-
self.check_missing_docs_attrs(cx, it.def_id, it.span, article, desc);
639+
self.check_missing_docs_attrs(cx, it.def_id, article, desc);
651640
}
652641

653642
fn check_trait_item(&mut self, cx: &LateContext<'_>, trait_item: &hir::TraitItem<'_>) {
654643
let (article, desc) = cx.tcx.article_and_description(trait_item.def_id.to_def_id());
655644

656-
self.check_missing_docs_attrs(cx, trait_item.def_id, trait_item.span, article, desc);
645+
self.check_missing_docs_attrs(cx, trait_item.def_id, article, desc);
657646
}
658647

659648
fn check_impl_item(&mut self, cx: &LateContext<'_>, impl_item: &hir::ImplItem<'_>) {
@@ -681,23 +670,23 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
681670
}
682671

683672
let (article, desc) = cx.tcx.article_and_description(impl_item.def_id.to_def_id());
684-
self.check_missing_docs_attrs(cx, impl_item.def_id, impl_item.span, article, desc);
673+
self.check_missing_docs_attrs(cx, impl_item.def_id, article, desc);
685674
}
686675

687676
fn check_foreign_item(&mut self, cx: &LateContext<'_>, foreign_item: &hir::ForeignItem<'_>) {
688677
let (article, desc) = cx.tcx.article_and_description(foreign_item.def_id.to_def_id());
689-
self.check_missing_docs_attrs(cx, foreign_item.def_id, foreign_item.span, article, desc);
678+
self.check_missing_docs_attrs(cx, foreign_item.def_id, article, desc);
690679
}
691680

692681
fn check_field_def(&mut self, cx: &LateContext<'_>, sf: &hir::FieldDef<'_>) {
693682
if !sf.is_positional() {
694683
let def_id = cx.tcx.hir().local_def_id(sf.hir_id);
695-
self.check_missing_docs_attrs(cx, def_id, sf.span, "a", "struct field")
684+
self.check_missing_docs_attrs(cx, def_id, "a", "struct field")
696685
}
697686
}
698687

699688
fn check_variant(&mut self, cx: &LateContext<'_>, v: &hir::Variant<'_>) {
700-
self.check_missing_docs_attrs(cx, cx.tcx.hir().local_def_id(v.id), v.span, "a", "variant");
689+
self.check_missing_docs_attrs(cx, cx.tcx.hir().local_def_id(v.id), "a", "variant");
701690
}
702691
}
703692

Diff for: compiler/rustc_middle/src/hir/map/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1013,12 +1013,13 @@ impl<'hir> Map<'hir> {
10131013
ItemKind::Use(path, _) => path.span,
10141014
_ => named_span(item.span, item.ident, item.kind.generics()),
10151015
},
1016+
Node::Variant(variant) => named_span(variant.span, variant.ident, None),
10161017
Node::ImplItem(item) => named_span(item.span, item.ident, Some(item.generics)),
10171018
Node::ForeignItem(item) => match item.kind {
10181019
ForeignItemKind::Fn(decl, _, _) => until_within(item.span, decl.output.span()),
10191020
_ => named_span(item.span, item.ident, None),
10201021
},
1021-
Node::Ctor(..) => return self.opt_span(self.get_parent_node(hir_id)),
1022+
Node::Ctor(_) => return self.opt_span(self.get_parent_node(hir_id)),
10221023
_ => self.span_with_body(hir_id),
10231024
};
10241025
Some(span)

Diff for: compiler/rustc_middle/src/mir/syntax.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ pub struct CopyNonOverlapping<'tcx> {
396396
///////////////////////////////////////////////////////////////////////////
397397
// Terminators
398398

399+
/// The various kinds of terminators, representing ways of exiting from a basic block.
400+
///
399401
/// A note on unwinding: Panics may occur during the execution of some terminators. Depending on the
400402
/// `-C panic` flag, this may either cause the program to abort or the call stack to unwind. Such
401403
/// terminators have a `cleanup: Option<BasicBlock>` field on them. If stack unwinding occurs, then
@@ -911,7 +913,7 @@ pub enum Operand<'tcx> {
911913
static_assert_size!(Operand<'_>, 24);
912914

913915
///////////////////////////////////////////////////////////////////////////
914-
/// Rvalues
916+
// Rvalues
915917

916918
/// The various kinds of rvalues that can appear in MIR.
917919
///

Diff for: compiler/rustc_middle/src/ty/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ fn foo(&self) -> Self::T { String::new() }
795795
if item_def_id == proj_ty_item_def_id =>
796796
{
797797
Some((
798-
self.sess.source_map().guess_head_span(self.def_span(item.def_id)),
798+
self.def_span(item.def_id),
799799
format!("consider calling `{}`", self.def_path_str(item.def_id)),
800800
))
801801
}

Diff for: compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -1112,18 +1112,12 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
11121112
})
11131113
.collect::<Option<Vec<ArgKind>>>()?,
11141114
),
1115-
Node::Item(&hir::Item { span, kind: hir::ItemKind::Fn(ref sig, ..), .. })
1116-
| Node::ImplItem(&hir::ImplItem {
1117-
span,
1118-
kind: hir::ImplItemKind::Fn(ref sig, _),
1119-
..
1120-
})
1115+
Node::Item(&hir::Item { kind: hir::ItemKind::Fn(ref sig, ..), .. })
1116+
| Node::ImplItem(&hir::ImplItem { kind: hir::ImplItemKind::Fn(ref sig, _), .. })
11211117
| Node::TraitItem(&hir::TraitItem {
1122-
span,
1123-
kind: hir::TraitItemKind::Fn(ref sig, _),
1124-
..
1118+
kind: hir::TraitItemKind::Fn(ref sig, _), ..
11251119
}) => (
1126-
sm.guess_head_span(span),
1120+
sig.span,
11271121
sig.decl
11281122
.inputs
11291123
.iter()
@@ -1138,7 +1132,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
11381132
),
11391133
Node::Ctor(ref variant_data) => {
11401134
let span = variant_data.ctor_hir_id().map_or(DUMMY_SP, |id| hir.span(id));
1141-
let span = sm.guess_head_span(span);
11421135
(span, vec![ArgKind::empty(); variant_data.fields().len()])
11431136
}
11441137
_ => panic!("non-FnLike node found: {:?}", node),
@@ -2185,7 +2178,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
21852178
let mut post = vec![];
21862179
for def_id in impls {
21872180
match self.tcx.span_of_impl(*def_id) {
2188-
Ok(span) => spans.push(self.tcx.sess.source_map().guess_head_span(span)),
2181+
Ok(span) => spans.push(span),
21892182
Err(name) => {
21902183
crates.push(name);
21912184
if let Some(header) = to_pretty_impl_header(self.tcx, *def_id) {
@@ -2532,8 +2525,7 @@ pub fn recursive_type_with_infinite_size_error<'tcx>(
25322525
spans: Vec<(Span, Option<hir::HirId>)>,
25332526
) {
25342527
assert!(type_def_id.is_local());
2535-
let span = tcx.hir().span_if_local(type_def_id).unwrap();
2536-
let span = tcx.sess.source_map().guess_head_span(span);
2528+
let span = tcx.def_span(type_def_id);
25372529
let path = tcx.def_path_str(type_def_id);
25382530
let mut err =
25392531
struct_span_err!(tcx.sess, span, E0072, "recursive type `{}` has infinite size", path);

Diff for: compiler/rustc_trait_selection/src/traits/specialize/mod.rs

+5-18
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,7 @@ fn report_negative_positive_conflict(
340340
positive_impl_def_id: DefId,
341341
sg: &mut specialization_graph::Graph,
342342
) {
343-
let impl_span = tcx
344-
.sess
345-
.source_map()
346-
.guess_head_span(tcx.span_of_impl(local_impl_def_id.to_def_id()).unwrap());
343+
let impl_span = tcx.def_span(local_impl_def_id);
347344

348345
let mut err = struct_span_err!(
349346
tcx.sess,
@@ -356,10 +353,7 @@ fn report_negative_positive_conflict(
356353

357354
match tcx.span_of_impl(negative_impl_def_id) {
358355
Ok(span) => {
359-
err.span_label(
360-
tcx.sess.source_map().guess_head_span(span),
361-
"negative implementation here".to_string(),
362-
);
356+
err.span_label(span, "negative implementation here");
363357
}
364358
Err(cname) => {
365359
err.note(&format!("negative implementation in crate `{}`", cname));
@@ -368,10 +362,7 @@ fn report_negative_positive_conflict(
368362

369363
match tcx.span_of_impl(positive_impl_def_id) {
370364
Ok(span) => {
371-
err.span_label(
372-
tcx.sess.source_map().guess_head_span(span),
373-
"positive implementation here".to_string(),
374-
);
365+
err.span_label(span, "positive implementation here");
375366
}
376367
Err(cname) => {
377368
err.note(&format!("positive implementation in crate `{}`", cname));
@@ -388,8 +379,7 @@ fn report_conflicting_impls(
388379
used_to_be_allowed: Option<FutureCompatOverlapErrorKind>,
389380
sg: &mut specialization_graph::Graph,
390381
) {
391-
let impl_span =
392-
tcx.sess.source_map().guess_head_span(tcx.span_of_impl(impl_def_id.to_def_id()).unwrap());
382+
let impl_span = tcx.def_span(impl_def_id);
393383

394384
// Work to be done after we've built the DiagnosticBuilder. We have to define it
395385
// now because the struct_lint methods don't return back the DiagnosticBuilder
@@ -416,10 +406,7 @@ fn report_conflicting_impls(
416406
let mut err = err.build(&msg);
417407
match tcx.span_of_impl(overlap.with_impl) {
418408
Ok(span) => {
419-
err.span_label(
420-
tcx.sess.source_map().guess_head_span(span),
421-
"first implementation here".to_string(),
422-
);
409+
err.span_label(span, "first implementation here".to_string());
423410

424411
err.span_label(
425412
impl_span,

Diff for: compiler/rustc_typeck/src/astconv/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1958,9 +1958,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
19581958
);
19591959
}
19601960

1961-
if let Some(sp) = tcx.hir().span_if_local(adt_def.did()) {
1962-
let sp = tcx.sess.source_map().guess_head_span(sp);
1963-
err.span_label(sp, format!("variant `{}` not found here", assoc_ident));
1961+
if adt_def.did().is_local() {
1962+
err.span_label(
1963+
tcx.def_span(adt_def.did()),
1964+
format!("variant `{assoc_ident}` not found for this enum"),
1965+
);
19641966
}
19651967

19661968
err.emit()
@@ -2450,7 +2452,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
24502452

24512453
let msg = format!("`Self` is of type `{ty}`");
24522454
if let (Ok(i_sp), Some(t_sp)) = (span_of_impl, span_of_ty) {
2453-
let i_sp = tcx.sess.source_map().guess_head_span(i_sp);
24542455
let mut span: MultiSpan = vec![t_sp].into();
24552456
span.push_span_label(
24562457
i_sp,

0 commit comments

Comments
 (0)