Skip to content

Commit 468f115

Browse files
committed
Auto merge of rust-lang#124026 - matthiaskrgr:rollup-an6s6gq, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#122632 (fetch submodule before checking llvm stamp) - rust-lang#123355 (Support type '/' to search) - rust-lang#123501 (Stabilize checking of cfgs at compile-time: `--check-cfg` option) - rust-lang#123535 (Match ergonomics 2024: `mut` doesn't reset binding mode) - rust-lang#123711 (drop `changelog-seen`) - rust-lang#123969 (The new solver ignores `DefineOpaqueTypes`, so switch it to `Yes`) - rust-lang#124007 (Miri subtree update) - rust-lang#124017 (Change a diagnostics-path-only `DefineOpaqueTypes` to `Yes`.) - rust-lang#124018 (interpret: pass MemoryKind to before_memory_deallocation) - rust-lang#124024 (interpret: remove outdated comment) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1dea922 + 4971d9f commit 468f115

File tree

125 files changed

+819
-423
lines changed

Some content is hidden

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

125 files changed

+819
-423
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3364,9 +3364,9 @@ dependencies = [
33643364

33653365
[[package]]
33663366
name = "rustc-build-sysroot"
3367-
version = "0.4.5"
3367+
version = "0.4.6"
33683368
source = "registry+https://github.com/rust-lang/crates.io-index"
3369-
checksum = "a26170e1d79ea32f7ccec3188dd13cfc1f18c82764a9cbc1071667c0f865a4ea"
3369+
checksum = "a9bf37423495cd3a6a9ef8c75fc4566de0d26de0ab75f36f67a426e58df5768c"
33703370
dependencies = [
33713371
"anyhow",
33723372
"rustc_version",

compiler/rustc_const_eval/src/interpret/machine.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,6 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
347347
/// allocation (because a copy had to be done to adjust things), machine memory will
348348
/// cache the result. (This relies on `AllocMap::get_or` being able to add the
349349
/// owned allocation to the map even when the map is shared.)
350-
///
351-
/// This must only fail if `alloc` contains provenance.
352350
fn adjust_allocation<'b>(
353351
ecx: &InterpCx<'mir, 'tcx, Self>,
354352
id: AllocId,
@@ -427,6 +425,7 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
427425
_prov: (AllocId, Self::ProvenanceExtra),
428426
_size: Size,
429427
_align: Align,
428+
_kind: MemoryKind<Self::MemoryKind>,
430429
) -> InterpResult<'tcx> {
431430
Ok(())
432431
}

compiler/rustc_const_eval/src/interpret/memory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
227227
self.allocate_raw_ptr(alloc, kind)
228228
}
229229

230-
/// This can fail only if `alloc` contains provenance.
231230
pub fn allocate_raw_ptr(
232231
&mut self,
233232
alloc: Allocation,
@@ -355,6 +354,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
355354
(alloc_id, prov),
356355
size,
357356
alloc.align,
357+
kind,
358358
)?;
359359

360360
// Don't forget to remember size and align of this now-dead allocation

compiler/rustc_feature/src/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,8 @@ declare_features! (
533533
(unstable, more_qualified_paths, "1.54.0", Some(86935)),
534534
/// Allows the `#[must_not_suspend]` attribute.
535535
(unstable, must_not_suspend, "1.57.0", Some(83310)),
536+
/// Make `mut` not reset the binding mode on edition >= 2024.
537+
(incomplete, mut_preserve_binding_mode_2024, "CURRENT_RUSTC_VERSION", Some(123076)),
536538
/// Allows `mut ref` and `mut ref mut` identifier patterns.
537539
(incomplete, mut_ref, "CURRENT_RUSTC_VERSION", Some(123076)),
538540
/// Allows using `#[naked]` on functions.

compiler/rustc_hir_typeck/messages.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ hir_typeck_ctor_is_private = tuple struct constructor `{$def}` is private
4646
4747
hir_typeck_deref_is_empty = this expression `Deref`s to `{$deref_ty}` which implements `is_empty`
4848
49+
hir_typeck_dereferencing_mut_binding = dereferencing `mut` binding
50+
.label = `mut` dereferences the type of this binding
51+
.help = this will change in edition 2024
52+
4953
hir_typeck_expected_default_return_type = expected `()` because of default return type
5054
5155
hir_typeck_expected_return_type = expected `{$expected}` because of return type

compiler/rustc_hir_typeck/src/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,3 +632,11 @@ pub enum SuggestBoxingForReturnImplTrait {
632632
ends: Vec<Span>,
633633
},
634634
}
635+
636+
#[derive(LintDiagnostic)]
637+
#[diag(hir_typeck_dereferencing_mut_binding)]
638+
pub struct DereferencingMutBinding {
639+
#[label]
640+
#[help]
641+
pub span: Span,
642+
}

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
16961696
if let ProbeResult::Match = result
16971697
&& self
16981698
.at(&ObligationCause::dummy(), self.param_env)
1699-
.sup(DefineOpaqueTypes::No, return_ty, xform_ret_ty)
1699+
.sup(DefineOpaqueTypes::Yes, return_ty, xform_ret_ty)
17001700
.is_err()
17011701
{
17021702
result = ProbeResult::BadReturnType;

compiler/rustc_hir_typeck/src/pat.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_hir::pat_util::EnumerateAndAdjustIterator;
1010
use rustc_hir::{self as hir, BindingAnnotation, ByRef, HirId, Mutability, Pat, PatKind};
1111
use rustc_infer::infer;
1212
use rustc_infer::infer::type_variable::TypeVariableOrigin;
13+
use rustc_lint as lint;
1314
use rustc_middle::mir::interpret::ErrorHandled;
1415
use rustc_middle::ty::{self, Adt, Ty, TypeVisitableExt};
1516
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
@@ -629,12 +630,26 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
629630
expected: Ty<'tcx>,
630631
pat_info: PatInfo<'tcx, '_>,
631632
) -> Ty<'tcx> {
632-
let PatInfo { binding_mode: def_bm, top_info: ti, .. } = pat_info;
633+
let PatInfo { binding_mode: BindingAnnotation(def_br, _), top_info: ti, .. } = pat_info;
633634

634635
// Determine the binding mode...
635636
let bm = match ba {
636-
BindingAnnotation(ByRef::No, Mutability::Not) => def_bm,
637-
_ => ba,
637+
BindingAnnotation(ByRef::No, Mutability::Mut)
638+
if !(pat.span.at_least_rust_2024()
639+
&& self.tcx.features().mut_preserve_binding_mode_2024)
640+
&& matches!(def_br, ByRef::Yes(_)) =>
641+
{
642+
// `mut x` resets the binding mode in edition <= 2021.
643+
self.tcx.emit_node_span_lint(
644+
lint::builtin::DEREFERENCING_MUT_BINDING,
645+
pat.hir_id,
646+
pat.span,
647+
errors::DereferencingMutBinding { span: pat.span },
648+
);
649+
BindingAnnotation(ByRef::No, Mutability::Mut)
650+
}
651+
BindingAnnotation(ByRef::No, mutbl) => BindingAnnotation(def_br, mutbl),
652+
BindingAnnotation(ByRef::Yes(_), _) => ba,
638653
};
639654
// ...and store it in a side table:
640655
self.typeck_results.borrow_mut().pat_binding_modes_mut().insert(pat.hir_id, bm);
@@ -743,7 +758,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
743758
}
744759
}
745760

746-
// Precondition: pat is a Ref(_) pattern
761+
/// Precondition: pat is a `Ref(_)` pattern
747762
fn borrow_pat_suggestion(&self, err: &mut Diag<'_>, pat: &Pat<'_>) {
748763
let tcx = self.tcx;
749764
if let PatKind::Ref(inner, mutbl) = pat.kind

compiler/rustc_infer/src/infer/at.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl<'a, 'tcx> Trace<'a, 'tcx> {
282282
{
283283
let Trace { at, trace } = self;
284284
debug_assert!(at.infcx.next_trait_solver());
285-
let mut fields = at.infcx.combine_fields(trace, at.param_env, DefineOpaqueTypes::No);
285+
let mut fields = at.infcx.combine_fields(trace, at.param_env, DefineOpaqueTypes::Yes);
286286
fields
287287
.equate(StructurallyRelateAliases::Yes)
288288
.relate(a, b)

compiler/rustc_lint/src/context/diagnostics/check_cfg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ pub(super) fn unexpected_cfg_name(
168168
diag.note("see <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#check-cfg> for more information about checking conditional configuration");
169169
} else {
170170
diag.help(format!("to expect this configuration use `--check-cfg={inst}`"));
171-
diag.note("see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration");
171+
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration");
172172
}
173173
}
174174

@@ -272,6 +272,6 @@ pub(super) fn unexpected_cfg_value(
272272
if !is_cfg_a_well_know_name {
273273
diag.help(format!("to expect this configuration use `--check-cfg={inst}`"));
274274
}
275-
diag.note("see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration");
275+
diag.note("see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration");
276276
}
277277
}

0 commit comments

Comments
 (0)