Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 529bb25

Browse files
committedMay 27, 2024
Auto merge of #125593 - workingjubilee:rollup-67qk7di, r=workingjubilee
Rollup of 8 pull requests Successful merges: - #124048 (Support C23's Variadics Without a Named Parameter) - #125046 (Only allow immutable statics with #[linkage]) - #125466 (Don't continue probing for method if in suggestion and autoderef hits ambiguity) - #125469 (Don't skip out of inner const when looking for body for suggestion) - #125544 (Also mention my-self for other check-cfg docs changes) - #125559 (Simplify the `unchecked_sh[lr]` ub-checks a bit) - #125566 (Notify T-rustdoc for beta-accepted and stable-accepted too) - #125582 (Avoid a `FieldIdx::from_usize` in InstSimplify) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0aad3f6 + 4ff7869 commit 529bb25

26 files changed

+185
-139
lines changed
 

‎compiler/rustc_ast_passes/messages.ftl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ ast_passes_fn_body_extern = incorrect function inside `extern` block
9292
ast_passes_fn_param_c_var_args_not_last =
9393
`...` must be the last argument of a C-variadic function
9494
95-
ast_passes_fn_param_c_var_args_only =
96-
C-variadic function must be declared with at least one named argument
97-
9895
ast_passes_fn_param_doc_comment =
9996
documentation comments cannot be applied to function parameters
10097
.label = doc comments are not allowed here

‎compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl<'a> AstValidator<'a> {
364364

365365
fn check_fn_decl(&self, fn_decl: &FnDecl, self_semantic: SelfSemantic) {
366366
self.check_decl_num_args(fn_decl);
367-
self.check_decl_cvaradic_pos(fn_decl);
367+
self.check_decl_cvariadic_pos(fn_decl);
368368
self.check_decl_attrs(fn_decl);
369369
self.check_decl_self_param(fn_decl, self_semantic);
370370
}
@@ -379,13 +379,11 @@ impl<'a> AstValidator<'a> {
379379
}
380380
}
381381

382-
fn check_decl_cvaradic_pos(&self, fn_decl: &FnDecl) {
382+
/// Emits an error if a function declaration has a variadic parameter in the
383+
/// beginning or middle of parameter list.
384+
/// Example: `fn foo(..., x: i32)` will emit an error.
385+
fn check_decl_cvariadic_pos(&self, fn_decl: &FnDecl) {
383386
match &*fn_decl.inputs {
384-
[Param { ty, span, .. }] => {
385-
if let TyKind::CVarArgs = ty.kind {
386-
self.dcx().emit_err(errors::FnParamCVarArgsOnly { span: *span });
387-
}
388-
}
389387
[ps @ .., _] => {
390388
for Param { ty, span, .. } in ps {
391389
if let TyKind::CVarArgs = ty.kind {

‎compiler/rustc_ast_passes/src/errors.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ pub struct FnParamTooMany {
9292
pub max_num_args: usize,
9393
}
9494

95-
#[derive(Diagnostic)]
96-
#[diag(ast_passes_fn_param_c_var_args_only)]
97-
pub struct FnParamCVarArgsOnly {
98-
#[primary_span]
99-
pub span: Span,
100-
}
101-
10295
#[derive(Diagnostic)]
10396
#[diag(ast_passes_fn_param_c_var_args_not_last)]
10497
pub struct FnParamCVarArgsNotLast {

‎compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,18 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
327327
} else {
328328
codegen_fn_attrs.linkage = linkage;
329329
}
330+
if tcx.is_mutable_static(did.into()) {
331+
let mut diag = tcx.dcx().struct_span_err(
332+
attr.span,
333+
"mutable statics are not allowed with `#[linkage]`",
334+
);
335+
diag.note(
336+
"making the static mutable would allow changing which symbol the \
337+
static references rather than make the target of the symbol \
338+
mutable",
339+
);
340+
diag.emit();
341+
}
330342
}
331343
}
332344
sym::link_section => {

‎compiler/rustc_hir_typeck/src/coercion.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,11 +1871,8 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
18711871
// If this is due to a block, then maybe we forgot a `return`/`break`.
18721872
if due_to_block
18731873
&& let Some(expr) = expression
1874-
&& let Some((parent_fn_decl, parent_id)) = fcx
1875-
.tcx
1876-
.hir()
1877-
.parent_iter(block_or_return_id)
1878-
.find_map(|(_, node)| Some((node.fn_decl()?, node.associated_body()?.0)))
1874+
&& let Some(parent_fn_decl) =
1875+
fcx.tcx.hir().fn_decl_by_hir_id(fcx.tcx.local_def_id_to_hir_id(fcx.body_id))
18791876
{
18801877
fcx.suggest_missing_break_or_return_expr(
18811878
&mut err,
@@ -1884,7 +1881,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
18841881
expected,
18851882
found,
18861883
block_or_return_id,
1887-
parent_id,
1884+
fcx.body_id,
18881885
);
18891886
}
18901887

‎compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
395395
// ambiguous.
396396
if let Some(bad_ty) = &steps.opt_bad_ty {
397397
if is_suggestion.0 {
398-
// Ambiguity was encountered during a suggestion. Just keep going.
399-
debug!("ProbeContext: encountered ambiguity in suggestion");
398+
// Ambiguity was encountered during a suggestion. There's really
399+
// not much use in suggesting methods in this case.
400+
return Err(MethodError::NoMatch(NoMatchData {
401+
static_candidates: Vec::new(),
402+
unsatisfied_predicates: Vec::new(),
403+
out_of_scope_traits: Vec::new(),
404+
similar_candidate: None,
405+
mode,
406+
}));
400407
} else if bad_ty.reached_raw_pointer
401408
&& !self.tcx.features().arbitrary_self_types
402409
&& !self.tcx.sess.at_least_rust_2018()

‎compiler/rustc_mir_transform/src/dataflow_const_prop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'_, 'tcx> {
142142
_ => return,
143143
};
144144
if let Some(variant_target_idx) = variant_target {
145-
for (field_index, operand) in operands.iter().enumerate() {
145+
for (field_index, operand) in operands.iter_enumerated() {
146146
if let Some(field) = self.map().apply(
147147
variant_target_idx,
148-
TrackElem::Field(FieldIdx::from_usize(field_index)),
148+
TrackElem::Field(field_index),
149149
) {
150150
self.assign_operand(state, field, operand);
151151
}

‎compiler/rustc_mir_transform/src/instsimplify.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use rustc_middle::ty::layout::ValidityRequirement;
99
use rustc_middle::ty::{self, GenericArgsRef, ParamEnv, Ty, TyCtxt};
1010
use rustc_span::sym;
1111
use rustc_span::symbol::Symbol;
12-
use rustc_target::abi::FieldIdx;
1312
use rustc_target::spec::abi::Abi;
1413

1514
pub struct InstSimplify;
@@ -217,11 +216,11 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
217216
&& let Some(place) = operand.place()
218217
{
219218
let variant = adt_def.non_enum_variant();
220-
for (i, field) in variant.fields.iter().enumerate() {
219+
for (i, field) in variant.fields.iter_enumerated() {
221220
let field_ty = field.ty(self.tcx, args);
222221
if field_ty == *cast_ty {
223222
let place = place.project_deeper(
224-
&[ProjectionElem::Field(FieldIdx::from_usize(i), *cast_ty)],
223+
&[ProjectionElem::Field(i, *cast_ty)],
225224
self.tcx,
226225
);
227226
let operand = if operand.is_move() {

‎library/core/src/num/int_macros.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,8 +1282,7 @@ macro_rules! int_impl {
12821282
concat!(stringify!($SelfT), "::unchecked_shl cannot overflow"),
12831283
(
12841284
rhs: u32 = rhs,
1285-
bits: u32 = Self::BITS,
1286-
) => rhs < bits,
1285+
) => rhs < <$ActualT>::BITS,
12871286
);
12881287

12891288
// SAFETY: this is guaranteed to be safe by the caller.
@@ -1381,8 +1380,7 @@ macro_rules! int_impl {
13811380
concat!(stringify!($SelfT), "::unchecked_shr cannot overflow"),
13821381
(
13831382
rhs: u32 = rhs,
1384-
bits: u32 = Self::BITS,
1385-
) => rhs < bits,
1383+
) => rhs < <$ActualT>::BITS,
13861384
);
13871385

13881386
// SAFETY: this is guaranteed to be safe by the caller.

‎library/core/src/num/uint_macros.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,8 +1369,7 @@ macro_rules! uint_impl {
13691369
concat!(stringify!($SelfT), "::unchecked_shl cannot overflow"),
13701370
(
13711371
rhs: u32 = rhs,
1372-
bits: u32 = Self::BITS,
1373-
) => rhs < bits,
1372+
) => rhs < <$ActualT>::BITS,
13741373
);
13751374

13761375
// SAFETY: this is guaranteed to be safe by the caller.
@@ -1468,8 +1467,7 @@ macro_rules! uint_impl {
14681467
concat!(stringify!($SelfT), "::unchecked_shr cannot overflow"),
14691468
(
14701469
rhs: u32 = rhs,
1471-
bits: u32 = Self::BITS,
1472-
) => rhs < bits,
1470+
) => rhs < <$ActualT>::BITS,
14731471
);
14741472

14751473
// SAFETY: this is guaranteed to be safe by the caller.

‎tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-abort.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030

3131
bb1: {
32-
+ _6 = core::num::<impl u16>::unchecked_shl::precondition_check(_4, const core::num::<impl u16>::BITS) -> [return: bb2, unwind unreachable];
32+
+ _6 = core::num::<impl u16>::unchecked_shl::precondition_check(_4) -> [return: bb2, unwind unreachable];
3333
+ }
3434
+
3535
+ bb2: {

‎tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.panic-unwind.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030

3131
bb1: {
32-
+ _6 = core::num::<impl u16>::unchecked_shl::precondition_check(_4, const core::num::<impl u16>::BITS) -> [return: bb2, unwind unreachable];
32+
+ _6 = core::num::<impl u16>::unchecked_shl::precondition_check(_4) -> [return: bb2, unwind unreachable];
3333
+ }
3434
+
3535
+ bb2: {

‎tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-abort.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030

3131
bb1: {
32-
+ _6 = core::num::<impl i64>::unchecked_shr::precondition_check(_4, const core::num::<impl i64>::BITS) -> [return: bb2, unwind unreachable];
32+
+ _6 = core::num::<impl i64>::unchecked_shr::precondition_check(_4) -> [return: bb2, unwind unreachable];
3333
+ }
3434
+
3535
+ bb2: {

‎tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_bigger.Inline.panic-unwind.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030

3131
bb1: {
32-
+ _6 = core::num::<impl i64>::unchecked_shr::precondition_check(_4, const core::num::<impl i64>::BITS) -> [return: bb2, unwind unreachable];
32+
+ _6 = core::num::<impl i64>::unchecked_shr::precondition_check(_4) -> [return: bb2, unwind unreachable];
3333
+ }
3434
+
3535
+ bb2: {
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
//@ build-pass
2+
3+
// Supported since C23
4+
// https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2975.pdf
15
extern "C" {
26
fn foo(...);
3-
//~^ ERROR C-variadic function must be declared with at least one named argument
47
}
58

69
fn main() {}

‎tests/ui/c-variadic/variadic-ffi-no-fixed-args.stderr

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

‎tests/ui/issues/issue-33992.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55

66
#![feature(linkage)]
77

8-
#[linkage = "common"]
9-
pub static mut TEST1: u32 = 0u32;
10-
118
#[linkage = "external"]
129
pub static TEST2: bool = true;
1310

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//! The symbols are resolved by the linker. It doesn't make sense to change
2+
//! them at runtime, so deny mutable statics with #[linkage].
3+
4+
#![feature(linkage)]
5+
6+
fn main() {
7+
extern "C" {
8+
#[linkage = "weak"] //~ ERROR mutable statics are not allowed with `#[linkage]`
9+
static mut ABC: *const u8;
10+
}
11+
12+
unsafe {
13+
assert_eq!(ABC as usize, 0);
14+
}
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: mutable statics are not allowed with `#[linkage]`
2+
--> $DIR/linkage-attr-mutable-static.rs:8:9
3+
|
4+
LL | #[linkage = "weak"]
5+
| ^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: making the static mutable would allow changing which symbol the static references rather than make the target of the symbol mutable
8+
9+
error: aborting due to 1 previous error
10+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Fix for <https://github.com/rust-lang/rust/issues/125432>.
2+
3+
fn separate_arms() {
4+
let mut x = None;
5+
match x {
6+
None => {
7+
x = Some(0);
8+
}
9+
Some(right) => {
10+
consume(right);
11+
//~^ ERROR cannot find function `consume` in this scope
12+
}
13+
}
14+
}
15+
16+
fn main() {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0425]: cannot find function `consume` in this scope
2+
--> $DIR/suggest-method-on-call-for-ambig-receiver.rs:10:13
3+
|
4+
LL | consume(right);
5+
| ^^^^^^^ not found in this scope
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0425`.

‎tests/ui/parser/variadic-ffi-semantic-restrictions.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@ fn f1_1(x: isize, ...) {}
88

99
fn f1_2(...) {}
1010
//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
11-
//~| ERROR C-variadic function must be declared with at least one named argument
1211

1312
extern "C" fn f2_1(x: isize, ...) {}
1413
//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
1514

1615
extern "C" fn f2_2(...) {}
1716
//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
18-
//~| ERROR C-variadic function must be declared with at least one named argument
1917

2018
extern "C" fn f2_3(..., x: isize) {}
2119
//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
@@ -26,7 +24,6 @@ extern "C" fn f3_1(x: isize, ...) {}
2624

2725
extern "C" fn f3_2(...) {}
2826
//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
29-
//~| ERROR C-variadic function must be declared with at least one named argument
3027

3128
extern "C" fn f3_3(..., x: isize) {}
3229
//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
@@ -47,8 +44,6 @@ const extern "C" fn f4_3(..., x: isize, ...) {}
4744
//~| ERROR `...` must be the last argument of a C-variadic function
4845

4946
extern "C" {
50-
fn e_f1(...);
51-
//~^ ERROR C-variadic function must be declared with at least one named argument
5247
fn e_f2(..., x: isize);
5348
//~^ ERROR `...` must be the last argument of a C-variadic function
5449
}
@@ -60,7 +55,6 @@ impl X {
6055
//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
6156
fn i_f2(...) {}
6257
//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
63-
//~| ERROR C-variadic function must be declared with at least one named argument
6458
fn i_f3(..., x: isize, ...) {}
6559
//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
6660
//~| ERROR `...` must be the last argument of a C-variadic function
@@ -80,10 +74,8 @@ trait T {
8074
//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
8175
fn t_f3(...) {}
8276
//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
83-
//~| ERROR C-variadic function must be declared with at least one named argument
8477
fn t_f4(...);
8578
//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
86-
//~| ERROR C-variadic function must be declared with at least one named argument
8779
fn t_f5(..., x: isize) {}
8880
//~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic
8981
//~| ERROR `...` must be the last argument of a C-variadic function

‎tests/ui/parser/variadic-ffi-semantic-restrictions.stderr

Lines changed: 35 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -4,104 +4,86 @@ error: only foreign or `unsafe extern "C"` functions may be C-variadic
44
LL | fn f1_1(x: isize, ...) {}
55
| ^^^
66

7-
error: C-variadic function must be declared with at least one named argument
8-
--> $DIR/variadic-ffi-semantic-restrictions.rs:9:9
9-
|
10-
LL | fn f1_2(...) {}
11-
| ^^^
12-
137
error: only foreign or `unsafe extern "C"` functions may be C-variadic
148
--> $DIR/variadic-ffi-semantic-restrictions.rs:9:9
159
|
1610
LL | fn f1_2(...) {}
1711
| ^^^
1812

1913
error: only foreign or `unsafe extern "C"` functions may be C-variadic
20-
--> $DIR/variadic-ffi-semantic-restrictions.rs:13:30
14+
--> $DIR/variadic-ffi-semantic-restrictions.rs:12:30
2115
|
2216
LL | extern "C" fn f2_1(x: isize, ...) {}
2317
| ^^^
2418

25-
error: C-variadic function must be declared with at least one named argument
26-
--> $DIR/variadic-ffi-semantic-restrictions.rs:16:20
27-
|
28-
LL | extern "C" fn f2_2(...) {}
29-
| ^^^
30-
3119
error: only foreign or `unsafe extern "C"` functions may be C-variadic
32-
--> $DIR/variadic-ffi-semantic-restrictions.rs:16:20
20+
--> $DIR/variadic-ffi-semantic-restrictions.rs:15:20
3321
|
3422
LL | extern "C" fn f2_2(...) {}
3523
| ^^^
3624

3725
error: `...` must be the last argument of a C-variadic function
38-
--> $DIR/variadic-ffi-semantic-restrictions.rs:20:20
26+
--> $DIR/variadic-ffi-semantic-restrictions.rs:18:20
3927
|
4028
LL | extern "C" fn f2_3(..., x: isize) {}
4129
| ^^^
4230

4331
error: only foreign or `unsafe extern "C"` functions may be C-variadic
44-
--> $DIR/variadic-ffi-semantic-restrictions.rs:20:20
32+
--> $DIR/variadic-ffi-semantic-restrictions.rs:18:20
4533
|
4634
LL | extern "C" fn f2_3(..., x: isize) {}
4735
| ^^^
4836

4937
error: only foreign or `unsafe extern "C"` functions may be C-variadic
50-
--> $DIR/variadic-ffi-semantic-restrictions.rs:24:30
38+
--> $DIR/variadic-ffi-semantic-restrictions.rs:22:30
5139
|
5240
LL | extern "C" fn f3_1(x: isize, ...) {}
5341
| ^^^
5442

55-
error: C-variadic function must be declared with at least one named argument
56-
--> $DIR/variadic-ffi-semantic-restrictions.rs:27:20
57-
|
58-
LL | extern "C" fn f3_2(...) {}
59-
| ^^^
60-
6143
error: only foreign or `unsafe extern "C"` functions may be C-variadic
62-
--> $DIR/variadic-ffi-semantic-restrictions.rs:27:20
44+
--> $DIR/variadic-ffi-semantic-restrictions.rs:25:20
6345
|
6446
LL | extern "C" fn f3_2(...) {}
6547
| ^^^
6648

6749
error: `...` must be the last argument of a C-variadic function
68-
--> $DIR/variadic-ffi-semantic-restrictions.rs:31:20
50+
--> $DIR/variadic-ffi-semantic-restrictions.rs:28:20
6951
|
7052
LL | extern "C" fn f3_3(..., x: isize) {}
7153
| ^^^
7254

7355
error: only foreign or `unsafe extern "C"` functions may be C-variadic
74-
--> $DIR/variadic-ffi-semantic-restrictions.rs:31:20
56+
--> $DIR/variadic-ffi-semantic-restrictions.rs:28:20
7557
|
7658
LL | extern "C" fn f3_3(..., x: isize) {}
7759
| ^^^
7860

7961
error: functions cannot be both `const` and C-variadic
80-
--> $DIR/variadic-ffi-semantic-restrictions.rs:35:1
62+
--> $DIR/variadic-ffi-semantic-restrictions.rs:32:1
8163
|
8264
LL | const unsafe extern "C" fn f4_1(x: isize, ...) {}
8365
| ^^^^^ `const` because of this ^^^ C-variadic because of this
8466

8567
error: functions cannot be both `const` and C-variadic
86-
--> $DIR/variadic-ffi-semantic-restrictions.rs:39:1
68+
--> $DIR/variadic-ffi-semantic-restrictions.rs:36:1
8769
|
8870
LL | const extern "C" fn f4_2(x: isize, ...) {}
8971
| ^^^^^ `const` because of this ^^^ C-variadic because of this
9072

9173
error: only foreign or `unsafe extern "C"` functions may be C-variadic
92-
--> $DIR/variadic-ffi-semantic-restrictions.rs:39:36
74+
--> $DIR/variadic-ffi-semantic-restrictions.rs:36:36
9375
|
9476
LL | const extern "C" fn f4_2(x: isize, ...) {}
9577
| ^^^
9678

9779
error: `...` must be the last argument of a C-variadic function
98-
--> $DIR/variadic-ffi-semantic-restrictions.rs:44:26
80+
--> $DIR/variadic-ffi-semantic-restrictions.rs:41:26
9981
|
10082
LL | const extern "C" fn f4_3(..., x: isize, ...) {}
10183
| ^^^
10284

10385
error: functions cannot be both `const` and C-variadic
104-
--> $DIR/variadic-ffi-semantic-restrictions.rs:44:1
86+
--> $DIR/variadic-ffi-semantic-restrictions.rs:41:1
10587
|
10688
LL | const extern "C" fn f4_3(..., x: isize, ...) {}
10789
| ^^^^^ ^^^ ^^^ C-variadic because of this
@@ -110,163 +92,139 @@ LL | const extern "C" fn f4_3(..., x: isize, ...) {}
11092
| `const` because of this
11193

11294
error: only foreign or `unsafe extern "C"` functions may be C-variadic
113-
--> $DIR/variadic-ffi-semantic-restrictions.rs:44:26
95+
--> $DIR/variadic-ffi-semantic-restrictions.rs:41:26
11496
|
11597
LL | const extern "C" fn f4_3(..., x: isize, ...) {}
11698
| ^^^ ^^^
11799

118-
error: C-variadic function must be declared with at least one named argument
119-
--> $DIR/variadic-ffi-semantic-restrictions.rs:50:13
120-
|
121-
LL | fn e_f1(...);
122-
| ^^^
123-
124100
error: `...` must be the last argument of a C-variadic function
125-
--> $DIR/variadic-ffi-semantic-restrictions.rs:52:13
101+
--> $DIR/variadic-ffi-semantic-restrictions.rs:47:13
126102
|
127103
LL | fn e_f2(..., x: isize);
128104
| ^^^
129105

130106
error: only foreign or `unsafe extern "C"` functions may be C-variadic
131-
--> $DIR/variadic-ffi-semantic-restrictions.rs:59:23
107+
--> $DIR/variadic-ffi-semantic-restrictions.rs:54:23
132108
|
133109
LL | fn i_f1(x: isize, ...) {}
134110
| ^^^
135111

136-
error: C-variadic function must be declared with at least one named argument
137-
--> $DIR/variadic-ffi-semantic-restrictions.rs:61:13
138-
|
139-
LL | fn i_f2(...) {}
140-
| ^^^
141-
142112
error: only foreign or `unsafe extern "C"` functions may be C-variadic
143-
--> $DIR/variadic-ffi-semantic-restrictions.rs:61:13
113+
--> $DIR/variadic-ffi-semantic-restrictions.rs:56:13
144114
|
145115
LL | fn i_f2(...) {}
146116
| ^^^
147117

148118
error: `...` must be the last argument of a C-variadic function
149-
--> $DIR/variadic-ffi-semantic-restrictions.rs:64:13
119+
--> $DIR/variadic-ffi-semantic-restrictions.rs:58:13
150120
|
151121
LL | fn i_f3(..., x: isize, ...) {}
152122
| ^^^
153123

154124
error: only foreign or `unsafe extern "C"` functions may be C-variadic
155-
--> $DIR/variadic-ffi-semantic-restrictions.rs:64:13
125+
--> $DIR/variadic-ffi-semantic-restrictions.rs:58:13
156126
|
157127
LL | fn i_f3(..., x: isize, ...) {}
158128
| ^^^ ^^^
159129

160130
error: `...` must be the last argument of a C-variadic function
161-
--> $DIR/variadic-ffi-semantic-restrictions.rs:67:13
131+
--> $DIR/variadic-ffi-semantic-restrictions.rs:61:13
162132
|
163133
LL | fn i_f4(..., x: isize, ...) {}
164134
| ^^^
165135

166136
error: only foreign or `unsafe extern "C"` functions may be C-variadic
167-
--> $DIR/variadic-ffi-semantic-restrictions.rs:67:13
137+
--> $DIR/variadic-ffi-semantic-restrictions.rs:61:13
168138
|
169139
LL | fn i_f4(..., x: isize, ...) {}
170140
| ^^^ ^^^
171141

172142
error: functions cannot be both `const` and C-variadic
173-
--> $DIR/variadic-ffi-semantic-restrictions.rs:70:5
143+
--> $DIR/variadic-ffi-semantic-restrictions.rs:64:5
174144
|
175145
LL | const fn i_f5(x: isize, ...) {}
176146
| ^^^^^ ^^^ C-variadic because of this
177147
| |
178148
| `const` because of this
179149

180150
error: only foreign or `unsafe extern "C"` functions may be C-variadic
181-
--> $DIR/variadic-ffi-semantic-restrictions.rs:70:29
151+
--> $DIR/variadic-ffi-semantic-restrictions.rs:64:29
182152
|
183153
LL | const fn i_f5(x: isize, ...) {}
184154
| ^^^
185155

186156
error: only foreign or `unsafe extern "C"` functions may be C-variadic
187-
--> $DIR/variadic-ffi-semantic-restrictions.rs:77:23
157+
--> $DIR/variadic-ffi-semantic-restrictions.rs:71:23
188158
|
189159
LL | fn t_f1(x: isize, ...) {}
190160
| ^^^
191161

192162
error: only foreign or `unsafe extern "C"` functions may be C-variadic
193-
--> $DIR/variadic-ffi-semantic-restrictions.rs:79:23
163+
--> $DIR/variadic-ffi-semantic-restrictions.rs:73:23
194164
|
195165
LL | fn t_f2(x: isize, ...);
196166
| ^^^
197167

198-
error: C-variadic function must be declared with at least one named argument
199-
--> $DIR/variadic-ffi-semantic-restrictions.rs:81:13
200-
|
201-
LL | fn t_f3(...) {}
202-
| ^^^
203-
204168
error: only foreign or `unsafe extern "C"` functions may be C-variadic
205-
--> $DIR/variadic-ffi-semantic-restrictions.rs:81:13
169+
--> $DIR/variadic-ffi-semantic-restrictions.rs:75:13
206170
|
207171
LL | fn t_f3(...) {}
208172
| ^^^
209173

210-
error: C-variadic function must be declared with at least one named argument
211-
--> $DIR/variadic-ffi-semantic-restrictions.rs:84:13
212-
|
213-
LL | fn t_f4(...);
214-
| ^^^
215-
216174
error: only foreign or `unsafe extern "C"` functions may be C-variadic
217-
--> $DIR/variadic-ffi-semantic-restrictions.rs:84:13
175+
--> $DIR/variadic-ffi-semantic-restrictions.rs:77:13
218176
|
219177
LL | fn t_f4(...);
220178
| ^^^
221179

222180
error: `...` must be the last argument of a C-variadic function
223-
--> $DIR/variadic-ffi-semantic-restrictions.rs:87:13
181+
--> $DIR/variadic-ffi-semantic-restrictions.rs:79:13
224182
|
225183
LL | fn t_f5(..., x: isize) {}
226184
| ^^^
227185

228186
error: only foreign or `unsafe extern "C"` functions may be C-variadic
229-
--> $DIR/variadic-ffi-semantic-restrictions.rs:87:13
187+
--> $DIR/variadic-ffi-semantic-restrictions.rs:79:13
230188
|
231189
LL | fn t_f5(..., x: isize) {}
232190
| ^^^
233191

234192
error: `...` must be the last argument of a C-variadic function
235-
--> $DIR/variadic-ffi-semantic-restrictions.rs:90:13
193+
--> $DIR/variadic-ffi-semantic-restrictions.rs:82:13
236194
|
237195
LL | fn t_f6(..., x: isize);
238196
| ^^^
239197

240198
error: only foreign or `unsafe extern "C"` functions may be C-variadic
241-
--> $DIR/variadic-ffi-semantic-restrictions.rs:90:13
199+
--> $DIR/variadic-ffi-semantic-restrictions.rs:82:13
242200
|
243201
LL | fn t_f6(..., x: isize);
244202
| ^^^
245203

246204
error[E0493]: destructor of `VaListImpl<'_>` cannot be evaluated at compile-time
247-
--> $DIR/variadic-ffi-semantic-restrictions.rs:35:43
205+
--> $DIR/variadic-ffi-semantic-restrictions.rs:32:43
248206
|
249207
LL | const unsafe extern "C" fn f4_1(x: isize, ...) {}
250208
| ^^^ - value is dropped here
251209
| |
252210
| the destructor for this type cannot be evaluated in constant functions
253211

254212
error[E0493]: destructor of `VaListImpl<'_>` cannot be evaluated at compile-time
255-
--> $DIR/variadic-ffi-semantic-restrictions.rs:39:36
213+
--> $DIR/variadic-ffi-semantic-restrictions.rs:36:36
256214
|
257215
LL | const extern "C" fn f4_2(x: isize, ...) {}
258216
| ^^^ - value is dropped here
259217
| |
260218
| the destructor for this type cannot be evaluated in constant functions
261219

262220
error[E0493]: destructor of `VaListImpl<'_>` cannot be evaluated at compile-time
263-
--> $DIR/variadic-ffi-semantic-restrictions.rs:70:29
221+
--> $DIR/variadic-ffi-semantic-restrictions.rs:64:29
264222
|
265223
LL | const fn i_f5(x: isize, ...) {}
266224
| ^^^ - value is dropped here
267225
| |
268226
| the destructor for this type cannot be evaluated in constant functions
269227

270-
error: aborting due to 43 previous errors
228+
error: aborting due to 36 previous errors
271229

272230
For more information about this error, try `rustc --explain E0493`.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const fn f() -> usize {
2+
//~^ ERROR mismatched types
3+
const FIELD: usize = loop {
4+
0
5+
//~^ ERROR mismatched types
6+
};
7+
}
8+
9+
fn main() {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/dont-suggest-through-inner-const.rs:4:9
3+
|
4+
LL | 0
5+
| ^ expected `()`, found integer
6+
7+
error[E0308]: mismatched types
8+
--> $DIR/dont-suggest-through-inner-const.rs:1:17
9+
|
10+
LL | const fn f() -> usize {
11+
| - ^^^^^ expected `usize`, found `()`
12+
| |
13+
| implicitly returns `()` as its body has no tail or `return` expression
14+
15+
error: aborting due to 2 previous errors
16+
17+
For more information about this error, try `rustc --explain E0308`.

‎triagebot.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,19 @@ message_on_remove = "PR #{number}'s beta-nomination has been removed."
468468
message_on_close = "PR #{number} has been closed. Thanks for participating!"
469469
message_on_reopen = "PR #{number} has been reopened. Pinging @*T-rustdoc*."
470470

471+
# FIXME: Patch triagebot to support `notify-zulip.<label>` getting mapped to an array of actions.
472+
# At the moment, the beta-accepted+T-rustdoc action fully occupies the beta-accepted slot
473+
# preventing others from adding more beta-accepted actions.
474+
[notify-zulip."beta-accepted"]
475+
required_labels = ["T-rustdoc"]
476+
zulip_stream = 266220 # #t-rustdoc
477+
# Put it in the same thread as beta-nominated.
478+
topic = "beta-nominated: #{number}"
479+
message_on_add = "PR #{number} has been **accepted** for beta backport."
480+
message_on_remove = "PR #{number}'s beta-acceptance has been **removed**."
481+
message_on_close = "PR #{number} has been closed. Thanks for participating!"
482+
message_on_reopen = "PR #{number} has been reopened. Pinging @*T-rustdoc*."
483+
471484
# FIXME: Patch triagebot to support `notify-zulip.<label>` getting mapped to an array of actions.
472485
# At the moment, the stable-nominated+T-rustdoc action fully occupies the stable-nominated slot
473486
# preventing others from adding more stable-nominated actions.
@@ -492,6 +505,19 @@ message_on_remove = "PR #{number}'s stable-nomination has been removed."
492505
message_on_close = "PR #{number} has been closed. Thanks for participating!"
493506
message_on_reopen = "PR #{number} has been reopened. Pinging @*T-rustdoc*."
494507

508+
# FIXME: Patch triagebot to support `notify-zulip.<label>` getting mapped to an array of actions.
509+
# At the moment, the stable-accepted+T-rustdoc action fully occupies the stable-accepted slot
510+
# preventing others from adding more stable-accepted actions.
511+
[notify-zulip."stable-accepted"]
512+
required_labels = ["T-rustdoc"]
513+
zulip_stream = 266220 # #t-rustdoc
514+
# Put it in the same thread as stable-nominated.
515+
topic = "stable-nominated: #{number}"
516+
message_on_add = "PR #{number} has been **accepted** for stable backport."
517+
message_on_remove = "PR #{number}'s stable-acceptance has been **removed**."
518+
message_on_close = "PR #{number} has been closed. Thanks for participating!"
519+
message_on_reopen = "PR #{number} has been reopened. Pinging @*T-rustdoc*."
520+
495521
[notify-zulip."I-types-nominated"]
496522
zulip_stream = 326866 # #T-types/nominated
497523
topic = "#{number}: {title}"
@@ -810,6 +836,9 @@ cc = ["@rust-lang/project-exploit-mitigations", "@rcvalle"]
810836
[mentions."src/doc/rustc/src/check-cfg.md"]
811837
cc = ["@Urgau"]
812838

839+
[mentions."src/doc/rustc/src/check-cfg"]
840+
cc = ["@Urgau"]
841+
813842
[mentions."src/doc/rustc/src/platform-support"]
814843
cc = ["@Nilstrieb"]
815844

0 commit comments

Comments
 (0)
Please sign in to comment.