Skip to content

Commit f23a80a

Browse files
committed
Auto merge of rust-lang#134414 - jhpratt:rollup-4gtfd1h, r=jhpratt
Rollup of 10 pull requests Successful merges: - rust-lang#134202 (Remove `rustc::existing_doc_keyword` lint) - rust-lang#134354 (Handle fndef rendering together with signature rendering) - rust-lang#134365 (Rename `rustc_mir_build::build` to `builder`) - rust-lang#134368 (Use links to edition guide for edition migrations) - rust-lang#134397 (rustc_borrowck: Suggest changing `&raw const` to `&raw mut` if applicable) - rust-lang#134398 (AIX: add alignment info for test) - rust-lang#134400 (Fix some comments related to upvars handling) - rust-lang#134406 (Fix `-Z input-stats` ordering) - rust-lang#134409 (bootstrap: fix a comment) - rust-lang#134412 (small borrowck cleanup) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 604d669 + cdd71c9 commit f23a80a

File tree

121 files changed

+571
-621
lines changed

Some content is hidden

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

121 files changed

+571
-621
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -4275,7 +4275,6 @@ dependencies = [
42754275
"rustc_fluent_macro",
42764276
"rustc_hir",
42774277
"rustc_index",
4278-
"rustc_lexer",
42794278
"rustc_macros",
42804279
"rustc_middle",
42814280
"rustc_privacy",

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+20-10
Original file line numberDiff line numberDiff line change
@@ -1474,16 +1474,27 @@ fn suggest_ampmut<'tcx>(
14741474
// let x: &i32 = &'a 5;
14751475
// ^^ lifetime annotation not allowed
14761476
//
1477-
if let Some(assignment_rhs_span) = opt_assignment_rhs_span
1478-
&& let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span)
1479-
&& let Some(stripped) = src.strip_prefix('&')
1477+
if let Some(rhs_span) = opt_assignment_rhs_span
1478+
&& let Ok(rhs_str) = tcx.sess.source_map().span_to_snippet(rhs_span)
1479+
&& let Some(rhs_str_no_amp) = rhs_str.strip_prefix('&')
14801480
{
1481-
let is_raw_ref = stripped.trim_start().starts_with("raw ");
1482-
// We don't support raw refs yet
1483-
if is_raw_ref {
1484-
return None;
1481+
// Suggest changing `&raw const` to `&raw mut` if applicable.
1482+
if rhs_str_no_amp.trim_start().strip_prefix("raw const").is_some() {
1483+
let const_idx = rhs_str.find("const").unwrap() as u32;
1484+
let const_span = rhs_span
1485+
.with_lo(rhs_span.lo() + BytePos(const_idx))
1486+
.with_hi(rhs_span.lo() + BytePos(const_idx + "const".len() as u32));
1487+
1488+
return Some(AmpMutSugg {
1489+
has_sugg: true,
1490+
span: const_span,
1491+
suggestion: "mut".to_owned(),
1492+
additional: None,
1493+
});
14851494
}
1486-
let is_mut = if let Some(rest) = stripped.trim_start().strip_prefix("mut") {
1495+
1496+
// Figure out if rhs already is `&mut`.
1497+
let is_mut = if let Some(rest) = rhs_str_no_amp.trim_start().strip_prefix("mut") {
14871498
match rest.chars().next() {
14881499
// e.g. `&mut x`
14891500
Some(c) if c.is_whitespace() => true,
@@ -1500,9 +1511,8 @@ fn suggest_ampmut<'tcx>(
15001511
// if the reference is already mutable then there is nothing we can do
15011512
// here.
15021513
if !is_mut {
1503-
let span = assignment_rhs_span;
15041514
// shrink the span to just after the `&` in `&variable`
1505-
let span = span.with_lo(span.lo() + BytePos(1)).shrink_to_lo();
1515+
let span = rhs_span.with_lo(rhs_span.lo() + BytePos(1)).shrink_to_lo();
15061516

15071517
// FIXME(Ezrashaw): returning is bad because we still might want to
15081518
// update the annotated type, see #106857.

compiler/rustc_borrowck/src/diagnostics/region_errors.rs

+13-11
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
848848
return;
849849
};
850850

851-
let fn_returns = self.infcx.tcx.return_type_impl_or_dyn_traits(suitable_region.def_id);
851+
let fn_returns = self.infcx.tcx.return_type_impl_or_dyn_traits(suitable_region.scope);
852852

853853
let param = if let Some(param) =
854854
find_param_with_region(self.infcx.tcx, self.mir_def_id(), f, outlived_f)
@@ -875,15 +875,15 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
875875
Some(arg),
876876
captures,
877877
Some((param.param_ty_span, param.param_ty.to_string())),
878-
Some(suitable_region.def_id),
878+
Some(suitable_region.scope),
879879
);
880880
return;
881881
}
882882

883883
let Some((alias_tys, alias_span, lt_addition_span)) = self
884884
.infcx
885885
.tcx
886-
.return_type_impl_or_dyn_traits_with_type_alias(suitable_region.def_id)
886+
.return_type_impl_or_dyn_traits_with_type_alias(suitable_region.scope)
887887
else {
888888
return;
889889
};
@@ -1018,18 +1018,20 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
10181018
return;
10191019
};
10201020

1021-
let Some((ty_sub, _)) =
1022-
self.infcx.tcx.is_suitable_region(self.mir_def_id(), sub).and_then(|anon_reg| {
1023-
find_anon_type(self.infcx.tcx, self.mir_def_id(), sub, &anon_reg.bound_region)
1024-
})
1021+
let Some((ty_sub, _)) = self
1022+
.infcx
1023+
.tcx
1024+
.is_suitable_region(self.mir_def_id(), sub)
1025+
.and_then(|_| find_anon_type(self.infcx.tcx, self.mir_def_id(), sub))
10251026
else {
10261027
return;
10271028
};
10281029

1029-
let Some((ty_sup, _)) =
1030-
self.infcx.tcx.is_suitable_region(self.mir_def_id(), sup).and_then(|anon_reg| {
1031-
find_anon_type(self.infcx.tcx, self.mir_def_id(), sup, &anon_reg.bound_region)
1032-
})
1030+
let Some((ty_sup, _)) = self
1031+
.infcx
1032+
.tcx
1033+
.is_suitable_region(self.mir_def_id(), sup)
1034+
.and_then(|_| find_anon_type(self.infcx.tcx, self.mir_def_id(), sup))
10331035
else {
10341036
return;
10351037
};

compiler/rustc_borrowck/src/lib.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ fn do_mir_borrowck<'tcx>(
141141
) -> (BorrowCheckResult<'tcx>, Option<Box<BodyWithBorrowckFacts<'tcx>>>) {
142142
let def = input_body.source.def_id().expect_local();
143143
let infcx = BorrowckInferCtxt::new(tcx, def);
144+
if let Some(e) = input_body.tainted_by_errors {
145+
infcx.set_tainted_by_errors(e);
146+
}
144147

145148
let mut local_names = IndexVec::from_elem(None, &input_body.local_decls);
146149
for var_debug_info in &input_body.var_debug_info {
@@ -162,13 +165,6 @@ fn do_mir_borrowck<'tcx>(
162165
}
163166
}
164167

165-
let diags = &mut diags::BorrowckDiags::new();
166-
167-
// Gather the upvars of a closure, if any.
168-
if let Some(e) = input_body.tainted_by_errors {
169-
infcx.set_tainted_by_errors(e);
170-
}
171-
172168
// Replace all regions with fresh inference variables. This
173169
// requires first making our own copy of the MIR. This copy will
174170
// be modified (in place) to contain non-lexical lifetimes. It
@@ -224,6 +220,7 @@ fn do_mir_borrowck<'tcx>(
224220

225221
// We also have a `#[rustc_regions]` annotation that causes us to dump
226222
// information.
223+
let diags = &mut diags::BorrowckDiags::new();
227224
nll::dump_annotation(&infcx, body, &regioncx, &opt_closure_req, &opaque_type_values, diags);
228225

229226
let movable_coroutine =

compiler/rustc_hir_typeck/src/upvar.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//! to everything owned by `x`, so the result is the same for something
1515
//! like `x.f = 5` and so on (presuming `x` is not a borrowed pointer to a
1616
//! struct). These adjustments are performed in
17-
//! `adjust_upvar_borrow_kind()` (you can trace backwards through the code
17+
//! `adjust_for_non_move_closure` (you can trace backwards through the code
1818
//! from there).
1919
//!
2020
//! The fact that we are inferring borrow kinds as we go results in a
@@ -1684,8 +1684,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16841684
// want to capture by ref to allow precise capture using reborrows.
16851685
//
16861686
// If the data will be moved out of this place, then the place will be truncated
1687-
// at the first Deref in `adjust_upvar_borrow_kind_for_consume` and then moved into
1688-
// the closure.
1687+
// at the first Deref in `adjust_for_move_closure` and then moved into the closure.
16891688
hir::CaptureBy::Value { .. } if !place.deref_tys().any(Ty::is_ref) => {
16901689
ty::UpvarCapture::ByValue
16911690
}

compiler/rustc_infer/src/infer/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -689,15 +689,15 @@ impl<'tcx> InferCtxt<'tcx> {
689689
/// Require that the region `r` be equal to one of the regions in
690690
/// the set `regions`.
691691
#[instrument(skip(self), level = "debug")]
692-
pub fn member_constraint(
692+
pub fn add_member_constraint(
693693
&self,
694694
key: ty::OpaqueTypeKey<'tcx>,
695695
definition_span: Span,
696696
hidden_ty: Ty<'tcx>,
697697
region: ty::Region<'tcx>,
698698
in_regions: Lrc<Vec<ty::Region<'tcx>>>,
699699
) {
700-
self.inner.borrow_mut().unwrap_region_constraints().member_constraint(
700+
self.inner.borrow_mut().unwrap_region_constraints().add_member_constraint(
701701
key,
702702
definition_span,
703703
hidden_ty,

compiler/rustc_infer/src/infer/opaque_types/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl<'tcx> InferCtxt<'tcx> {
364364
concrete_ty.visit_with(&mut ConstrainOpaqueTypeRegionVisitor {
365365
tcx: self.tcx,
366366
op: |r| {
367-
self.member_constraint(
367+
self.add_member_constraint(
368368
opaque_type_key,
369369
span,
370370
concrete_ty,

compiler/rustc_infer/src/infer/region_constraints/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ impl<'tcx> RegionConstraintCollector<'_, 'tcx> {
466466
}
467467
}
468468

469-
pub(super) fn member_constraint(
469+
pub(super) fn add_member_constraint(
470470
&mut self,
471471
key: ty::OpaqueTypeKey<'tcx>,
472472
definition_span: Span,

compiler/rustc_lint/messages.ftl

-3
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,6 @@ lint_non_camel_case_type = {$sort} `{$name}` should have an upper camel case nam
536536
.suggestion = convert the identifier to upper camel case
537537
.label = should have an UpperCamelCase name
538538
539-
lint_non_existent_doc_keyword = found non-existing keyword `{$keyword}` used in `#[doc(keyword = "...")]`
540-
.help = only existing keywords are allowed in core/std
541-
542539
lint_non_fmt_panic = panic message is not a string literal
543540
.note = this usage of `{$name}!()` is deprecated; it will be a hard error in Rust 2021
544541
.more_info_note = for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>

compiler/rustc_lint/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,7 @@ declare_lint! {
18141814
"detects edition keywords being used as an identifier",
18151815
@future_incompatible = FutureIncompatibleInfo {
18161816
reason: FutureIncompatibilityReason::EditionError(Edition::Edition2024),
1817-
reference: "issue #49716 <https://github.com/rust-lang/rust/issues/49716>",
1817+
reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/gen-keyword.html>",
18181818
};
18191819
}
18201820

compiler/rustc_lint/src/if_let_rescope.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ declare_lint! {
8484
rewriting in `match` is an option to preserve the semantics up to Edition 2021",
8585
@future_incompatible = FutureIncompatibleInfo {
8686
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024),
87-
reference: "issue #124085 <https://github.com/rust-lang/rust/issues/124085>",
87+
reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html>",
8888
};
8989
}
9090

compiler/rustc_lint/src/internal.rs

+2-42
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use rustc_middle::ty::{self, GenericArgsRef, Ty as MiddleTy};
1212
use rustc_session::{declare_lint_pass, declare_tool_lint};
1313
use rustc_span::Span;
1414
use rustc_span::hygiene::{ExpnKind, MacroKind};
15-
use rustc_span::symbol::{Symbol, kw, sym};
15+
use rustc_span::symbol::sym;
1616
use tracing::debug;
1717

1818
use crate::lints::{
19-
BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand, NonExistentDocKeyword,
19+
BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand,
2020
NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked, SpanUseEqCtxtDiag,
2121
SymbolInternStringLiteralDiag, TyQualified, TykindDiag, TykindKind, TypeIrInherentUsage,
2222
UntranslatableDiag,
@@ -375,46 +375,6 @@ impl EarlyLintPass for LintPassImpl {
375375
}
376376
}
377377

378-
declare_tool_lint! {
379-
/// The `existing_doc_keyword` lint detects use `#[doc()]` keywords
380-
/// that don't exist, e.g. `#[doc(keyword = "..")]`.
381-
pub rustc::EXISTING_DOC_KEYWORD,
382-
Allow,
383-
"Check that documented keywords in std and core actually exist",
384-
report_in_external_macro: true
385-
}
386-
387-
declare_lint_pass!(ExistingDocKeyword => [EXISTING_DOC_KEYWORD]);
388-
389-
fn is_doc_keyword(s: Symbol) -> bool {
390-
s <= kw::Union
391-
}
392-
393-
impl<'tcx> LateLintPass<'tcx> for ExistingDocKeyword {
394-
fn check_item(&mut self, cx: &LateContext<'_>, item: &rustc_hir::Item<'_>) {
395-
for attr in cx.tcx.hir().attrs(item.hir_id()) {
396-
if !attr.has_name(sym::doc) {
397-
continue;
398-
}
399-
if let Some(list) = attr.meta_item_list() {
400-
for nested in list {
401-
if nested.has_name(sym::keyword) {
402-
let keyword = nested
403-
.value_str()
404-
.expect("#[doc(keyword = \"...\")] expected a value!");
405-
if is_doc_keyword(keyword) {
406-
return;
407-
}
408-
cx.emit_span_lint(EXISTING_DOC_KEYWORD, attr.span, NonExistentDocKeyword {
409-
keyword,
410-
});
411-
}
412-
}
413-
}
414-
}
415-
}
416-
}
417-
418378
declare_tool_lint! {
419379
/// The `untranslatable_diagnostic` lint detects messages passed to functions with `impl
420380
/// Into<{D,Subd}iagMessage` parameters without using translatable Fluent strings.

compiler/rustc_lint/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -600,8 +600,6 @@ fn register_internals(store: &mut LintStore) {
600600
store.register_late_mod_pass(|_| Box::new(DefaultHashTypes));
601601
store.register_lints(&QueryStability::lint_vec());
602602
store.register_late_mod_pass(|_| Box::new(QueryStability));
603-
store.register_lints(&ExistingDocKeyword::lint_vec());
604-
store.register_late_mod_pass(|_| Box::new(ExistingDocKeyword));
605603
store.register_lints(&TyTyKind::lint_vec());
606604
store.register_late_mod_pass(|_| Box::new(TyTyKind));
607605
store.register_lints(&TypeIr::lint_vec());
@@ -629,7 +627,6 @@ fn register_internals(store: &mut LintStore) {
629627
LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO),
630628
LintId::of(USAGE_OF_QUALIFIED_TY),
631629
LintId::of(NON_GLOB_IMPORT_OF_TYPE_IR_INHERENT),
632-
LintId::of(EXISTING_DOC_KEYWORD),
633630
LintId::of(BAD_OPT_ACCESS),
634631
LintId::of(SPAN_USE_EQ_CTXT),
635632
]);

compiler/rustc_lint/src/lints.rs

-7
Original file line numberDiff line numberDiff line change
@@ -950,13 +950,6 @@ pub(crate) struct NonGlobImportTypeIrInherent {
950950
#[help]
951951
pub(crate) struct LintPassByHand;
952952

953-
#[derive(LintDiagnostic)]
954-
#[diag(lint_non_existent_doc_keyword)]
955-
#[help]
956-
pub(crate) struct NonExistentDocKeyword {
957-
pub keyword: Symbol,
958-
}
959-
960953
#[derive(LintDiagnostic)]
961954
#[diag(lint_diag_out_of_impl)]
962955
pub(crate) struct DiagOutOfImpl;

compiler/rustc_lint/src/shadowed_into_iter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ declare_lint! {
6161
"detects calling `into_iter` on boxed slices in Rust 2015, 2018, and 2021",
6262
@future_incompatible = FutureIncompatibleInfo {
6363
reason: FutureIncompatibilityReason::EditionSemanticsChange(Edition::Edition2024),
64+
reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/intoiterator-box-slice.html>"
6465
};
6566
}
6667

0 commit comments

Comments
 (0)