Skip to content

Commit 9822e3d

Browse files
committed
Auto merge of rust-lang#142492 - matthiaskrgr:rollup-a132ytq, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#140593 (Temporary lifetime extension through tuple struct and tuple variant constructors) - rust-lang#141399 ([rustdoc] Give more information into extracted doctest information) - rust-lang#141493 (Delegate `<SocketAddr as Debug>` to `ByteStr`) - rust-lang#141811 (Unimplement unsized_locals) - rust-lang#142243 (float tests: deduplicate min, max, and rounding tests) - rust-lang#142464 (variadic functions: remove list of supported ABIs from error) - rust-lang#142477 (Fix incorrect suggestion when calling an associated type with a type anchor) - rust-lang#142484 (Remove unneeded lifetime bound from signature of BTreeSet::extract_if) - rust-lang#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,

0 commit comments

Comments
 (0)