Run rustfmt on tests/run-make/.

With the exception of `tests/run-make/translation/test.rs`, which has a
syntax error.

The expected output in `rustdoc-error-lines/rmake.rs`'s required slight
tweaking.

The two `reproducible-build.rs` files need `// ignore-tidy-linelength`
because rustfmt produces lines longer than 100 chars, which tidy doesn't
like, yuk.
This commit is contained in:
Nicholas Nethercote 2024-05-29 15:01:33 +10:00
parent 70bc0c5b20
commit 3079bd96b9
136 changed files with 421 additions and 370 deletions

View File

@ -20,7 +20,7 @@ ignore = [
"/tests/incremental/", "/tests/incremental/",
"/tests/mir-opt/", "/tests/mir-opt/",
"/tests/pretty/", "/tests/pretty/",
"/tests/run-make/", "/tests/run-make/translation/test.rs", # Contains syntax errors.
"/tests/run-make-fulldeps/", "/tests/run-make-fulldeps/",
"/tests/run-pass-valgrind/", "/tests/run-pass-valgrind/",
"/tests/rustdoc/", "/tests/rustdoc/",

View File

@ -2,7 +2,7 @@
#![crate_type = "dylib"] #![crate_type = "dylib"]
#[cfg(x)] #[cfg(x)]
pub fn foo(x: u32) { } pub fn foo(x: u32) {}
#[cfg(y)] #[cfg(y)]
pub fn foo(x: i32) { } pub fn foo(x: i32) {}

View File

@ -2,4 +2,4 @@
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct Foo; pub struct Foo;
pub fn main() { } pub fn main() {}

View File

@ -2,4 +2,6 @@
extern crate bar; extern crate bar;
pub fn main() { bar::baz() } pub fn main() {
bar::baz()
}

View File

@ -1,5 +1,5 @@
#![feature(no_core, intrinsics, lang_items)] #![feature(no_core, intrinsics, lang_items)]
#![crate_type="rlib"] #![crate_type = "rlib"]
#![no_core] #![no_core]
extern "rust-intrinsic" { extern "rust-intrinsic" {

View File

@ -1,2 +1 @@
fn main() { fn main() {}
}

View File

@ -1,4 +1,4 @@
#![crate_type="lib"] #![crate_type = "lib"]
pub struct Foo(()); pub struct Foo(());
impl Foo { impl Foo {

View File

@ -1,4 +1,4 @@
#![crate_type="lib"] #![crate_type = "lib"]
extern crate foo; extern crate foo;
use foo::Foo; use foo::Foo;

View File

@ -1,16 +1,16 @@
#![crate_type = "staticlib"] #![crate_type = "staticlib"]
#![feature(c_variadic)] #![feature(c_variadic)]
use std::ffi::{c_char, c_double, c_int, c_long, c_longlong};
use std::ffi::VaList; use std::ffi::VaList;
use std::ffi::{CString, CStr}; use std::ffi::{c_char, c_double, c_int, c_long, c_longlong};
use std::ffi::{CStr, CString};
macro_rules! continue_if { macro_rules! continue_if {
($cond:expr) => { ($cond:expr) => {
if !($cond) { if !($cond) {
return 0xff; return 0xff;
} }
} };
} }
unsafe fn compare_c_str(ptr: *const c_char, val: &str) -> bool { unsafe fn compare_c_str(ptr: *const c_char, val: &str) -> bool {
@ -59,13 +59,11 @@ pub unsafe extern "C" fn check_list_copy_0(mut ap: VaList) -> usize {
continue_if!(ap.arg::<c_int>() == 16); continue_if!(ap.arg::<c_int>() == 16);
continue_if!(ap.arg::<c_char>() == 'A' as c_char); continue_if!(ap.arg::<c_char>() == 'A' as c_char);
continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Skip Me!")); continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Skip Me!"));
ap.with_copy(|mut ap| { ap.with_copy(
if compare_c_str(ap.arg::<*const c_char>(), "Correct") { |mut ap| {
0 if compare_c_str(ap.arg::<*const c_char>(), "Correct") { 0 } else { 0xff }
} else { },
0xff )
}
})
} }
#[no_mangle] #[no_mangle]

View File

@ -1,3 +1,3 @@
#![crate_type = "lib"] #![crate_type = "lib"]
extern crate b;
extern crate a; extern crate a;
extern crate b;

View File

@ -3,41 +3,20 @@ use std::process::Output;
use run_make_support::{bin_name, rust_lib_name, rustc}; use run_make_support::{bin_name, rust_lib_name, rustc};
fn compare_stdout<S: AsRef<str>>(output: Output, expected: S) { fn compare_stdout<S: AsRef<str>>(output: Output, expected: S) {
assert_eq!( assert_eq!(String::from_utf8(output.stdout).unwrap().trim(), expected.as_ref());
String::from_utf8(output.stdout).unwrap().trim(),
expected.as_ref()
);
} }
fn main() { fn main() {
compare_stdout(rustc().print("crate-name").input("crate.rs").run(), "foo"); compare_stdout(rustc().print("crate-name").input("crate.rs").run(), "foo");
compare_stdout(rustc().print("file-names").input("crate.rs").run(), bin_name("foo"));
compare_stdout( compare_stdout(
rustc().print("file-names").input("crate.rs").run(), rustc().print("file-names").crate_type("lib").arg("--test").input("crate.rs").run(),
bin_name("foo"), bin_name("foo"),
); );
compare_stdout( compare_stdout(
rustc() rustc().print("file-names").arg("--test").input("lib.rs").run(),
.print("file-names")
.crate_type("lib")
.arg("--test")
.input("crate.rs")
.run(),
bin_name("foo"),
);
compare_stdout(
rustc()
.print("file-names")
.arg("--test")
.input("lib.rs")
.run(),
bin_name("mylib"), bin_name("mylib"),
); );
compare_stdout( compare_stdout(rustc().print("file-names").input("lib.rs").run(), rust_lib_name("mylib"));
rustc().print("file-names").input("lib.rs").run(), compare_stdout(rustc().print("file-names").input("rlib.rs").run(), rust_lib_name("mylib"));
rust_lib_name("mylib"),
);
compare_stdout(
rustc().print("file-names").input("rlib.rs").run(),
rust_lib_name("mylib"),
);
} }

View File

@ -1,4 +1,4 @@
#![crate_type="staticlib"] #![crate_type = "staticlib"]
#[no_mangle] #[no_mangle]
pub extern "C" fn rust_always_inlined() -> u32 { pub extern "C" fn rust_always_inlined() -> u32 {

View File

@ -1,4 +1,4 @@
#![crate_type="staticlib"] #![crate_type = "staticlib"]
#[no_mangle] #[no_mangle]
pub extern "C" fn rust_always_inlined() -> u32 { pub extern "C" fn rust_always_inlined() -> u32 {

View File

@ -1,4 +1,4 @@
#![crate_type="staticlib"] #![crate_type = "staticlib"]
extern crate upstream; extern crate upstream;

View File

@ -15,19 +15,33 @@ fn main() {
fn debug_assert_eq() { fn debug_assert_eq() {
let mut hit1 = false; let mut hit1 = false;
let mut hit2 = false; let mut hit2 = false;
debug_assert_eq!({ hit1 = true; 1 }, { hit2 = true; 2 }); debug_assert_eq!(
{
hit1 = true;
1
},
{
hit2 = true;
2
}
);
assert!(!hit1); assert!(!hit1);
assert!(!hit2); assert!(!hit2);
} }
fn debug_assert() { fn debug_assert() {
let mut hit = false; let mut hit = false;
debug_assert!({ hit = true; false }); debug_assert!({
hit = true;
false
});
assert!(!hit); assert!(!hit);
} }
fn overflow() { fn overflow() {
fn add(a: u8, b: u8) -> u8 { a + b } fn add(a: u8, b: u8) -> u8 {
a + b
}
add(200u8, 200u8); add(200u8, 200u8);
} }

View File

@ -1,4 +1,4 @@
#[path="foo foo.rs"] #[path = "foo foo.rs"]
pub mod foo; pub mod foo;
pub mod bar; pub mod bar;

View File

@ -1,4 +1,4 @@
#![crate_name = "foo"] #![crate_name = "foo"]
pub mod foo;
pub mod bar; pub mod bar;
pub mod foo;

View File

@ -1,8 +1,10 @@
extern crate foo;
extern crate bar; extern crate bar;
extern crate foo;
pub struct Bar; pub struct Bar;
impl ::std::ops::Deref for Bar { impl ::std::ops::Deref for Bar {
type Target = bar::S; type Target = bar::S;
fn deref(&self) -> &Self::Target { unimplemented!() } fn deref(&self) -> &Self::Target {
unimplemented!()
}
} }

View File

@ -3,7 +3,9 @@
extern crate proc_macro; extern crate proc_macro;
#[proc_macro_derive(A)] #[proc_macro_derive(A)]
pub fn derive(ts: proc_macro::TokenStream) -> proc_macro::TokenStream { ts } pub fn derive(ts: proc_macro::TokenStream) -> proc_macro::TokenStream {
ts
}
#[derive(Debug)] #[derive(Debug)]
struct S; struct S;

View File

@ -1,4 +1,6 @@
#![crate_type = "dylib"] #![crate_type = "dylib"]
extern crate m1; extern crate m1;
pub fn m2() { m1::m1() } pub fn m2() {
m1::m1()
}

View File

@ -1,4 +1,6 @@
#![crate_type = "dylib"] #![crate_type = "dylib"]
extern crate m2; extern crate m2;
pub fn m3() { m2::m2() } pub fn m3() {
m2::m2()
}

View File

@ -1,3 +1,5 @@
extern crate m3; extern crate m3;
fn main() { m3::m3() } fn main() {
m3::m3()
}

View File

@ -6,16 +6,22 @@ fn main() {
type Key = u32; type Key = u32;
const NUM_THREADS: usize = 2; const NUM_THREADS: usize = 2;
#[derive(Clone,Copy)] #[derive(Clone, Copy)]
struct Stats<S> { struct Stats<S> {
upsert: S, upsert: S,
delete: S, delete: S,
insert: S, insert: S,
update: S update: S,
}; };
impl<S> Stats<S> where S: Copy { impl<S> Stats<S>
fn dot<B, F, T>(self, s: Stats<T>, f: F) -> Stats<B> where F: Fn(S, T) -> B { where
S: Copy,
{
fn dot<B, F, T>(self, s: Stats<T>, f: F) -> Stats<B>
where
F: Fn(S, T) -> B,
{
let Stats { upsert: u1, delete: d1, insert: i1, update: p1 } = self; let Stats { upsert: u1, delete: d1, insert: i1, update: p1 } = self;
let Stats { upsert: u2, delete: d2, insert: i2, update: p2 } = s; let Stats { upsert: u2, delete: d2, insert: i2, update: p2 } = s;
Stats { upsert: f(u1, u2), delete: f(d1, d2), insert: f(i1, i2), update: f(p1, p2) } Stats { upsert: f(u1, u2), delete: f(d1, d2), insert: f(i1, i2), update: f(p1, p2) }
@ -38,9 +44,12 @@ fn main() {
make_threads(); make_threads();
{ {
let Stats { ref upsert, ref delete, ref insert, ref update } = stats.iter().fold( let Stats { ref upsert, ref delete, ref insert, ref update } = stats
Stats::new(0), |res, &s| res.dot(s, |x: Key, y: Key| x.wrapping_add(y))); .iter()
println!("upserts: {}, deletes: {}, inserts: {}, updates: {}", .fold(Stats::new(0), |res, &s| res.dot(s, |x: Key, y: Key| x.wrapping_add(y)));
upsert, delete, insert, update); println!(
"upserts: {}, deletes: {}, inserts: {}, updates: {}",
upsert, delete, insert, update
);
} }
} }

View File

@ -1,5 +1,4 @@
#[macro_use] #[macro_use]
extern crate foo; extern crate foo;
fn main() { fn main() {}
}

View File

@ -3,4 +3,6 @@
static FOO: usize = 3; static FOO: usize = 3;
pub fn token() -> &'static usize { &FOO } pub fn token() -> &'static usize {
&FOO
}

View File

@ -5,5 +5,9 @@ extern crate a;
static FOO: usize = 3; static FOO: usize = 3;
pub fn token() -> &'static usize { &FOO } pub fn token() -> &'static usize {
pub fn a_token() -> &'static usize { a::token() } &FOO
}
pub fn a_token() -> &'static usize {
a::token()
}

View File

@ -5,5 +5,9 @@ extern crate a;
static FOO: usize = 3; static FOO: usize = 3;
pub fn token() -> &'static usize { &FOO } pub fn token() -> &'static usize {
pub fn a_token() -> &'static usize { a::token() } &FOO
}
pub fn a_token() -> &'static usize {
a::token()
}

View File

@ -1,9 +1,13 @@
#[cfg(before)] extern crate a; #[cfg(before)]
extern crate a;
#[cfg(after)]
extern crate a;
extern crate b; extern crate b;
extern crate c; extern crate c;
#[cfg(after)] extern crate a;
fn t(a: &'static usize) -> usize { a as *const _ as usize } fn t(a: &'static usize) -> usize {
a as *const _ as usize
}
fn main() { fn main() {
assert_eq!(t(a::token()), t(b::a_token())); assert_eq!(t(a::token()), t(b::a_token()));

View File

@ -1,6 +1,6 @@
// Issue #80127: Passing structs via FFI should work with explicit alignment. // Issue #80127: Passing structs via FFI should work with explicit alignment.
use std::ffi::{CStr, c_char}; use std::ffi::{c_char, CStr};
use std::ptr::null_mut; use std::ptr::null_mut;
#[repr(C)] #[repr(C)]
@ -18,7 +18,7 @@ pub struct TwoU64s {
#[repr(C)] #[repr(C)]
pub struct WrappedU64s { pub struct WrappedU64s {
pub a: TwoU64s pub a: TwoU64s,
} }
#[repr(C)] #[repr(C)]

View File

@ -1,14 +1,19 @@
#![crate_type = "dylib"] #![crate_type = "dylib"]
#![allow(dead_code)] #![allow(dead_code)]
#[no_mangle] pub extern "C" fn fun1() {} #[no_mangle]
#[no_mangle] extern "C" fn fun2() {} pub extern "C" fn fun1() {}
#[no_mangle]
extern "C" fn fun2() {}
mod foo { mod foo {
#[no_mangle] pub extern "C" fn fun3() {} #[no_mangle]
pub extern "C" fn fun3() {}
} }
pub mod bar { pub mod bar {
#[no_mangle] pub extern "C" fn fun4() {} #[no_mangle]
pub extern "C" fn fun4() {}
} }
#[no_mangle] pub fn fun5() {} #[no_mangle]
pub fn fun5() {}

View File

@ -90,8 +90,12 @@ extern "C" {
fn byval_rect_with_many_huge(a: Huge, b: Huge, c: Huge, d: Huge, e: Huge, f: Huge, g: Rect); fn byval_rect_with_many_huge(a: Huge, b: Huge, c: Huge, d: Huge, e: Huge, f: Huge, g: Rect);
fn byval_rect_with_many_huge64( fn byval_rect_with_many_huge64(
a: Huge64, b: Huge64, c: Huge64, a: Huge64,
d: Huge64, e: Huge64, f: Huge64, b: Huge64,
c: Huge64,
d: Huge64,
e: Huge64,
f: Huge64,
g: Rect, g: Rect,
); );

View File

@ -1,5 +1,5 @@
extern crate foo2; // foo2 first to exhibit the bug
extern crate foo1; extern crate foo1;
extern crate foo2; // foo2 first to exhibit the bug
fn main() { fn main() {
/* ... */ /* ... */

View File

@ -1,7 +1,6 @@
#![crate_type = "bin"] #![crate_type = "bin"]
#![no_main] #![no_main]
#![no_std] #![no_std]
#![deny(unused_extern_crates)] #![deny(unused_extern_crates)]
// `panic` provides a `panic_handler` so it shouldn't trip the `unused_extern_crates` lint // `panic` provides a `panic_handler` so it shouldn't trip the `unused_extern_crates` lint

View File

@ -9,8 +9,4 @@ fn main() {
// Basically, avoid modifying this file, including adding or removing whitespace! // Basically, avoid modifying this file, including adding or removing whitespace!
fn foo() { fn foo() {
assert_eq!(1, 1); assert_eq!(1, 1);
} }

View File

@ -8,5 +8,5 @@ fn main() {
// a.rs, the body must end on a line number which does not exist in b.rs. // a.rs, the body must end on a line number which does not exist in b.rs.
// Basically, avoid modifying this file, including adding or removing whitespace! // Basically, avoid modifying this file, including adding or removing whitespace!
fn foo() { fn foo() {
assert_eq!(1, 1);//// assert_eq!(1, 1); ////
} }

View File

@ -2,11 +2,9 @@
pub mod a { pub mod a {
#[inline(always)] #[inline(always)]
pub fn foo() { pub fn foo() {}
}
pub fn bar() { pub fn bar() {}
}
} }
#[no_mangle] #[no_mangle]

View File

@ -1,5 +1,5 @@
extern crate foo;
extern crate bar; extern crate bar;
extern crate foo;
fn main() { fn main() {
bar::doit(); bar::doit();

View File

@ -1,4 +1,4 @@
#![crate_type="lib"] #![crate_type = "lib"]
use std::arch::asm; use std::arch::asm;
#[deny(unreachable_code)] #[deny(unreachable_code)]

View File

@ -1,5 +1,5 @@
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![crate_type="lib"] #![crate_type = "lib"]
use std::arch::asm; use std::arch::asm;
use std::intrinsics; use std::intrinsics;

View File

@ -1,5 +1,5 @@
trait Foo { } trait Foo {}
trait Bar { } trait Bar {}
impl<'a> Foo for Bar + 'a { } impl<'a> Foo for Bar + 'a {}

View File

@ -1,4 +1,6 @@
fn identity(a: &u32) -> &u32 { a } fn identity(a: &u32) -> &u32 {
a
}
fn print_foo(f: &fn(&u32) -> &u32, x: &u32) { fn print_foo(f: &fn(&u32) -> &u32, x: &u32) {
print!("{}", (*f)(x)); print!("{}", (*f)(x));

View File

@ -2,4 +2,6 @@
/// assert_eq!(foo::foo(), 1); /// assert_eq!(foo::foo(), 1);
/// ``` /// ```
#[cfg(feature = "bar")] #[cfg(feature = "bar")]
pub fn foo() -> i32 { 1 } pub fn foo() -> i32 {
1
}

View File

@ -1,3 +1,3 @@
#![crate_type="rlib"] #![crate_type = "rlib"]
pub fn something(){} pub fn something() {}

View File

@ -1,4 +1,4 @@
#![feature(rustc_private)] #![feature(rustc_private)]
extern crate libc; extern crate libc;
fn main(){} fn main() {}

View File

@ -1,2 +1,3 @@
#![crate_type = "lib"] #![crate_type = "lib"]
#[macro_use] extern crate a; #[macro_use]
extern crate a;

View File

@ -7,9 +7,7 @@ struct Foo {
impl Foo { impl Foo {
const fn new() -> Self { const fn new() -> Self {
Self { Self { array: [0x1122_3344_5566_7788; 10240] }
array: [0x1122_3344_5566_7788; 10240]
}
} }
} }

View File

@ -2,8 +2,8 @@
#![feature(start)] #![feature(start)]
#![no_std] #![no_std]
extern crate alloc;
extern crate a; extern crate a;
extern crate alloc;
extern crate b; extern crate b;
use alloc::vec::Vec; use alloc::vec::Vec;

View File

@ -1 +1 @@
fn main() { } fn main() {}

View File

@ -13,13 +13,13 @@
use std::env; use std::env;
use std::fs::{self, File}; use std::fs::{self, File};
use std::io::{BufWriter, Write, Read}; use std::io::{BufWriter, Read, Write};
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Command; use std::process::Command;
fn main() { fn main() {
if !cfg!(windows) { if !cfg!(windows) {
return return;
} }
let tmpdir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); let tmpdir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
@ -31,16 +31,16 @@ fn main() {
let file = file.to_str().unwrap(); let file = file.to_str().unwrap();
fs::copy(&file[1..], &ok).unwrap(); fs::copy(&file[1..], &ok).unwrap();
} }
None => { File::create(&not_ok).unwrap(); } None => {
File::create(&not_ok).unwrap();
} }
return }
return;
} }
let rustc = env::var_os("RUSTC").unwrap_or("rustc".into()); let rustc = env::var_os("RUSTC").unwrap_or("rustc".into());
let me = env::current_exe().unwrap(); let me = env::current_exe().unwrap();
let bat = me.parent() let bat = me.parent().unwrap().join("foo.bat");
.unwrap()
.join("foo.bat");
let bat_linker = format!("linker={}", bat.display()); let bat_linker = format!("linker={}", bat.display());
for i in (1..).map(|i| i * 10) { for i in (1..).map(|i| i * 10) {
println!("attempt: {}", i); println!("attempt: {}", i);
@ -61,8 +61,10 @@ fn main() {
drop(fs::remove_file(&not_ok)); drop(fs::remove_file(&not_ok));
let status = Command::new(&rustc) let status = Command::new(&rustc)
.arg(&file) .arg(&file)
.arg("-C").arg(&bat_linker) .arg("-C")
.arg("--out-dir").arg(&tmpdir) .arg(&bat_linker)
.arg("--out-dir")
.arg(&tmpdir)
.env("YOU_ARE_A_LINKER", "1") .env("YOU_ARE_A_LINKER", "1")
.env("MY_LINKER", &me) .env("MY_LINKER", &me)
.status() .status()
@ -74,7 +76,7 @@ fn main() {
if !ok.exists() { if !ok.exists() {
assert!(not_ok.exists()); assert!(not_ok.exists());
continue continue;
} }
let mut contents = Vec::new(); let mut contents = Vec::new();
@ -96,6 +98,6 @@ fn main() {
assert!(contents.windows(exp.len()).any(|w| w == &exp[..])); assert!(contents.windows(exp.len()).any(|w| w == &exp[..]));
} }
break break;
} }
} }

View File

@ -34,9 +34,7 @@ fn write_test_case(file: &Path, n: usize) -> HashSet<String> {
fn read_linker_args(path: &Path) -> String { fn read_linker_args(path: &Path) -> String {
let contents = fs::read(path).unwrap(); let contents = fs::read(path).unwrap();
if cfg!(target_env = "msvc") { if cfg!(target_env = "msvc") {
let mut i = contents.chunks(2).map(|c| { let mut i = contents.chunks(2).map(|c| c[0] as u16 | ((c[1] as u16) << 8));
c[0] as u16 | ((c[1] as u16) << 8)
});
assert_eq!(i.next(), Some(0xfeff), "Expected UTF-16 BOM"); assert_eq!(i.next(), Some(0xfeff), "Expected UTF-16 BOM");
String::from_utf16(&i.collect::<Vec<u16>>()).unwrap() String::from_utf16(&i.collect::<Vec<u16>>()).unwrap()
} else { } else {
@ -52,7 +50,7 @@ fn main() {
let file = file.to_str().expect("non-utf8 file argument"); let file = file.to_str().expect("non-utf8 file argument");
fs::copy(&file[1..], &ok).unwrap(); fs::copy(&file[1..], &ok).unwrap();
} }
return return;
} }
let rustc = env::var_os("RUSTC").unwrap_or("rustc".into()); let rustc = env::var_os("RUSTC").unwrap_or("rustc".into());
@ -65,28 +63,35 @@ fn main() {
drop(fs::remove_file(&ok)); drop(fs::remove_file(&ok));
let output = Command::new(&rustc) let output = Command::new(&rustc)
.arg(&file) .arg(&file)
.arg("-C").arg(&me_as_linker) .arg("-C")
.arg("--out-dir").arg(&tmpdir) .arg(&me_as_linker)
.arg("--out-dir")
.arg(&tmpdir)
.env("YOU_ARE_A_LINKER", "1") .env("YOU_ARE_A_LINKER", "1")
.output() .output()
.unwrap(); .unwrap();
if !output.status.success() { if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr); let stderr = String::from_utf8_lossy(&output.stderr);
panic!("status: {}\nstdout:\n{}\nstderr:\n{}", panic!(
"status: {}\nstdout:\n{}\nstderr:\n{}",
output.status, output.status,
String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stdout),
stderr.lines().map(|l| { stderr
.lines()
.map(|l| {
if l.len() > 200 { if l.len() > 200 {
format!("{}...\n", &l[..200]) format!("{}...\n", &l[..200])
} else { } else {
format!("{}\n", l) format!("{}\n", l)
} }
}).collect::<String>()); })
.collect::<String>()
);
} }
if !ok.exists() { if !ok.exists() {
continue continue;
} }
let linker_args = read_linker_args(&ok); let linker_args = read_linker_args(&ok);
@ -101,6 +106,6 @@ fn main() {
linker_args, linker_args,
); );
break break;
} }
} }

View File

@ -1,4 +1,4 @@
#![crate_name="crateA"] #![crate_name = "crateA"]
// Base crate // Base crate
pub fn func<T>() {} pub fn func<T>() {}

View File

@ -1,4 +1,6 @@
#![crate_name="crateA"] #![crate_name = "crateA"]
// Base crate // Base crate
pub fn func<T>() { println!("hello"); } pub fn func<T>() {
println!("hello");
}

View File

@ -1,4 +1,6 @@
#![crate_name="crateA"] #![crate_name = "crateA"]
// Base crate // Base crate
pub fn foo<T>() { println!("world!"); } pub fn foo<T>() {
println!("world!");
}

View File

@ -3,4 +3,6 @@
static FOO: usize = 3; static FOO: usize = 3;
pub fn foo() -> &'static usize { &FOO } pub fn foo() -> &'static usize {
&FOO
}

View File

@ -3,4 +3,6 @@ extern crate both;
use std::mem; use std::mem;
pub fn addr() -> usize { unsafe { mem::transmute(&both::foo) } } pub fn addr() -> usize {
unsafe { mem::transmute(&both::foo) }
}

View File

@ -1,9 +1,8 @@
extern crate dylib;
extern crate both; extern crate both;
extern crate dylib;
use std::mem; use std::mem;
fn main() { fn main() {
assert_eq!(unsafe { mem::transmute::<&isize, usize>(&both::foo) }, assert_eq!(unsafe { mem::transmute::<&isize, usize>(&both::foo) }, dylib::addr());
dylib::addr());
} }

View File

@ -1,4 +1,6 @@
#![crate_type = "dylib"] #![crate_type = "dylib"]
extern crate rlib; extern crate rlib;
pub fn dylib() { rlib::rlib() } pub fn dylib() {
rlib::rlib()
}

View File

@ -1,9 +1,11 @@
use std::io::Write; use std::io::Write;
#[link(name = "c_static_lib_with_constructor", #[link(
name = "c_static_lib_with_constructor",
kind = "static", kind = "static",
modifiers = "-bundle,+whole-archive")] modifiers = "-bundle,+whole-archive"
extern {} )]
extern "C" {}
pub fn hello() { pub fn hello() {
print!("native_lib_in_src."); print!("native_lib_in_src.");

View File

@ -2,7 +2,9 @@
struct Destroy; struct Destroy;
impl Drop for Destroy { impl Drop for Destroy {
fn drop(&mut self) { println!("drop"); } fn drop(&mut self) {
println!("drop");
}
} }
thread_local! { thread_local! {

View File

@ -4,7 +4,7 @@ pub enum TT {
BB, BB,
} }
#[repr(C,u8)] #[repr(C, u8)]
pub enum T { pub enum T {
A(u64), A(u64),
B, B,
@ -16,6 +16,6 @@ extern "C" {
} }
fn main() { fn main() {
assert_eq!(33, unsafe { tt_add(TT::AA(1,2), TT::AA(10,20)) }); assert_eq!(33, unsafe { tt_add(TT::AA(1, 2), TT::AA(10, 20)) });
assert_eq!(11, unsafe { t_add(T::A(1), T::A(10)) }); assert_eq!(11, unsafe { t_add(T::A(1), T::A(10)) });
} }

View File

@ -1,2 +1 @@
fn main() { fn main() {}
}

View File

@ -1,5 +1,5 @@
#![crate_name="interesting"] #![crate_name = "interesting"]
#![crate_type="rlib"] #![crate_type = "rlib"]
extern crate opaque; extern crate opaque;
@ -22,7 +22,6 @@ pub fn function_called_42_times(c: char) {
// This branch is taken 12 times // This branch is taken 12 times
opaque::f1(); opaque::f1();
} else { } else {
if c == 'b' { if c == 'b' {
// This branch is taken 28 times // This branch is taken 28 times
opaque::f2(); opaque::f2();

View File

@ -1,5 +1,5 @@
#![crate_name="opaque"] #![crate_name = "opaque"]
#![crate_type="rlib"] #![crate_type = "rlib"]
pub fn f1() {} pub fn f1() {}
pub fn f2() {} pub fn f2() {}

View File

@ -1,5 +1,5 @@
#![crate_name="interesting"] #![crate_name = "interesting"]
#![crate_type="rlib"] #![crate_type = "rlib"]
extern crate opaque; extern crate opaque;
@ -15,7 +15,6 @@ pub fn function_called_never() {
#[no_mangle] #[no_mangle]
pub fn call_a_bunch_of_functions(fns: &[fn()]) { pub fn call_a_bunch_of_functions(fns: &[fn()]) {
// Indirect call promotion transforms the below into something like // Indirect call promotion transforms the below into something like
// //
// for f in fns { // for f in fns {
@ -33,13 +32,11 @@ pub fn call_a_bunch_of_functions(fns: &[fn()]) {
} }
} }
pub trait Foo { pub trait Foo {
fn foo(&self); fn foo(&self);
} }
impl Foo for u32 { impl Foo for u32 {
#[no_mangle] #[no_mangle]
fn foo(&self) { fn foo(&self) {
opaque::opaque_f2(); opaque::opaque_f2();
@ -48,7 +45,6 @@ impl Foo for u32 {
#[no_mangle] #[no_mangle]
pub fn call_a_bunch_of_trait_methods(trait_objects: &[&dyn Foo]) { pub fn call_a_bunch_of_trait_methods(trait_objects: &[&dyn Foo]) {
// Same as above, just with vtables in between // Same as above, just with vtables in between
for x in trait_objects { for x in trait_objects {
x.foo(); x.foo();

View File

@ -2,9 +2,8 @@ extern crate interesting;
fn main() { fn main() {
// function pointer case // function pointer case
let fns: Vec<_> = std::iter::repeat(interesting::function_called_always as fn()) let fns: Vec<_> =
.take(1000) std::iter::repeat(interesting::function_called_always as fn()).take(1000).collect();
.collect();
interesting::call_a_bunch_of_functions(&fns[..]); interesting::call_a_bunch_of_functions(&fns[..]);
// Trait object case // Trait object case

View File

@ -1,5 +1,5 @@
#![crate_name="opaque"] #![crate_name = "opaque"]
#![crate_type="rlib"] #![crate_type = "rlib"]
#[no_mangle] #[no_mangle]
pub fn opaque_f1() {} pub fn opaque_f1() {}

View File

@ -11,7 +11,7 @@ pub fn hot_function(c: u8) {
fn main() { fn main() {
let arg = std::env::args().skip(1).next().unwrap(); let arg = std::env::args().skip(1).next().unwrap();
for i in 0 .. 1000_000 { for i in 0..1000_000 {
let some_value = arg.as_bytes()[i % arg.len()]; let some_value = arg.as_bytes()[i % arg.len()];
if some_value == b'!' { if some_value == b'!' {
// This branch is never taken at runtime // This branch is never taken at runtime

View File

@ -4,5 +4,7 @@ extern "C" {
} }
fn main() { fn main() {
unsafe {foo();} unsafe {
foo();
}
} }

View File

@ -1,5 +1,5 @@
#[crate_type="lib"] #[crate_type = "lib"]
pub fn pub fn foo() -> i32 {
foo() -> i32 45
{ 45 } }

View File

@ -40,19 +40,21 @@ fn main() {
/*contains*/ &["feature", "feature=\"\"", "feature=\"test\"", "feature=\"lol\""], /*contains*/ &["feature", "feature=\"\"", "feature=\"test\"", "feature=\"lol\""],
); );
check( check(
/*args*/ &[ /*args*/
&[
r#"--check-cfg=cfg(feature, values(any()))"#, r#"--check-cfg=cfg(feature, values(any()))"#,
r#"--check-cfg=cfg(feature, values("tmp"))"# r#"--check-cfg=cfg(feature, values("tmp"))"#,
], ],
/*has_any*/ false, /*has_any*/ false,
/*has_any_any*/ false, /*has_any_any*/ false,
/*contains*/ &["unix", "miri", "feature=any()"], /*contains*/ &["unix", "miri", "feature=any()"],
); );
check( check(
/*args*/ &[ /*args*/
&[
r#"--check-cfg=cfg(has_foo, has_bar)"#, r#"--check-cfg=cfg(has_foo, has_bar)"#,
r#"--check-cfg=cfg(feature, values("tmp"))"#, r#"--check-cfg=cfg(feature, values("tmp"))"#,
r#"--check-cfg=cfg(feature, values("tmp"))"# r#"--check-cfg=cfg(feature, values("tmp"))"#,
], ],
/*has_any*/ false, /*has_any*/ false,
/*has_any_any*/ false, /*has_any_any*/ false,

View File

@ -1,2 +1,3 @@
#![crate_type = "lib"] #![crate_type = "lib"]
#[macro_use] extern crate a; #[macro_use]
extern crate a;

View File

@ -1,3 +1,3 @@
#![crate_type = "staticlib"] #![crate_type = "staticlib"]
extern crate b;
extern crate a; extern crate a;
extern crate b;

View File

@ -1 +1 @@
fn main() { } fn main() {}

View File

@ -2,7 +2,6 @@ extern crate raw_dylib_alt_calling_convention_test;
fn main() { fn main() {
raw_dylib_alt_calling_convention_test::library_function( raw_dylib_alt_calling_convention_test::library_function(
std::env::args().skip(1).next().map_or( std::env::args().skip(1).next().map_or(false, |s| std::str::FromStr::from_str(&s).unwrap()),
false, );
|s| std::str::FromStr::from_str(&s).unwrap()));
} }

View File

@ -1,16 +1,16 @@
#[link(name = "extern_1.dll", kind = "raw-dylib", modifiers = "+verbatim")] #[link(name = "extern_1.dll", kind = "raw-dylib", modifiers = "+verbatim")]
extern { extern "C" {
fn extern_fn_1(); fn extern_fn_1();
} }
#[link(name = "extern_2", kind = "raw-dylib")] #[link(name = "extern_2", kind = "raw-dylib")]
extern { extern "C" {
fn extern_fn_3(); fn extern_fn_3();
} }
pub fn library_function() { pub fn library_function() {
#[link(name = "extern_1", kind = "raw-dylib")] #[link(name = "extern_1", kind = "raw-dylib")]
extern { extern "C" {
fn extern_fn_2(); fn extern_fn_2();
fn print_extern_variable(); fn print_extern_variable();
static mut extern_variable: i32; static mut extern_variable: i32;

View File

@ -8,7 +8,7 @@
trait Sized {} trait Sized {}
#[link(name = "extern_1", kind = "raw-dylib")] #[link(name = "extern_1", kind = "raw-dylib")]
extern { extern "C" {
fn extern_fn(); fn extern_fn();
} }

View File

@ -1,5 +1,5 @@
#[link(name = "extern_1", kind = "raw-dylib")] #[link(name = "extern_1", kind = "raw-dylib")]
extern { extern "C" {
fn extern_fn_1(); fn extern_fn_1();
} }

View File

@ -76,7 +76,7 @@ extern "vectorcall" {
} }
#[link(name = "extern", kind = "raw-dylib")] #[link(name = "extern", kind = "raw-dylib")]
extern { extern "C" {
fn print_extern_variable_undecorated(); fn print_extern_variable_undecorated();
fn print_extern_variable_noprefix(); fn print_extern_variable_noprefix();
fn print_extern_variable_decorated(); fn print_extern_variable_decorated();

View File

@ -2,7 +2,7 @@ extern crate raw_dylib_test;
extern crate raw_dylib_test_wrapper; extern crate raw_dylib_test_wrapper;
#[link(name = "extern_2", kind = "raw-dylib")] #[link(name = "extern_2", kind = "raw-dylib")]
extern { extern "C" {
fn extern_fn_2(); fn extern_fn_2();
} }

View File

@ -1,5 +1,5 @@
#[link(name = "extern_1", kind = "raw-dylib")] #[link(name = "extern_1", kind = "raw-dylib")]
extern { extern "C" {
fn extern_fn_1(); fn extern_fn_1();
fn extern_fn_2(); fn extern_fn_2();
} }

View File

@ -1,5 +1,5 @@
#[link(name = "exporter", kind = "raw-dylib")] #[link(name = "exporter", kind = "raw-dylib")]
extern { extern "C" {
#[link_ordinal(13)] #[link_ordinal(13)]
fn imported_function(); fn imported_function();
#[link_ordinal(5)] #[link_ordinal(5)]

View File

@ -1,7 +1,7 @@
use std::env; use std::env;
use std::path::Path;
use std::fs::File; use std::fs::File;
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::path::Path;
fn main() { fn main() {
let mut dst = env::current_exe().unwrap(); let mut dst = env::current_exe().unwrap();
@ -19,7 +19,7 @@ fn main() {
if !path.is_file() { if !path.is_file() {
out.push_str(&arg); out.push_str(&arg);
out.push_str("\n"); out.push_str("\n");
continue continue;
} }
let mut contents = Vec::new(); let mut contents = Vec::new();

View File

@ -1,4 +1,4 @@
#![crate_type="lib"] #![crate_type = "lib"]
pub static STATIC: i32 = 1234; pub static STATIC: i32 = 1234;
@ -18,7 +18,7 @@ impl<T1, T2> Drop for Struct<T1, T2> {
pub enum Enum { pub enum Enum {
Variant1, Variant1,
Variant2(u32), Variant2(u32),
Variant3 { x: u32 } Variant3 { x: u32 },
} }
pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64); pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64);

View File

@ -18,6 +18,8 @@
// - Trait object shims // - Trait object shims
// - Fn Pointer shims // - Fn Pointer shims
// ignore-tidy-linelength
#![allow(dead_code, warnings)] #![allow(dead_code, warnings)]
extern crate reproducible_build_aux; extern crate reproducible_build_aux;
@ -40,7 +42,7 @@ impl<T1, T2> Drop for Struct<T1, T2> {
pub enum Enum { pub enum Enum {
Variant1, Variant1,
Variant2(u32), Variant2(u32),
Variant3 { x: u32 } Variant3 { x: u32 },
} }
struct TupleStruct(i8, i16, i32, i64); struct TupleStruct(i8, i16, i32, i64);
@ -67,19 +69,14 @@ fn main() {
generic_fn::<char, Struct<u32, u64>>(); generic_fn::<char, Struct<u32, u64>>();
generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>(); generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>();
let dropped = Struct { let dropped = Struct { x: "", y: 'a' };
x: "",
y: 'a',
};
let _ = Enum::Variant1; let _ = Enum::Variant1;
let _ = Enum::Variant2(0); let _ = Enum::Variant2(0);
let _ = Enum::Variant3 { x: 0 }; let _ = Enum::Variant3 { x: 0 };
let _ = TupleStruct(1, 2, 3, 4); let _ = TupleStruct(1, 2, 3, 4);
let closure = |x| { let closure = |x| x + 1i32;
x + 1i32
};
fn inner<F: Fn(i32) -> i32>(f: F) -> i32 { fn inner<F: Fn(i32) -> i32>(f: F) -> i32 {
f(STATIC) f(STATIC)
@ -94,13 +91,13 @@ fn main() {
f(0); f(0);
} }
with_fn_once_adapter(|_:i32| { }); with_fn_once_adapter(|_: i32| {});
reproducible_build_aux::regular_fn(STATIC); reproducible_build_aux::regular_fn(STATIC);
reproducible_build_aux::generic_fn::<u32, char>(); reproducible_build_aux::generic_fn::<u32, char>();
reproducible_build_aux::generic_fn::<char, Struct<u32, u64>>(); reproducible_build_aux::generic_fn::<char, Struct<u32, u64>>();
reproducible_build_aux::generic_fn::<Struct<u64, u32>, reproducible_build_aux::generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>(
reproducible_build_aux::Struct<u32, u64>>(); );
let _ = reproducible_build_aux::Enum::Variant1; let _ = reproducible_build_aux::Enum::Variant1;
let _ = reproducible_build_aux::Enum::Variant2(0); let _ = reproducible_build_aux::Enum::Variant2(0);

View File

@ -1,7 +1,7 @@
use std::env; use std::env;
use std::path::Path;
use std::fs::File; use std::fs::File;
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::path::Path;
fn main() { fn main() {
let mut dst = env::current_exe().unwrap(); let mut dst = env::current_exe().unwrap();
@ -19,7 +19,7 @@ fn main() {
if !path.is_file() { if !path.is_file() {
out.push_str(&arg); out.push_str(&arg);
out.push_str("\n"); out.push_str("\n");
continue continue;
} }
let mut contents = Vec::new(); let mut contents = Vec::new();

View File

@ -1,4 +1,4 @@
#![crate_type="lib"] #![crate_type = "lib"]
pub static STATIC: i32 = 1234; pub static STATIC: i32 = 1234;
@ -18,7 +18,7 @@ impl<T1, T2> Drop for Struct<T1, T2> {
pub enum Enum { pub enum Enum {
Variant1, Variant1,
Variant2(u32), Variant2(u32),
Variant3 { x: u32 } Variant3 { x: u32 },
} }
pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64); pub struct TupleStruct(pub i8, pub i16, pub i32, pub i64);

View File

@ -18,6 +18,8 @@
// - Trait object shims // - Trait object shims
// - Fn Pointer shims // - Fn Pointer shims
// ignore-tidy-linelength
#![allow(dead_code, warnings)] #![allow(dead_code, warnings)]
extern crate reproducible_build_aux; extern crate reproducible_build_aux;
@ -40,7 +42,7 @@ impl<T1, T2> Drop for Struct<T1, T2> {
pub enum Enum { pub enum Enum {
Variant1, Variant1,
Variant2(u32), Variant2(u32),
Variant3 { x: u32 } Variant3 { x: u32 },
} }
struct TupleStruct(i8, i16, i32, i64); struct TupleStruct(i8, i16, i32, i64);
@ -67,19 +69,14 @@ fn main() {
generic_fn::<char, Struct<u32, u64>>(); generic_fn::<char, Struct<u32, u64>>();
generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>(); generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>();
let dropped = Struct { let dropped = Struct { x: "", y: 'a' };
x: "",
y: 'a',
};
let _ = Enum::Variant1; let _ = Enum::Variant1;
let _ = Enum::Variant2(0); let _ = Enum::Variant2(0);
let _ = Enum::Variant3 { x: 0 }; let _ = Enum::Variant3 { x: 0 };
let _ = TupleStruct(1, 2, 3, 4); let _ = TupleStruct(1, 2, 3, 4);
let closure = |x| { let closure = |x| x + 1i32;
x + 1i32
};
fn inner<F: Fn(i32) -> i32>(f: F) -> i32 { fn inner<F: Fn(i32) -> i32>(f: F) -> i32 {
f(STATIC) f(STATIC)
@ -94,13 +91,13 @@ fn main() {
f(0); f(0);
} }
with_fn_once_adapter(|_:i32| { }); with_fn_once_adapter(|_: i32| {});
reproducible_build_aux::regular_fn(STATIC); reproducible_build_aux::regular_fn(STATIC);
reproducible_build_aux::generic_fn::<u32, char>(); reproducible_build_aux::generic_fn::<u32, char>();
reproducible_build_aux::generic_fn::<char, Struct<u32, u64>>(); reproducible_build_aux::generic_fn::<char, Struct<u32, u64>>();
reproducible_build_aux::generic_fn::<Struct<u64, u32>, reproducible_build_aux::generic_fn::<Struct<u64, u32>, reproducible_build_aux::Struct<u32, u64>>(
reproducible_build_aux::Struct<u32, u64>>(); );
let _ = reproducible_build_aux::Enum::Variant1; let _ = reproducible_build_aux::Enum::Variant1;
let _ = reproducible_build_aux::Enum::Variant2(0); let _ = reproducible_build_aux::Enum::Variant2(0);

View File

@ -1 +1 @@
fn main() { } fn main() {}

View File

@ -2,4 +2,6 @@
extern crate foo; extern crate foo;
pub fn bar() { foo::foo() } pub fn bar() {
foo::foo()
}

View File

@ -2,4 +2,6 @@
extern crate bar; extern crate bar;
pub fn baz() { bar::bar() } pub fn baz() {
bar::bar()
}

View File

@ -4,7 +4,7 @@ pub enum TT {
BB, BB,
} }
#[repr(C,u8)] #[repr(C, u8)]
pub enum T { pub enum T {
A(u64), A(u64),
B, B,

View File

@ -9,7 +9,7 @@ pub extern "C" fn tt_new(a: u64, b: u64) -> TT {
TT::AA(a, b) TT::AA(a, b)
} }
#[repr(C,u8)] #[repr(C, u8)]
pub enum T { pub enum T {
A(u64), A(u64),
B, B,

View File

@ -1,4 +1,6 @@
#![crate_type = "rlib"] #![crate_type = "rlib"]
extern crate m1; extern crate m1;
pub fn m2() { m1::m1() } pub fn m2() {
m1::m1()
}

View File

@ -1,4 +1,6 @@
#![crate_type = "rlib"] #![crate_type = "rlib"]
extern crate m2; extern crate m2;
pub fn m3() { m2::m2() } pub fn m3() {
m2::m2()
}

View File

@ -1,3 +1,5 @@
extern crate m3; extern crate m3;
fn main() { m3::m3() } fn main() {
m3::m3()
}

View File

@ -6,9 +6,7 @@
/// #![feature(bool_to_option)] /// #![feature(bool_to_option)]
/// let x: char = 1; /// let x: char = 1;
/// ``` /// ```
pub fn foo() { pub fn foo() {}
}
/// Add some text around the test... /// Add some text around the test...
/// ///

View File

@ -11,10 +11,10 @@ fn main() {
let should_contain = &[ let should_contain = &[
"input.rs - foo (line 5)", "input.rs - foo (line 5)",
"input.rs:7:15", "input.rs:7:15",
"input.rs - bar (line 15)", "input.rs - bar (line 13)",
"input.rs:17:15", "input.rs:15:15",
"input.rs - bar (line 24)", "input.rs - bar (line 22)",
"input.rs:26:15", "input.rs:24:15",
]; ];
for text in should_contain { for text in should_contain {
assert!(output.contains(text), "output doesn't contains {:?}", text); assert!(output.contains(text), "output doesn't contains {:?}", text);

View File

@ -1,5 +1,5 @@
pub use private::Quz;
pub use hidden::Bar; pub use hidden::Bar;
pub use private::Quz;
mod private { mod private {
pub struct Quz; pub struct Quz;
@ -12,5 +12,5 @@ pub mod hidden {
#[macro_export] #[macro_export]
macro_rules! foo { macro_rules! foo {
() => {} () => {};
} }

View File

@ -1 +1,3 @@
pub const fn f() -> usize { 5 } pub const fn f() -> usize {
5
}

View File

@ -24,4 +24,4 @@ fn d() {
a_rules_macro!(()); // no a_rules_macro!(()); // no
} }
fn main(){} fn main() {}

Some files were not shown because too many files have changed in this diff Show More