summaryrefslogtreecommitdiffstats
path: root/src/test/ui/cross
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/test/ui/cross
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--src/test/ui/cross-crate/auxiliary/cci_borrow_lib.rs3
-rw-r--r--src/test/ui/cross-crate/auxiliary/cci_capture_clause.rs10
-rw-r--r--src/test/ui/cross-crate/auxiliary/cci_const.rs6
-rw-r--r--src/test/ui/cross-crate/auxiliary/cci_impl_lib.rs16
-rw-r--r--src/test/ui/cross-crate/auxiliary/cci_iter_lib.rs11
-rw-r--r--src/test/ui/cross-crate/auxiliary/cci_nested_lib.rs50
-rw-r--r--src/test/ui/cross-crate/auxiliary/cci_no_inline_lib.rs12
-rw-r--r--src/test/ui/cross-crate/auxiliary/moves_based_on_type_lib.rs17
-rw-r--r--src/test/ui/cross-crate/auxiliary/pub_static_array.rs1
-rw-r--r--src/test/ui/cross-crate/auxiliary/reexported_static_methods.rs43
-rw-r--r--src/test/ui/cross-crate/auxiliary/static_init_aux.rs10
-rw-r--r--src/test/ui/cross-crate/auxiliary/xcrate-trait-lifetime-param.rs3
-rw-r--r--src/test/ui/cross-crate/auxiliary/xcrate_address_insignificant.rs8
-rw-r--r--src/test/ui/cross-crate/auxiliary/xcrate_associated_type_defaults.rs12
-rw-r--r--src/test/ui/cross-crate/auxiliary/xcrate_generic_fn_nested_return.rs16
-rw-r--r--src/test/ui/cross-crate/auxiliary/xcrate_static_addresses.rs17
-rw-r--r--src/test/ui/cross-crate/cci_borrow.rs12
-rw-r--r--src/test/ui/cross-crate/cci_capture_clause.rs14
-rw-r--r--src/test/ui/cross-crate/cci_impl_exe.rs18
-rw-r--r--src/test/ui/cross-crate/cci_iter_exe.rs13
-rw-r--r--src/test/ui/cross-crate/cci_nested_exe.rs20
-rw-r--r--src/test/ui/cross-crate/cci_no_inline_exe.rs23
-rw-r--r--src/test/ui/cross-crate/const-cross-crate-const.rs16
-rw-r--r--src/test/ui/cross-crate/const-cross-crate-extern.rs11
-rw-r--r--src/test/ui/cross-crate/cross-crate-const-pat.rs14
-rw-r--r--src/test/ui/cross-crate/issue-64872/auxiliary/a_def_obj.rs16
-rw-r--r--src/test/ui/cross-crate/issue-64872/auxiliary/b_reexport_obj.rs7
-rw-r--r--src/test/ui/cross-crate/issue-64872/auxiliary/c_another_vtable_for_obj.rs12
-rw-r--r--src/test/ui/cross-crate/issue-64872/auxiliary/d_chain_of_rlibs_and_dylibs.rs9
-rw-r--r--src/test/ui/cross-crate/issue-64872/issue-64872.rs17
-rw-r--r--src/test/ui/cross-crate/moves-based-on-type-cross-crate.rs11
-rw-r--r--src/test/ui/cross-crate/reexported-static-methods-cross-crate.rs16
-rw-r--r--src/test/ui/cross-crate/static-array-across-crate.rs13
-rw-r--r--src/test/ui/cross-crate/static-init.rs15
-rw-r--r--src/test/ui/cross-crate/xcrate-address-insignificant.rs9
-rw-r--r--src/test/ui/cross-crate/xcrate-associated-type-defaults.rs29
-rw-r--r--src/test/ui/cross-crate/xcrate-static-addresses.rs13
-rw-r--r--src/test/ui/cross-crate/xcrate-trait-lifetime-param.rs19
-rw-r--r--src/test/ui/cross-crate/xcrate_generic_fn_nested_return.rs8
-rw-r--r--src/test/ui/cross/cross-borrow-trait.rs13
-rw-r--r--src/test/ui/cross/cross-borrow-trait.stderr14
-rw-r--r--src/test/ui/cross/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs13
-rw-r--r--src/test/ui/cross/cross-crate-macro-backtrace/main.rs8
-rw-r--r--src/test/ui/cross/cross-crate-macro-backtrace/main.stderr10
-rw-r--r--src/test/ui/cross/cross-file-errors/main.rs7
-rw-r--r--src/test/ui/cross/cross-file-errors/main.stderr15
-rw-r--r--src/test/ui/cross/cross-file-errors/underscore.rs10
-rw-r--r--src/test/ui/cross/cross-fn-cache-hole.rs31
-rw-r--r--src/test/ui/cross/cross-fn-cache-hole.stderr12
49 files changed, 703 insertions, 0 deletions
diff --git a/src/test/ui/cross-crate/auxiliary/cci_borrow_lib.rs b/src/test/ui/cross-crate/auxiliary/cci_borrow_lib.rs
new file mode 100644
index 000000000..7c57a1c66
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/cci_borrow_lib.rs
@@ -0,0 +1,3 @@
+pub fn foo(x: &usize) -> usize {
+ *x
+}
diff --git a/src/test/ui/cross-crate/auxiliary/cci_capture_clause.rs b/src/test/ui/cross-crate/auxiliary/cci_capture_clause.rs
new file mode 100644
index 000000000..4cd001ecc
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/cci_capture_clause.rs
@@ -0,0 +1,10 @@
+use std::thread;
+use std::sync::mpsc::{Receiver, channel};
+
+pub fn foo<T:'static + Send + Clone>(x: T) -> Receiver<T> {
+ let (tx, rx) = channel();
+ thread::spawn(move|| {
+ tx.send(x.clone());
+ });
+ rx
+}
diff --git a/src/test/ui/cross-crate/auxiliary/cci_const.rs b/src/test/ui/cross-crate/auxiliary/cci_const.rs
new file mode 100644
index 000000000..c83b3f4a5
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/cci_const.rs
@@ -0,0 +1,6 @@
+pub extern "C" fn bar() {
+}
+
+pub const foopy: &'static str = "hi there";
+pub const uint_val: usize = 12;
+pub const uint_expr: usize = (1 << uint_val) - 1;
diff --git a/src/test/ui/cross-crate/auxiliary/cci_impl_lib.rs b/src/test/ui/cross-crate/auxiliary/cci_impl_lib.rs
new file mode 100644
index 000000000..0db0037b2
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/cci_impl_lib.rs
@@ -0,0 +1,16 @@
+#![crate_name="cci_impl_lib"]
+
+pub trait uint_helpers {
+ fn to<F>(&self, v: usize, f: F) where F: FnMut(usize);
+}
+
+impl uint_helpers for usize {
+ #[inline]
+ fn to<F>(&self, v: usize, mut f: F) where F: FnMut(usize) {
+ let mut i = *self;
+ while i < v {
+ f(i);
+ i += 1;
+ }
+ }
+}
diff --git a/src/test/ui/cross-crate/auxiliary/cci_iter_lib.rs b/src/test/ui/cross-crate/auxiliary/cci_iter_lib.rs
new file mode 100644
index 000000000..60c36bc7d
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/cci_iter_lib.rs
@@ -0,0 +1,11 @@
+#![crate_name="cci_iter_lib"]
+
+#[inline]
+pub fn iter<T, F>(v: &[T], mut f: F) where F: FnMut(&T) {
+ let mut i = 0;
+ let n = v.len();
+ while i < n {
+ f(&v[i]);
+ i += 1;
+ }
+}
diff --git a/src/test/ui/cross-crate/auxiliary/cci_nested_lib.rs b/src/test/ui/cross-crate/auxiliary/cci_nested_lib.rs
new file mode 100644
index 000000000..23d76ef36
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/cci_nested_lib.rs
@@ -0,0 +1,50 @@
+use std::cell::RefCell;
+
+pub struct Entry<A,B> {
+ key: A,
+ value: B
+}
+
+pub struct alist<A,B> {
+ eq_fn: extern "Rust" fn(A,A) -> bool,
+ data: Box<RefCell<Vec<Entry<A,B>>>>,
+}
+
+pub fn alist_add<A:'static,B:'static>(lst: &alist<A,B>, k: A, v: B) {
+ let mut data = lst.data.borrow_mut();
+ (*data).push(Entry{key:k, value:v});
+}
+
+pub fn alist_get<A:Clone + 'static,
+ B:Clone + 'static>(
+ lst: &alist<A,B>,
+ k: A)
+ -> B {
+ let eq_fn = lst.eq_fn;
+ let data = lst.data.borrow();
+ for entry in &(*data) {
+ if eq_fn(entry.key.clone(), k.clone()) {
+ return entry.value.clone();
+ }
+ }
+ panic!();
+}
+
+#[inline]
+pub fn new_int_alist<B:'static>() -> alist<isize, B> {
+ fn eq_int(a: isize, b: isize) -> bool { a == b }
+ return alist {
+ eq_fn: eq_int,
+ data: Box::new(RefCell::new(Vec::new())),
+ };
+}
+
+#[inline]
+pub fn new_int_alist_2<B:'static>() -> alist<isize, B> {
+ #[inline]
+ fn eq_int(a: isize, b: isize) -> bool { a == b }
+ return alist {
+ eq_fn: eq_int,
+ data: Box::new(RefCell::new(Vec::new())),
+ };
+}
diff --git a/src/test/ui/cross-crate/auxiliary/cci_no_inline_lib.rs b/src/test/ui/cross-crate/auxiliary/cci_no_inline_lib.rs
new file mode 100644
index 000000000..177dba217
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/cci_no_inline_lib.rs
@@ -0,0 +1,12 @@
+#![crate_name="cci_no_inline_lib"]
+
+
+// same as cci_iter_lib, more-or-less, but not marked inline
+pub fn iter<F>(v: Vec<usize> , mut f: F) where F: FnMut(usize) {
+ let mut i = 0;
+ let n = v.len();
+ while i < n {
+ f(v[i]);
+ i += 1;
+ }
+}
diff --git a/src/test/ui/cross-crate/auxiliary/moves_based_on_type_lib.rs b/src/test/ui/cross-crate/auxiliary/moves_based_on_type_lib.rs
new file mode 100644
index 000000000..7e7e3b860
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/moves_based_on_type_lib.rs
@@ -0,0 +1,17 @@
+#![crate_type="lib"]
+
+pub struct S {
+ x: isize,
+}
+
+impl Drop for S {
+ fn drop(&mut self) {
+ println!("goodbye");
+ }
+}
+
+pub fn f() {
+ let x = S { x: 1 };
+ let y = x;
+ let _z = y;
+}
diff --git a/src/test/ui/cross-crate/auxiliary/pub_static_array.rs b/src/test/ui/cross-crate/auxiliary/pub_static_array.rs
new file mode 100644
index 000000000..49cb76921
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/pub_static_array.rs
@@ -0,0 +1 @@
+pub static ARRAY: [u8; 1] = [1];
diff --git a/src/test/ui/cross-crate/auxiliary/reexported_static_methods.rs b/src/test/ui/cross-crate/auxiliary/reexported_static_methods.rs
new file mode 100644
index 000000000..cc961625f
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/reexported_static_methods.rs
@@ -0,0 +1,43 @@
+pub use sub_foo::Foo;
+pub use self::Bar as Baz;
+pub use sub_foo::Boz;
+pub use sub_foo::Bort;
+
+pub trait Bar {
+ fn bar() -> Self;
+}
+
+impl Bar for isize {
+ fn bar() -> isize { 84 }
+}
+
+pub mod sub_foo {
+ pub trait Foo {
+ fn foo() -> Self;
+ }
+
+ impl Foo for isize {
+ fn foo() -> isize { 42 }
+ }
+
+ pub struct Boz {
+ unused_str: String
+ }
+
+ impl Boz {
+ pub fn boz(i: isize) -> bool {
+ i > 0
+ }
+ }
+
+ pub enum Bort {
+ Bort1,
+ Bort2
+ }
+
+ impl Bort {
+ pub fn bort() -> String {
+ "bort()".to_string()
+ }
+ }
+}
diff --git a/src/test/ui/cross-crate/auxiliary/static_init_aux.rs b/src/test/ui/cross-crate/auxiliary/static_init_aux.rs
new file mode 100644
index 000000000..3b664f436
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/static_init_aux.rs
@@ -0,0 +1,10 @@
+pub static V: &u32 = &X;
+pub static F: fn() = f;
+
+static X: u32 = 42;
+
+pub fn v() -> *const u32 {
+ V
+}
+
+fn f() {}
diff --git a/src/test/ui/cross-crate/auxiliary/xcrate-trait-lifetime-param.rs b/src/test/ui/cross-crate/auxiliary/xcrate-trait-lifetime-param.rs
new file mode 100644
index 000000000..7c1175f7a
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/xcrate-trait-lifetime-param.rs
@@ -0,0 +1,3 @@
+pub trait FromBuf<'a> {
+ fn from_buf(_: &'a [u8]) -> Self;
+}
diff --git a/src/test/ui/cross-crate/auxiliary/xcrate_address_insignificant.rs b/src/test/ui/cross-crate/auxiliary/xcrate_address_insignificant.rs
new file mode 100644
index 000000000..e79e334b5
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/xcrate_address_insignificant.rs
@@ -0,0 +1,8 @@
+pub fn foo<T>() -> isize {
+ static a: isize = 3;
+ a
+}
+
+pub fn bar() -> isize {
+ foo::<isize>()
+}
diff --git a/src/test/ui/cross-crate/auxiliary/xcrate_associated_type_defaults.rs b/src/test/ui/cross-crate/auxiliary/xcrate_associated_type_defaults.rs
new file mode 100644
index 000000000..d8a55dd34
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/xcrate_associated_type_defaults.rs
@@ -0,0 +1,12 @@
+#![feature(associated_type_defaults)]
+
+pub trait Foo<T: Default + ToString> {
+ type Out: Default + ToString = T;
+}
+
+impl Foo<u32> for () {
+}
+
+impl Foo<u64> for () {
+ type Out = bool;
+}
diff --git a/src/test/ui/cross-crate/auxiliary/xcrate_generic_fn_nested_return.rs b/src/test/ui/cross-crate/auxiliary/xcrate_generic_fn_nested_return.rs
new file mode 100644
index 000000000..2ab23b4d7
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/xcrate_generic_fn_nested_return.rs
@@ -0,0 +1,16 @@
+pub struct Request {
+ pub id: String,
+ pub arg: String,
+}
+
+pub fn decode<T>() -> Result<Request, ()> {
+ (|| {
+ Ok(Request {
+ id: "hi".to_owned(),
+ arg: match Err(()) {
+ Ok(v) => v,
+ Err(e) => return Err(e)
+ },
+ })
+ })()
+}
diff --git a/src/test/ui/cross-crate/auxiliary/xcrate_static_addresses.rs b/src/test/ui/cross-crate/auxiliary/xcrate_static_addresses.rs
new file mode 100644
index 000000000..e18d34799
--- /dev/null
+++ b/src/test/ui/cross-crate/auxiliary/xcrate_static_addresses.rs
@@ -0,0 +1,17 @@
+pub static global: isize = 3;
+
+static global0: isize = 4;
+
+pub static global2: &'static isize = &global0;
+
+pub fn verify_same(a: &'static isize) {
+ let a = a as *const isize as usize;
+ let b = &global as *const isize as usize;
+ assert_eq!(a, b);
+}
+
+pub fn verify_same2(a: &'static isize) {
+ let a = a as *const isize as usize;
+ let b = global2 as *const isize as usize;
+ assert_eq!(a, b);
+}
diff --git a/src/test/ui/cross-crate/cci_borrow.rs b/src/test/ui/cross-crate/cci_borrow.rs
new file mode 100644
index 000000000..fee6b5d03
--- /dev/null
+++ b/src/test/ui/cross-crate/cci_borrow.rs
@@ -0,0 +1,12 @@
+// run-pass
+// aux-build:cci_borrow_lib.rs
+
+extern crate cci_borrow_lib;
+use cci_borrow_lib::foo;
+
+pub fn main() {
+ let p: Box<_> = Box::new(22);
+ let r = foo(&*p);
+ println!("r={}", r);
+ assert_eq!(r, 22);
+}
diff --git a/src/test/ui/cross-crate/cci_capture_clause.rs b/src/test/ui/cross-crate/cci_capture_clause.rs
new file mode 100644
index 000000000..ea699b5f5
--- /dev/null
+++ b/src/test/ui/cross-crate/cci_capture_clause.rs
@@ -0,0 +1,14 @@
+// run-pass
+// aux-build:cci_capture_clause.rs
+
+// This test makes sure we can do cross-crate inlining on functions
+// that use capture clauses.
+
+// pretty-expanded FIXME #23616
+// ignore-emscripten no threads support
+
+extern crate cci_capture_clause;
+
+pub fn main() {
+ cci_capture_clause::foo(()).recv().unwrap();
+}
diff --git a/src/test/ui/cross-crate/cci_impl_exe.rs b/src/test/ui/cross-crate/cci_impl_exe.rs
new file mode 100644
index 000000000..b11fb23eb
--- /dev/null
+++ b/src/test/ui/cross-crate/cci_impl_exe.rs
@@ -0,0 +1,18 @@
+// run-pass
+// aux-build:cci_impl_lib.rs
+
+extern crate cci_impl_lib;
+use cci_impl_lib::uint_helpers;
+
+pub fn main() {
+ //let bt0 = sys::frame_address();
+ //println!("%?", bt0);
+
+ 3.to(10, |i| {
+ println!("{}", i);
+
+ //let bt1 = sys::frame_address();
+ //println!("%?", bt1);
+ //assert_eq!(bt0, bt1);
+ })
+}
diff --git a/src/test/ui/cross-crate/cci_iter_exe.rs b/src/test/ui/cross-crate/cci_iter_exe.rs
new file mode 100644
index 000000000..8b58d90fe
--- /dev/null
+++ b/src/test/ui/cross-crate/cci_iter_exe.rs
@@ -0,0 +1,13 @@
+// run-pass
+// aux-build:cci_iter_lib.rs
+
+extern crate cci_iter_lib;
+
+pub fn main() {
+ //let bt0 = sys::rusti::frame_address(1);
+ //println!("%?", bt0);
+ cci_iter_lib::iter(&[1, 2, 3], |i| {
+ println!("{}", *i);
+ //assert_eq!(bt0, sys::rusti::frame_address(2));
+ })
+}
diff --git a/src/test/ui/cross-crate/cci_nested_exe.rs b/src/test/ui/cross-crate/cci_nested_exe.rs
new file mode 100644
index 000000000..1c001a2a3
--- /dev/null
+++ b/src/test/ui/cross-crate/cci_nested_exe.rs
@@ -0,0 +1,20 @@
+// run-pass
+// aux-build:cci_nested_lib.rs
+
+
+extern crate cci_nested_lib;
+use cci_nested_lib::*;
+
+pub fn main() {
+ let lst = new_int_alist();
+ alist_add(&lst, 22, "hi".to_string());
+ alist_add(&lst, 44, "ho".to_string());
+ assert_eq!(alist_get(&lst, 22), "hi".to_string());
+ assert_eq!(alist_get(&lst, 44), "ho".to_string());
+
+ let lst = new_int_alist_2();
+ alist_add(&lst, 22, "hi".to_string());
+ alist_add(&lst, 44, "ho".to_string());
+ assert_eq!(alist_get(&lst, 22), "hi".to_string());
+ assert_eq!(alist_get(&lst, 44), "ho".to_string());
+}
diff --git a/src/test/ui/cross-crate/cci_no_inline_exe.rs b/src/test/ui/cross-crate/cci_no_inline_exe.rs
new file mode 100644
index 000000000..ffc701678
--- /dev/null
+++ b/src/test/ui/cross-crate/cci_no_inline_exe.rs
@@ -0,0 +1,23 @@
+// run-pass
+// aux-build:cci_no_inline_lib.rs
+
+extern crate cci_no_inline_lib;
+use cci_no_inline_lib::iter;
+
+pub fn main() {
+ // Check that a cross-crate call function not marked as inline
+ // does not, in fact, get inlined. Also, perhaps more
+ // importantly, checks that our scheme of using
+ // sys::frame_address() to determine if we are inlining is
+ // actually working.
+ //let bt0 = sys::frame_address();
+ //println!("%?", bt0);
+ iter(vec![1, 2, 3], |i| {
+ println!("{}", i);
+
+ //let bt1 = sys::frame_address();
+ //println!("%?", bt1);
+
+ //assert!(bt0 != bt1);
+ })
+}
diff --git a/src/test/ui/cross-crate/const-cross-crate-const.rs b/src/test/ui/cross-crate/const-cross-crate-const.rs
new file mode 100644
index 000000000..92020417f
--- /dev/null
+++ b/src/test/ui/cross-crate/const-cross-crate-const.rs
@@ -0,0 +1,16 @@
+// run-pass
+// aux-build:cci_const.rs
+#![allow(non_upper_case_globals)]
+
+extern crate cci_const;
+static foo: &'static str = cci_const::foopy;
+static a: usize = cci_const::uint_val;
+static b: usize = cci_const::uint_expr + 5;
+
+pub fn main() {
+ assert_eq!(a, 12);
+ let foo2 = a;
+ assert_eq!(foo2, cci_const::uint_val);
+ assert_eq!(b, cci_const::uint_expr + 5);
+ assert_eq!(foo, cci_const::foopy);
+}
diff --git a/src/test/ui/cross-crate/const-cross-crate-extern.rs b/src/test/ui/cross-crate/const-cross-crate-extern.rs
new file mode 100644
index 000000000..3c61afd5b
--- /dev/null
+++ b/src/test/ui/cross-crate/const-cross-crate-extern.rs
@@ -0,0 +1,11 @@
+// run-pass
+// aux-build:cci_const.rs
+#![allow(non_upper_case_globals)]
+
+extern crate cci_const;
+use cci_const::bar;
+static foo: extern "C" fn() = bar;
+
+pub fn main() {
+ assert!(foo == bar);
+}
diff --git a/src/test/ui/cross-crate/cross-crate-const-pat.rs b/src/test/ui/cross-crate/cross-crate-const-pat.rs
new file mode 100644
index 000000000..e8fa8485a
--- /dev/null
+++ b/src/test/ui/cross-crate/cross-crate-const-pat.rs
@@ -0,0 +1,14 @@
+// run-pass
+// aux-build:cci_const.rs
+
+// pretty-expanded FIXME #23616
+
+extern crate cci_const;
+
+pub fn main() {
+ let x = cci_const::uint_val;
+ match x {
+ cci_const::uint_val => {}
+ _ => {}
+ }
+}
diff --git a/src/test/ui/cross-crate/issue-64872/auxiliary/a_def_obj.rs b/src/test/ui/cross-crate/issue-64872/auxiliary/a_def_obj.rs
new file mode 100644
index 000000000..82bb95f1e
--- /dev/null
+++ b/src/test/ui/cross-crate/issue-64872/auxiliary/a_def_obj.rs
@@ -0,0 +1,16 @@
+// compile-flags: -C debuginfo=2
+
+// no-prefer-dynamic
+#![crate_type = "rlib"]
+
+pub trait Object { fn method(&self) { } }
+
+impl Object for u32 { }
+impl Object for () { }
+impl<T> Object for &T { }
+
+pub fn unused() {
+ let ref u = 0_u32;
+ let _d = &u as &dyn crate::Object;
+ _d.method()
+}
diff --git a/src/test/ui/cross-crate/issue-64872/auxiliary/b_reexport_obj.rs b/src/test/ui/cross-crate/issue-64872/auxiliary/b_reexport_obj.rs
new file mode 100644
index 000000000..21c0274b9
--- /dev/null
+++ b/src/test/ui/cross-crate/issue-64872/auxiliary/b_reexport_obj.rs
@@ -0,0 +1,7 @@
+// compile-flags: -C debuginfo=2 -C prefer-dynamic
+
+#![crate_type="dylib"]
+
+extern crate a_def_obj;
+
+pub use a_def_obj::Object;
diff --git a/src/test/ui/cross-crate/issue-64872/auxiliary/c_another_vtable_for_obj.rs b/src/test/ui/cross-crate/issue-64872/auxiliary/c_another_vtable_for_obj.rs
new file mode 100644
index 000000000..611238f56
--- /dev/null
+++ b/src/test/ui/cross-crate/issue-64872/auxiliary/c_another_vtable_for_obj.rs
@@ -0,0 +1,12 @@
+// no-prefer-dynamic
+// compile-flags: -C debuginfo=2
+#![crate_type="rlib"]
+
+extern crate b_reexport_obj;
+use b_reexport_obj::Object;
+
+pub fn another_dyn_debug() {
+ let ref u = 1_u32;
+ let _d = &u as &dyn crate::Object;
+ _d.method()
+}
diff --git a/src/test/ui/cross-crate/issue-64872/auxiliary/d_chain_of_rlibs_and_dylibs.rs b/src/test/ui/cross-crate/issue-64872/auxiliary/d_chain_of_rlibs_and_dylibs.rs
new file mode 100644
index 000000000..8d73f9b66
--- /dev/null
+++ b/src/test/ui/cross-crate/issue-64872/auxiliary/d_chain_of_rlibs_and_dylibs.rs
@@ -0,0 +1,9 @@
+// compile-flags: -C debuginfo=2 -C prefer-dynamic
+
+#![crate_type="rlib"]
+
+extern crate c_another_vtable_for_obj;
+
+pub fn chain() {
+ c_another_vtable_for_obj::another_dyn_debug();
+}
diff --git a/src/test/ui/cross-crate/issue-64872/issue-64872.rs b/src/test/ui/cross-crate/issue-64872/issue-64872.rs
new file mode 100644
index 000000000..20fe2053c
--- /dev/null
+++ b/src/test/ui/cross-crate/issue-64872/issue-64872.rs
@@ -0,0 +1,17 @@
+// run-pass
+
+// note that these aux-build directives must be in this order: the
+// later crates depend on the earlier ones. (The particular bug that
+// is being exercised here used to exhibit itself during the build of
+// `chain_of_rlibs_and_dylibs.dylib`)
+
+// aux-build:a_def_obj.rs
+// aux-build:b_reexport_obj.rs
+// aux-build:c_another_vtable_for_obj.rs
+// aux-build:d_chain_of_rlibs_and_dylibs.rs
+
+extern crate d_chain_of_rlibs_and_dylibs;
+
+pub fn main() {
+ d_chain_of_rlibs_and_dylibs::chain();
+}
diff --git a/src/test/ui/cross-crate/moves-based-on-type-cross-crate.rs b/src/test/ui/cross-crate/moves-based-on-type-cross-crate.rs
new file mode 100644
index 000000000..3881e3352
--- /dev/null
+++ b/src/test/ui/cross-crate/moves-based-on-type-cross-crate.rs
@@ -0,0 +1,11 @@
+// run-pass
+// aux-build:moves_based_on_type_lib.rs
+
+// pretty-expanded FIXME #23616
+
+extern crate moves_based_on_type_lib;
+use moves_based_on_type_lib::f;
+
+pub fn main() {
+ f();
+}
diff --git a/src/test/ui/cross-crate/reexported-static-methods-cross-crate.rs b/src/test/ui/cross-crate/reexported-static-methods-cross-crate.rs
new file mode 100644
index 000000000..8c70a1ce4
--- /dev/null
+++ b/src/test/ui/cross-crate/reexported-static-methods-cross-crate.rs
@@ -0,0 +1,16 @@
+// run-pass
+// aux-build:reexported_static_methods.rs
+
+extern crate reexported_static_methods;
+
+use reexported_static_methods::Foo;
+use reexported_static_methods::Baz;
+use reexported_static_methods::Boz;
+use reexported_static_methods::Bort;
+
+pub fn main() {
+ assert_eq!(42_isize, Foo::foo());
+ assert_eq!(84_isize, Baz::bar());
+ assert!(Boz::boz(1));
+ assert_eq!("bort()".to_string(), Bort::bort());
+}
diff --git a/src/test/ui/cross-crate/static-array-across-crate.rs b/src/test/ui/cross-crate/static-array-across-crate.rs
new file mode 100644
index 000000000..0b84e0e6a
--- /dev/null
+++ b/src/test/ui/cross-crate/static-array-across-crate.rs
@@ -0,0 +1,13 @@
+// run-pass
+#![allow(dead_code)]
+// aux-build:pub_static_array.rs
+
+extern crate pub_static_array as array;
+
+use array::ARRAY;
+
+static X: &'static u8 = &ARRAY[0];
+static Y: &'static u8 = &(&ARRAY)[0];
+static Z: u8 = (&ARRAY)[0];
+
+pub fn main() {}
diff --git a/src/test/ui/cross-crate/static-init.rs b/src/test/ui/cross-crate/static-init.rs
new file mode 100644
index 000000000..2e893c5d9
--- /dev/null
+++ b/src/test/ui/cross-crate/static-init.rs
@@ -0,0 +1,15 @@
+// run-pass
+// aux-build:static_init_aux.rs
+extern crate static_init_aux as aux;
+
+static V: &u32 = aux::V;
+static F: fn() = aux::F;
+
+fn v() -> *const u32 {
+ V
+}
+
+fn main() {
+ assert_eq!(aux::v(), crate::v());
+ F();
+}
diff --git a/src/test/ui/cross-crate/xcrate-address-insignificant.rs b/src/test/ui/cross-crate/xcrate-address-insignificant.rs
new file mode 100644
index 000000000..33c706506
--- /dev/null
+++ b/src/test/ui/cross-crate/xcrate-address-insignificant.rs
@@ -0,0 +1,9 @@
+// run-pass
+// aux-build:xcrate_address_insignificant.rs
+
+
+extern crate xcrate_address_insignificant as foo;
+
+pub fn main() {
+ assert_eq!(foo::foo::<f64>(), foo::bar());
+}
diff --git a/src/test/ui/cross-crate/xcrate-associated-type-defaults.rs b/src/test/ui/cross-crate/xcrate-associated-type-defaults.rs
new file mode 100644
index 000000000..0f3e077d1
--- /dev/null
+++ b/src/test/ui/cross-crate/xcrate-associated-type-defaults.rs
@@ -0,0 +1,29 @@
+// run-pass
+// aux-build:xcrate_associated_type_defaults.rs
+
+extern crate xcrate_associated_type_defaults;
+use xcrate_associated_type_defaults::Foo;
+
+struct LocalDefault;
+impl Foo<u32> for LocalDefault {}
+
+struct LocalOverride;
+impl Foo<u64> for LocalOverride {
+ type Out = bool;
+}
+
+fn main() {
+ assert_eq!(
+ <() as Foo<u32>>::Out::default().to_string(),
+ "0");
+ assert_eq!(
+ <() as Foo<u64>>::Out::default().to_string(),
+ "false");
+
+ assert_eq!(
+ <LocalDefault as Foo<u32>>::Out::default().to_string(),
+ "0");
+ assert_eq!(
+ <LocalOverride as Foo<u64>>::Out::default().to_string(),
+ "false");
+}
diff --git a/src/test/ui/cross-crate/xcrate-static-addresses.rs b/src/test/ui/cross-crate/xcrate-static-addresses.rs
new file mode 100644
index 000000000..3c3397656
--- /dev/null
+++ b/src/test/ui/cross-crate/xcrate-static-addresses.rs
@@ -0,0 +1,13 @@
+// run-pass
+// aux-build:xcrate_static_addresses.rs
+
+// pretty-expanded FIXME #23616
+
+extern crate xcrate_static_addresses;
+
+use xcrate_static_addresses as other;
+
+pub fn main() {
+ other::verify_same(&other::global);
+ other::verify_same2(other::global2);
+}
diff --git a/src/test/ui/cross-crate/xcrate-trait-lifetime-param.rs b/src/test/ui/cross-crate/xcrate-trait-lifetime-param.rs
new file mode 100644
index 000000000..1fd7eb878
--- /dev/null
+++ b/src/test/ui/cross-crate/xcrate-trait-lifetime-param.rs
@@ -0,0 +1,19 @@
+// run-pass
+#![allow(dead_code)]
+// aux-build:xcrate-trait-lifetime-param.rs
+
+// pretty-expanded FIXME #23616
+
+extern crate xcrate_trait_lifetime_param as other;
+
+struct Reader<'a> {
+ b : &'a [u8]
+}
+
+impl <'a> other::FromBuf<'a> for Reader<'a> {
+ fn from_buf(b : &'a [u8]) -> Reader<'a> {
+ Reader { b : b }
+ }
+}
+
+pub fn main () {}
diff --git a/src/test/ui/cross-crate/xcrate_generic_fn_nested_return.rs b/src/test/ui/cross-crate/xcrate_generic_fn_nested_return.rs
new file mode 100644
index 000000000..4593fec51
--- /dev/null
+++ b/src/test/ui/cross-crate/xcrate_generic_fn_nested_return.rs
@@ -0,0 +1,8 @@
+// run-pass
+// aux-build:xcrate_generic_fn_nested_return.rs
+
+extern crate xcrate_generic_fn_nested_return as test;
+
+pub fn main() {
+ assert!(test::decode::<()>().is_err());
+}
diff --git a/src/test/ui/cross/cross-borrow-trait.rs b/src/test/ui/cross/cross-borrow-trait.rs
new file mode 100644
index 000000000..180a75e3d
--- /dev/null
+++ b/src/test/ui/cross/cross-borrow-trait.rs
@@ -0,0 +1,13 @@
+// Test that cross-borrowing (implicitly converting from `Box<T>` to `&T`) is
+// forbidden when `T` is a trait.
+
+struct Foo;
+trait Trait { fn foo(&self) {} }
+impl Trait for Foo {}
+
+pub fn main() {
+ let x: Box<dyn Trait> = Box::new(Foo);
+ let _y: &dyn Trait = x; //~ ERROR E0308
+ //~| expected reference `&dyn Trait`
+ //~| found struct `Box<dyn Trait>`
+}
diff --git a/src/test/ui/cross/cross-borrow-trait.stderr b/src/test/ui/cross/cross-borrow-trait.stderr
new file mode 100644
index 000000000..81f309eae
--- /dev/null
+++ b/src/test/ui/cross/cross-borrow-trait.stderr
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+ --> $DIR/cross-borrow-trait.rs:10:26
+ |
+LL | let _y: &dyn Trait = x;
+ | ---------- ^ expected `&dyn Trait`, found struct `Box`
+ | |
+ | expected due to this
+ |
+ = note: expected reference `&dyn Trait`
+ found struct `Box<dyn Trait>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/cross/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs b/src/test/ui/cross/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs
new file mode 100644
index 000000000..fbda3dbe9
--- /dev/null
+++ b/src/test/ui/cross/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs
@@ -0,0 +1,13 @@
+#![crate_type = "dylib"]
+
+pub fn print(_args: std::fmt::Arguments) {}
+
+#[macro_export]
+macro_rules! myprint {
+ ($($arg:tt)*) => ($crate::print(format_args!($($arg)*)));
+}
+
+#[macro_export]
+macro_rules! myprintln {
+ ($fmt:expr) => (myprint!(concat!($fmt, "\n")));
+}
diff --git a/src/test/ui/cross/cross-crate-macro-backtrace/main.rs b/src/test/ui/cross/cross-crate-macro-backtrace/main.rs
new file mode 100644
index 000000000..f7d4330ab
--- /dev/null
+++ b/src/test/ui/cross/cross-crate-macro-backtrace/main.rs
@@ -0,0 +1,8 @@
+// aux-build:extern_macro_crate.rs
+#[macro_use(myprintln, myprint)]
+extern crate extern_macro_crate;
+
+fn main() {
+ myprintln!("{}");
+ //~^ ERROR in format string
+}
diff --git a/src/test/ui/cross/cross-crate-macro-backtrace/main.stderr b/src/test/ui/cross/cross-crate-macro-backtrace/main.stderr
new file mode 100644
index 000000000..5bd4ea97e
--- /dev/null
+++ b/src/test/ui/cross/cross-crate-macro-backtrace/main.stderr
@@ -0,0 +1,10 @@
+error: 1 positional argument in format string, but no arguments were given
+ --> $DIR/main.rs:6:5
+ |
+LL | myprintln!("{}");
+ | ^^^^^^^^^^^^^^^^
+ |
+ = note: this error originates in the macro `concat` which comes from the expansion of the macro `myprintln` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/cross/cross-file-errors/main.rs b/src/test/ui/cross/cross-file-errors/main.rs
new file mode 100644
index 000000000..4219f892d
--- /dev/null
+++ b/src/test/ui/cross/cross-file-errors/main.rs
@@ -0,0 +1,7 @@
+#[macro_use]
+mod underscore;
+
+fn main() {
+ underscore!();
+ //~^ ERROR `_` can only be used on the left-hand side of an assignment
+}
diff --git a/src/test/ui/cross/cross-file-errors/main.stderr b/src/test/ui/cross/cross-file-errors/main.stderr
new file mode 100644
index 000000000..293a300ed
--- /dev/null
+++ b/src/test/ui/cross/cross-file-errors/main.stderr
@@ -0,0 +1,15 @@
+error: in expressions, `_` can only be used on the left-hand side of an assignment
+ --> $DIR/underscore.rs:8:9
+ |
+LL | _
+ | ^ `_` not allowed here
+ |
+ ::: $DIR/main.rs:5:5
+ |
+LL | underscore!();
+ | ------------- in this macro invocation
+ |
+ = note: this error originates in the macro `underscore` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/cross/cross-file-errors/underscore.rs b/src/test/ui/cross/cross-file-errors/underscore.rs
new file mode 100644
index 000000000..76e72a93f
--- /dev/null
+++ b/src/test/ui/cross/cross-file-errors/underscore.rs
@@ -0,0 +1,10 @@
+// We want this file only so we can test cross-file error
+// messages, but we don't want it in an external crate.
+// ignore-test
+#![crate_type = "lib"]
+
+macro_rules! underscore {
+ () => (
+ _
+ )
+}
diff --git a/src/test/ui/cross/cross-fn-cache-hole.rs b/src/test/ui/cross/cross-fn-cache-hole.rs
new file mode 100644
index 000000000..c38a5001a
--- /dev/null
+++ b/src/test/ui/cross/cross-fn-cache-hole.rs
@@ -0,0 +1,31 @@
+// Check that when there are vacuous predicates in the environment
+// (which make a fn uncallable) we don't erroneously cache those and
+// then consider them satisfied elsewhere. The current technique for
+// doing this is to not use global caches when there is a chance that
+// the environment contains such a predicate.
+// We still error for `i32: Bar<u32>` pending #48214
+
+trait Foo<X,Y>: Bar<X> {
+}
+
+trait Bar<X> { }
+
+// We don't always check where clauses for sanity, but in this case
+// wfcheck does report an error here:
+fn vacuous<A>()
+ where i32: Foo<u32, A> //~ ERROR the trait bound `i32: Bar<u32>` is not satisfied
+{
+ // ... the original intention was to check that we don't use that
+ // vacuous where clause (which could never be satisfied) to accept
+ // the following line and then mess up calls elsewhere.
+ require::<i32, u32>();
+}
+
+fn require<A,B>()
+ where A: Bar<B>
+{
+}
+
+fn main() {
+ require::<i32, u32>();
+}
diff --git a/src/test/ui/cross/cross-fn-cache-hole.stderr b/src/test/ui/cross/cross-fn-cache-hole.stderr
new file mode 100644
index 000000000..7e15562b0
--- /dev/null
+++ b/src/test/ui/cross/cross-fn-cache-hole.stderr
@@ -0,0 +1,12 @@
+error[E0277]: the trait bound `i32: Bar<u32>` is not satisfied
+ --> $DIR/cross-fn-cache-hole.rs:16:11
+ |
+LL | where i32: Foo<u32, A>
+ | ^^^^^^^^^^^^^^^^ the trait `Bar<u32>` is not implemented for `i32`
+ |
+ = help: see issue #48214
+ = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.