Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 20 additions & 10 deletions
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

Lines changed: 13 additions & 11 deletions
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

Lines changed: 4 additions & 7 deletions
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

Lines changed: 2 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
 (0)