diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:41 +0000 |
commit | 4f9fe856a25ab29345b90e7725509e9ee38a37be (patch) | |
tree | e4ffd8a9374cae7b21f7cbfb352927e0e074aff6 /tests/run-make | |
parent | Adding upstream version 1.68.2+dfsg1. (diff) | |
download | rustc-upstream/1.69.0+dfsg1.tar.xz rustc-upstream/1.69.0+dfsg1.zip |
Adding upstream version 1.69.0+dfsg1.upstream/1.69.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
44 files changed, 148 insertions, 1084 deletions
diff --git a/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs b/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs index 3aa57d589..8dac53c2a 100644 --- a/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs +++ b/tests/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs @@ -27,6 +27,8 @@ use std::any::Any; struct TheBackend; impl CodegenBackend for TheBackend { + fn locale_resource(&self) -> &'static str { "" } + fn codegen_crate<'a, 'tcx>( &self, tcx: TyCtxt<'tcx>, diff --git a/tests/run-make-fulldeps/issue-19371/foo.rs b/tests/run-make-fulldeps/issue-19371/foo.rs index 5bb38fc02..53ec79e47 100644 --- a/tests/run-make-fulldeps/issue-19371/foo.rs +++ b/tests/run-make-fulldeps/issue-19371/foo.rs @@ -53,6 +53,7 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) { output_file: Some(output), output_dir: None, file_loader: None, + locale_resources: &[], lint_caps: Default::default(), parse_sess_created: None, register_lints: None, diff --git a/tests/run-make-fulldeps/issues-41478-43796/Makefile b/tests/run-make-fulldeps/issues-41478-43796/Makefile deleted file mode 100644 index e451cb031..000000000 --- a/tests/run-make-fulldeps/issues-41478-43796/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -include ../tools.mk - -all: - # Work in /tmp, because we need to create the `save-analysis-temp` folder. - cp a.rs $(TMPDIR)/ - cd $(TMPDIR) && $(RUSTC) -Zsave-analysis $(TMPDIR)/a.rs 2> $(TMPDIR)/stderr.txt || ( cat $(TMPDIR)/stderr.txt && exit 1 ) - [ ! -s $(TMPDIR)/stderr.txt ] || ( cat $(TMPDIR)/stderr.txt && exit 1 ) - [ -f $(TMPDIR)/save-analysis/liba.json ] || ( ls -la $(TMPDIR) && exit 1 ) diff --git a/tests/run-make-fulldeps/issues-41478-43796/a.rs b/tests/run-make-fulldeps/issues-41478-43796/a.rs deleted file mode 100644 index b072235b5..000000000 --- a/tests/run-make-fulldeps/issues-41478-43796/a.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![crate_type = "lib"] -pub struct V<S>(#[allow(unused_tuple_struct_fields)] S); -pub trait An { - type U; -} -pub trait F<A> { -} -impl<A: An> F<A> for V<<A as An>::U> { -} diff --git a/tests/run-make-fulldeps/save-analysis-fail/Makefile b/tests/run-make-fulldeps/save-analysis-fail/Makefile deleted file mode 100644 index 69a2b2746..000000000 --- a/tests/run-make-fulldeps/save-analysis-fail/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -include ../tools.mk -all: code -krate2: krate2.rs - $(RUSTC) $< -code: foo.rs krate2 - $(RUSTC) foo.rs -Zsave-analysis || exit 0 diff --git a/tests/run-make-fulldeps/save-analysis-fail/SameDir.rs b/tests/run-make-fulldeps/save-analysis-fail/SameDir.rs deleted file mode 100644 index 2c690d5f7..000000000 --- a/tests/run-make-fulldeps/save-analysis-fail/SameDir.rs +++ /dev/null @@ -1,5 +0,0 @@ -// sub-module in the same directory as the main crate file - -pub struct SameStruct { - pub name: String -} diff --git a/tests/run-make-fulldeps/save-analysis-fail/SameDir3.rs b/tests/run-make-fulldeps/save-analysis-fail/SameDir3.rs deleted file mode 100644 index fab03ee2e..000000000 --- a/tests/run-make-fulldeps/save-analysis-fail/SameDir3.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub fn hello(x: isize) { - println!("macro {} :-(", x); -} diff --git a/tests/run-make-fulldeps/save-analysis-fail/SubDir/mod.rs b/tests/run-make-fulldeps/save-analysis-fail/SubDir/mod.rs deleted file mode 100644 index 511721d92..000000000 --- a/tests/run-make-fulldeps/save-analysis-fail/SubDir/mod.rs +++ /dev/null @@ -1,27 +0,0 @@ -// sub-module in a sub-directory - -use sub::sub2 as msalias; -use sub::sub2; - -static yy: usize = 25; - -mod sub { - pub mod sub2 { - pub mod sub3 { - pub fn hello() { - println!("hello from module 3"); - } - } - pub fn hello() { - println!("hello from a module"); - } - - pub struct nested_struct { - pub field2: u32, - } - } -} - -pub struct SubStruct { - pub name: String -} diff --git a/tests/run-make-fulldeps/save-analysis-fail/foo.rs b/tests/run-make-fulldeps/save-analysis-fail/foo.rs deleted file mode 100644 index c5a70605e..000000000 --- a/tests/run-make-fulldeps/save-analysis-fail/foo.rs +++ /dev/null @@ -1,463 +0,0 @@ -#![crate_name = "test"] -#![feature(rustc_private)] - -extern crate rustc_graphviz; -// A simple rust project - -extern crate krate2; -extern crate krate2 as krate3; - -use rustc_graphviz::RenderOption; -use std::cell::RefCell; -use std::collections::{HashMap, HashSet}; -use std::io::Write; - -use sub::sub2 as msalias; -use sub::sub2; -use sub::sub2::nested_struct as sub_struct; - -use std::mem::size_of; - -use std::char::from_u32; - -static uni: &'static str = "Les Miséééééééérables"; -static yy: usize = 25; - -static bob: Option<graphviz::RenderOption> = None; - -// buglink test - see issue #1337. - -fn test_alias<I: Iterator>(i: Option<<I as Iterator>::Item>) { - let s = sub_struct { field2: 45u32 }; - - // import tests - fn foo(x: &Write) {} - let _: Option<_> = from_u32(45); - - let x = 42usize; - - krate2::hello(); - krate3::hello(); - - let x = (3isize, 4usize); - let y = x.1; -} - -// Issue #37700 -const LUT_BITS: usize = 3; -pub struct HuffmanTable { - ac_lut: Option<[(i16, u8); 1 << LUT_BITS]>, -} - -struct TupStruct(isize, isize, Box<str>); - -fn test_tup_struct(x: TupStruct) -> isize { - x.1 -} - -fn println(s: &str) { - std::io::stdout().write_all(s.as_bytes()); -} - -mod sub { - pub mod sub2 { - use std::io::Write; - pub mod sub3 { - use std::io::Write; - pub fn hello() { - ::println("hello from module 3"); - } - } - pub fn hello() { - ::println("hello from a module"); - } - - pub struct nested_struct { - pub field2: u32, - } - - pub enum nested_enum { - Nest2 = 2, - Nest3 = 3, - } - } -} - -pub mod SameDir; -pub mod SubDir; - -#[path = "SameDir3.rs"] -pub mod SameDir2; - -struct nofields; - -#[derive(Clone)] -struct some_fields { - field1: u32, -} - -type SF = some_fields; - -trait SuperTrait { - fn qux(&self) { - panic!(); - } -} - -trait SomeTrait: SuperTrait { - fn Method(&self, x: u32) -> u32; - - fn prov(&self, x: u32) -> u32 { - println(&x.to_string()); - 42 - } - fn provided_method(&self) -> u32 { - 42 - } -} - -trait SubTrait: SomeTrait { - fn stat2(x: &Self) -> u32 { - 32 - } -} - -trait SizedTrait: Sized {} - -fn error(s: &SizedTrait) { - let foo = 42; - println!("Hello world! {}", foo); -} - -impl SomeTrait for some_fields { - fn Method(&self, x: u32) -> u32 { - println(&x.to_string()); - self.field1 - } -} - -impl SuperTrait for some_fields {} - -impl SubTrait for some_fields {} - -impl some_fields { - fn stat(x: u32) -> u32 { - println(&x.to_string()); - 42 - } - fn stat2(x: &some_fields) -> u32 { - 42 - } - - fn align_to<T>(&mut self) {} - - fn test(&mut self) { - self.align_to::<bool>(); - } -} - -impl SuperTrait for nofields {} -impl SomeTrait for nofields { - fn Method(&self, x: u32) -> u32 { - self.Method(x); - 43 - } - - fn provided_method(&self) -> u32 { - 21 - } -} - -impl SubTrait for nofields {} - -impl SuperTrait for (Box<nofields>, Box<some_fields>) {} - -fn f_with_params<T: SomeTrait>(x: &T) { - x.Method(41); -} - -type MyType = Box<some_fields>; - -enum SomeEnum<'a> { - Ints(isize, isize), - Floats(f64, f64), - Strings(&'a str, &'a str, &'a str), - MyTypes(MyType, MyType), -} - -#[derive(Copy, Clone)] -enum SomeOtherEnum { - SomeConst1, - SomeConst2, - SomeConst3, -} - -enum SomeStructEnum { - EnumStruct { a: isize, b: isize }, - EnumStruct2 { f1: MyType, f2: MyType }, - EnumStruct3 { f1: MyType, f2: MyType, f3: SomeEnum<'static> }, -} - -fn matchSomeEnum(val: SomeEnum) { - match val { - SomeEnum::Ints(int1, int2) => { - println(&(int1 + int2).to_string()); - } - SomeEnum::Floats(float1, float2) => { - println(&(float2 * float1).to_string()); - } - SomeEnum::Strings(.., s3) => { - println(s3); - } - SomeEnum::MyTypes(mt1, mt2) => { - println(&(mt1.field1 - mt2.field1).to_string()); - } - } -} - -fn matchSomeStructEnum(se: SomeStructEnum) { - match se { - SomeStructEnum::EnumStruct { a: a, .. } => println(&a.to_string()), - SomeStructEnum::EnumStruct2 { f1: f1, f2: f_2 } => println(&f_2.field1.to_string()), - SomeStructEnum::EnumStruct3 { f1, .. } => println(&f1.field1.to_string()), - } -} - -fn matchSomeStructEnum2(se: SomeStructEnum) { - use SomeStructEnum::*; - match se { - EnumStruct { a: ref aaa, .. } => println(&aaa.to_string()), - EnumStruct2 { f1, f2: f2 } => println(&f1.field1.to_string()), - EnumStruct3 { f1, f3: SomeEnum::Ints(..), f2 } => println(&f1.field1.to_string()), - _ => {} - } -} - -fn matchSomeOtherEnum(val: SomeOtherEnum) { - use SomeOtherEnum::{SomeConst2, SomeConst3}; - match val { - SomeOtherEnum::SomeConst1 => { - println("I'm const1."); - } - SomeConst2 | SomeConst3 => { - println("I'm const2 or const3."); - } - } -} - -fn hello<X: SomeTrait>((z, a): (u32, String), ex: X) { - SameDir2::hello(43); - - println(&yy.to_string()); - let (x, y): (u32, u32) = (5, 3); - println(&x.to_string()); - println(&z.to_string()); - let x: u32 = x; - println(&x.to_string()); - let x = "hello"; - println(x); - - let x = 32.0f32; - let _ = (x + ((x * x) + 1.0).sqrt()).ln(); - - let s: Box<SomeTrait> = Box::new(some_fields { field1: 43 }); - let s2: Box<some_fields> = Box::new(some_fields { field1: 43 }); - let s3 = Box::new(nofields); - - s.Method(43); - s3.Method(43); - s2.Method(43); - - ex.prov(43); - - let y: u32 = 56; - // static method on struct - let r = some_fields::stat(y); - // trait static method, calls default - let r = SubTrait::stat2(&*s3); - - let s4 = s3 as Box<SomeTrait>; - s4.Method(43); - - s4.provided_method(); - s2.prov(45); - - let closure = |x: u32, s: &SomeTrait| { - s.Method(23); - return x + y; - }; - - let z = closure(10, &*s); -} - -pub struct blah { - used_link_args: RefCell<[&'static str; 0]>, -} - -#[macro_use] -mod macro_use_test { - macro_rules! test_rec { - (q, $src: expr) => {{ - print!("{}", $src); - test_rec!($src); - }}; - ($src: expr) => { - print!("{}", $src); - }; - } - - macro_rules! internal_vars { - ($src: ident) => {{ - let mut x = $src; - x += 100; - }}; - } -} - -fn main() { - // foo - let s = Box::new(some_fields { field1: 43 }); - hello((43, "a".to_string()), *s); - sub::sub2::hello(); - sub2::sub3::hello(); - - let h = sub2::sub3::hello; - h(); - - // utf8 chars - let ut = "Les Miséééééééérables"; - - // For some reason, this pattern of macro_rules foiled our generated code - // avoiding strategy. - macro_rules! variable_str(($name:expr) => ( - some_fields { - field1: $name, - } - )); - let vs = variable_str!(32); - - let mut candidates: RefCell<HashMap<&'static str, &'static str>> = RefCell::new(HashMap::new()); - let _ = blah { used_link_args: RefCell::new([]) }; - let s1 = nofields; - let s2 = SF { field1: 55 }; - let s3: some_fields = some_fields { field1: 55 }; - let s4: msalias::nested_struct = sub::sub2::nested_struct { field2: 55 }; - let s4: msalias::nested_struct = sub2::nested_struct { field2: 55 }; - println(&s2.field1.to_string()); - let s5: MyType = Box::new(some_fields { field1: 55 }); - let s = SameDir::SameStruct { name: "Bob".to_string() }; - let s = SubDir::SubStruct { name: "Bob".to_string() }; - let s6: SomeEnum = SomeEnum::MyTypes(Box::new(s2.clone()), s5); - let s7: SomeEnum = SomeEnum::Strings("one", "two", "three"); - matchSomeEnum(s6); - matchSomeEnum(s7); - let s8: SomeOtherEnum = SomeOtherEnum::SomeConst2; - matchSomeOtherEnum(s8); - let s9: SomeStructEnum = - SomeStructEnum::EnumStruct2 { f1: Box::new(some_fields { field1: 10 }), f2: Box::new(s2) }; - matchSomeStructEnum(s9); - - for x in &vec![1, 2, 3] { - let _y = x; - } - - let s7: SomeEnum = SomeEnum::Strings("one", "two", "three"); - if let SomeEnum::Strings(..) = s7 { - println!("hello!"); - } - - for i in 0..5 { - foo_foo(i); - } - - if let Some(x) = None { - foo_foo(x); - } - - if false { - } else if let Some(y) = None { - foo_foo(y); - } - - while let Some(z) = None { - foo_foo(z); - } - - let mut x = 4; - test_rec!(q, "Hello"); - assert_eq!(x, 4); - internal_vars!(x); -} - -fn foo_foo(_: i32) {} - -impl Iterator for nofields { - type Item = (usize, usize); - - fn next(&mut self) -> Option<(usize, usize)> { - panic!() - } - - fn size_hint(&self) -> (usize, Option<usize>) { - panic!() - } -} - -trait Pattern<'a> { - type Searcher; -} - -struct CharEqPattern; - -impl<'a> Pattern<'a> for CharEqPattern { - type Searcher = CharEqPattern; -} - -struct CharSearcher<'a>(<CharEqPattern as Pattern<'a>>::Searcher); - -pub trait Error {} - -impl Error + 'static { - pub fn is<T: Error + 'static>(&self) -> bool { - panic!() - } -} - -impl Error + 'static + Send { - pub fn is<T: Error + 'static>(&self) -> bool { - <Error + 'static>::is::<T>(self) - } -} -extern crate serialize; -#[derive(Clone, Copy, Hash, Encodable, Decodable, PartialEq, Eq, PartialOrd, Ord, Debug, Default)] -struct AllDerives(i32); - -fn test_format_args() { - let x = 1; - let y = 2; - let name = "Joe Blogg"; - println!("Hello {}", name); - print!("Hello {0}", name); - print!("{0} + {} = {}", x, y); - print!("x is {}, y is {1}, name is {n}", x, y, n = name); -} - -extern "C" { - static EXTERN_FOO: u8; - fn extern_foo(a: u8, b: i32) -> String; -} - -struct Rls699 { - f: u32, -} - -fn new(f: u32) -> Rls699 { - Rls699 { fs } -} - -fn invalid_tuple_struct_access() { - bar.0; - - struct S; - S.0; -} diff --git a/tests/run-make-fulldeps/save-analysis-fail/krate2.rs b/tests/run-make-fulldeps/save-analysis-fail/krate2.rs deleted file mode 100644 index 7d787e0c9..000000000 --- a/tests/run-make-fulldeps/save-analysis-fail/krate2.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![ crate_name = "krate2" ] -#![ crate_type = "lib" ] - -use std::io::Write; - -pub fn hello() { - std::io::stdout().write_all(b"hello world!\n"); -} diff --git a/tests/run-make-fulldeps/save-analysis-rfc2126/Makefile b/tests/run-make-fulldeps/save-analysis-rfc2126/Makefile deleted file mode 100644 index 30f57034b..000000000 --- a/tests/run-make-fulldeps/save-analysis-rfc2126/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -include ../tools.mk - -all: extern_absolute_paths.rs krate2 - $(RUSTC) extern_absolute_paths.rs -Zsave-analysis --edition=2018 --extern krate2 - cat $(TMPDIR)/save-analysis/extern_absolute_paths.json | "$(PYTHON)" validate_json.py - -krate2: krate2.rs - $(RUSTC) $< diff --git a/tests/run-make-fulldeps/save-analysis-rfc2126/extern_absolute_paths.rs b/tests/run-make-fulldeps/save-analysis-rfc2126/extern_absolute_paths.rs deleted file mode 100644 index 7a8e3fff0..000000000 --- a/tests/run-make-fulldeps/save-analysis-rfc2126/extern_absolute_paths.rs +++ /dev/null @@ -1,6 +0,0 @@ -use krate2::hello; - -fn main() { - hello(); - ::krate2::hello(); -} diff --git a/tests/run-make-fulldeps/save-analysis-rfc2126/krate2.rs b/tests/run-make-fulldeps/save-analysis-rfc2126/krate2.rs deleted file mode 100644 index d24c68862..000000000 --- a/tests/run-make-fulldeps/save-analysis-rfc2126/krate2.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![crate_name = "krate2"] -#![crate_type = "lib"] - -pub fn hello() { -} diff --git a/tests/run-make-fulldeps/save-analysis-rfc2126/validate_json.py b/tests/run-make-fulldeps/save-analysis-rfc2126/validate_json.py deleted file mode 100644 index 882d29a8b..000000000 --- a/tests/run-make-fulldeps/save-analysis-rfc2126/validate_json.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env python - -import sys -import json - -crates = json.loads(sys.stdin.readline().strip())["prelude"]["external_crates"] -assert any(map(lambda c: c["id"]["name"] == "krate2", crates)) diff --git a/tests/run-make-fulldeps/save-analysis/Makefile b/tests/run-make-fulldeps/save-analysis/Makefile deleted file mode 100644 index b8b6be13d..000000000 --- a/tests/run-make-fulldeps/save-analysis/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -include ../tools.mk -all: code -krate2: krate2.rs - $(RUSTC) $< -code: foo.rs krate2 - $(RUSTC) foo.rs -Zsave-analysis diff --git a/tests/run-make-fulldeps/save-analysis/SameDir.rs b/tests/run-make-fulldeps/save-analysis/SameDir.rs deleted file mode 100644 index 2c690d5f7..000000000 --- a/tests/run-make-fulldeps/save-analysis/SameDir.rs +++ /dev/null @@ -1,5 +0,0 @@ -// sub-module in the same directory as the main crate file - -pub struct SameStruct { - pub name: String -} diff --git a/tests/run-make-fulldeps/save-analysis/SameDir3.rs b/tests/run-make-fulldeps/save-analysis/SameDir3.rs deleted file mode 100644 index fab03ee2e..000000000 --- a/tests/run-make-fulldeps/save-analysis/SameDir3.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub fn hello(x: isize) { - println!("macro {} :-(", x); -} diff --git a/tests/run-make-fulldeps/save-analysis/SubDir/mod.rs b/tests/run-make-fulldeps/save-analysis/SubDir/mod.rs deleted file mode 100644 index 511721d92..000000000 --- a/tests/run-make-fulldeps/save-analysis/SubDir/mod.rs +++ /dev/null @@ -1,27 +0,0 @@ -// sub-module in a sub-directory - -use sub::sub2 as msalias; -use sub::sub2; - -static yy: usize = 25; - -mod sub { - pub mod sub2 { - pub mod sub3 { - pub fn hello() { - println!("hello from module 3"); - } - } - pub fn hello() { - println!("hello from a module"); - } - - pub struct nested_struct { - pub field2: u32, - } - } -} - -pub struct SubStruct { - pub name: String -} diff --git a/tests/run-make-fulldeps/save-analysis/extra-docs.md b/tests/run-make-fulldeps/save-analysis/extra-docs.md deleted file mode 100644 index 0605ca517..000000000 --- a/tests/run-make-fulldeps/save-analysis/extra-docs.md +++ /dev/null @@ -1 +0,0 @@ -Extra docs for this struct. diff --git a/tests/run-make-fulldeps/save-analysis/foo.rs b/tests/run-make-fulldeps/save-analysis/foo.rs deleted file mode 100644 index 384589de3..000000000 --- a/tests/run-make-fulldeps/save-analysis/foo.rs +++ /dev/null @@ -1,465 +0,0 @@ -#![crate_name = "test"] -#![feature(rustc_private)] -#![feature(associated_type_defaults)] - -extern crate rustc_graphviz; -// A simple rust project - -// Necessary to pull in object code as the rest of the rustc crates are shipped only as rmeta -// files. -#[allow(unused_extern_crates)] -extern crate rustc_driver; - -extern crate krate2; -extern crate krate2 as krate3; - -use rustc_graphviz::RenderOption; -use std::cell::RefCell; -use std::collections::{HashMap, HashSet}; -use std::io::Write; - -use sub::sub2 as msalias; -use sub::sub2; -use sub::sub2::nested_struct as sub_struct; - -use std::mem::size_of; - -use std::char::from_u32; - -static uni: &'static str = "Les Miséééééééérables"; -static yy: usize = 25; - -static bob: Option<rustc_graphviz::RenderOption> = None; - -// buglink test - see issue #1337. - -fn test_alias<I: Iterator>(i: Option<<I as Iterator>::Item>) { - let s = sub_struct { field2: 45u32 }; - - // import tests - fn foo(x: &Write) {} - let _: Option<_> = from_u32(45); - - let x = 42usize; - - krate2::hello(); - krate3::hello(); - - let x = (3isize, 4usize); - let y = x.1; -} - -// Issue #37700 -const LUT_BITS: usize = 3; -pub struct HuffmanTable { - ac_lut: Option<[(i16, u8); 1 << LUT_BITS]>, -} - -struct TupStruct(isize, isize, Box<str>); - -fn test_tup_struct(x: TupStruct) -> isize { - x.1 -} - -fn println(s: &str) { - std::io::stdout().write_all(s.as_bytes()); -} - -mod sub { - pub mod sub2 { - use std::io::Write; - pub mod sub3 { - use std::io::Write; - pub fn hello() { - ::println("hello from module 3"); - } - } - pub fn hello() { - ::println("hello from a module"); - } - - pub struct nested_struct { - pub field2: u32, - } - - pub enum nested_enum { - Nest2 = 2, - Nest3 = 3, - } - } -} - -pub mod SameDir; -pub mod SubDir; - -#[path = "SameDir3.rs"] -pub mod SameDir2; - -struct nofields; - -#[derive(Clone)] -struct some_fields { - field1: u32, -} - -type SF = some_fields; - -trait SuperTrait { - fn qux(&self) { - panic!(); - } -} - -trait SomeTrait: SuperTrait { - fn Method(&self, x: u32) -> u32; - - fn prov(&self, x: u32) -> u32 { - println(&x.to_string()); - 42 - } - fn provided_method(&self) -> u32 { - 42 - } -} - -trait SubTrait: SomeTrait { - fn stat2(x: &Self) -> u32 { - 32 - } -} - -impl SomeTrait for some_fields { - fn Method(&self, x: u32) -> u32 { - println(&x.to_string()); - self.field1 - } -} - -impl SuperTrait for some_fields {} - -impl SubTrait for some_fields {} - -impl some_fields { - fn stat(x: u32) -> u32 { - println(&x.to_string()); - 42 - } - fn stat2(x: &some_fields) -> u32 { - 42 - } - - fn align_to<T>(&mut self) {} - - fn test(&mut self) { - self.align_to::<bool>(); - } -} - -impl SuperTrait for nofields {} -impl SomeTrait for nofields { - fn Method(&self, x: u32) -> u32 { - self.Method(x); - 43 - } - - fn provided_method(&self) -> u32 { - 21 - } -} - -impl SubTrait for nofields {} - -impl SuperTrait for (Box<nofields>, Box<some_fields>) {} - -fn f_with_params<T: SomeTrait>(x: &T) { - x.Method(41); -} - -type MyType = Box<some_fields>; - -enum SomeEnum<'a> { - Ints(isize, isize), - Floats(f64, f64), - Strings(&'a str, &'a str, &'a str), - MyTypes(MyType, MyType), -} - -#[derive(Copy, Clone)] -enum SomeOtherEnum { - SomeConst1, - SomeConst2, - SomeConst3, -} - -enum SomeStructEnum { - EnumStruct { a: isize, b: isize }, - EnumStruct2 { f1: MyType, f2: MyType }, - EnumStruct3 { f1: MyType, f2: MyType, f3: SomeEnum<'static> }, -} - -fn matchSomeEnum(val: SomeEnum) { - match val { - SomeEnum::Ints(int1, int2) => { - println(&(int1 + int2).to_string()); - } - SomeEnum::Floats(float1, float2) => { - println(&(float2 * float1).to_string()); - } - SomeEnum::Strings(.., s3) => { - println(s3); - } - SomeEnum::MyTypes(mt1, mt2) => { - println(&(mt1.field1 - mt2.field1).to_string()); - } - } -} - -fn matchSomeStructEnum(se: SomeStructEnum) { - match se { - SomeStructEnum::EnumStruct { a: a, .. } => println(&a.to_string()), - SomeStructEnum::EnumStruct2 { f1: f1, f2: f_2 } => println(&f_2.field1.to_string()), - SomeStructEnum::EnumStruct3 { f1, .. } => println(&f1.field1.to_string()), - } -} - -fn matchSomeStructEnum2(se: SomeStructEnum) { - use SomeStructEnum::*; - match se { - EnumStruct { a: ref aaa, .. } => println(&aaa.to_string()), - EnumStruct2 { f1, f2: f2 } => println(&f1.field1.to_string()), - EnumStruct3 { f1, f3: SomeEnum::Ints(..), f2 } => println(&f1.field1.to_string()), - _ => {} - } -} - -fn matchSomeOtherEnum(val: SomeOtherEnum) { - use SomeOtherEnum::{SomeConst2, SomeConst3}; - match val { - SomeOtherEnum::SomeConst1 => { - println("I'm const1."); - } - SomeConst2 | SomeConst3 => { - println("I'm const2 or const3."); - } - } -} - -fn hello<X: SomeTrait>((z, a): (u32, String), ex: X) { - SameDir2::hello(43); - - println(&yy.to_string()); - let (x, y): (u32, u32) = (5, 3); - println(&x.to_string()); - println(&z.to_string()); - let x: u32 = x; - println(&x.to_string()); - let x = "hello"; - println(x); - - let x = 32.0f32; - let _ = (x + ((x * x) + 1.0).sqrt()).ln(); - - let s: Box<SomeTrait> = Box::new(some_fields { field1: 43 }); - let s2: Box<some_fields> = Box::new(some_fields { field1: 43 }); - let s3 = Box::new(nofields); - - s.Method(43); - s3.Method(43); - s2.Method(43); - - ex.prov(43); - - let y: u32 = 56; - // static method on struct - let r = some_fields::stat(y); - // trait static method, calls default - let r = SubTrait::stat2(&*s3); - - let s4 = s3 as Box<SomeTrait>; - s4.Method(43); - - s4.provided_method(); - s2.prov(45); - - let closure = |x: u32, s: &SomeTrait| { - s.Method(23); - return x + y; - }; - - let z = closure(10, &*s); -} - -pub struct blah { - used_link_args: RefCell<[&'static str; 0]>, -} - -#[macro_use] -mod macro_use_test { - macro_rules! test_rec { - (q, $src: expr) => {{ - print!("{}", $src); - test_rec!($src); - }}; - ($src: expr) => { - print!("{}", $src); - }; - } - - macro_rules! internal_vars { - ($src: ident) => {{ - let mut x = $src; - x += 100; - }}; - } -} - -fn main() { - // foo - let s = Box::new(some_fields { field1: 43 }); - hello((43, "a".to_string()), *s); - sub::sub2::hello(); - sub2::sub3::hello(); - - let h = sub2::sub3::hello; - h(); - - // utf8 chars - let ut = "Les Miséééééééérables"; - - // For some reason, this pattern of macro_rules foiled our generated code - // avoiding strategy. - macro_rules! variable_str(($name:expr) => ( - some_fields { - field1: $name, - } - )); - let vs = variable_str!(32); - - let mut candidates: RefCell<HashMap<&'static str, &'static str>> = RefCell::new(HashMap::new()); - let _ = blah { used_link_args: RefCell::new([]) }; - let s1 = nofields; - let s2 = SF { field1: 55 }; - let s3: some_fields = some_fields { field1: 55 }; - let s4: msalias::nested_struct = sub::sub2::nested_struct { field2: 55 }; - let s4: msalias::nested_struct = sub2::nested_struct { field2: 55 }; - println(&s2.field1.to_string()); - let s5: MyType = Box::new(some_fields { field1: 55 }); - let s = SameDir::SameStruct { name: "Bob".to_string() }; - let s = SubDir::SubStruct { name: "Bob".to_string() }; - let s6: SomeEnum = SomeEnum::MyTypes(Box::new(s2.clone()), s5); - let s7: SomeEnum = SomeEnum::Strings("one", "two", "three"); - matchSomeEnum(s6); - matchSomeEnum(s7); - let s8: SomeOtherEnum = SomeOtherEnum::SomeConst2; - matchSomeOtherEnum(s8); - let s9: SomeStructEnum = - SomeStructEnum::EnumStruct2 { f1: Box::new(some_fields { field1: 10 }), f2: Box::new(s2) }; - matchSomeStructEnum(s9); - - for x in &vec![1, 2, 3] { - let _y = x; - } - - let s7: SomeEnum = SomeEnum::Strings("one", "two", "three"); - if let SomeEnum::Strings(..) = s7 { - println!("hello!"); - } - - for i in 0..5 { - foo_foo(i); - } - - if let Some(x) = None { - foo_foo(x); - } - - if false { - } else if let Some(y) = None { - foo_foo(y); - } - - while let Some(z) = None { - foo_foo(z); - } - - let mut x = 4; - test_rec!(q, "Hello"); - assert_eq!(x, 4); - internal_vars!(x); -} - -fn foo_foo(_: i32) {} - -impl Iterator for nofields { - type Item = (usize, usize); - - fn next(&mut self) -> Option<(usize, usize)> { - panic!() - } - - fn size_hint(&self) -> (usize, Option<usize>) { - panic!() - } -} - -trait Pattern<'a> { - type Searcher; -} - -struct CharEqPattern; - -impl<'a> Pattern<'a> for CharEqPattern { - type Searcher = CharEqPattern; -} - -struct CharSearcher<'a>(<CharEqPattern as Pattern<'a>>::Searcher); - -pub trait Error {} - -impl Error + 'static { - pub fn is<T: Error + 'static>(&self) -> bool { - panic!() - } -} - -impl Error + 'static + Send { - pub fn is<T: Error + 'static>(&self) -> bool { - <Error + 'static>::is::<T>(self) - } -} -extern crate rustc_serialize; -#[derive(Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Debug, Default)] -struct AllDerives(i32); - -fn test_format_args() { - let x = 1; - let y = 2; - let name = "Joe Blogg"; - println!("Hello {}", name); - print!("Hello {0}", name); - print!("{0} + {} = {}", x, y); - print!("x is {}, y is {1}, name is {n}", x, y, n = name); -} - -union TestUnion { - f1: u32, -} - -struct FrameBuffer; - -struct SilenceGenerator; - -impl Iterator for SilenceGenerator { - type Item = FrameBuffer; - - fn next(&mut self) -> Option<Self::Item> { - panic!(); - } -} - -#[doc = include_str!("extra-docs.md")] -struct StructWithDocs; - -trait Foo { - type Bar = FrameBuffer; -} diff --git a/tests/run-make-fulldeps/save-analysis/krate2.rs b/tests/run-make-fulldeps/save-analysis/krate2.rs deleted file mode 100644 index 7d787e0c9..000000000 --- a/tests/run-make-fulldeps/save-analysis/krate2.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![ crate_name = "krate2" ] -#![ crate_type = "lib" ] - -use std::io::Write; - -pub fn hello() { - std::io::stdout().write_all(b"hello world!\n"); -} diff --git a/tests/run-make-fulldeps/split-debuginfo/Makefile b/tests/run-make-fulldeps/split-debuginfo/Makefile index 1831ab38f..44cda0d3d 100644 --- a/tests/run-make-fulldeps/split-debuginfo/Makefile +++ b/tests/run-make-fulldeps/split-debuginfo/Makefile @@ -254,12 +254,12 @@ unpacked-remapped-single: $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a foo.rs -g objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 - ls $(TMPDIR)/*.o + rm $(TMPDIR)/*.o ls $(TMPDIR)/*.dwo && exit 1 || exit 0 ls $(TMPDIR)/*.dwp && exit 1 || exit 0 rm $(TMPDIR)/$(call BIN,foo) -unpacked-crosscrate: packed-crosscrate-split packed-crosscrate-single +unpacked-crosscrate: unpacked-crosscrate-split unpacked-crosscrate-single # - Debuginfo in `.dwo` files # - (bar) `.rlib` file created, contains `.dwo` diff --git a/tests/run-make-fulldeps/type-mismatch-same-crate-name/Makefile b/tests/run-make-fulldeps/type-mismatch-same-crate-name/Makefile index 9f4be7126..a2a2a41c7 100644 --- a/tests/run-make-fulldeps/type-mismatch-same-crate-name/Makefile +++ b/tests/run-make-fulldeps/type-mismatch-same-crate-name/Makefile @@ -11,7 +11,7 @@ all: tr -d '\r\n' | $(CGREP) -e \ "mismatched types.*\ crateB::try_foo\(foo2\);.*\ - expected struct \`crateA::foo::Foo\`, found struct \`Foo\`.*\ + expected \`crateA::foo::Foo\`, found \`Foo\`.*\ different versions of crate \`crateA\`.*\ mismatched types.*\ crateB::try_bar\(bar2\);.*\ diff --git a/tests/run-make/incremental-session-fail/Makefile b/tests/run-make/incremental-session-fail/Makefile index 0461bb926..6ce137092 100644 --- a/tests/run-make/incremental-session-fail/Makefile +++ b/tests/run-make/incremental-session-fail/Makefile @@ -9,6 +9,6 @@ all: touch $(SESSION_DIR) # Check exit code is 1 for an error, and not 101 for ICE. $(RUSTC) foo.rs --crate-type=rlib -C incremental=$(SESSION_DIR) > $(OUTPUT_FILE) 2>&1; [ $$? -eq 1 ] - $(CGREP) "Could not create incremental compilation crate directory" < $(OUTPUT_FILE) + $(CGREP) "could not create incremental compilation crate directory" < $(OUTPUT_FILE) # -v tests are fragile, hopefully this text won't change $(CGREP) -v "internal compiler error" < $(OUTPUT_FILE) diff --git a/tests/run-make/native-link-modifier-bundle/Makefile b/tests/run-make/native-link-modifier-bundle/Makefile index 7c78d7783..e8a1121bf 100644 --- a/tests/run-make/native-link-modifier-bundle/Makefile +++ b/tests/run-make/native-link-modifier-bundle/Makefile @@ -5,7 +5,12 @@ include ../../run-make-fulldeps/tools.mk # We're using the llvm-nm instead of the system nm to ensure it is compatible # with the LLVM bitcode generated by rustc. +# Except on Windows where piping/IO redirection under MSYS2 is wonky with llvm-nm. +ifndef IS_WINDOWS NM = "$(LLVM_BIN_DIR)"/llvm-nm +else +NM = nm +endif all: $(call NATIVE_STATICLIB,native-staticlib) # Build a staticlib and a rlib, the `native_func` symbol will be bundled into them diff --git a/tests/run-make/no-input-file/Makefile b/tests/run-make/no-input-file/Makefile new file mode 100644 index 000000000..2f0215922 --- /dev/null +++ b/tests/run-make/no-input-file/Makefile @@ -0,0 +1,4 @@ +include ../../run-make-fulldeps/tools.mk + +all: + $(RUSTC) --print crate-name 2>&1 | diff - no-input-file.stderr diff --git a/tests/run-make/no-input-file/no-input-file.stderr b/tests/run-make/no-input-file/no-input-file.stderr new file mode 100644 index 000000000..b843eb524 --- /dev/null +++ b/tests/run-make/no-input-file/no-input-file.stderr @@ -0,0 +1,2 @@ +error: no input filename given + diff --git a/tests/run-make/overwrite-input/Makefile b/tests/run-make/overwrite-input/Makefile new file mode 100644 index 000000000..03b03eb14 --- /dev/null +++ b/tests/run-make/overwrite-input/Makefile @@ -0,0 +1,13 @@ +include ../../run-make-fulldeps/tools.mk + +all: + $(RUSTC) main.rs -o main.rs 2> $(TMPDIR)/file.stderr || echo "failed successfully" + $(RUSTC) main.rs -o . 2> $(TMPDIR)/folder.stderr || echo "failed successfully" + +ifdef RUSTC_BLESS_TEST + cp "$(TMPDIR)"/file.stderr file.stderr + cp "$(TMPDIR)"/folder.stderr folder.stderr +else + $(DIFF) file.stderr "$(TMPDIR)"/file.stderr + $(DIFF) folder.stderr "$(TMPDIR)"/folder.stderr +endif diff --git a/tests/run-make/overwrite-input/file.stderr b/tests/run-make/overwrite-input/file.stderr new file mode 100644 index 000000000..9936962b4 --- /dev/null +++ b/tests/run-make/overwrite-input/file.stderr @@ -0,0 +1,6 @@ +warning: ignoring --out-dir flag due to -o flag + +error: the input file "main.rs" would be overwritten by the generated executable + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/run-make/overwrite-input/folder.stderr b/tests/run-make/overwrite-input/folder.stderr new file mode 100644 index 000000000..81b1e7367 --- /dev/null +++ b/tests/run-make/overwrite-input/folder.stderr @@ -0,0 +1,6 @@ +warning: ignoring --out-dir flag due to -o flag + +error: the generated executable for the input file "main.rs" conflicts with the existing directory "." + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/run-make/overwrite-input/main.rs b/tests/run-make/overwrite-input/main.rs new file mode 100644 index 000000000..f328e4d9d --- /dev/null +++ b/tests/run-make/overwrite-input/main.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/tests/run-make/overwrite-input/main.stderr b/tests/run-make/overwrite-input/main.stderr new file mode 100644 index 000000000..9936962b4 --- /dev/null +++ b/tests/run-make/overwrite-input/main.stderr @@ -0,0 +1,6 @@ +warning: ignoring --out-dir flag due to -o flag + +error: the input file "main.rs" would be overwritten by the generated executable + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/run-make/raw-dylib-inline-cross-dylib/Makefile b/tests/run-make/raw-dylib-inline-cross-dylib/Makefile index 9e603f958..722a49b02 100644 --- a/tests/run-make/raw-dylib-inline-cross-dylib/Makefile +++ b/tests/run-make/raw-dylib-inline-cross-dylib/Makefile @@ -4,15 +4,19 @@ include ../../run-make-fulldeps/tools.mk +# We'd be using the llvm-objdump instead of the system objdump to ensure compatibility +# with the LLVM bitcode generated by rustc but on Windows piping/IO redirection under MSYS2 is wonky with llvm-objdump. +OBJDUMP = objdump + all: $(RUSTC) --crate-type dylib --crate-name raw_dylib_test lib.rs -C prefer-dynamic $(RUSTC) --crate-type dylib --crate-name raw_dylib_test_wrapper lib_wrapper.rs -C prefer-dynamic $(RUSTC) --crate-type bin driver.rs -L "$(TMPDIR)" -C prefer-dynamic # Make sure we don't find an import to the functions we expect to be inlined. - "$(LLVM_BIN_DIR)"/llvm-objdump -p $(TMPDIR)/driver.exe | $(CGREP) -v -e "inline_library_function" - "$(LLVM_BIN_DIR)"/llvm-objdump -p $(TMPDIR)/driver.exe | $(CGREP) -v -e "inline_library_function_calls_inline" + $(OBJDUMP) -p $(TMPDIR)/driver.exe | $(CGREP) -v -e "inline_library_function" + $(OBJDUMP) -p $(TMPDIR)/driver.exe | $(CGREP) -v -e "inline_library_function_calls_inline" # Make sure we do find an import to the functions we expect to be imported. - "$(LLVM_BIN_DIR)"/llvm-objdump -p $(TMPDIR)/driver.exe | $(CGREP) -e "library_function" + $(OBJDUMP) -p $(TMPDIR)/driver.exe | $(CGREP) -e "library_function" $(call COMPILE_OBJ,"$(TMPDIR)"/extern_1.obj,extern_1.c) $(call COMPILE_OBJ,"$(TMPDIR)"/extern_2.obj,extern_2.c) ifdef IS_MSVC diff --git a/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile b/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile index 4574cf17f..37b8d809a 100644 --- a/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile +++ b/tests/run-make/rlib-format-packed-bundled-libs-2/Makefile @@ -6,7 +6,12 @@ # We're using the llvm-nm instead of the system nm to ensure it is compatible # with the LLVM bitcode generated by rustc. +# Except on Windows where piping/IO redirection under MSYS2 is wonky with llvm-nm. +ifndef IS_WINDOWS NM = "$(LLVM_BIN_DIR)"/llvm-nm +else +NM = nm +endif all: # Build strange-named dep. diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile b/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile new file mode 100644 index 000000000..62dc1b5f6 --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile @@ -0,0 +1,35 @@ +-include ../../run-make-fulldeps/tools.mk + +# ignore-cross-compile +# only-linux + +# Make sure -Zpacked_bundled_libs-like behavior activates with whole-archive. + +# We're using the llvm-nm instead of the system nm to ensure it is compatible +# with the LLVM bitcode generated by rustc. +NM = "$(LLVM_BIN_DIR)"/llvm-nm + +all: $(call NATIVE_STATICLIB,native_dep_1) $(call NATIVE_STATICLIB,native_dep_2) $(call NATIVE_STATICLIB,native_dep_3) $(call NATIVE_STATICLIB,native_dep_4) + # test cfg with packed bundle + $(RUSTC) rust_dep_cfg.rs --crate-type=rlib -Zpacked_bundled_libs + $(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep_cfg.rlib --crate-type=staticlib --cfg should_add + $(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_1.a" + $(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_2.a" + $(AR) t $(TMPDIR)/libmain.a | $(CGREP) -e "libnative_dep_1.o" + $(AR) t $(TMPDIR)/libmain.a | $(CGREP) -ev "libnative_dep_2.o" + + + # test bundle with whole_archive + $(RUSTC) rust_dep.rs --crate-type=rlib + $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "native_dep_1" + $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -e "native_dep_3" + $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -ev "native_dep_2" + $(AR) t $(TMPDIR)/librust_dep.rlib | $(CGREP) -ev "native_dep_4" + + # Make sure compiler doesn't use files, that it shouldn't know about. + rm $(TMPDIR)/libnative_dep_1.a + rm $(TMPDIR)/libnative_dep_3.a + + $(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep.rlib --print link-args > $(TMPDIR)/link_args + cat $(TMPDIR)/link_args | $(CGREP) -ev "native_dep_3" + cat $(TMPDIR)/link_args | $(CGREP) -e "--whole-archive.*native_dep_1.*--whole-archive.*lnative_dep_2.*no-whole-archive.*lnative_dep_4" diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/main.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/main.rs new file mode 100644 index 000000000..8d2b8a285 --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/main.rs @@ -0,0 +1,5 @@ +extern crate rust_dep; + +pub fn main() { + rust_dep::rust_dep(); +} diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c new file mode 100644 index 000000000..07be8562c --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_1.c @@ -0,0 +1 @@ +int native_f1() { return 1; } diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c new file mode 100644 index 000000000..a1b94e40d --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_2.c @@ -0,0 +1 @@ +int native_f2() { return 2; } diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c new file mode 100644 index 000000000..f81f397a4 --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_3.c @@ -0,0 +1 @@ +int native_f3() { return 3; } diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c new file mode 100644 index 000000000..14d41d60b --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/native_dep_4.c @@ -0,0 +1 @@ +int native_f4() { return 4; } diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs new file mode 100644 index 000000000..abd846b68 --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs @@ -0,0 +1,16 @@ +#![feature(packed_bundled_libs)] + +#[link(name = "native_dep_1", kind = "static", modifiers = "+whole-archive,+bundle")] +extern "C" {} + +#[link(name = "native_dep_2", kind = "static", modifiers = "+whole-archive,-bundle")] +extern "C" {} + +#[link(name = "native_dep_3", kind = "static", modifiers = "+bundle")] +extern "C" {} + +#[link(name = "native_dep_4", kind = "static", modifiers = "-bundle")] +extern "C" {} + +#[no_mangle] +pub fn rust_dep() {} diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs new file mode 100644 index 000000000..506ca62a8 --- /dev/null +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep_cfg.rs @@ -0,0 +1,10 @@ +#![feature(link_cfg)] + +#[link(name = "native_dep_1", kind = "static", cfg(should_add))] +extern "C" {} + +#[link(name = "native_dep_2", kind = "static", cfg(should_not_add))] +extern "C" {} + +#[no_mangle] +pub fn rust_dep() {} diff --git a/tests/run-make/rlib-format-packed-bundled-libs/Makefile b/tests/run-make/rlib-format-packed-bundled-libs/Makefile index 0b991ac42..7fb6ce8d1 100644 --- a/tests/run-make/rlib-format-packed-bundled-libs/Makefile +++ b/tests/run-make/rlib-format-packed-bundled-libs/Makefile @@ -6,7 +6,12 @@ # We're using the llvm-nm instead of the system nm to ensure it is compatible # with the LLVM bitcode generated by rustc. +# Except on Windows where piping/IO redirection under MSYS2 is wonky with llvm-nm. +ifndef IS_WINDOWS NM = "$(LLVM_BIN_DIR)"/llvm-nm +else +NM = nm +endif all: $(call NATIVE_STATICLIB,native_dep_1) $(call NATIVE_STATICLIB,native_dep_2) $(call NATIVE_STATICLIB,native_dep_3) $(RUSTC) rust_dep_up.rs --crate-type=rlib -Zpacked_bundled_libs diff --git a/tests/run-make/translation/Makefile b/tests/run-make/translation/Makefile index 20e86c7f9..5b0b331ca 100644 --- a/tests/run-make/translation/Makefile +++ b/tests/run-make/translation/Makefile @@ -6,8 +6,10 @@ include ../../run-make-fulldeps/tools.mk SYSROOT:=$(shell $(RUSTC) --print sysroot) FAKEROOT=$(TMPDIR)/fakeroot +RUSTC_LOG:=rustc_error_messages +export RUSTC_TRANSLATION_NO_DEBUG_ASSERT:=1 -all: normal custom sysroot +all: normal custom missing broken sysroot sysroot-invalid sysroot-missing # Check that the test works normally, using the built-in fallback bundle. normal: test.rs @@ -32,6 +34,7 @@ broken: test.rs broken.ftl # identifier by making a local copy of the sysroot and adding the custom locale # to it. sysroot: test.rs working.ftl + rm -rf $(FAKEROOT) mkdir $(FAKEROOT) ln -s $(SYSROOT)/* $(FAKEROOT) rm -f $(FAKEROOT)/lib @@ -51,12 +54,12 @@ sysroot: test.rs working.ftl # found. This test might start failing if there actually exists a Klingon # translation of rustc's error messages. sysroot-missing: - $(RUSTC) $< -Ztranslate-lang=tlh 2>&1 || grep "missing locale directory" + $(RUSTC) $< -Ztranslate-lang=tlh 2>&1 | grep "missing locale directory" -# Check that the compiler errors out when the sysroot requested cannot be -# found. This test might start failing if there actually exists a Klingon -# translation of rustc's error messages. +# Check that the compiler errors out when the directory for the locale in the +# sysroot is actually a file. sysroot-invalid: test.rs working.ftl + rm -rf $(FAKEROOT) mkdir $(FAKEROOT) ln -s $(SYSROOT)/* $(FAKEROOT) rm -f $(FAKEROOT)/lib @@ -68,5 +71,6 @@ sysroot-invalid: test.rs working.ftl rm -f $(FAKEROOT)/lib/rustlib/src mkdir $(FAKEROOT)/lib/rustlib/src ln -s $(SYSROOT)/lib/rustlib/src/* $(FAKEROOT)/lib/rustlib/src - touch $(FAKEROOT)/share/locale/zh-CN/ - $(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 || grep "`\$sysroot/share/locales/\$locale` is not a directory" + mkdir -p $(FAKEROOT)/share/locale + touch $(FAKEROOT)/share/locale/zh-CN + $(RUSTC) $< --sysroot $(FAKEROOT) -Ztranslate-lang=zh-CN 2>&1 | grep "`\$sysroot/share/locales/\$locale` is not a directory" |