Skip to content

Commit 9822e3d

Browse files
committed
Auto merge of #142492 - matthiaskrgr:rollup-a132ytq, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #140593 (Temporary lifetime extension through tuple struct and tuple variant constructors) - #141399 ([rustdoc] Give more information into extracted doctest information) - #141493 (Delegate `<SocketAddr as Debug>` to `ByteStr`) - #141811 (Unimplement unsized_locals) - #142243 (float tests: deduplicate min, max, and rounding tests) - #142464 (variadic functions: remove list of supported ABIs from error) - #142477 (Fix incorrect suggestion when calling an associated type with a type anchor) - #142484 (Remove unneeded lifetime bound from signature of BTreeSet::extract_if) - #142489 (Update the `compiler-builtins` subtree) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 64033a4 + fd1f479 commit 9822e3d

File tree

158 files changed

+1821
-1903
lines changed

Some content is hidden

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

158 files changed

+1821
-1903
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,8 +373,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
373373
}
374374

375375
fn unsized_feature_enabled(&self) -> bool {
376-
let features = self.tcx().features();
377-
features.unsized_locals() || features.unsized_fn_params()
376+
self.tcx().features().unsized_fn_params()
378377
}
379378

380379
/// Equate the inferred type and the annotated type for user type annotations
@@ -957,7 +956,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
957956
}
958957
}
959958

960-
// When `unsized_fn_params` or `unsized_locals` is enabled, only function calls
959+
// When `unsized_fn_params` is enabled, only function calls
961960
// and nullary ops are checked in `check_call_dest`.
962961
if !self.unsized_feature_enabled() {
963962
match self.body.local_kind(local) {
@@ -1941,7 +1940,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19411940
);
19421941
}
19431942

1944-
// When `unsized_fn_params` and `unsized_locals` are both not enabled,
1943+
// When `unsized_fn_params` is not enabled,
19451944
// this check is done at `check_local`.
19461945
if self.unsized_feature_enabled() {
19471946
let span = term.source_info.span;

compiler/rustc_codegen_cranelift/example/arbitrary_self_types_pointers_and_wrappers.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ impl<T: CoerceUnsized<U>, U> CoerceUnsized<Wrapper<U>> for Wrapper<T> {}
3232
impl<T: DispatchFromDyn<U>, U> DispatchFromDyn<Wrapper<U>> for Wrapper<T> {}
3333

3434
trait Trait {
35-
// This method isn't object-safe yet. Unsized by-value `self` is object-safe (but not callable
36-
// without unsized_locals), but wrappers around `Self` currently are not.
37-
// FIXME (mikeyhew) uncomment this when unsized rvalues object-safety is implemented
38-
// fn wrapper(self: Wrapper<Self>) -> i32;
3935
fn ptr_wrapper(self: Ptr<Wrapper<Self>>) -> i32;
4036
fn wrapper_ptr(self: Wrapper<Ptr<Self>>) -> i32;
4137
fn wrapper_ptr_wrapper(self: Wrapper<Ptr<Wrapper<Self>>>) -> i32;

compiler/rustc_codegen_gcc/example/arbitrary_self_types_pointers_and_wrappers.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ impl<T: DispatchFromDyn<U>, U> DispatchFromDyn<Wrapper<U>> for Wrapper<T> {}
3737

3838

3939
trait Trait {
40-
// This method isn't object-safe yet. Unsized by-value `self` is object-safe (but not callable
41-
// without unsized_locals), but wrappers around `Self` currently are not.
42-
// FIXME (mikeyhew) uncomment this when unsized rvalues object-safety is implemented
43-
// fn wrapper(self: Wrapper<Self>) -> i32;
4440
fn ptr_wrapper(self: Ptr<Wrapper<Self>>) -> i32;
4541
fn wrapper_ptr(self: Wrapper<Ptr<Self>>) -> i32;
4642
fn wrapper_ptr_wrapper(self: Wrapper<Ptr<Wrapper<Self>>>) -> i32;

compiler/rustc_feature/src/removed.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ declare_features! (
263263
/// Allows unnamed fields of struct and union type
264264
(removed, unnamed_fields, "1.83.0", Some(49804), Some("feature needs redesign"), 131045),
265265
(removed, unsafe_no_drop_flag, "1.0.0", None, None),
266+
/// Allows unsized rvalues at arguments and parameters.
267+
(removed, unsized_locals, "CURRENT_RUSTC_VERSION", Some(48055), Some("removed due to implementation concerns; see https://github.com/rust-lang/rust/issues/111942")),
266268
(removed, unsized_tuple_coercion, "1.87.0", Some(42877),
267269
Some("The feature restricts possible layouts for tuples, and this restriction is not worth it."), 137728),
268270
/// Allows `union` fields that don't implement `Copy` as long as they don't have any drop glue.

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,6 @@ declare_features! (
667667
(incomplete, unsized_const_params, "1.82.0", Some(95174)),
668668
/// Allows unsized fn parameters.
669669
(internal, unsized_fn_params, "1.49.0", Some(48055)),
670-
/// Allows unsized rvalues at arguments and parameters.
671-
(incomplete, unsized_locals, "1.30.0", Some(48055)),
672670
/// Allows using the `#[used(linker)]` (or `#[used(compiler)]`) attribute.
673671
(unstable, used_with_arg, "1.60.0", Some(93798)),
674672
/// Allows use of attributes in `where` clauses.

compiler/rustc_hir_analysis/messages.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ hir_analysis_value_of_associated_struct_already_specified =
599599
.label = re-bound here
600600
.previous_bound_label = `{$item_name}` bound here first
601601
602-
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like {$conventions}
602+
hir_analysis_variadic_function_compatible_convention = C-variadic functions with the {$convention} calling convention are not supported
603603
.label = C-variadic function must have a compatible calling convention
604604
605605
hir_analysis_variances_of = {$variances}

compiler/rustc_hir_analysis/src/check/region.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::mem;
1010

1111
use rustc_data_structures::fx::FxHashMap;
1212
use rustc_hir as hir;
13+
use rustc_hir::def::{CtorKind, DefKind, Res};
1314
use rustc_hir::def_id::DefId;
1415
use rustc_hir::intravisit::{self, Visitor};
1516
use rustc_hir::{Arm, Block, Expr, LetStmt, Pat, PatKind, Stmt};
@@ -752,13 +753,19 @@ fn resolve_local<'tcx>(
752753
record_rvalue_scope_if_borrow_expr(visitor, arm.body, blk_id);
753754
}
754755
}
755-
hir::ExprKind::Call(..) | hir::ExprKind::MethodCall(..) => {
756-
// FIXME(@dingxiangfei2009): choose call arguments here
757-
// for candidacy for extended parameter rule application
758-
}
759-
hir::ExprKind::Index(..) => {
760-
// FIXME(@dingxiangfei2009): select the indices
761-
// as candidate for rvalue scope rules
756+
hir::ExprKind::Call(func, args) => {
757+
// Recurse into tuple constructors, such as `Some(&temp())`.
758+
//
759+
// That way, there is no difference between `Some(..)` and `Some { 0: .. }`,
760+
// even though the former is syntactically a function call.
761+
if let hir::ExprKind::Path(path) = &func.kind
762+
&& let hir::QPath::Resolved(None, path) = path
763+
&& let Res::SelfCtor(_) | Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) = path.res
764+
{
765+
for arg in args {
766+
record_rvalue_scope_if_borrow_expr(visitor, arg, blk_id);
767+
}
768+
}
762769
}
763770
_ => {}
764771
}

compiler/rustc_hir_analysis/src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
633633
#[primary_span]
634634
#[label]
635635
pub span: Span,
636-
pub conventions: &'a str,
636+
pub convention: &'a str,
637637
}
638638

639639
#[derive(Diagnostic)]

compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,6 @@ fn require_c_abi_if_c_variadic(
115115
abi: ExternAbi,
116116
span: Span,
117117
) {
118-
const CONVENTIONS_UNSTABLE: &str =
119-
"`C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`";
120-
const CONVENTIONS_STABLE: &str = "`C` or `cdecl`";
121-
const UNSTABLE_EXPLAIN: &str =
122-
"using calling conventions other than `C` or `cdecl` for varargs functions is unstable";
123-
124118
// ABIs which can stably use varargs
125119
if !decl.c_variadic || matches!(abi, ExternAbi::C { .. } | ExternAbi::Cdecl { .. }) {
126120
return;
@@ -140,20 +134,18 @@ fn require_c_abi_if_c_variadic(
140134

141135
// Looks like we need to pick an error to emit.
142136
// Is there any feature which we could have enabled to make this work?
137+
let unstable_explain =
138+
format!("C-variadic functions with the {abi} calling convention are unstable");
143139
match abi {
144140
ExternAbi::System { .. } => {
145-
feature_err(&tcx.sess, sym::extern_system_varargs, span, UNSTABLE_EXPLAIN)
141+
feature_err(&tcx.sess, sym::extern_system_varargs, span, unstable_explain)
146142
}
147143
abi if abi.supports_varargs() => {
148-
feature_err(&tcx.sess, sym::extended_varargs_abi_support, span, UNSTABLE_EXPLAIN)
144+
feature_err(&tcx.sess, sym::extended_varargs_abi_support, span, unstable_explain)
149145
}
150146
_ => tcx.dcx().create_err(errors::VariadicFunctionCompatibleConvention {
151147
span,
152-
conventions: if tcx.sess.opts.unstable_features.is_nightly_build() {
153-
CONVENTIONS_UNSTABLE
154-
} else {
155-
CONVENTIONS_STABLE
156-
},
148+
convention: &format!("{abi}"),
157149
}),
158150
}
159151
.emit();

compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,9 +1662,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
16621662
blk_id,
16631663
expression,
16641664
);
1665-
if !fcx.tcx.features().unsized_locals() {
1666-
unsized_return = self.is_return_ty_definitely_unsized(fcx);
1667-
}
1665+
unsized_return = self.is_return_ty_definitely_unsized(fcx);
16681666
}
16691667
ObligationCauseCode::ReturnValue(return_expr_id) => {
16701668
err = self.report_return_mismatched_types(
@@ -1676,9 +1674,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
16761674
return_expr_id,
16771675
expression,
16781676
);
1679-
if !fcx.tcx.features().unsized_locals() {
1680-
unsized_return = self.is_return_ty_definitely_unsized(fcx);
1681-
}
1677+
unsized_return = self.is_return_ty_definitely_unsized(fcx);
16821678
}
16831679
ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause {
16841680
arm_span,

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,9 +809,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
809809
);
810810
}
811811
}
812-
// Here we want to prevent struct constructors from returning unsized types.
813-
// There were two cases this happened: fn pointer coercion in stable
814-
// and usual function call in presence of unsized_locals.
812+
// Here we want to prevent struct constructors from returning unsized types,
813+
// which can happen with fn pointer coercion on stable.
815814
// Also, as we just want to check sizedness, instead of introducing
816815
// placeholder lifetimes with probing, we just replace higher lifetimes
817816
// with fresh vars.

compiler/rustc_hir_typeck/src/gather_locals.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
202202
),
203203
);
204204
}
205-
} else if !self.fcx.tcx.features().unsized_locals() {
205+
} else {
206206
self.fcx.require_type_is_sized(
207207
var_ty,
208208
p.span,

compiler/rustc_hir_typeck/src/method/suggest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
724724
{
725725
let def_path = tcx.def_path_str(adt_def.did());
726726
err.span_suggestion(
727-
ty.span.to(item_ident.span),
727+
sugg_span,
728728
format!("to construct a value of type `{}`, use the explicit path", def_path),
729729
def_path,
730730
Applicability::MachineApplicable,

compiler/rustc_hir_typeck/src/upvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
492492
let final_upvar_tys = self.final_upvar_tys(closure_def_id);
493493
debug!(?closure_hir_id, ?args, ?final_upvar_tys);
494494

495-
if self.tcx.features().unsized_locals() || self.tcx.features().unsized_fn_params() {
495+
if self.tcx.features().unsized_fn_params() {
496496
for capture in
497497
self.typeck_results.borrow().closure_min_captures_flattened(closure_def_id)
498498
{

compiler/rustc_middle/src/mir/syntax.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,13 +1133,6 @@ pub type AssertMessage<'tcx> = AssertKind<Operand<'tcx>>;
11331133
/// Each local naturally corresponds to the place `Place { local, projection: [] }`. This place has
11341134
/// the address of the local's allocation and the type of the local.
11351135
///
1136-
/// **Needs clarification:** Unsized locals seem to present a bit of an issue. Their allocation
1137-
/// can't actually be created on `StorageLive`, because it's unclear how big to make the allocation.
1138-
/// Furthermore, MIR produces assignments to unsized locals, although that is not permitted under
1139-
/// `#![feature(unsized_locals)]` in Rust. Besides just putting "unsized locals are special and
1140-
/// different" in a bunch of places, I (JakobDegen) don't know how to incorporate this behavior into
1141-
/// the current MIR semantics in a clean way - possibly this needs some design work first.
1142-
///
11431136
/// For places that are not locals, ie they have a non-empty list of projections, we define the
11441137
/// values as a function of the parent place, that is the place with its last [`ProjectionElem`]
11451138
/// stripped. The way this is computed of course depends on the kind of that last projection

compiler/rustc_middle/src/ty/instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub enum InstanceKind<'tcx> {
7979
Intrinsic(DefId),
8080

8181
/// `<T as Trait>::method` where `method` receives unsizeable `self: Self` (part of the
82-
/// `unsized_locals` feature).
82+
/// `unsized_fn_params` feature).
8383
///
8484
/// The generated shim will take `Self` via `*mut Self` - conceptually this is `&owned Self` -
8585
/// and dereference the argument to call the original function.

compiler/rustc_mir_build/src/builder/expr/as_operand.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
5555
/// local variable of unsized type. For example, consider this program:
5656
///
5757
/// ```
58-
/// #![feature(unsized_locals, unsized_fn_params)]
58+
/// #![feature(unsized_fn_params)]
5959
/// # use core::fmt::Debug;
60-
/// fn foo(p: dyn Debug) { dbg!(p); }
60+
/// fn foo(_p: dyn Debug) { /* ... */ }
6161
///
6262
/// fn bar(box_p: Box<dyn Debug>) { foo(*box_p); }
6363
/// ```
@@ -84,7 +84,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
8484
/// will actually provide a pointer to the interior of the box, and not move the `dyn Debug`
8585
/// value to the stack.
8686
///
87-
/// See #68304 for more details.
87+
/// See <https://github.com/rust-lang/rust/issues/68304> for more details.
8888
pub(crate) fn as_local_call_operand(
8989
&mut self,
9090
block: BasicBlock,

compiler/rustc_mir_transform/src/coroutine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,9 +1417,9 @@ fn check_field_tys_sized<'tcx>(
14171417
coroutine_layout: &CoroutineLayout<'tcx>,
14181418
def_id: LocalDefId,
14191419
) {
1420-
// No need to check if unsized_locals/unsized_fn_params is disabled,
1420+
// No need to check if unsized_fn_params is disabled,
14211421
// since we will error during typeck.
1422-
if !tcx.features().unsized_locals() && !tcx.features().unsized_fn_params() {
1422+
if !tcx.features().unsized_fn_params() {
14231423
return;
14241424
}
14251425

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@ struct VnState<'body, 'tcx> {
240240
next_opaque: usize,
241241
/// Cache the deref values.
242242
derefs: Vec<VnIndex>,
243-
/// Cache the value of the `unsized_locals` features, to avoid fetching it repeatedly in a loop.
244-
feature_unsized_locals: bool,
245243
ssa: &'body SsaLocals,
246244
dominators: Dominators<BasicBlock>,
247245
reused_locals: DenseBitSet<Local>,
@@ -273,7 +271,6 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
273271
evaluated: IndexVec::with_capacity(num_values),
274272
next_opaque: 1,
275273
derefs: Vec::new(),
276-
feature_unsized_locals: tcx.features().unsized_locals(),
277274
ssa,
278275
dominators,
279276
reused_locals: DenseBitSet::new_empty(local_decls.len()),
@@ -329,13 +326,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
329326
fn assign(&mut self, local: Local, value: VnIndex) {
330327
debug_assert!(self.ssa.is_ssa(local));
331328
self.locals[local] = Some(value);
332-
333-
// Only register the value if its type is `Sized`, as we will emit copies of it.
334-
let is_sized = !self.feature_unsized_locals
335-
|| self.local_decls[local].ty.is_sized(self.tcx, self.typing_env());
336-
if is_sized {
337-
self.rev_locals[value].push(local);
338-
}
329+
self.rev_locals[value].push(local);
339330
}
340331

341332
fn insert_constant(&mut self, value: Const<'tcx>) -> VnIndex {

compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,9 +2995,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
29952995
if local {
29962996
err.note("all local variables must have a statically known size");
29972997
}
2998-
if !tcx.features().unsized_locals() {
2999-
err.help("unsized locals are gated as an unstable feature");
3000-
}
30012998
}
30022999
ObligationCauseCode::SizedArgumentType(hir_id) => {
30033000
let mut ty = None;

compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ fn virtual_call_violations_for_method<'tcx>(
414414

415415
let receiver_ty = tcx.liberate_late_bound_regions(method.def_id, sig.input(0));
416416

417-
// Until `unsized_locals` is fully implemented, `self: Self` can't be dispatched on.
418-
// However, this is already considered dyn compatible. We allow it as a special case here.
417+
// `self: Self` can't be dispatched on.
418+
// However, this is considered dyn compatible. We allow it as a special case here.
419419
// FIXME(mikeyhew) get rid of this `if` statement once `receiver_is_dispatchable` allows
420420
// `Receiver: Unsize<Receiver[Self => dyn Trait]>`.
421421
if receiver_ty != tcx.types.self_param {

library/alloc/src/collections/btree/set.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,11 +1220,11 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
12201220
/// assert_eq!(high.into_iter().collect::<Vec<_>>(), [4, 5, 6, 7]);
12211221
/// ```
12221222
#[unstable(feature = "btree_extract_if", issue = "70530")]
1223-
pub fn extract_if<'a, F, R>(&'a mut self, range: R, pred: F) -> ExtractIf<'a, T, R, F, A>
1223+
pub fn extract_if<F, R>(&mut self, range: R, pred: F) -> ExtractIf<'_, T, R, F, A>
12241224
where
12251225
T: Ord,
12261226
R: RangeBounds<T>,
1227-
F: 'a + FnMut(&T) -> bool,
1227+
F: FnMut(&T) -> bool,
12281228
{
12291229
let (inner, alloc) = self.map.extract_if_inner(range);
12301230
ExtractIf { pred, inner, alloc }
@@ -1585,11 +1585,11 @@ where
15851585
}
15861586

15871587
#[unstable(feature = "btree_extract_if", issue = "70530")]
1588-
impl<'a, T, R, F, A: Allocator + Clone> Iterator for ExtractIf<'_, T, R, F, A>
1588+
impl<T, R, F, A: Allocator + Clone> Iterator for ExtractIf<'_, T, R, F, A>
15891589
where
15901590
T: PartialOrd,
15911591
R: RangeBounds<T>,
1592-
F: 'a + FnMut(&T) -> bool,
1592+
F: FnMut(&T) -> bool,
15931593
{
15941594
type Item = T;
15951595

library/compiler-builtins/.release-plz.toml

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)