Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Nov 1, 2024
1 parent ae79471 commit 2f57b1a
Show file tree
Hide file tree
Showing 63 changed files with 199 additions and 144 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/example/mini_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ impl<T> Index<usize> for [T] {
}
}

extern {
extern "C" {
type VaListImpl;
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ fn main() {

assert_eq!(((|()| 42u8) as fn(()) -> u8)(()), 42);

extern {
extern "C" {
#[linkage = "weak"]
static ABC: *const u8;
}

{
extern {
extern "C" {
#[linkage = "weak"]
static ABC: *const u8;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/example/mod_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![allow(internal_features)]

#[link(name = "c")]
extern {}
extern "C" {}

#[panic_handler]
fn panic_handler(_: &core::panic::PanicInfo<'_>) -> ! {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/example/std_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::arch::x86_64::*;
use std::io::Write;
use std::ops::Coroutine;

extern {
extern "C" {
pub fn printf(format: *const i8, ...) -> i32;
}

Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/tests/ui/boxed_local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ mod issue_3739 {
/// This shouldn't warn for `boxed_local` as it is intended to called from non-Rust code.
pub extern "C" fn do_not_warn_me(_c_pointer: Box<String>) -> () {}

#[allow(missing_abi)]
#[rustfmt::skip] // Forces rustfmt to not add ABI
pub extern fn do_not_warn_me_no_abi(_c_pointer: Box<String>) -> () {}

Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/tests/ui/boxed_local.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ LL | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
| ^^^^^^^^^^^

error: local variable doesn't need to be boxed here
--> tests/ui/boxed_local.rs:188:44
--> tests/ui/boxed_local.rs:189:44
|
LL | fn default_impl_x(self: Box<Self>, x: Box<u32>) -> u32 {
| ^

error: local variable doesn't need to be boxed here
--> tests/ui/boxed_local.rs:196:16
--> tests/ui/boxed_local.rs:197:16
|
LL | fn foo(x: Box<u32>) {}
| ^
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/doc/doc-fixable.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ fn parenthesized_word() {}
/// UXes
fn plural_acronym_test() {}

extern {
extern "C" {
/// `foo()`
fn in_extern();
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/tests/ui/doc/doc-fixable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ fn parenthesized_word() {}
/// UXes
fn plural_acronym_test() {}

extern {
extern "C" {
/// foo()
fn in_extern();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ mod msrv {
//~^ ERROR: this could be a `const fn`

#[rustfmt::skip]
#[allow(missing_abi)]
const extern fn implicit_c() {}
//~^ ERROR: this could be a `const fn`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ mod msrv {
//~^ ERROR: this could be a `const fn`

#[rustfmt::skip]
#[allow(missing_abi)]
extern fn implicit_c() {}
//~^ ERROR: this could be a `const fn`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ LL | const extern "C" fn c() {}
| +++++

error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:153:9
--> tests/ui/missing_const_for_fn/could_be_const.rs:154:9
|
LL | extern fn implicit_c() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -233,7 +233,7 @@ LL | const extern fn implicit_c() {}
| +++++

error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:170:9
--> tests/ui/missing_const_for_fn/could_be_const.rs:171:9
|
LL | / pub fn new(strings: Vec<String>) -> Self {
LL | | Self { strings }
Expand All @@ -246,7 +246,7 @@ LL | pub const fn new(strings: Vec<String>) -> Self {
| +++++

error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:175:9
--> tests/ui/missing_const_for_fn/could_be_const.rs:176:9
|
LL | / pub fn empty() -> Self {
LL | | Self { strings: Vec::new() }
Expand All @@ -259,7 +259,7 @@ LL | pub const fn empty() -> Self {
| +++++

error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:186:9
--> tests/ui/missing_const_for_fn/could_be_const.rs:187:9
|
LL | / pub fn new(text: String) -> Self {
LL | | let vec = Vec::new();
Expand All @@ -273,7 +273,7 @@ LL | pub const fn new(text: String) -> Self {
| +++++

error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:205:5
--> tests/ui/missing_const_for_fn/could_be_const.rs:206:5
|
LL | fn alias_ty_is_projection(bar: <() as FooTrait>::Foo) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -284,7 +284,7 @@ LL | const fn alias_ty_is_projection(bar: <() as FooTrait>::Foo) {}
| +++++

error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:209:5
--> tests/ui/missing_const_for_fn/could_be_const.rs:210:5
|
LL | extern "C-unwind" fn c_unwind() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -295,7 +295,7 @@ LL | const extern "C-unwind" fn c_unwind() {}
| +++++

error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:211:5
--> tests/ui/missing_const_for_fn/could_be_const.rs:212:5
|
LL | extern "system" fn system() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -306,7 +306,7 @@ LL | const extern "system" fn system() {}
| +++++

error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:213:5
--> tests/ui/missing_const_for_fn/could_be_const.rs:214:5
|
LL | extern "system-unwind" fn system_unwind() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -317,7 +317,7 @@ LL | const extern "system-unwind" fn system_unwind() {}
| +++++

error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:215:5
--> tests/ui/missing_const_for_fn/could_be_const.rs:216:5
|
LL | pub extern "vectorcall" fn std_call() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -328,7 +328,7 @@ LL | pub const extern "vectorcall" fn std_call() {}
| +++++

error: this could be a `const fn`
--> tests/ui/missing_const_for_fn/could_be_const.rs:217:5
--> tests/ui/missing_const_for_fn/could_be_const.rs:218:5
|
LL | pub extern "vectorcall-unwind" fn std_call_unwind() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/associated-types/issue-91231.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![feature(extern_types)]
#![allow(dead_code)]

extern {
extern "C" {
type Extern;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/attributes/key-value-expansion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bug!();
macro_rules! doc_comment {
($x:expr) => {
#[doc = $x]
extern {}
extern "C" {}
};
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/borrowck/issue-92157.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#[cfg(target_os = "linux")]
#[link(name = "c")]
extern {}
extern "C" {}

#[lang = "start"]
fn start<T>(_main: fn() -> T, _argc: isize, _argv: *const *const u8) -> isize {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/coherence/coherence-negative-impls-copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl !Copy for WithDrop {}

struct Type;
trait Trait {}
extern {
extern "C" {
type ExternType;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const B: bool = true;

// ForeignType::unresolved - error

extern {
extern "C" {
type ForeignType;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(extern_types)]

extern {
extern "C" {
type Opaque;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/delegation/glob-non-impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trait OtherTrait {
reuse Trait::*; //~ ERROR glob delegation is only supported in impls
}

extern {
extern "C" {
reuse Trait::*; //~ ERROR delegation is not supported in `extern` blocks
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ui/extern/extern-type-diag-not-similar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
// because they are both extern types.

#![feature(extern_types)]
extern {
extern "C" {
type ShouldNotBeMentioned;
}

extern {
extern "C" {
type Foo;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/extern/issue-10025.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ run-pass
//@ pretty-expanded FIXME #23616
#![allow(dead_code)]
#![allow(dead_code, missing_abi)]

unsafe extern fn foo() {}
unsafe extern "C" fn bar() {}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/extern/issue-95829.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@ edition:2018

extern {
extern "C" {
async fn L() { //~ ERROR: incorrect function inside `extern` block
//~^ ERROR: functions in `extern` blocks cannot have `async` qualifier
async fn M() {}
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/extern/issue-95829.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: incorrect function inside `extern` block
--> $DIR/issue-95829.rs:4:14
|
LL | extern {
| ------ `extern` blocks define existing foreign functions and functions inside of them cannot have a body
LL | extern "C" {
| ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body
LL | async fn L() {
| ______________^___-
| | |
Expand All @@ -18,8 +18,8 @@ LL | | }
error: functions in `extern` blocks cannot have `async` qualifier
--> $DIR/issue-95829.rs:4:5
|
LL | extern {
| ------ in this `extern` block
LL | extern "C" {
| ---------- in this `extern` block
LL | async fn L() {
| ^^^^^ help: remove the `async` qualifier

Expand Down
1 change: 1 addition & 0 deletions tests/ui/extern/not-in-block.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![crate_type = "lib"]
#![allow(missing_abi)]

extern fn none_fn(x: bool) -> i32;
//~^ ERROR free function without a body
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/extern/not-in-block.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: free function without a body
--> $DIR/not-in-block.rs:3:1
--> $DIR/not-in-block.rs:4:1
|
LL | extern fn none_fn(x: bool) -> i32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -14,7 +14,7 @@ LL | extern { fn none_fn(x: bool) -> i32; }
| ~~~~~~~~ +

error: free function without a body
--> $DIR/not-in-block.rs:5:1
--> $DIR/not-in-block.rs:6:1
|
LL | extern "C" fn c_fn(x: bool) -> i32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/foreign/issue-91370-foreign-fn-block-impl.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Regression test for issue #91370.

extern {
extern "C" {
//~^ `extern` blocks define existing foreign functions
fn f() {
//~^ incorrect function inside `extern` block
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/foreign/issue-91370-foreign-fn-block-impl.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: incorrect function inside `extern` block
--> $DIR/issue-91370-foreign-fn-block-impl.rs:5:8
|
LL | extern {
| ------ `extern` blocks define existing foreign functions and functions inside of them cannot have a body
LL | extern "C" {
| ---------- `extern` blocks define existing foreign functions and functions inside of them cannot have a body
LL |
LL | fn f() {
| ________^___-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct S;
#[rustc_legacy_const_generics(0usize)] //~ ERROR suffixed literals are not allowed in attributes
fn foo6<const X: usize>() {}

extern {
extern "C" {
#[rustc_legacy_const_generics(1)] //~ ERROR attribute should be applied to a function
fn foo7<const X: usize>(); //~ ERROR foreign items may not have const parameters
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/linkage-attr/issue-109144.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![crate_type = "lib"]
#[link(kind = "static", modifiers = "+whole-archive,+bundle")]
//~^ ERROR `#[link]` attribute requires a `name = "string"` argument
extern {}
extern "C" {}
2 changes: 1 addition & 1 deletion tests/ui/lint/function-item-references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn baz(x: u32, y: u32) -> u32 { x + y }
unsafe fn unsafe_fn() { }
extern "C" fn c_fn() { }
unsafe extern "C" fn unsafe_c_fn() { }
unsafe extern fn variadic(_x: u32, _args: ...) { }
unsafe extern "C" fn variadic(_x: u32, _args: ...) { }
fn take_generic_ref<'a, T>(_x: &'a T) { }
fn take_generic_array<T, const N: usize>(_x: [T; N]) { }
fn multiple_generic<T, U>(_x: T, _y: U) { }
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/lint/lint-ctypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ extern "C" {
pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: uses type `Box<u32>`
pub fn raw_array(arr: [u8; 8]); //~ ERROR: uses type `[u8; 8]`

pub fn no_niche_a(a: Option<UnsafeCell<extern fn()>>);
pub fn no_niche_a(a: Option<UnsafeCell<extern "C" fn()>>);
//~^ ERROR: uses type `Option<UnsafeCell<extern "C" fn()>>`
pub fn no_niche_b(b: Option<UnsafeCell<&i32>>);
//~^ ERROR: uses type `Option<UnsafeCell<&i32>>`
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/lint/lint-ctypes.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ LL | pub fn raw_array(arr: [u8; 8]);
error: `extern` block uses type `Option<UnsafeCell<extern "C" fn()>>`, which is not FFI-safe
--> $DIR/lint-ctypes.rs:75:26
|
LL | pub fn no_niche_a(a: Option<UnsafeCell<extern fn()>>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
LL | pub fn no_niche_a(a: Option<UnsafeCell<extern "C" fn()>>);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
|
= help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum
= note: enum has no representation hint
Expand Down
Loading

0 comments on commit 2f57b1a

Please sign in to comment.