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

Commit 3198c52

Browse files
committed
Auto merge of rust-lang#86226 - JohnTitor:rollup-5ubdolf, r=JohnTitor
Rollup of 7 pull requests Successful merges: - rust-lang#85800 (Fix some diagnostic issues with const_generics_defaults feature gate) - rust-lang#85823 (Do not suggest ampmut if rhs is already mutable) - rust-lang#86153 (Print dummy spans as `no-location`) - rust-lang#86174 (Detect incorrect vtable alignment during const eval) - rust-lang#86189 (Make `relate_type_and_mut` public) - rust-lang#86205 (Run full const-generics test for issue-72293) - rust-lang#86217 (Remove "generic type" in boxed.rs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0a8629b + e13b53e commit 3198c52

24 files changed

+152
-41
lines changed

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -938,8 +938,11 @@ fn validate_generic_param_order(
938938
}
939939
GenericParamKind::Type { default: None } => (),
940940
GenericParamKind::Lifetime => (),
941-
// FIXME(const_generics_defaults)
942-
GenericParamKind::Const { ty: _, kw_span: _, default: _ } => (),
941+
GenericParamKind::Const { ty: _, kw_span: _, default: Some(default) } => {
942+
ordered_params += " = ";
943+
ordered_params += &pprust::expr_to_string(&*default.value);
944+
}
945+
GenericParamKind::Const { ty: _, kw_span: _, default: None } => (),
943946
}
944947
first = false;
945948
}
@@ -959,7 +962,7 @@ fn validate_generic_param_order(
959962
span,
960963
&format!(
961964
"reorder the parameters: lifetimes, {}",
962-
if sess.features_untracked().const_generics {
965+
if sess.features_untracked().unordered_const_ty_params() {
963966
"then consts and types"
964967
} else {
965968
"then types, then consts"

compiler/rustc_middle/src/ty/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'tcx> TyS<'tcx> {
5454
/// ADTs with no type arguments.
5555
pub fn is_simple_text(&self) -> bool {
5656
match self.kind() {
57-
Adt(_, substs) => substs.types().next().is_none(),
57+
Adt(_, substs) => substs.non_erasable_generics().next().is_none(),
5858
Ref(_, ty, _) => ty.is_simple_text(),
5959
_ => self.is_simple_ty(),
6060
}

compiler/rustc_middle/src/ty/relate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ pub trait Relate<'tcx>: TypeFoldable<'tcx> + Copy {
112112
///////////////////////////////////////////////////////////////////////////
113113
// Relate impls
114114

115-
fn relate_type_and_mut<'tcx, R: TypeRelation<'tcx>>(
115+
pub fn relate_type_and_mut<'tcx, R: TypeRelation<'tcx>>(
116116
relation: &mut R,
117117
a: ty::TypeAndMut<'tcx>,
118118
b: ty::TypeAndMut<'tcx>,

compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,9 +902,13 @@ fn suggest_ampmut<'tcx>(
902902
{
903903
let lt_name = &src[1..ws_pos];
904904
let ty = &src[ws_pos..];
905-
return (assignment_rhs_span, format!("&{} mut {}", lt_name, ty));
905+
if !ty.trim_start().starts_with("mut") {
906+
return (assignment_rhs_span, format!("&{} mut {}", lt_name, ty));
907+
}
906908
} else if let Some(stripped) = src.strip_prefix('&') {
907-
return (assignment_rhs_span, format!("&mut {}", stripped));
909+
if !stripped.trim_start().starts_with("mut") {
910+
return (assignment_rhs_span, format!("&mut {}", stripped));
911+
}
908912
}
909913
}
910914
}

compiler/rustc_mir/src/interpret/traits.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,15 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
158158
let size = u64::try_from(self.force_bits(size, pointer_size)?).unwrap();
159159
let align = vtable.read_ptr_sized(pointer_size * 2)?.check_init()?;
160160
let align = u64::try_from(self.force_bits(align, pointer_size)?).unwrap();
161+
let align = Align::from_bytes(align)
162+
.map_err(|e| err_ub_format!("invalid vtable: alignment {}", e))?;
161163

162164
if size >= self.tcx.data_layout.obj_size_bound() {
163165
throw_ub_format!(
164166
"invalid vtable: \
165167
size is bigger than largest supported object"
166168
);
167169
}
168-
Ok((Size::from_bytes(size), Align::from_bytes(align).unwrap()))
170+
Ok((Size::from_bytes(size), align))
169171
}
170172
}

compiler/rustc_span/src/source_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ impl SourceMap {
407407
}
408408

409409
fn span_to_string(&self, sp: Span, prefer_local: bool) -> String {
410-
if self.files.borrow().source_files.is_empty() && sp.is_dummy() {
410+
if self.files.borrow().source_files.is_empty() || sp.is_dummy() {
411411
return "no-location".to_string();
412412
}
413413

library/alloc/src/boxed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ impl<T: ?Sized + Hasher, A: Allocator> Hasher for Box<T, A> {
12091209
#[cfg(not(no_global_oom_handling))]
12101210
#[stable(feature = "from_for_ptrs", since = "1.6.0")]
12111211
impl<T> From<T> for Box<T> {
1212-
/// Converts a generic type `T` into a `Box<T>`
1212+
/// Converts a `T` into a `Box<T>`
12131213
///
12141214
/// The conversion allocates on the heap and moves `t`
12151215
/// from the stack into it.

src/test/mir-opt/generator_storage_dead_unwind.main-{closure#0}.StateTransform.before.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ yields ()
8585
bb8 (cleanup): {
8686
StorageDead(_10); // scope 2 at $DIR/generator-storage-dead-unwind.rs:27:15: 27:16
8787
StorageDead(_9); // scope 2 at $DIR/generator-storage-dead-unwind.rs:27:16: 27:17
88-
goto -> bb10; // scope 2 at $DIR/generator-storage-dead-unwind.rs:1:1: 1:1
88+
goto -> bb10; // scope 2 at no-location
8989
}
9090

9191
bb9 (cleanup): {
9292
StorageDead(_8); // scope 2 at $DIR/generator-storage-dead-unwind.rs:26:15: 26:16
9393
StorageDead(_7); // scope 2 at $DIR/generator-storage-dead-unwind.rs:26:16: 26:17
94-
goto -> bb10; // scope 2 at $DIR/generator-storage-dead-unwind.rs:1:1: 1:1
94+
goto -> bb10; // scope 2 at no-location
9595
}
9696

9797
bb10 (cleanup): {

src/test/mir-opt/loop_test.main.SimplifyCfg-promote-consts.after.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn main() -> () {
4343
_6 = const 1_i32; // scope 0 at $DIR/loop_test.rs:14:17: 14:18
4444
FakeRead(ForLet(None), _6); // scope 0 at $DIR/loop_test.rs:14:13: 14:14
4545
StorageDead(_6); // scope 0 at $DIR/loop_test.rs:16:5: 16:6
46-
goto -> bb3; // scope 0 at $DIR/loop_test.rs:1:1: 1:1
46+
goto -> bb3; // scope 0 at no-location
4747
}
4848

4949
bb5 (cleanup): {

src/test/mir-opt/match_arm_scopes.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494
_0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:15:59: 15:60
9595
StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
9696
StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
97-
- goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:1:1: 1:1
98-
+ goto -> bb20; // scope 0 at $DIR/match-arm-scopes.rs:1:1: 1:1
97+
- goto -> bb23; // scope 0 at no-location
98+
+ goto -> bb20; // scope 0 at no-location
9999
}
100100

101101
- bb10: {
@@ -150,8 +150,8 @@
150150
_0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:15:59: 15:60
151151
StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73
152152
StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78
153-
- goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:1:1: 1:1
154-
+ goto -> bb20; // scope 0 at $DIR/match-arm-scopes.rs:1:1: 1:1
153+
- goto -> bb23; // scope 0 at no-location
154+
+ goto -> bb20; // scope 0 at no-location
155155
}
156156

157157
- bb15: {

0 commit comments

Comments
 (0)